--- parser3/src/include/pa_common.h 2009/01/12 07:10:33 1.126 +++ parser3/src/include/pa_common.h 2009/04/22 04:35:31 1.129 @@ -8,16 +8,23 @@ #ifndef PA_COMMON_H #define PA_COMMON_H -static const char * const IDENT_COMMON_H="$Date: 2009/01/12 07:10:33 $"; +static const char * const IDENT_COMMON_H="$Date: 2009/04/22 04:35:31 $"; #include "pa_string.h" #include "pa_hash.h" +class Request; + // defines -#define HTTP_USER_AGENT "USER-AGENT" -#define HTTP_CONTENT_TYPE "CONTENT-TYPE" -#define HTTP_CONTENT_TYPE_FORM_URLENCODED "application/x-www-form-urlencoded" -#define HTTP_CONTENT_TYPE_MULTIPART "multipart/form-data" +#define HTTP_USER_AGENT_UPPER "USER-AGENT" +#define HTTP_CONTENT_TYPE_UPPER "CONTENT-TYPE" +#define HTTP_USER_AGENT "User-Agent" +#define HTTP_CONTENT_TYPE "Content-Type" +#define HTTP_CONTENT_DISPOSITION "Content-Disposition" +#define HTTP_CONTENT_TYPE_FORM_URLENCODED "application/x-www-form-urlencoded" +#define HTTP_CONTENT_TYPE_MULTIPART_FORMDATA "multipart/form-data" +#define HTTP_CONTENT_TYPE_MULTIPART_RELATED "multipart/related" +#define HTTP_CONTENT_TYPE_MULTIPART_MIXED "multipart/mixed" class Value; typedef Hash HashStringValue; @@ -94,13 +101,12 @@ bool file_read_action_under_lock(const S 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 if fail_on_read_problem is true[default] throws an exception WARNING: charset is used for http header case conversion, it's not a charset of input file! - - @returns true if read OK */ char *file_read_text(Request_charsets& charsets, const String& file_spec, @@ -108,6 +114,12 @@ char *file_read_text(Request_charsets& c HashStringValue* options=0, bool transcode_result=true); +char *file_load_text(Request& r, + const String& file_spec, + bool fail_on_read_problem=true, + HashStringValue* options=0, + bool transcode_result=true); + struct File_read_result { bool success; char* str; size_t length; @@ -119,11 +131,16 @@ struct File_read_result { if fail_on_read_problem is true[default] throws an exception WARNING: charset is used for http header case conversion, it's not a charset of input file! - - @returns true if read OK */ -File_read_result file_read(Request_charsets& charsets, - const String& file_spec, +File_read_result file_read(Request_charsets& charsets, + const String& file_spec, + bool as_text, + HashStringValue* options=0, + bool fail_on_read_problem=true, + char* buf=0, size_t offset=0, size_t size=0, bool transcode_text_result=true); + +File_read_result file_load(Request& r, + const String& file_spec, bool as_text, HashStringValue* options=0, bool fail_on_read_problem=true, @@ -275,7 +292,6 @@ static void file_crc32_file_action( int f, const String&, const char* /*fname*/, bool, void *context); -char* print_pcre_exec_error_text(int exec_result); static const char* hex_string(unsigned char* bytes, size_t size, bool upcase) { char *bytes_hex=new(PointerFreeGC) char [size*2/*byte->hh*/+1/*for zero-teminator*/];