--- parser3/src/include/pa_common.h 2019/11/12 21:13:31 1.176 +++ parser3/src/include/pa_common.h 2020/11/21 23:26:26 1.183 @@ -8,11 +8,10 @@ #ifndef PA_COMMON_H #define PA_COMMON_H -#define IDENT_PA_COMMON_H "$Id: pa_common.h,v 1.176 2019/11/12 21:13:31 moko Exp $" +#define IDENT_PA_COMMON_H "$Id: pa_common.h,v 1.183 2020/11/21 23:26:26 moko Exp $" #include "pa_string.h" #include "pa_hash.h" -#include "pa_base64.h" class Request; @@ -40,8 +39,6 @@ class Request; #define HTTP_CONTENT_TYPE_MULTIPART_RELATED "multipart/related" #define HTTP_CONTENT_TYPE_MULTIPART_MIXED "multipart/mixed" -#define BASE64_STRICT_OPTION_NAME "strict" - const String content_disposition_filename_name(CONTENT_DISPOSITION_FILENAME_NAME); #define HASH_ORDER @@ -125,22 +122,13 @@ bool file_read_action_under_lock(const S bool fail_on_read_problem=true); /** - read specified text file using + read specified text file 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! */ -char *file_read_text(Request_charsets& charsets, - const String& file_spec, - bool fail_on_read_problem=true, - 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); +char *file_read_text(Request_charsets& charsets, const String& file_spec, bool fail_on_read_problem = 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; @@ -149,24 +137,18 @@ struct File_read_result { }; /** - read specified file using + read specified binary file 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! +File_read_result file_read_binary(const String& file_spec, bool fail_on_read_problem = true, char* buf = 0, size_t offset = 0, size_t limit = 0); + +/** + load specified file + if fail_on_read_problem is true[default] throws an exception */ -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, - 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, bool transcode_text_result=true); typedef void (*File_write_action)(int f, void *context); @@ -220,7 +202,7 @@ const String* file_exist(const String& p bool file_executable(const String& file_spec); bool file_stat(const String& file_spec, uint64_t& rsize, time_t& ratime, time_t& rmtime, time_t& rctime, bool fail_on_read_problem=true); -size_t check_file_size(uint64_t size, const String& file_spec); +size_t check_file_size(uint64_t size, const String* file_spec); size_t stdout_write(const void *buf, size_t size); @@ -263,6 +245,9 @@ int remove_crlf(char *start, char *end); inline bool pa_isalpha(unsigned char c) { return (((c>='A') && (c<='Z')) || ((c>='a') && (c<='z'))); } inline bool pa_isalnum(unsigned char c) { return (((c>='0') && (c<='9')) || pa_isalpha(c)); } +char *pa_strcat(const char *a, const char *b, const char *c = 0); +const char *pa_filename(const char *path); + const char* capitalize(const char* s); char *str_lower(const char *s, size_t helper_length=0); char *str_upper(const char *s, size_t helper_length=0);