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

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.5       paf         5:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.4       paf         6: 
1.52    ! parser      7:        $Id: pa_common.h,v 1.51 2001/09/26 10:32:25 parser Exp $
1.1       paf         8: */
                      9: 
                     10: #ifndef PA_COMMON_H
                     11: #define PA_COMMON_H
                     12: 
1.21      paf        13: #include "pa_config_includes.h"
1.2       paf        14: #include "pa_pool.h"
1.33      paf        15: #include "pa_string.h"
1.1       paf        16: 
1.14      paf        17: class Value;
1.11      paf        18: 
1.21      paf        19: #if _MSC_VER
1.12      paf        20: 
1.20      paf        21: #ifndef open
                     22: #      define open _open
                     23: #endif
                     24: #ifndef close
                     25: #      define close _close
                     26: #endif
                     27: #ifndef read
                     28: #      define read _read
1.21      paf        29: #endif
                     30: #ifndef write
                     31: #      define write _write
1.20      paf        32: #endif
                     33: #ifndef stat
                     34: #      define stat _stat
1.38      paf        35: #endif
                     36: #ifndef lseek
                     37: #      define lseek _lseek
1.20      paf        38: #endif
1.1       paf        39: 
1.20      paf        40: #ifndef vsnprintf
1.42      paf        41: int __vsnprintf(char *, size_t, const char *, va_list);
1.20      paf        42: #      define vsnprintf __vsnprintf 
                     43: #endif
                     44: #ifndef snprintf
1.42      paf        45: int __snprintf(char *, size_t, const char *, ...);
1.20      paf        46: #      define snprintf __snprintf
                     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,
1.37      paf        86:                           bool fail_on_read_problem=true,
                     87:                           size_t offset=0, size_t limit=0);
1.29      paf        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.47      parser    104: /**
                    105:        move specified file 
                    106:        throws an exception in case of problems
                    107: */
                    108: void file_move(Pool& pool, const String& old_spec, const String& new_spec);
1.27      paf       109: 
                    110: bool file_readable(const String& file_spec);
1.41      paf       111: bool dir_readable(const String& file_spec);
1.49      parser    112: String *file_readable(const String& path, const String& name);
1.36      paf       113: bool file_executable(const String& file_spec);
1.37      paf       114: 
1.48      parser    115: bool file_stat(const String& file_spec, 
1.46      parser    116:                           size_t& rsize, 
                    117:                           time_t& ratime,
                    118:                           time_t& rmtime,
1.48      parser    119:                           time_t& rctime,
                    120:                           bool fail_on_read_problem=true);
1.15      paf       121: 
                    122: /**
1.18      paf       123:        scans for @a delim[default \n] in @a *row_ref, 
                    124:        @return piece of line before it or end of string, if no @a delim found
                    125:        assigns @a *row_ref to point right after delimiter if there were one
                    126:        or to zero if no @a delim were found.
1.15      paf       127: */
1.7       paf       128: char *getrow(char **row_ref,char delim='\n');
1.22      paf       129: //char *lsplit(char *string, char delim);
1.7       paf       130: char *lsplit(char **string_ref,char delim);
1.8       paf       131: char *rsplit(char *string, char delim);
1.9       paf       132: char *format(Pool& pool, double value, char *fmt);
1.10      paf       133: 
                    134: #ifndef max
                    135: inline int max(int a,int b) { return a>b?a:b; }
                    136: inline int min(int a,int b){ return a<b?a:b; }
                    137: #endif
                    138: 
1.30      paf       139: size_t stdout_write(const void *buf, size_t size);
1.14      paf       140: 
                    141: const char *unescape_chars(Pool& pool, const char *cp, int len);
                    142: 
1.24      paf       143: /**
                    144:        $content-type[text/html] -> 
1.32      paf       145:                content-type: text/html
1.24      paf       146:        $content-type[$value[text/html] charset[windows-1251]] -> 
1.32      paf       147:                content-type: text/html; charset=windows-1251
1.24      paf       148: */
1.33      paf       149: const String& attributed_meaning_to_string(Value& meaning, String::Untaint_lang lang);
1.23      paf       150: 
                    151: #ifdef WIN32
                    152: void back_slashes_to_slashes(char *s);
1.35      paf       153: //void slashes_to_back_slashes(char *s);
1.23      paf       154: #endif
                    155: 
1.28      paf       156: #ifndef _qsort
                    157: #      define _qsort(names,cnt,sizeof_names,func_addr) \
                    158:                qsort(names,cnt,sizeof_names,func_addr)
                    159: #endif
1.34      paf       160: 
1.40      paf       161: bool StrEqNc(const char *s1, const char *s2, bool strict=true);
1.39      paf       162: char *unquote(char*& current, char stop_at);
1.45      parser    163: 
                    164: #define SECS_PER_DAY (60*60*24)
                    165: int getMonthDays(int year, int month);
1.52    ! parser    166: 
        !           167: void remove_crlf(char *start, char *end);
1.1       paf       168: 
                    169: #endif

E-mail: