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

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.39    ! paf         8:        $Id: pa_common.h,v 1.38 2001/04/10 11:23:58 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
1.38      paf        39: #endif
                     40: #ifndef lseek
                     41: #      define lseek _lseek
1.20      paf        42: #endif
1.1       paf        43: 
1.20      paf        44: #ifndef vsnprintf
                     45: #      define vsnprintf __vsnprintf 
1.1       paf        46: int __vsnprintf(char *, size_t, const char *, va_list);
1.20      paf        47: #endif
                     48: #ifndef snprintf
                     49: #      define snprintf __snprintf
1.1       paf        50: int __snprintf(char *, size_t, const char *, ...);
1.20      paf        51: #endif
1.17      paf        52: 
                     53: //access
                     54: #define F_OK 0
                     55: #define X_OK 1
                     56: #define W_OK 2
                     57: #define R_OK 4
                     58: 
1.20      paf        59: #ifndef strcasecmp
                     60: #      define strcasecmp _stricmp
                     61: #endif
                     62: #ifndef strncasecmp
                     63: #      define strncasecmp _strnicmp
                     64: #endif
                     65: #ifndef mkdir
                     66: #      define mkdir(path, mode) _mkdir(path)
                     67: #endif
1.17      paf        68: 
1.20      paf        69: #ifndef putenv
                     70: #      define putenv _putenv
1.1       paf        71: #endif
1.2       paf        72: 
1.17      paf        73: #endif
                     74: 
1.15      paf        75: /**
1.19      paf        76:        read specified text file using pool, 
1.15      paf        77:        if fail_on_read_problem is true[default] throws an exception
                     78: */
1.19      paf        79: char *file_read_text(Pool& pool, 
1.25      paf        80:                                         const String& file_spec, 
1.19      paf        81:                                         bool fail_on_read_problem=true);
1.17      paf        82: 
                     83: /**
1.29      paf        84:        read specified file using pool, 
                     85:        if fail_on_read_problem is true[default] throws an exception
                     86: */
                     87: bool file_read(Pool& pool, const String& file_spec, 
                     88:                           void*& data, size_t& size, 
                     89:                           bool as_text,
1.37      paf        90:                           bool fail_on_read_problem=true,
                     91:                           size_t offset=0, size_t limit=0);
1.29      paf        92: 
                     93: /**
1.17      paf        94:        write data to specified file using pool, 
                     95:        throws an exception in case of problems
                     96: */
                     97: void file_write(Pool& pool, 
1.25      paf        98:                                const String& file_spec,
1.29      paf        99:                                const void *data, size_t size, 
1.20      paf       100:                                bool as_text/*,
                    101:                                bool exclusive=false*/);
1.26      paf       102: 
                    103: /**
                    104:        delete specified file 
                    105:        throws an exception in case of problems
                    106: */
                    107: void file_delete(Pool& pool, const String& file_spec);
1.27      paf       108: 
                    109: bool file_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: 
                    153: bool StrEqNc(const char *s1, const char *s2, bool strict);
1.39    ! paf       154: char *unquote(char*& current, char stop_at);
1.1       paf       155: 
                    156: #endif

E-mail: