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

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.31    ! paf         8:        $Id: pa_common.h,v 1.30 2001/04/03 06:23:04 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.1       paf        18: 
1.14      paf        19: class String;
                     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
                     38: #endif
1.1       paf        39: 
1.20      paf        40: #ifndef vsnprintf
                     41: #      define vsnprintf __vsnprintf 
1.1       paf        42: int __vsnprintf(char *, size_t, const char *, va_list);
1.20      paf        43: #endif
                     44: #ifndef snprintf
                     45: #      define snprintf __snprintf
1.1       paf        46: int __snprintf(char *, size_t, const char *, ...);
1.20      paf        47: #endif
1.17      paf        48: 
                     49: //access
                     50: #define F_OK 0
                     51: #define X_OK 1
                     52: #define W_OK 2
                     53: #define R_OK 4
                     54: 
1.20      paf        55: #ifndef strcasecmp
                     56: #      define strcasecmp _stricmp
                     57: #endif
                     58: #ifndef strncasecmp
                     59: #      define strncasecmp _strnicmp
                     60: #endif
                     61: #ifndef mkdir
                     62: #      define mkdir(path, mode) _mkdir(path)
                     63: #endif
1.17      paf        64: 
1.20      paf        65: #ifndef putenv
                     66: #      define putenv _putenv
1.1       paf        67: #endif
1.2       paf        68: 
1.17      paf        69: #endif
                     70: 
1.15      paf        71: /**
1.19      paf        72:        read specified text file using pool, 
1.15      paf        73:        if fail_on_read_problem is true[default] throws an exception
                     74: */
1.19      paf        75: char *file_read_text(Pool& pool, 
1.25      paf        76:                                         const String& file_spec, 
1.19      paf        77:                                         bool fail_on_read_problem=true);
1.17      paf        78: 
                     79: /**
1.29      paf        80:        read specified file using pool, 
                     81:        if fail_on_read_problem is true[default] throws an exception
                     82: */
                     83: bool file_read(Pool& pool, const String& file_spec, 
                     84:                           void*& data, size_t& size, 
                     85:                           bool as_text,
                     86:                           bool fail_on_read_problem=true);
                     87: 
                     88: /**
1.17      paf        89:        write data to specified file using pool, 
                     90:        throws an exception in case of problems
                     91: */
                     92: void file_write(Pool& pool, 
1.25      paf        93:                                const String& file_spec,
1.29      paf        94:                                const void *data, size_t size, 
1.20      paf        95:                                bool as_text/*,
                     96:                                bool exclusive=false*/);
1.26      paf        97: 
                     98: /**
                     99:        delete specified file 
                    100:        throws an exception in case of problems
                    101: */
                    102: void file_delete(Pool& pool, const String& file_spec);
1.27      paf       103: 
                    104: bool file_readable(const String& file_spec);
1.15      paf       105: 
                    106: /**
1.18      paf       107:        scans for @a delim[default \n] in @a *row_ref, 
                    108:        @return piece of line before it or end of string, if no @a delim found
                    109:        assigns @a *row_ref to point right after delimiter if there were one
                    110:        or to zero if no @a delim were found.
1.15      paf       111: */
1.7       paf       112: char *getrow(char **row_ref,char delim='\n');
1.22      paf       113: //char *lsplit(char *string, char delim);
1.7       paf       114: char *lsplit(char **string_ref,char delim);
1.8       paf       115: char *rsplit(char *string, char delim);
1.9       paf       116: char *format(Pool& pool, double value, char *fmt);
1.10      paf       117: 
                    118: #ifndef max
                    119: inline int max(int a,int b) { return a>b?a:b; }
                    120: inline int min(int a,int b){ return a<b?a:b; }
                    121: #endif
                    122: 
1.30      paf       123: size_t stdout_write(const void *buf, size_t size);
1.14      paf       124: 
                    125: const char *unescape_chars(Pool& pool, const char *cp, int len);
                    126: 
1.24      paf       127: /**
                    128:        $content-type[text/html] -> 
1.31    ! paf       129:                Content-type: text/html
1.24      paf       130:        $content-type[$value[text/html] charset[windows-1251]] -> 
1.31    ! paf       131:                Content-type: text/html; charset=windows-1251
1.24      paf       132: */
1.20      paf       133: const String& attributed_meaning_to_string(Value& meaning);
1.23      paf       134: 
                    135: 
                    136: #ifdef WIN32
                    137: void back_slashes_to_slashes(char *s);
                    138: #endif
                    139: 
1.28      paf       140: #ifndef _qsort
                    141: #      define _qsort(names,cnt,sizeof_names,func_addr) \
                    142:                qsort(names,cnt,sizeof_names,func_addr)
                    143: #endif
1.1       paf       144: 
                    145: #endif

E-mail: