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

📄 mod_gzip.c

📁 look at this software its cool really cool
💻 C
📖 第 1 页 / 共 5 页
字号:
   {    return 1;   } for ( i=0; i<len1; i++ )    {     if ( ( *s1 == 0 ) || ( *s2 == 0 ) ) return( 1 );      ch1 = *s1;     ch2 = *s2;     if ( ch1 > 96 ) ch1 -= 32;     if ( ch2 > 96 ) ch2 -= 32;     if ( ch1 == '/' ) ch1 = '\\';     if ( ch2 == '/' ) ch2 = '\\';     if ( ch1 != ch2 ) return 1;     s1++;     s2++;    } return 0;}int mod_gzip_strendswith( char *s1, char *s2, int ignorcase ){ int len1; int len2; if ( ( s1 == 0 ) || ( s2 == 0 ) )   {    return 0;   } len1 = mod_gzip_strlen( s1 ); len2 = mod_gzip_strlen( s2 ); if ( len1 < len2 )   {    /* Source string is shorter than search string */    /* so no match is possible */    return 0;   } s1 += ( len1 - len2 ); if ( ignorcase )   {    if ( mod_gzip_strnicmp( s1, s2, len2 ) == 0 ) return 1; /* TRUE */   } else   {    if ( mod_gzip_strncmp(  s1, s2, len2 ) == 0 ) return 1; /* TRUE */   } return 0; /* FALSE */}int mod_gzip_strlen( char *s1 ){ int len = 0; if ( s1 != 0 )   {    while( *s1 != 0 ) { s1++; len++; }   } return len;}int mod_gzip_strcpy( char *s1, char *s2 ){ int len = 0; if ( ( s1 != 0 )&&( s2 != 0 ) )   {    while( *s2 != 0 ) { *s1++ = *s2++; len++; }    *s1=0;    } return len;}int mod_gzip_strcat( char *s1, char *s2 ){ int len = 0; if ( s1 != 0 )   {    while( *s1 != 0 ) { s1++; len++; }    if ( s2 != 0 )      {       while( *s2 != 0 ) { *s1++ = *s2++; len++; }       *s1 = 0;       }   } return len;}int mod_gzip_stringcontains( char *source, char *substring ){ int i; int len1; int len2; int len3; int offset=1;  char *source1;     char *substring1;  if ( source == NULL )   {    return 0;   } if ( substring == NULL )   {    return 0;   } source1    = source;     substring1 = substring;  len1 = mod_gzip_strlen( source    ); len2 = mod_gzip_strlen( substring ); if ( len1 < len2 )   {    return 0;   } len3 = len1 - len2; for ( i=0; i<=len3; i++ )    {     if ( mod_gzip_strnicmp( source, substring, len2 ) == 0 )       {        source    = source1;            substring = substring1;         return offset;       }     source++;     offset++;    } source    = source1;     substring = substring1;  return 0;}const char *mod_gzip_npp( const char *s ){ /* NOTE: This 'Null Pointer Protection' call is really only */ /* needed for the Solaris Operating System which seems to have */ /* some kind of problem handling NULL pointers passed to certain */ /* STDLIB calls. Sloaris will GP fault where all other OS's are OK. */ if ( s ) return s; else     return "NULL";}#ifdef MOD_GZIP_DEBUG1int mod_gzip_dump_a_table( request_rec *r, apr_table_t *t ){ /* Print the contents of an Apache standard 'table' */ /* such as 'r->headers_in' or 'r->headers_out' */ int i; const apr_array_header_t *elts_arr = apr_table_elts(t); const apr_table_entry_t *elts = (apr_table_entry_t *) elts_arr->elts; #ifdef MOD_GZIP_DEBUG1 char cn[]="mod_gzip_dump_a_table()"; #endif /* Start... */ #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: Entry...",cn); mod_gzip_printf( "%s: elts_arr->nelts = %d",cn,(int)elts_arr->nelts); #endif for (i = 0; i < elts_arr->nelts; ++i)    {     #ifdef MOD_GZIP_DEBUG1     mod_gzip_printf( "%s: %3.3d key=[%s] val=[%s]",     cn,i,elts[i].key,elts[i].val);     #endif    }/* End 'i' loop */ #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( "%s: Exit > return( 0 ) >",cn); #endif return 0;}/* End of mod_gzip_dump_a_table() */void mod_gzip_hexdump( char *buffer, int buflen ){ int i,o1,o2,o3; int len1; int len2; char ch1; char ch2; char s[40]; char l1[129]; char l2[129]; char l3[300]; long offset1=0L; o1=0; o2=0; o3=0; l1[0] = 0; l2[0] = 0; l3[0] = 0; offset1 = 0; for ( i=0; i<buflen; i++ )    {     ch1 = (char) *buffer++;     #define DUMPIT_ASTERISK    42     #define DUMPIT_LAPOSTROPHE 96     #define DUMPIT_RAPOSTROPHE 39     #define DUMPIT_PERIOD      46     #define DUMPIT_CR          67     #define DUMPIT_LF          76     #ifdef MASK_ONLY_CERTAIN_CHARS          if ( ch1 ==  0 ) ch2 = DUMPIT_PERIOD;     else if ( ch1 == 13 ) ch2 = DUMPIT_CR;     else if ( ch1 == 10 ) ch2 = DUMPIT_LF;     else if ( ch1 ==  9 ) ch2 = DUMPIT_LAPOSTROPHE;     else                  ch2 = ch1;     #endif     #define MASK_ALL_NON_PRINTABLE_CHARS     #ifdef  MASK_ALL_NON_PRINTABLE_CHARS          if ( ch1 == 13 ) ch2 = DUMPIT_CR;     else if ( ch1 == 10 ) ch2 = DUMPIT_LF;     else if ( ch1 <  32 ) ch2 = DUMPIT_PERIOD;     else if ( ch1 >  126) ch2 = DUMPIT_LAPOSTROPHE;     else if ( ch1 == 37 ) ch2 = DUMPIT_ASTERISK;      else if ( ch1 == 92 ) ch2 = DUMPIT_ASTERISK;      else                  ch2 = ch1;     #endif     l2[o2++] = ch2;     sprintf( s, "%02X", ch1 );     if ( mod_gzip_strlen(s) > 2 ) s[2]=0;      len1 = mod_gzip_strlen(s);     len2 = mod_gzip_strlen(l1);     if ( mod_gzip_strlen(l1) < (int)(sizeof(l1) - (len1+1)) )       {        strcat( l1, s   );        strcat( l1, " " );       }     if ( o2 >= 16 )       {        l2[o2]=0;        mod_gzip_printf( "%6lu| %-49.49s| %-16.16s |", offset1, l1, l2 );        offset1 += o2;        o1=0;        o2=0;        o3=0;        l1[0] = 0;        l2[0] = 0;        l3[0] = 0;       }    } if ( o2 > 0  )   {    l2[o2]=0;    mod_gzip_printf( "%6lu| %-49.49s| %-16.16s |", offset1, l1, l2 );    offset1 += o2;    o1 = o2 = o3 = 0;    l1[0] = 0;    l2[0] = 0;    l3[0] = 0;   }}/* End of mod_gzip_hexdump() */#endif MOD_GZIP_DEBUG1/* ITEM INCLUSION/EXCLUSION MAPPING SUPPORT... */static const char *mod_gzip_imap_add_item(cmd_parms     *parms,mod_gzip_conf *mgc,char          *a1,char          *a2,int            flag1){ int      x; char    *p1; int      ignorecase=0; int      this_include=flag1; int      this_type=0; int      this_action=0; int      this_direction=0; unsigned this_port=0; int      this_len1=0; regex_t *this_pregex=NULL; char    *regex; /* Diagnostic only #define MOD_GZIP_TEST_REGEX1 */ #ifdef  MOD_GZIP_TEST_REGEX1 char string[129]; int  regex_error; #endif #ifdef MOD_GZIP_DEBUG1 char cn[]="mod_gzip_imap_add_item()"; #endif #ifdef MOD_GZIP_DEBUG1 mod_gzip_printf( " "); /* Feed down 1 line */ mod_gzip_printf( "%s: Entry", cn ); mod_gzip_printf( "%s: 1 a1=[%s]", cn, mod_gzip_npp(a1)); mod_gzip_printf( "%s: 1 a2=[%s]", cn, mod_gzip_npp(a2)); 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 ); if ( flag1 == 1 )   {    mod_gzip_printf( "%s: flag1 = %d = INCLUDE", cn, flag1 );   } else if ( flag1 == 0 )   {    mod_gzip_printf( "%s: flag1 = %d = EXCLUDE", cn, flag1 );   } else   {    mod_gzip_printf( "%s: flag1 = %d = ??? Unknown value", cn, flag1 );   } #endif this_type = MOD_GZIP_IMAP_ISNONE; if ( mod_gzip_strnicmp( a1, "mime", 4 ) == 0 )   {    this_type = MOD_GZIP_IMAP_ISMIME;    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type = MOD_GZIP_IMAP_ISMIME", cn);    #endif   } else if ( mod_gzip_strnicmp( a1, "file", 4 ) == 0 )   {    this_type = MOD_GZIP_IMAP_ISFILE;    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type = MOD_GZIP_IMAP_ISFILE",cn);    #endif   } else if ( mod_gzip_strnicmp( a1, "ur", 2 ) == 0 )   {    /* Allow user to specify EITHER 'uri' or 'url' for this 'type' */    this_type = MOD_GZIP_IMAP_ISURI;    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type = MOD_GZIP_IMAP_ISURI",cn);    #endif   } else if ( mod_gzip_strnicmp( a1, "hand", 4 ) == 0 )   {    this_type = MOD_GZIP_IMAP_ISHANDLER;    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type = MOD_GZIP_IMAP_ISHANDLER",cn);    #endif   } else if ( mod_gzip_strnicmp( a1, "reqh", 4 ) == 0 )   {    this_type      = MOD_GZIP_IMAP_ISREQHEADER;    this_direction = MOD_GZIP_REQUEST;    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type      = MOD_GZIP_IMAP_ISREQHEADER",cn);    #endif   } else if ( mod_gzip_strnicmp( a1, "rsph", 4 ) == 0 )   {    this_type      = MOD_GZIP_IMAP_ISRSPHEADER;    this_direction = MOD_GZIP_RESPONSE;    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type      = MOD_GZIP_IMAP_ISRSPHEADER",cn);    #endif   } if ( this_type == MOD_GZIP_IMAP_ISNONE )   {    #ifdef MOD_GZIP_DEBUG1    mod_gzip_printf( "%s: this_type = ?? UNKNOWN ??",cn);    mod_gzip_printf( "%s: Exit > return( ERRORSTRING ) >",cn);    #endif    return "mod_gzip: ERROR: Valid item types are mime,file,uri,handler,reqheader or rspheader";   } p1 = a2;

⌨️ 快捷键说明

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