--- parser3/src/include/pa_common.h 2010/05/17 22:54:58 1.142 +++ parser3/src/include/pa_common.h 2011/02/18 06:01:21 1.144 @@ -8,7 +8,7 @@ #ifndef PA_COMMON_H #define PA_COMMON_H -static const char * const IDENT_COMMON_H="$Date: 2010/05/17 22:54:58 $"; +static const char * const IDENT_COMMON_H="$Date: 2011/02/18 06:01:21 $"; #include "pa_string.h" #include "pa_hash.h" @@ -274,6 +274,14 @@ int getMonthDays(int year, int month); 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)); +} + void check_safe_mode(struct stat finfo, const String& file_spec, const char* fname); void pa_base64_decode(const char *in, size_t in_size, char*& result, size_t& result_size); @@ -376,6 +384,20 @@ static String::C date_gmt_string(tm* tms tms->tm_hour,tms->tm_min,tms->tm_sec)); } +static int lastposafter(const String& s, size_t after, const char* substr, size_t substr_size, bool beforelast=false) { + size_t size=0; // just to calm down compiler + if(beforelast) + size=s.length(); + size_t at; + while((at=s.pos(String::Body(substr), after))!=STRING_NOT_FOUND) { + size_t newafter=at+substr_size/*skip substr*/; + if(beforelast && newafter==size) + break; + after=newafter; + } + + return after; +} // globals