Annotation of parser3/src/types/pa_vrequest.C, revision 1.5

1.2       paf         1: /** @file
1.5     ! paf         2:        Parser: @b request class.
1.2       paf         3: 
1.1       paf         4:        Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
1.2       paf         5: 
1.1       paf         6:        Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
                      7: 
1.5     ! paf         8:        $Id: pa_vrequest.C,v 1.4 2001/03/28 14:41:33 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #include "pa_vrequest.h"
                     12: #include "pa_request.h"
                     13: 
                     14: // request: CLASS,BASE,method,field
                     15: Value *VRequest::get_element(const String& aname) {
1.4       paf        16:        // $browser
                     17:        if(aname=="browser") {
                     18:                VHash *vhash=NEW VHash(pool());
                     19: 
                     20:                // analize
                     21:                bool ie=true;
                     22:                const char *version=0;
                     23:                const char *agent=frequest.info.user_agent;
                     24:                if(agent) {
                     25:                        if(strstr(agent, "compatible")) {
                     26:                                if(const char *msie=strstr(agent, "MSIE ")) {
                     27:                                        ie=true;
                     28:                                        version=msie+5;
                     29:                                }
                     30:                        } else {
                     31:                                if(!strncasecmp(agent, "MOZILLA/", 8)) {
                     32:                                        ie=false;
                     33:                                        version=agent+8;
                     34:                                }
                     35:                        }
                     36:                }
                     37:                
                     38:                // set $browser.type
                     39:                vhash->hash().put(*NEW String(pool(), "type"), 
                     40:                        NEW VString(*NEW String(pool(), ie?"ie":"nn")));
                     41:                if(version) { // we know the version
                     42:                        // set $browser.version
                     43:                        vhash->hash().put(*NEW String(pool(), "version"), 
                     44:                                NEW VDouble(pool(), atof(version)));
                     45:                }
                     46:                //
                     47:                return vhash;
                     48:        }
                     49: 
1.1       paf        50:        // $query $uri 
                     51:        const char *cstr=0;
                     52:        if(aname=="query")
                     53:                cstr=frequest.info.query_string;
                     54:        if(aname=="uri")
                     55:                cstr=frequest.info.uri;
                     56:        if(!cstr)
                     57:                return 0;
                     58:        
                     59:        String& string=*NEW String(pool());
                     60:        string.APPEND_TAINTED(cstr, 0, "request", 0);
                     61:        return NEW VString(string);
                     62: }
                     63: 

E-mail: