// use this line to compile // g++ -I. -fPIC -shared -g -o steampowered.com.so steampowered.com.cpp // regex: // http.{3,4}cdn\.(\w|\.)*cs\.steampowered\.com\/depot\/[0-9]+\/chunk\/\w{40} // string get_filename(string url) { vector<string> paths, direct; string file = ""; stringexplode(url, "/", &paths); int psize = paths.size(); short save = 0; for(int i=0;i<psize;i++) { if(save == 1) { file = paths.at(i); save = 0; } if(save == 2) { stringexplode(paths.at(i), "?", &direct); file = file + "_" + direct.at(0); return file; } if(paths.at(i) == "depot") save = 1; if(paths.at(i) == "chunk") save = 2; } return ""; }
string get_filename(string url, int *ra, int *rb) { vector<string> resultado; string tmp; if (url.find(".flv?") != string::npos) { stringexplode(url, "/", &resultado); url = resultado.at(resultado.size() - 1); resultado.clear(); if ( (tmp = regex_match("[\\?&]ec_seek=[0-9]+", url)) != "" ) { tmp.erase(0,9); *ra = atoi(tmp.c_str()); *rb = -1; } stringexplode(url, "?", &resultado); return resultado.at(0); } else { stringexplode(url, "/", &resultado); tmp = resultado.at(resultado.size()-1); if( regex_match(".flv$", tmp) == "" ) return ""; else return tmp; } return ""; }
string get_filename(string url) { vector<string> resultado; if (url.find("?") != string::npos) { stringexplode(url, "?", &resultado); stringexplode(resultado.at(resultado.size()-2), "/", &resultado); return resultado.at(resultado.size()-1); } else { stringexplode(url, "/", &resultado); return resultado.at(resultado.size()-1); } }
string get_filename(string url) { vector<string> resultado; stringexplode(url, "/", &resultado); if( resultado.size() == 4 ) return resultado.at(2) + "-" + resultado.at(3); else return ""; }
// use this line to compile // g++ -I. -fPIC -shared -g -o eset.com.so eset.com.cpp // http.{1,10}update\.eset\.com\/v[0-9]+(.*\/){2}.*\.nup$ // string get_filename(string url) { vector<string> split; stringexplode(url, "/", &split); int len = split.size(); if ( len >= 3 ) { return split.at(len-3) + DELIM + split.at(len-2) + DELIM + split.at(len-1); } else return ""; }
// use this line to compile // g++ -I. -fPIC -shared -g -o xtube.com.so xtube.com.cpp //~ http.*\.(publicvideo|publicphoto)\.xtube\.com\/(videowall\/)?videos?\/.*(\.flv\?.*|\_Thumb\.flv$) //~ string get_filename(string url, int *ra, int *rb) { vector<string> resultado; stringexplode(url,"/",&resultado); url = resultado.at(resultado.size() - 1); if (url.find("?") == string::npos) { return url; } else { resultado.clear(); stringexplode(url, "?", &resultado); string tmp; if( (tmp = regex_match("[\\?&]fs=[0-9]+",resultado.at(1))) != "" ) { tmp.erase(0,4); *ra = atoi(tmp.c_str()); *rb = -1; } return resultado.at(0); } }
// use this line to compile // g++ -I. -fPIC -shared -g -o avira-update.com.so avira-update.com.cpp // ^http.{3,4}install\.avira-update\.com\/package\/((\w|\_|-)*\/){3}(\w|\_|-)*(\.exe)$ // string get_filename(string url) { vector<string> resultado; stringexplode(url, "/", &resultado); int size = resultado.size(); string fname = resultado.at(size - 4); for(int i = 3; i >= 1; i--) fname = fname + "_-_" + resultado.at(size - i); return fname; }
// use this line to compile // g++ -I. -fPIC -shared -g -o blogspot.com.so blogspot.com.cpp // Regex // ^http.{1,10}\.bp\.blogspot\.com\/.*(\.jpg|\.mp4|\.flv|\.swf)$ // string get_filename(string url) { vector<string> resultado; string filename = ""; stringexplode(url, "/", &resultado); int size = resultado.size(); if ( size < 6 ) return ""; for( int i = 5;i >= 2; i-- ) filename = filename + resultado.at(size - i) + "_"; return filename = filename + resultado.at(size - 1); }
void gen_charfield(Datasrc* src, Odometer* odom, int index, Bytebuffer* fieldbuf) { int i; int lastdim = (index == (odom->rank - 1)); size_t declsize = odom->declsize[index]; Constant* con; ASSERT(declsize != 0); if(lastdim) { for(i=0;i<declsize;) { con = srcnext(src); if(con == NULL) break; if(!isstringable(con->nctype)) { semerror(srcline(src), "Encountered non-string constant in compound field"); return; } i += collectstring(con,declsize,fieldbuf); } if(i < declsize) i=fillstring(declsize,i,fieldbuf); } else { /* ! lastdim*/ int exploded = 0; size_t slicesize; /* Compute subslice size */ slicesize = 1; for(i=index+1;i<odom->rank;i++) slicesize *= MAX(odom->declsize[i],odom->unlimitedsize[i]); con = srcpeek(src); if(con != NULL && !isstringable(con->nctype)) { semerror(srcline(src), "Encountered non-string constant in compound field"); return; } if(con != NULL && con->value.stringv.len > slicesize) { /* Constant is larger than just our slice */ /* Explode the constant into subchunks */ exploded = stringexplode(src,slicesize); } for(i=0;i<declsize;i++) { gen_charfield(src,odom,index+1,fieldbuf); } if(exploded) srcpop(src); } }
void gen_chararray(Symbol* vsym, Bytebuffer* databuf, Datasrc* src, Odometer* odom, int index) { /* Assume that all dimensions from index+1 to rank-1 are !unlimited */ int i; int rank = odom->rank; int lastdim = (index == (rank - 1)); /* last dimension*/ int firstdim = (index == 0); int isunlimited = (odom->declsize[index] == NC_UNLIMITED); int exploded = 0; Constant* con; if(lastdim) { gen_chararraysuffix(vsym,databuf,src,odom,index); return; } ASSERT(index >= 0 && index < rank); odom->index[index] = odom->start[index]; /* reset */ if(isunlimited) { size_t slicesize; Constant* con; if(!firstdim) { if(!issublist(src)) { semerror(srcline(src),"Unlimited data must be enclosed in {..}"); return; } srcpush(src); /* enter the unlimited data */ } con=srcpeek(src); /* Break up the constant if it is too large */ slicesize = odomsubarray(odom,index+1); if(con != NULL && con->value.stringv.len > slicesize) { /* Constant is larger than just our slice */ /* Explode the constant into subchunks */ exploded = stringexplode(src,slicesize); } while((con=srcpeek(src))!=NULL) { gen_chararray(vsym,databuf,src,odom,index+1); odom->index[index]++; } odom->unlimitedsize[index] = odom->index[index]; if(exploded) srcpop(src); if(!firstdim) srcpop(src); } else { /* !isunlimited*/ size_t slicesize; con = srcpeek(src); ASSERT(!lastdim); /* Break up the constant if it is too large */ slicesize = odomsubarray(odom,index+1); if(con != NULL && con->value.stringv.len > slicesize) { /* Constant is larger than just our slice */ /* Explode the constant into subchunks */ exploded = stringexplode(src,slicesize); } for(i=0;i<odom->declsize[index];i++) { gen_chararray(vsym,databuf,src,odom,index+1); } if(exploded) srcpop(src); } }
static void gen_chararraysuffix(Symbol* vsym, Bytebuffer* databuf, Datasrc* src, Odometer* odom, int index) { int i; int rank = odom->rank; int lastdim = (index == (rank - 1)); /* last dimension*/ int firstdim = (index == 0); size_t declsize = odom->declsize[index]; int isunlimited = (declsize==NC_UNLIMITED); Constant* con; ASSERT(index >= 0 && index < rank); odom->index[index] = odom->start[index]; /* reset*/ con = srcpeek(src); if(!isunlimited) { if(con != NULL && !isstringable(con->nctype)) { semerror(srcline(src), "Encountered non-string constant in char data: %s", vsym->name); return; } if(lastdim) { /* To mimic ncgen original, it appears we have to hack. I think firstdim==lastdim may work. */ for(i=0;i<declsize;) { int slen; con = srcnext(src); if(con == NULL) break; slen = collectstring(con,declsize,databuf); if(!firstdim && slen < declsize) slen=fillstring(declsize,slen,databuf); i += slen; } if(firstdim && i < declsize) i = fillstring(declsize,i,databuf); odom->index[index] = i; } else { /* ! lastdim*/ int exploded = 0; size_t slicesize = odometertotal(odom,index+1); if(con != NULL && con->nctype == NC_STRING && con->value.stringv.len > slicesize) { /* Constant is larger than just our slice */ /* Explode the constant into subchunks */ exploded = stringexplode(src,slicesize); } for(i=0;i<odom->declsize[index];i++) { gen_chararraysuffix(vsym,databuf,src,odom,index+1); odom->index[index]++; } if(exploded) srcpop(src); } } else { /* unlimited => lastdim*/ Constant* con; if(!firstdim) { if(!issublist(src)) { semerror(srcline(src),"Unlimited data must be enclosed in {..}"); return; } srcpush(src); /* enter the unlimited data */ } /* Basically, collect all the strings until we run out */ i = 0; while((con=srcnext(src))!=NULL) { i += collectstring(con,0,databuf); } odom->index[index] = i; odom->unlimitedsize[index] = odom->index[index]; if(!firstdim) srcpop(src); } }