⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_gzip.c

📁 look at this software its cool really cool
💻 C
📖 第 1 页 / 共 5 页
字号:
 if ( ( this_type == MOD_GZIP_IMAP_ISREQHEADER ) ||      ( this_type == MOD_GZIP_IMAP_ISRSPHEADER ) )   {    while((*p1!=0)&&(*p1!=':')) { p1++; this_len1++; }    if (*p1==':')      {       if ( this_len1 < 1 )         {          return "mod_gzip: ERROR: Missing HTTP field name.";         }       p1++;      }    else      {       return "mod_gzip: ERROR: Missing HTTP field name. No colon found.";      }    while((*p1!=0)&&(*p1<33)) p1++;   } regex = p1; #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: regex = [%s]", cn, mod_gzip_npp(regex) ); #endif if ( !*regex )   {    return "mod_gzip: ERROR: Missing regular expression string.";   } ignorecase = 1; #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: ignorecase = %d",cn,ignorecase); mod_gzip_printf( "%s: Call ap_pregcomp(%s)...",cn,mod_gzip_npp(regex)); #endif this_pregex = ap_pregcomp(parms->pool, regex, (REG_EXTENDED | REG_NOSUB | (ignorecase ? REG_ICASE : 0))); if ( this_pregex == NULL )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: .... ap_pregcomp(%s) FAILED...",cn,mod_gzip_npp(regex));    mod_gzip_printf( "%s: regex 'pre-compile' FAILED...", cn );    mod_gzip_printf( "%s: Exit > return( ERRORSTRING ) >",cn);    #endif    return "mod_gzip: ERROR: Regular expression compile failed.";   } #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: .... ap_pregcomp(%s) SUCCEEDED...",cn,mod_gzip_npp(regex)); mod_gzip_printf( "%s: regex 'pre-compiled' OK", cn ); #endif #ifdef MOD_GZIP_TEST_REGEX1 if ( ( this_type == MOD_GZIP_IMAP_ISREQHEADER ) ||      ( this_type == MOD_GZIP_IMAP_ISRSPHEADER ) )   {    mod_gzip_strcpy(    string,    "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt; TUCOWS)"    );    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: Call ap_regexec( regex=[%s], string=[%s] )",                   cn, mod_gzip_npp(regex), mod_gzip_npp(string) );    #endif    regex_error = ap_regexec(this_pregex, string, 0, (regmatch_t *)NULL,0);    #ifdef MOD_GZIP_DEBUG1    if ( regex_error != 0 )    mod_gzip_printf( "%s: regex_error = %d = NO MATCH!", cn, regex_error );    else    mod_gzip_printf( "%s: regex_error = %d = MATCH!", cn, regex_error );    #endif   } #endif /* MOD_GZIP_TEST_REGEX1 */ this_action = MOD_GZIP_IMAP_STATIC1; #ifdef FUTURE_USE if ( ( this_action != MOD_GZIP_IMAP_DYNAMIC1 ) &&      ( this_action != MOD_GZIP_IMAP_DYNAMIC2 ) &&      ( this_action != MOD_GZIP_IMAP_STATIC1  ) )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_action = %d = MOD_GZIP_IMAP_??? Unknown action",cn,this_action);    mod_gzip_printf( "%s: return( mod_gzip: ERROR: Unrecognized item 'action'",cn);    #endif    return( "mod_gzip: ERROR: Unrecognized item 'action'" );   } #endif /* FUTURE_USE */ if ( mgc->imap_total_entries < MOD_GZIP_IMAP_MAXNAMES )   {    if ( mod_gzip_strlen( a2 ) < MOD_GZIP_IMAP_MAXNAMELEN )      {       x = mgc->imap_total_entries;       p1 = a2;       mod_gzip_strcpy( mgc->imap[x].name, p1 );       mgc->imap[x].namelen = mod_gzip_strlen( mgc->imap[x].name );       mgc->imap[x].include   = this_include;       mgc->imap[x].type      = this_type;       mgc->imap[x].action    = this_action;       mgc->imap[x].direction = this_direction;       mgc->imap[x].port      = this_port;       mgc->imap[x].len1      = this_len1;       mgc->imap[x].pregex    = this_pregex;       mgc->imap_total_entries++;       if ( this_type == MOD_GZIP_IMAP_ISMIME )         {          mgc->imap_total_ismime++;         }       else if ( this_type == MOD_GZIP_IMAP_ISFILE )         {          mgc->imap_total_isfile++;         }       else if ( this_type == MOD_GZIP_IMAP_ISURI )         {          mgc->imap_total_isuri++;         }       else if ( this_type == MOD_GZIP_IMAP_ISHANDLER )         {          mgc->imap_total_ishandler++;         }       else if ( this_type == MOD_GZIP_IMAP_ISREQHEADER )         {          mgc->imap_total_isreqheader++;         }       else if ( this_type == MOD_GZIP_IMAP_ISRSPHEADER )         {          mgc->imap_total_isrspheader++;         }      }    else      {       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: return( mod_gzip: ERROR: Item name is too long",cn);       #endif       return( "mod_gzip: ERROR: Item name is too long" );      }   } else   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: return( mod_gzip: ERROR: Item index is full",cn);    #endif    return( "mod_gzip: ERROR: Item index is full" );   } #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: mgc->imap_total_entries     = %d",                   cn, mgc->imap_total_entries ); mod_gzip_printf( "%s: mgc->imap_total_ismime      = %d",                   cn, mgc->imap_total_ismime ); mod_gzip_printf( "%s: mgc->imap_total_isfile      = %d",                   cn, mgc->imap_total_isfile ); mod_gzip_printf( "%s: mgc->imap_total_isuri       = %d",                   cn, mgc->imap_total_isuri ); mod_gzip_printf( "%s: mgc->imap_total_ishandler   = %d",                   cn, mgc->imap_total_ishandler ); mod_gzip_printf( "%s: mgc->imap_total_isreqheader = %d",                   cn, mgc->imap_total_isreqheader ); mod_gzip_printf( "%s: mgc->imap_total_isrspheader = %d",                   cn, mgc->imap_total_isrspheader ); mod_gzip_printf( "%s: Exit > return( NULL ) >",cn); #endif return NULL;}int mod_gzip_validate1(request_rec   *r,mod_gzip_conf *mgc,char          *r__filename,char          *r__uri,char          *r__content_type,char          *r__handler,char          *fieldkey,char          *fieldstring,int            direction){ int   x                = 0; int   clen             = 0; int   hlen             = 0; int   flen             = 0; int   ulen             = 0; int   pass             = 0; int   passes           = 2; char *this_name        = 0; int   this_type        = 0; int   this_len1        = 0; int   this_action      = 0; int   this_include     = 0; char *checktarget      = 0; int   pass_result      = 0; int   action_value     = 0; int   filter_value     = 0; int   type_to_match    = 0; int   ok_to_check_it   = 0; int   http_field_check = 0; int   item_is_included = 0; int   item_is_excluded = 0; int   type_is_included = 0; regex_t *this_pregex   = NULL; int      regex_error   = 0; #ifdef MOD_GZIP_DEBUG1 char cn[]="mod_gzip_validate1()"; #endif if ( r__filename     ) flen = mod_gzip_strlen( (char *) r__filename ); if ( r__uri          ) ulen = mod_gzip_strlen( (char *) r__uri ); if ( r__content_type ) clen = mod_gzip_strlen( (char *) r__content_type ); if ( r__handler      ) hlen = mod_gzip_strlen( (char *) r__handler ); #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: Entry...",cn); mod_gzip_printf( "%s: r__filename     = [%s]",cn,mod_gzip_npp(r__filename)); mod_gzip_printf( "%s: flen            = %d",  cn,flen); mod_gzip_printf( "%s: r__uri          = [%s]",cn,mod_gzip_npp(r__uri)); mod_gzip_printf( "%s: ulen            = %d",  cn,ulen); mod_gzip_printf( "%s: r__content_type = [%s]",cn,mod_gzip_npp(r__content_type)); mod_gzip_printf( "%s: clen            = %d",  cn,clen); mod_gzip_printf( "%s: r__handler      = [%s]",cn,mod_gzip_npp(r__handler)); mod_gzip_printf( "%s: hlen            = %d",  cn,hlen); mod_gzip_printf( "%s: fieldkey        = [%s]",cn,mod_gzip_npp(fieldkey)); mod_gzip_printf( "%s: fieldstring     = [%s]",cn,mod_gzip_npp(fieldstring)); mod_gzip_printf( "%s: direction       = %d",  cn,direction); #endif if ( ( fieldkey ) && ( fieldstring ) )   {    http_field_check = 1;    passes = 1;    if ( direction == MOD_GZIP_REQUEST )      {       type_to_match = MOD_GZIP_IMAP_ISREQHEADER;      }    else if ( direction == MOD_GZIP_RESPONSE )      {       type_to_match = MOD_GZIP_IMAP_ISRSPHEADER;      }    else      {       #ifdef MOD_GZIP_DEBUG1       mod_gzip_printf( "%s: Invalid 'direction' value.",cn);       mod_gzip_printf( "%s: Must be MOD_GZIP_REQUEST or MOD_GZIP_RESPONSE",cn);       mod_gzip_printf( "%s: Exit > return( MOD_GZIP_IMAP_DECLINED1 ) >",cn);       #endif       return( MOD_GZIP_IMAP_DECLINED1 );      }   } else if ( ( hlen == 0 ) && ( clen == 0 ) && ( flen == 0 ) )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: hlen = 0 = No handler name passed...",cn);    mod_gzip_printf( "%s: clen = 0 = No valid content-type passed",cn);    mod_gzip_printf( "%s: flen = 0 = No valid filename passed",cn);    mod_gzip_printf( "%s: There is nothing we can use to search",cn);    mod_gzip_printf( "%s: for a match in the inclusion/exclusion list.",cn);    mod_gzip_printf( "%s: Exit > return( MOD_GZIP_IMAP_DECLINED1 ) >",cn);    #endif    return( MOD_GZIP_IMAP_DECLINED1 );   } #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: passes = %d", cn,                 (int) passes ); mod_gzip_printf( "%s: http_field_check = %d", cn,                 (int) http_field_check ); mod_gzip_printf( "%s: mgc->imap_total_entries = %d", cn,                 (int) mgc->imap_total_entries ); #endif for ( pass=0; pass<passes; pass++ )    {     pass_result = 0;     #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1     #ifdef MOD_GZIP_DEBUG1     mod_gzip_printf( "%s: ",cn);     #endif     #endif     filter_value = pass;     #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1     #ifdef MOD_GZIP_DEBUG1     mod_gzip_printf( "%s: pass         = %d", cn, pass );     mod_gzip_printf( "%s: filter_value = %d", cn, filter_value );     mod_gzip_printf( "%s: mgc->imap_total_entries = %d", cn,                     (int) mgc->imap_total_entries );     #endif     #endif     for ( x=0; x < mgc->imap_total_entries; x++ )        {         this_include = mgc->imap[x].include;         this_type    = mgc->imap[x].type;         this_action  = mgc->imap[x].action;         #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1         #ifdef MOD_GZIP_DEBUG1         mod_gzip_printf( "%s: --------------------------------------------",cn);         mod_gzip_printf( "%s: http_field_check = %d",  cn,http_field_check );         if ( http_field_check )           {            mod_gzip_printf( "%s: fieldkey         = [%s]",cn,mod_gzip_npp(fieldkey));            mod_gzip_printf( "%s: fieldstring      = [%s]",cn,mod_gzip_npp(fieldstring));           }         else           {            mod_gzip_printf( "%s: r__filename      = [%s]",cn,mod_gzip_npp(r__filename));            mod_gzip_printf( "%s: r__uri           = [%s]",cn,mod_gzip_npp(r__uri));            mod_gzip_printf( "%s: r__content_type  = [%s]",cn,mod_gzip_npp(r__content_type));            mod_gzip_printf( "%s: r__handler       = [%s]",cn,mod_gzip_npp(r__handler));           }         if ( this_include == 0 )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].include = %d EXCLUDE",cn,x,this_include);           }         else if ( this_include == 1 )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].include = %d INCLUDE",cn,x,this_include);           }         else           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].include = %d ??? UNKNOWN VALUE",cn,x,this_include);           }         if ( mgc->imap[x].type == MOD_GZIP_IMAP_ISMIME )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_ISMIME",                              cn,x,this_type);           }         else if ( mgc->imap[x].type == MOD_GZIP_IMAP_ISHANDLER )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_ISHANDLER",                              cn,x,this_type);           }         else if ( mgc->imap[x].type == MOD_GZIP_IMAP_ISFILE )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_ISFILE",                              cn,x,this_type);           }         else if ( mgc->imap[x].type == MOD_GZIP_IMAP_ISURI )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_ISURI",                              cn,x,this_type);           }         else if ( mgc->imap[x].type == MOD_GZIP_IMAP_ISREQHEADER )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_ISREQHEADER",                              cn,x,this_type);           }         else if ( mgc->imap[x].type == MOD_GZIP_IMAP_ISRSPHEADER )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_ISRSPHEADER",                              cn,x,this_type);           }         else           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].type    = %d MOD_GZIP_IMAP_IS??? Unknown type",                              cn,x,this_type);           }         if ( mgc->imap[x].action == MOD_GZIP_IMAP_STATIC1 )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].action  = %d MOD_GZIP_IMAP_STATIC1",                              cn,x,this_action);           }         else if ( mgc->imap[x].action == MOD_GZIP_IMAP_DYNAMIC1 )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].action  = %d MOD_GZIP_IMAP_DYNAMIC1",                              cn,x,this_action);           }         else if ( mgc->imap[x].action == MOD_GZIP_IMAP_DYNAMIC2 )           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].action  = %d MOD_GZIP_IMAP_DYNAMIC2",                              cn,x,this_action);           }         else           {            mod_gzip_printf( "%s: mgc->imap[%3.3d].action  = %d MOD_GZIP_IMAP_??? Unknown action",                              cn,x,this_action);           }         mod_gzip_printf( "%s: mgc->imap[%3.3d].name    = [%s]",cn,x,mod_gzip_npp(mgc->imap[x].name));         mod_gzip_printf( "%s: mgc->imap[%3.3d].namelen = %d",  cn,x,mgc->imap[x].namelen);         #endif         #endif         if ( this_include == filter_value )           {            #ifdef MOD_GZIP_DEBUG1_VALIDATE1_VERBOSE1            #ifdef MOD_GZIP_DEBUG1            mod_gzip_printf( "%s: This record matches filter_value %d",                              cn, filter_value );            mod_gzip_printf( "%s: The record will be checked...",cn);            #endif            #endif            type_is_included = 0;            checktarget      = 0;            if ( http_field_check )              {               if ( this_type == type_to_match )                 {                  type_is_included = 1;                  checktarget = (char *) fieldstring;                 }              }            else              {               if ( ( this_type == MOD_GZIP_IMAP_ISMIME ) &&                    ( clen > 0 ) )                 {                  type_is_included = 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -