--- parser3/src/include/pa_common.h 2003/04/02 10:10:00 1.89.2.13.2.9 +++ parser3/src/include/pa_common.h 2005/08/05 13:02:58 1.101.8.1 @@ -1,21 +1,20 @@ /** @file Parser: commonly used functions. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_COMMON_H #define PA_COMMON_H -static const char* IDENT_COMMON_H="$Date: 2003/04/02 10:10:00 $"; - +static const char * const IDENT_COMMON_H="$Date: 2005/08/05 13:02:58 $"; #include "pa_string.h" #include "pa_hash.h" class Value; -typedef Hash HashStringValue; +typedef Hash HashStringValue; // replace system s*nprintf with our versions #undef vsnprintf @@ -57,9 +56,6 @@ inline long lseek( int handle, long offs #endif -/// yields to OS for secs secs and usecs milliseconds -int pa_sleep(unsigned long secs, unsigned long usecs); - /** under WIN32 "t" mode fixes DOS chars OK, can't say that about other systems/ line break styles */ @@ -68,6 +64,13 @@ void fix_line_breaks( size_t& length///< may change! used to speedup next actions ); +int pa_lock_shared_blocking(int fd); +int pa_lock_exclusive_blocking(int fd); +int pa_lock_exclusive_nonblocking(int fd); +int pa_unlock(int fd); + +void create_dir_for_file(const String& file_spec); + typedef void (*File_read_action)( struct stat& finfo, int f, @@ -93,7 +96,7 @@ bool file_read_action_under_lock(const S @returns true if read OK */ -char *file_read_text(Charset& charset, +char *file_read_text(Request_charsets& charsets, const String& file_spec, bool fail_on_read_problem=true, HashStringValue* options=0/*, HashStringValue* * out_fields=0*/); @@ -112,11 +115,12 @@ struct File_read_result { @returns true if read OK */ -File_read_result file_read(Charset& charset, +File_read_result file_read(Request_charsets& charsets, const String& file_spec, bool as_text, HashStringValue* options=0, - bool fail_on_read_problem=true); + bool fail_on_read_problem=true, + char* buf=0, size_t offset=0, size_t size=0); typedef void (*File_write_action)(int f, void *context); @@ -150,7 +154,7 @@ void file_write( delete specified file throws an exception in case of problems */ -bool file_delete(const String& file_spec, bool fail_on_read_problem=true); +bool file_delete(const String& file_spec, bool fail_on_problem=true); /** move specified file throws an exception in case of problems @@ -183,13 +187,6 @@ char *lsplit(char **string_ref,char deli char *rsplit(char *string, char delim); const char* format(double value, char *fmt); -#ifndef max -inline int max(int a, int b) { return a>b?a:b; } -inline int min(int a, int b){ return ab?a:b; } -inline size_t min(size_t a, size_t b){ return a