--- parser3/src/include/pa_common.h 2002/08/01 11:26:46 1.78 +++ parser3/src/include/pa_common.h 2002/11/25 14:10:52 1.85 @@ -8,12 +8,12 @@ #ifndef PA_COMMON_H #define PA_COMMON_H -static const char* IDENT_COMMON_H="$Id: pa_common.h,v 1.78 2002/08/01 11:26:46 paf Exp $"; +static const char* IDENT_COMMON_H="$Date: 2002/11/25 14:10:52 $"; #include "pa_pool.h" #include "pa_string.h" -class Value; +class Hash; // replace system s*nprintf with our versions #undef vsnprintf @@ -89,23 +89,47 @@ void fix_line_breaks( size_t& size ///< may change! used to speedup next actions ); +typedef void (*File_read_action)(Pool& pool, + struct stat& finfo, + int f, + const String& file_spec, const char *fname, bool as_text, + void *context); + +/** + shared-lock specified file, + do actions under lock. + if fail_on_read_problem is true[default] throws an exception + + @returns true if read OK +*/ +bool file_read_action_under_lock(Pool& pool, const String& file_spec, + const char *action_name, File_read_action action, void *context, + bool as_text=false, + bool fail_on_read_problem=true); /** read specified text file using pool, if fail_on_read_problem is true[default] throws an exception + + @returns true if read OK */ char *file_read_text(Pool& pool, const String& file_spec, - bool fail_on_read_problem=true); + bool fail_on_read_problem=true, + Hash *params=0, Hash** out_fields=0); /** read specified file using pool, if fail_on_read_problem is true[default] throws an exception + + @returns true if read OK */ bool file_read(Pool& pool, const String& file_spec, void*& data, size_t& size, bool as_text, - bool fail_on_read_problem=true, - size_t offset=0, size_t limit=0); + Hash *params=0, Hash** out_fields=0, + bool fail_on_read_problem=true); + +typedef void (*File_write_action)(int f, void *context); /** lock specified file exclusively, @@ -117,7 +141,7 @@ bool file_read(Pool& pool, const String& */ bool file_write_action_under_lock( const String& file_spec, - const char *action_name, void (*action)(int, void *), void *context=0, + const char *action_name, File_write_action action, void *context, bool as_text=false, bool do_append=false, bool do_block=true, @@ -144,6 +168,8 @@ bool file_delete(const String& file_spec */ void file_move(const String& old_spec, const String& new_spec); +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); String *file_readable(const String& path, const String& name); @@ -179,14 +205,6 @@ size_t stdout_write(const void *buf, siz char *unescape_chars(Pool& pool, const char *cp, int len); -/** - $content-type[text/html] -> - content-type: text/html - $content-type[$value[text/html] charset[windows-1251]] -> - content-type: text/html; charset=windows-1251 -*/ -const String& attributed_meaning_to_string(Value& meaning, String::Untaint_lang lang); - #ifdef WIN32 void back_slashes_to_slashes(char *s); //void slashes_to_back_slashes(char *s);