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