--- parser3/src/main/pa_common.C 2013/07/04 10:27:49 1.271 +++ parser3/src/main/pa_common.C 2013/07/30 12:36:22 1.277 @@ -36,7 +36,18 @@ #include "pcre.h" #include "pa_request.h" -volatile const char * IDENT_PA_COMMON_C="$Id: pa_common.C,v 1.271 2013/07/04 10:27:49 moko Exp $" IDENT_PA_COMMON_H IDENT_PA_HASH_H IDENT_PA_ARRAY_H IDENT_PA_STACK_H; +#ifdef _MSC_VER +#include +#include +#endif + +#ifdef _MSC_VER +#define pa_mkdir(path, mode) _mkdir(path) +#else +#define pa_mkdir(path, mode) mkdir(path, mode) +#endif + +volatile const char * IDENT_PA_COMMON_C="$Id: pa_common.C,v 1.277 2013/07/30 12:36:22 moko Exp $" IDENT_PA_COMMON_H IDENT_PA_HASH_H IDENT_PA_ARRAY_H IDENT_PA_STACK_H; // some maybe-undefined constants @@ -326,7 +337,7 @@ void create_dir_for_file(const String& f size_t pos_after=1; size_t pos_before; while((pos_before=file_spec.pos('/', pos_after))!=STRING_NOT_FOUND) { - mkdir(file_spec.mid(0, pos_before).taint_cstr(String::L_FILE_SPEC), 0775); + pa_mkdir(file_spec.mid(0, pos_before).taint_cstr(String::L_FILE_SPEC), 0775); pos_after=pos_before+1; } } @@ -403,7 +414,7 @@ static void file_write_action(int f, voi ssize_t written=write(f, info.str, info.length); if(written<0) throw Exception("file.write", 0, "write failed: %s (%d)", strerror(errno), errno); - if(written!=info.length) + if((size_t)written!=info.length) throw Exception("file.write", 0, "write failed: %u of %u bytes written", written, info.length); } } @@ -473,11 +484,11 @@ static bool entry_readable(const String& } // throws nothing! [this is required in file_move & file_delete] -static void rmdir(const String& file_spec, size_t pos_after=0) { +static void rmdir(const String& file_spec, size_t pos_after) { char* dir_spec=file_spec.taint_cstrm(String::L_FILE_SPEC); size_t length=strlen(dir_spec); while( (length=get_dir(dir_spec, length)) && (length > pos_after) ){ -#ifdef WIN32 +#ifdef _MSC_VER if(!entry_readable(dir_spec, true)) break; DWORD attrs=GetFileAttributes(dir_spec); @@ -634,7 +645,7 @@ enum FormatType { FormatUInt, FormatDouble }; -FormatType format_type(char* fmt){ +FormatType format_type(const char* fmt){ enum FormatState { Percent, Flags, @@ -645,7 +656,7 @@ FormatType format_type(char* fmt){ FormatType result=FormatInvalid; - char* pos=fmt; + const char* pos=fmt; while(char c=*(pos++)){ switch(state){ case Percent: @@ -689,7 +700,7 @@ FormatType format_type(char* fmt){ } -const char* format(double value, char* fmt) { +const char* format(double value, const char* fmt) { char local_buf[MAX_NUMBER]; int size=-1; @@ -839,14 +850,6 @@ void back_slashes_to_slashes(char* s) { if(*s=='\\') *s='/'; } -/* -void slashes_to_back_slashes(char* s) { - if(s) - for(; *s; s++) - if(*s=='/') - *s='\\'; -} -*/ #endif bool StrStartFromNC(const char* str, const char* substr, bool equal){ @@ -972,7 +975,7 @@ int __vsnprintf(char* b, size_t s, const if((ssize_t)s<0) return 0; -#if _MSC_VER +#ifdef _MSC_VER /* win32: mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2001APR\1033\vccore.chm::/html/_crt__vsnprintf.2c_._vsnwprintf.htm