#ifdef _WINDOWS // VS6 doesn't like the length of STL generated names: disabling #pragma warning(disable:4786) #endif #include "global_define.h" #include #include #include #include #include #include #ifndef WIN32 #include #endif #include #include "misc.h" #include "types.h" #include #include "strings.h" std::map DBFieldNames; #ifndef WIN32 #if defined(FREEBSD) || defined(__CYGWIN__) int print_stacktrace() { printf("Insert stack trace here...\n"); return(0); } #else //!WIN32 && !FREEBSD == linux #include int print_stacktrace() { void *ba[20]; int n = backtrace (ba, 20); if (n != 0) { char **names = backtrace_symbols (ba, n); if (names != nullptr) { int i; std::cerr << "called from " << (char*)names[0] << std::endl; for (i = 1; i < n; ++i) std::cerr << " " << (char*)names[i] << std::endl; free (names); } } return(0); } #endif //!FREEBSD #endif //!WIN32 void Unprotect(std::string &s, char what) { if (s.length()) { for(std::string::size_type i=0;i fields_list each fields_list is a map of field index -> value */ bool ItemParse(const char *data, int length, std::map > &items, int id_pos, int name_pos, int max_field, int level) { int i; char *end,*ptr; std::map field; static char *buffer=nullptr; static int buffsize=0; static char *temp=nullptr; if (!buffsize || buffsize<(length+1)) { buffer=(char *)realloc(buffer,length+1); temp=(char *)realloc(temp,length+1); buffsize=length+1; } memcpy(buffer,data,length); buffer[length]=0; ptr=buffer; for(i=0;i & tokens, char delim) { int i,len; std::string::size_type end; //char temp[1024]; std::string x; tokens.clear(); i=0; while(s.length()) { if (s[0]==delim) { s.erase(0,1); tokens[i++]=""; } else { end=0; while((end=s.find(delim,end+1))!=std::string::npos && s[end-1]=='\\'); if (end!=std::string::npos) { x=s; x.erase(end,std::string::npos); s.erase(0,end+1); Unprotect(x,'|'); tokens[i++]=x; } else { Unprotect(s,'|'); tokens[i++]=s; break; } } len=0; } return i; } void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader, FILE *to) { unsigned long i,j; unsigned long rows,offset=0; rows=(length/16)+1; for(i=0;i