--- parser3/src/include/pa_common.h 2003/01/24 08:19:09 1.89.2.2 +++ parser3/src/include/pa_common.h 2003/01/27 15:07:47 1.89.2.4 @@ -8,15 +8,14 @@ #ifndef PA_COMMON_H #define PA_COMMON_H -static const char* IDENT_COMMON_H="$Date: 2003/01/24 08:19:09 $"; +static const char* IDENT_COMMON_H="$Date: 2003/01/27 15:07:47 $"; #include "pa_pool.h" #include "pa_string.h" +#include "pa_hash.h" +#include "pa_value.h" -template class Hash; -typedef Hash StringHash; - -class Value; +typedef Hash HashStringValue; // replace system s*nprintf with our versions #undef vsnprintf @@ -92,10 +91,10 @@ void fix_line_breaks( size_t& size ///< may change! used to speedup next actions ); -typedef void (*File_read_action)( +typedef void (*File_read_action)(Pool& pool, struct stat& finfo, int f, - ConstStringPtr file_spec, CharPtr fname, bool as_text, + ConstStringPtr file_spec, const char *fname, bool as_text, void *context); /** @@ -105,7 +104,7 @@ typedef void (*File_read_action)( @returns true if read OK */ -bool file_read_action_under_lock(ConstStringPtr file_spec, +bool file_read_action_under_lock(Pool& pool, ConstStringPtr file_spec, const char *action_name, File_read_action action, void *context, bool as_text=false, bool fail_on_read_problem=true); @@ -115,10 +114,15 @@ bool file_read_action_under_lock(ConstSt @returns true if read OK */ -char *file_read_text(Pool& pool, +char *file_read_text(Pool& pool, Charset& charset, ConstStringPtr file_spec, bool fail_on_read_problem=true, - StringHash* options=0, StringHash** out_fields=0); + HashStringValue* options=0, HashStringValue** out_fields=0); + +struct File_read_result { + bool success; + HashStringValuePtr fields; +}; /** read specified file using pool, @@ -126,11 +130,11 @@ char *file_read_text(Pool& pool, @returns true if read OK */ -bool file_read(Pool& pool, +File_read_result file_read(Pool& pool, Charset& charset, ConstStringPtr file_spec, - void *& ptr, size_t& size, + char *& ptr, size_t& size, bool as_text, - StringHash* options=0, StringHash** out_fields=0, + HashStringValue* options=0, HashStringValue** out_fields=0, bool fail_on_read_problem=true); typedef void (*File_write_action)(int f, void *context); @@ -176,7 +180,7 @@ bool entry_exists(const char *fname, str bool entry_exists(ConstStringPtr file_spec); bool file_readable(ConstStringPtr file_spec); bool dir_readable(ConstStringPtr file_spec); -String *file_readable(ConstStringPtr path, ConstStringPtr name); +ConstStringPtr file_readable(ConstStringPtr path, ConstStringPtr name); bool file_executable(ConstStringPtr file_spec); bool file_stat(ConstStringPtr file_spec, @@ -196,7 +200,7 @@ char *getrow(char **row_ref,char delim=' char *lsplit(char *string, char delim); char *lsplit(char **string_ref,char delim); char *rsplit(char *string, char delim); -char *format(double value, char *fmt); +const char *format(Pool& pool, double value, char *fmt); #ifndef max inline int max(int a, int b) { return a>b?a:b; }