--- parser3/src/include/pa_common.h 2003/07/24 11:31:21 1.93 +++ parser3/src/include/pa_common.h 2005/11/24 14:05:04 1.101.8.5 @@ -1,20 +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/07/24 11:31:21 $"; +static const char * const IDENT_COMMON_H="$Date: 2005/11/24 14:05:04 $"; #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 @@ -56,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 */ @@ -67,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, @@ -115,7 +119,8 @@ File_read_result file_read(Request_chars 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); @@ -149,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 @@ -158,9 +163,9 @@ void file_move(const String& old_spec, c bool entry_exists(const char* fname, struct stat *afinfo=0); bool entry_exists(const String& file_spec); -bool file_readable(const String& file_spec); -bool dir_readable(const String& file_spec); -const String* file_readable(const String& path, const String& name); +bool file_exist(const String& file_spec); +bool dir_exists(const String& file_spec); +const String* file_exist(const String& path, const String& name); bool file_executable(const String& file_spec); bool file_stat(const String& file_spec, @@ -207,8 +212,20 @@ void remove_crlf(char *start, char *end) void check_safe_mode(struct stat finfo, const String& file_spec, const char* fname); #endif +char* pa_base64_encode(const char *in, size_t in_size); +void pa_base64_decode(const char *in, size_t in_size, char*& result, size_t& result_size); + +int pa_get_valid_file_options_count(HashStringValue& options); + // globals extern const String file_status_name; +// global defines for file options which are handled but not checked elsewhere, we check them + +#define PA_SQL_LIMIT_NAME "limit" +#define PA_SQL_OFFSET_NAME "offset" +#define PA_COLUMN_SEPARATOR_NAME "separator" +#define PA_COLUMN_ENCLOSER_NAME "encloser" + #endif