Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef USEMSV_PCRE
- //RewriteEngine
- if(listen_http_options.GetOptionGlobal("RewriteEngine", host).compareu("on")){
- ilink.Link(url);
- // rewrite
- listen_http_option *rw_host = host;
- listen_http_option *opt = 0;
- while(1){
- opt = listen_http_options.FindOption("RewriteRule", opt, rw_host);
- if(!opt && rw_host){
- opt = listen_http_options.FindOption("RewriteRule", 0, 0);
- rw_host = 0;
- }
- if(!opt)
- break;
- // init
- VString rule, result, options;
- const char *errptr; int erroffset;
- int opt_l = 0, opt_qsa = 0;
- int arr[255];
- VString rurl = ilink.GetPathFile().str(1);
- rule = PartLine(opt->val, result, " ");
- result = PartLine(result, options, " ");
- // compile
- pcre *p = pcre_compile(it.set(rule), 0, &errptr, &erroffset, 0);
- // find
- int f = pcre_exec(p, 0, rurl, rurl, 0, 0, arr, 255);
- // found
- if(f > 0){
- // options
- if(options[0] == '[' && options.endo() == ']'){
- options = options.str(1, -2);
- while(options){
- VString k = PartLine(options, options, ",");
- if(k == "L" || k == "last")
- opt_l = 1;
- else if(k == "SQA" || k == "qsappend")
- opt_qsa = 1;
- }
- }
- it.Reserv(prmf_pcre_result(0, 0, result, result, rurl, rule, arr, f, opt_qsa, ilink.iquest));
- prmf_pcre_result(it, it, result, result, rurl, rule, arr, f, opt_qsa, ilink.iquest);
- ilink.Link(url = it);
- }
- pcre_free(p);
- if(opt_l)
- break;
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement