Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <vector>
- #include "../utils.cpp"
- // use this line to compile
- // g++ -I. -fPIC -shared -g -o sunat.gob.pe.so sunat.gob.pe.cpp
- // regex
- // http.*\.sunat\.gob\.pe.*(\.gif|\.jpg|\.png|\.exe|\.rar|\.zip|\.swf)
- 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);
- }
- }
- extern "C" resposta hgetmatch2(const string url) {
- resposta r;
- r.range_min = 0;
- r.range_max = 0;
- if ( (url.find(".sunat.gob.pe") != string::npos)
- ) {
- r.file = get_filename(url);
- if (!r.file.empty()) {
- r.match = true;
- r.domain = "Sunat";
- } else {
- r.match = false;
- }
- } else {
- r.match = false;
- }
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement