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

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

E-mail: