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

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.28    ! paf         8:        $Id: pa_common.h,v 1.27 2001/03/27 13:47:29 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: /**
                     80:        write data to specified file using pool, 
                     81:        throws an exception in case of problems
                     82: */
                     83: void file_write(Pool& pool, 
1.25      paf        84:                                const String& file_spec,
1.17      paf        85:                                const char *data, size_t size, 
1.20      paf        86:                                bool as_text/*,
                     87:                                bool exclusive=false*/);
1.26      paf        88: 
                     89: /**
                     90:        delete specified file 
                     91:        throws an exception in case of problems
                     92: */
                     93: void file_delete(Pool& pool, const String& file_spec);
1.27      paf        94: 
                     95: bool file_readable(const String& file_spec);
1.15      paf        96: 
                     97: /**
1.18      paf        98:        scans for @a delim[default \n] in @a *row_ref, 
                     99:        @return piece of line before it or end of string, if no @a delim found
                    100:        assigns @a *row_ref to point right after delimiter if there were one
                    101:        or to zero if no @a delim were found.
1.15      paf       102: */
1.7       paf       103: char *getrow(char **row_ref,char delim='\n');
1.22      paf       104: //char *lsplit(char *string, char delim);
1.7       paf       105: char *lsplit(char **string_ref,char delim);
1.8       paf       106: char *rsplit(char *string, char delim);
1.9       paf       107: char *format(Pool& pool, double value, char *fmt);
1.10      paf       108: 
                    109: #ifndef max
                    110: inline int max(int a,int b) { return a>b?a:b; }
                    111: inline int min(int a,int b){ return a<b?a:b; }
                    112: #endif
                    113: 
1.13      paf       114: size_t stdout_write(const char *buf, size_t size);
1.14      paf       115: 
                    116: const char *unescape_chars(Pool& pool, const char *cp, int len);
                    117: 
1.24      paf       118: /**
                    119:        $content-type[text/html] -> 
                    120:                content-type: text/html
                    121:        $content-type[$value[text/html] charset[windows-1251]] -> 
                    122:                content-type: text/html; charset=windows-1251
                    123: */
1.20      paf       124: const String& attributed_meaning_to_string(Value& meaning);
1.23      paf       125: 
                    126: 
                    127: #ifdef WIN32
                    128: void back_slashes_to_slashes(char *s);
                    129: #endif
                    130: 
1.28    ! paf       131: #ifndef _qsort
        !           132: #      define _qsort(names,cnt,sizeof_names,func_addr) \
        !           133:                qsort(names,cnt,sizeof_names,func_addr)
        !           134: #endif
1.1       paf       135: 
                    136: #endif

E-mail: