#include #include #include #include #include #include #ifdef _WIN32 #include #else #include #endif #include #include #include #include #ifndef _NO_MMAP #include #include #endif #include "util/rw/MmapReader.h" std::string getstring(char*first, char*end) { char quotechar=0; while (first tld7= { ".museum", ".travel" }; std::vector tld5= { ".aero", ".asia", ".coop", ".info", ".jobs", ".mobi", ".name" }; std::vector tld4= { ".biz", ".cat", ".com", ".edu", ".gov", ".int", ".mil", ".net", ".org", ".pro", ".tel", ".xxx" }; std::vector tld3= { ".ac", ".ad", ".ae", ".af", ".ag", ".ai", ".al", ".am", ".an", ".ao", ".aq", ".ar", ".as", ".at", ".au", ".aw", ".ax", ".az", ".ba", ".bb", ".bd", ".be", ".bf", ".bg", ".bh", ".bi", ".bj", ".bm", ".bn", ".bo", ".br", ".bs", ".bt", ".bv", ".bw", ".by", ".bz", ".ca", ".cc", ".cd", ".cf", ".cg", ".ch", ".ci", ".ck", ".cl", ".cm", ".cn", ".co", ".cr", ".cs", ".cu", ".cv", ".cx", ".cy", ".cz", ".de", ".dj", ".dk", ".dm", ".do", ".dz", ".ec", ".ee", ".eg", ".er", ".es", ".et", ".eu", ".fi", ".fj", ".fk", ".fm", ".fo", ".fr", ".ga", ".gb", ".gd", ".ge", ".gf", ".gg", ".gh", ".gi", ".gl", ".gm", ".gn", ".gp", ".gq", ".gr", ".gs", ".gt", ".gu", ".gw", ".gy", ".hk", ".hm", ".hn", ".hr", ".ht", ".hu", ".id", ".ie", ".il", ".im", ".in", ".io", ".iq", ".ir", ".is", ".it", ".je", ".jm", ".jo", ".jp", ".ke", ".kg", ".kh", ".ki", ".km", ".kn", ".kp", ".kr", ".kw", ".ky", ".kz", ".la", ".lb", ".lc", ".li", ".lk", ".lr", ".ls", ".lt", ".lu", ".lv", ".ly", ".ma", ".mc", ".md", ".me", ".mg", ".mh", ".mk", ".ml", ".mm", ".mn", ".mo", ".mp", ".mq", ".mr", ".ms", ".mt", ".mu", ".mv", ".mw", ".mx", ".my", ".mz", ".na", ".nc", ".ne", ".nf", ".ng", ".ni", ".nl", ".no", ".np", ".nr", ".nu", ".nz", ".om", ".pa", ".pe", ".pf", ".pg", ".ph", ".pk", ".pl", ".pm", ".pn", ".pr", ".ps", ".pt", ".pw", ".py", ".qa", ".re", ".ro", ".rs", ".ru", ".rw", ".sa", ".sb", ".sc", ".sd", ".se", ".sg", ".sh", ".si", ".sj", ".sk", ".sl", ".sm", ".sn", ".so", ".sr", ".st", ".su", ".sv", ".sy", ".sz", ".tc", ".td", ".tf", ".tg", ".th", ".tj", ".tk", ".tl", ".tm", ".tn", ".to", ".tp", ".tr", ".tt", ".tv", ".tw", ".tz", ".ua", ".ug", ".uk", ".us", ".uy", ".uz", ".va", ".vc", ".ve", ".vg", ".vi", ".vn", ".vu", ".wf", ".ws", ".ye", ".yt", ".za", ".zm", ".zw" }; bool ishostpath(const std::string& base) { size_t ix= base.find_last_of('.'); if (ix==base.npos) return false; std::string tld= base.substr(ix); switch(base.size()-ix) { case 3: return std::binary_search(tld3.begin(), tld3.end(), tld); case 4: return std::binary_search(tld4.begin(), tld4.end(), tld); case 5: return std::binary_search(tld5.begin(), tld5.end(), tld); case 7: return std::binary_search(tld7.begin(), tld7.end(), tld); } return false; } std::string gethostpath(const std::string& filename) { std::string str= filename; while (!str.empty() && !ishostpath(str)) { size_t ix= str.find_last_of('/'); if (ix==str.npos) break; str.resize(ix); } return str; } std::string makepath(const std::string& filename, const std::string& path) { if (path.find("://")!=path.npos) return path; if (path.find("javascript:")==0) return path; if (path.find("mailto:")==0) return path; if (!path.empty() && path[0]=='/') return gethostpath(filename)+path; return filename.substr(0, filename.find_last_of('/'))+"/"+path; } void findstrings(const std::string& filename, char *first, char *last, const std::string& token) { char *p= first; while (p void processargs(int& i, int argc, char**argv, ACTION act) { bool nomoreoptions=false; while (i files; try { for (int i=1 ; i