/* Read the transsql file and filter some entries */ #include #include #include #include #include #include using namespace std; struct TRANS{ string title; string from; string to; bool mark; TRANS (const string &_title, const string &_from, const string &_to){ title = _title; from = _from; to = _to; mark = false; } }; int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *nonoldjoin = NULL; glocal.ret = (argc,argv); setproginfo ("transsql-filter",VERSION,"Filter transsql.conf"); setarg ('o',"nooldjoin","File holding non old join queries",glocal.nonoldjoin,false); int ret = -1; if (argc != 1){ usage(); }else{ glocal string title; glocal string from; glocal string to; glocal string one; glocal bool in_from = true; glocal vector tb; (argv[0],true); if (line[0] == '#'){ if (glocal.to.size() > 0) glocal.tb.push_back(TRANS(glocal.title,glocal.from,glocal.to)); glocal.in_from = true; glocal.from.clear(); glocal.title = str_skip(line+1); glocal.one.clear(); }else if (line[0] == '!'){ glocal.in_from = false; glocal.to.clear(); glocal.one.clear(); }else if (glocal.in_from){ glocal.from += glocal.one + line; glocal.one = " "; }else{ glocal.to += glocal.one + line; glocal.one = " "; } return 0; if (glocal.to.size() > 0) glocal.tb.push_back(TRANS(glocal.title,glocal.from,glocal.to)); int nboldjoin = 0; int nbinto = 0; for (vector::iterator it = glocal.tb.begin(); it != glocal.tb.end(); it++){ if (strstr(it->from.c_str(),"*=") != NULL || strstr(it->from.c_str(),"=*")!=NULL){ it->mark = true; // printf ("oldjoin: %s\n",it->title.c_str()); nboldjoin++; } static const char *selectinto = "select * into #"; static int selectinto_len = strlen(selectinto); printf ("selectinto %d %s: %-30.30s\n",selectinto_len,selectinto,it->to.c_str()); if (strncasecmp(it->to.c_str(),selectinto,selectinto_len)==0){ it->mark = true; nbinto++; } } printf ("tb.size=%lu nboldjoin=%d nbinto=%d\n",glocal.tb.size(),nboldjoin,nbinto); } return ret; return glocal.ret; }