Annotation of parser3/src/include/pa_common.h, revision 1.43

1.15      paf         1: /** @file
1.16      paf         2:        Parser: commonly used functions.
                      3: 
1.4       paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.16      paf         5: 
1.5       paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.4       paf         7: 
1.43    ! paf         8:        $Id: pa_common.h,v 1.42 2001/04/26 10:16:02 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_COMMON_H
                     12: #define PA_COMMON_H
                     13: 
1.21      paf        14: #include "pa_config_includes.h"
                     15: #include <stdio.h>
1.11      paf        16: 
1.2       paf        17: #include "pa_pool.h"
1.33      paf        18: #include "pa_string.h"
1.1       paf        19: 
1.14      paf        20: class Value;
1.11      paf        21: 
1.21      paf        22: #if _MSC_VER
1.12      paf        23: 
1.20      paf        24: #ifndef open
                     25: #      define open _open
                     26: #endif
                     27: #ifndef close
                     28: #      define close _close
                     29: #endif
                     30: #ifndef read
                     31: #      define read _read
1.21      paf        32: #endif
                     33: #ifndef write
                     34: #      define write _write
1.20      paf        35: #endif
                     36: #ifndef stat
                     37: #      define stat _stat
1.38      paf        38: #endif
                     39: #ifndef lseek
                     40: #      define lseek _lseek
1.20      paf        41: #endif
1.1       paf        42: 
1.20      paf        43: #ifndef vsnprintf
1.42      paf        44: int __vsnprintf(char *, size_t, const char *, va_list);
1.20      paf        45: #      define vsnprintf __vsnprintf 
                     46: #endif
                     47: #ifndef snprintf
1.42      paf        48: int __snprintf(char *, size_t, const char *, ...);
1.20      paf        49: #      define snprintf __snprintf
                     50: #endif
1.17      paf        51: 
                     52: //access
                     53: #define F_OK 0
                     54: #define X_OK 1
                     55: #define W_OK 2
                     56: #define R_OK 4
                     57: 
1.20      paf        58: #ifndef strcasecmp
                     59: #      define strcasecmp _stricmp
                     60: #endif
                     61: #ifndef strncasecmp
                     62: #      define strncasecmp _strnicmp
                     63: #endif
                     64: #ifndef mkdir
                     65: #      define mkdir(path, mode) _mkdir(path)
                     66: #endif
1.17      paf        67: 
1.20      paf        68: #ifndef putenv
                     69: #      define putenv _putenv
1.1       paf        70: #endif
1.2       paf        71: 
1.17      paf        72: #endif
                     73: 
1.15      paf        74: /**
1.19      paf        75:        read specified text file using pool, 
1.15      paf        76:        if fail_on_read_problem is true[default] throws an exception
                     77: */
1.19      paf        78: char *file_read_text(Pool& pool, 
1.25      paf        79:                                         const String& file_spec, 
1.19      paf        80:                                         bool fail_on_read_problem=true);
1.17      paf        81: 
                     82: /**
1.29      paf        83:        read specified file using pool, 
                     84:        if fail_on_read_problem is true[default] throws an exception
                     85: */
                     86: bool file_read(Pool& pool, const String& file_spec, 
                     87:                           void*& data, size_t& size, 
                     88:                           bool as_text,
1.37      paf        89:                           bool fail_on_read_problem=true,
                     90:                           size_t offset=0, size_t limit=0);
1.29      paf        91: 
                     92: /**
1.17      paf        93:        write data to specified file using pool, 
                     94:        throws an exception in case of problems
                     95: */
                     96: void file_write(Pool& pool, 
1.25      paf        97:                                const String& file_spec,
1.29      paf        98:                                const void *data, size_t size, 
1.20      paf        99:                                bool as_text/*,
                    100:                                bool exclusive=false*/);
1.26      paf       101: 
                    102: /**
                    103:        delete specified file 
                    104:        throws an exception in case of problems
                    105: */
                    106: void file_delete(Pool& pool, const String& file_spec);
1.27      paf       107: 
                    108: bool file_readable(const String& file_spec);
1.41      paf       109: bool dir_readable(const String& file_spec);
1.36      paf       110: bool file_executable(const String& file_spec);
1.37      paf       111: 
                    112: size_t file_size(const String& file_spec);
1.15      paf       113: 
                    114: /**
1.18      paf       115:        scans for @a delim[default \n] in @a *row_ref, 
                    116:        @return piece of line before it or end of string, if no @a delim found
                    117:        assigns @a *row_ref to point right after delimiter if there were one
                    118:        or to zero if no @a delim were found.
1.15      paf       119: */
1.7       paf       120: char *getrow(char **row_ref,char delim='\n');
1.22      paf       121: //char *lsplit(char *string, char delim);
1.7       paf       122: char *lsplit(char **string_ref,char delim);
1.8       paf       123: char *rsplit(char *string, char delim);
1.9       paf       124: char *format(Pool& pool, double value, char *fmt);
1.10      paf       125: 
                    126: #ifndef max
                    127: inline int max(int a,int b) { return a>b?a:b; }
                    128: inline int min(int a,int b){ return a<b?a:b; }
                    129: #endif
                    130: 
1.30      paf       131: size_t stdout_write(const void *buf, size_t size);
1.14      paf       132: 
                    133: const char *unescape_chars(Pool& pool, const char *cp, int len);
                    134: 
1.24      paf       135: /**
                    136:        $content-type[text/html] -> 
1.32      paf       137:                content-type: text/html
1.24      paf       138:        $content-type[$value[text/html] charset[windows-1251]] -> 
1.32      paf       139:                content-type: text/html; charset=windows-1251
1.24      paf       140: */
1.33      paf       141: const String& attributed_meaning_to_string(Value& meaning, String::Untaint_lang lang);
1.23      paf       142: 
                    143: #ifdef WIN32
                    144: void back_slashes_to_slashes(char *s);
1.35      paf       145: //void slashes_to_back_slashes(char *s);
1.23      paf       146: #endif
                    147: 
1.28      paf       148: #ifndef _qsort
                    149: #      define _qsort(names,cnt,sizeof_names,func_addr) \
                    150:                qsort(names,cnt,sizeof_names,func_addr)
                    151: #endif
1.34      paf       152: 
1.40      paf       153: bool StrEqNc(const char *s1, const char *s2, bool strict=true);
1.39      paf       154: char *unquote(char*& current, char stop_at);
1.1       paf       155: 
                    156: #endif

E-mail: