"Fossies" - the Fresh Open Source Software Archive

Member "mod_gzip-1.3.26.1a/mod_gzip.h" (1 Oct 2002, 10099 Bytes) of package /linux/www/apache_httpd_modules/old/mod_gzip-1.3.26.1a.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 /* ====================================================================
    3  *
    4  * MOD_GZIP.C - Version 1.3.26.1a
    5  *
    6  * This program was developed by
    7  *
    8  * Remote Communications, Inc.
    9  * Home page: http://www.RemoteCommunications.com
   10  *
   11  * and is currently maintained by
   12  *
   13  * Christian Kruse, <ckruse@wwwtech.de> and Michael Schroepl,
   14  * <michael@schroepl.net>
   15  * Home page: http://sourceforge.net/projects/mod-gzip/
   16  *
   17  * Original author: Kevin Kiley, CTO, Remote Communications, Inc.
   18  * Email: Kiley@RemoteCommunications.com
   19  *
   20  * As of this writing there is an online support forum which
   21  * anyone may join by following the instructions found at...
   22  * http://lists.over.net/mailman/listinfo/mod_gzip
   23  *
   24  * ====================================================================
   25  */
   26 
   27 /* APACHE LICENSE: START
   28  *
   29  * Portions of this software are covered under the following license
   30  * which, as it states, must remain included in this source code
   31  * module and may not be altered in any way.
   32  */
   33 
   34 /* ====================================================================
   35  * The Apache Software License, Version 1.1
   36  *
   37  * Copyright (c) 2000 The Apache Software Foundation.  All rights
   38  * reserved.
   39  *
   40  * Redistribution and use in source and binary forms, with or without
   41  * modification, are permitted provided that the following conditions
   42  * are met:
   43  *
   44  * 1. Redistributions of source code must retain the above copyright
   45  *    notice, this list of conditions and the following disclaimer.
   46  *
   47  * 2. Redistributions in binary form must reproduce the above copyright
   48  *    notice, this list of conditions and the following disclaimer in
   49  *    the documentation and/or other materials provided with the
   50  *    distribution.
   51  *
   52  * 3. The end-user documentation included with the redistribution,
   53  *    if any, must include the following acknowledgment:
   54  *       "This product includes software developed by the
   55  *        Apache Software Foundation (http://www.apache.org/)."
   56  *    Alternately, this acknowledgment may appear in the software itself,
   57  *    if and wherever such third-party acknowledgments normally appear.
   58  *
   59  * 4. The names "Apache" and "Apache Software Foundation" must
   60  *    not be used to endorse or promote products derived from this
   61  *    software without prior written permission. For written
   62  *    permission, please contact apache@apache.org.
   63  *
   64  * 5. Products derived from this software may not be called "Apache",
   65  *    nor may "Apache" appear in their name, without prior written
   66  *    permission of the Apache Software Foundation.
   67  *
   68  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   69  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   70  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   71  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   72  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   73  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   74  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   75  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   76  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   77  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   78  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   79  * SUCH DAMAGE.
   80  * ====================================================================
   81  *
   82  * This software consists of voluntary contributions made by many
   83  * individuals on behalf of the Apache Software Foundation.  For more
   84  * information on the Apache Software Foundation, please see
   85  * <http://www.apache.org/>.
   86  *
   87  * Portions of this software are based upon public domain software
   88  * originally written at the National Center for Supercomputing Applications,
   89  * University of Illinois, Urbana-Champaign.
   90  */
   91 
   92 /* APACHE LICENSE: END */
   93 
   94 #ifndef _MOD_GZIP_H
   95 #define _MOD_GZIP_H
   96 
   97 #define MOD_GZIP_VERSION_INFO_STRING "mod_gzip/1.3.26.1a"
   98 
   99 /*
  100  * Declare the NAME by which this module will be known.
  101  * This is the NAME that will be used in LoadModule command(s).
  102  */
  103 
  104 extern module MODULE_VAR_EXPORT gzip_module;
  105 
  106 /*
  107  * Turn MOD_GZIP_USES_APACHE_LOGS switch ON to include the
  108  * code that can update Apache logs with compression information.
  109  */
  110 
  111 #define MOD_GZIP_USES_APACHE_LOGS
  112 
  113 /*
  114  * Turn MOD_GZIP_DEBUG1 switch ON to include debug code.
  115  * This is normally OFF by default and should only be
  116  * used for diagnosing problems. The log output is
  117  * VERY detailed and the log files will be HUGE.
  118  */
  119 
  120 /*
  121 #define MOD_GZIP_DEBUG1
  122 */
  123 
  124 /*
  125  * Turn MOD_GZIP_DEBUG1_VERBOSE1 switch ON to include
  126  * some VERY 'verbose' debug code such as request record
  127  * dumps during transactions and hex dumps of data.
  128  * This is normally OFF by default. MOD_GZIP_DEBUG1
  129  * switch must also be 'on' for this to have any effect.
  130  */
  131 
  132 #ifdef  MOD_GZIP_DEBUG1
  133 #define MOD_GZIP_DEBUG1_VERBOSE1
  134 #endif
  135 
  136 /*
  137  * Turn this 'define' on to send all log output to
  138  * Apache error_log instead of a flat file. "LogLevel debug"
  139  * must be set in httpd.conf for log output to appear in error_log.
  140  */
  141 
  142 /*
  143 #define MOD_GZIP_LOG_IS_APACHE_LOG
  144 */
  145 
  146 /*
  147  * Other globals...
  148  */
  149 
  150 #ifndef MOD_GZIP_MAX_PATH_LEN
  151 #define MOD_GZIP_MAX_PATH_LEN 512
  152 #endif
  153 
  154 #define MOD_GZIP_IMAP_MAXNAMES   256
  155 #define MOD_GZIP_IMAP_MAXNAMELEN 90
  156 
  157 #define MOD_GZIP_IMAP_ISNONE      0
  158 #define MOD_GZIP_IMAP_ISMIME      1
  159 #define MOD_GZIP_IMAP_ISHANDLER   2
  160 #define MOD_GZIP_IMAP_ISFILE      3
  161 #define MOD_GZIP_IMAP_ISURI       4
  162 #define MOD_GZIP_IMAP_ISREQHEADER 5
  163 #define MOD_GZIP_IMAP_ISRSPHEADER 6
  164 #define MOD_GZIP_IMAP_ISPORT      7
  165 #define MOD_GZIP_IMAP_ISADDRESS   8
  166 
  167 #define MOD_GZIP_IMAP_STATIC1     9001
  168 #define MOD_GZIP_IMAP_DYNAMIC1    9002
  169 #define MOD_GZIP_IMAP_DYNAMIC2    9003
  170 #define MOD_GZIP_IMAP_DECLINED1   9004
  171 
  172 #define MOD_GZIP_REQUEST          9005
  173 #define MOD_GZIP_RESPONSE         9006
  174 
  175 typedef struct {
  176     int      include;   
  177     int      type;      
  178     int      action;    
  179     int      direction; 
  180     unsigned port;      
  181     int      len1;      
  182     regex_t *pregex;    
  183 
  184     char name[ MOD_GZIP_IMAP_MAXNAMELEN + 2 ];
  185     int  namelen; 
  186 } mod_gzip_imap;
  187 
  188 extern int mod_gzip_imap_size;
  189 
  190 #define MOD_GZIP_CONFIG_MODE_SERVER      1
  191 #define MOD_GZIP_CONFIG_MODE_DIRECTORY   2
  192 #define MOD_GZIP_CONFIG_MODE_COMBO       3
  193 
  194 typedef struct {
  195 
  196     int  cmode;
  197 
  198     char *loc;                   
  199 
  200     int  is_on;                  
  201     int  is_on_set;
  202 
  203     int  keep_workfiles;         
  204     int  keep_workfiles_set;
  205 
  206     int  dechunk;                
  207     int  dechunk_set;
  208 
  209     int  add_header_count;       
  210     int  add_header_count_set;
  211 
  212     int  min_http;               
  213     int  min_http_set;
  214 
  215     long minimum_file_size;      
  216     int  minimum_file_size_set;
  217 
  218     long maximum_file_size;      
  219     int  maximum_file_size_set;
  220 
  221     long maximum_inmem_size;     
  222     int  maximum_inmem_size_set;
  223 
  224     char temp_dir[256]; /* Length is safety-checked during startup */
  225     int  temp_dir_set;
  226 
  227     int imap_total_entries;
  228     int imap_total_ismime;
  229     int imap_total_isfile;
  230     int imap_total_isuri;
  231     int imap_total_ishandler;
  232     int imap_total_isreqheader;
  233     int imap_total_isrspheader;
  234 
  235     mod_gzip_imap imap[ MOD_GZIP_IMAP_MAXNAMES + 1 ];
  236 
  237     #define MOD_GZIP_COMMAND_VERSION_USED
  238     #ifdef  MOD_GZIP_COMMAND_VERSION_USED
  239     #define MOD_GZIP_COMMAND_VERSION 8001
  240     #define MOD_GZIP_COMMAND_VERSION_MAXLEN 128
  241     char command_version[ MOD_GZIP_COMMAND_VERSION_MAXLEN + 1 ];
  242     int  command_version_set;
  243     #endif
  244 
  245     #define MOD_GZIP_CAN_NEGOTIATE
  246     #ifdef  MOD_GZIP_CAN_NEGOTIATE
  247     int can_negotiate;
  248     int can_negotiate_set;
  249     #endif
  250 
  251     #define MOD_GZIP_M_BOTH    -1
  252     #define MOD_GZIP_M_NOT_SET -2
  253     int handle_methods;
  254 
  255     #define MOD_GZIP_MAX_SUFFIX_LEN 5
  256     char suffix[MOD_GZIP_MAX_SUFFIX_LEN + 1];
  257     int  suffix_set;
  258 
  259     int  send_vary;
  260     int  send_vary_set;
  261 
  262     int  refresh_files;
  263     int  refresh_files_set;
  264 } mod_gzip_conf;
  265 
  266 extern long mod_gzip_iusn;
  267 
  268 int mod_gzip_strncmp( char *s1, char *s2, int len1 );
  269 int mod_gzip_strnicmp( char *s1, char *s2, int len1 );
  270 int mod_gzip_strcpy( char *s1, char *s2 );
  271 int mod_gzip_strcat( char *s1, char *s2 );
  272 int mod_gzip_strlen( char *s1 );
  273 int mod_gzip_stringcontains( char *source, char *substring );
  274 int mod_gzip_strendswith( char *s1, char *s2, int ignorcase );
  275 
  276 int mod_gzip_create_unique_filename(
  277 char *prefix,
  278 char *target,
  279 int   targetmaxlen
  280 );
  281 
  282 int mod_gzip_delete_file(
  283 request_rec   *r,
  284 char          *filename
  285 );
  286 
  287 int mod_gzip_flush_and_update_counts(
  288 request_rec   *r,
  289 mod_gzip_conf *dconf,
  290 long           total_header_bytes_sent,
  291 long           total_body_bytes_sent
  292 );
  293 
  294 long mod_gzip_sendfile1(
  295 request_rec *r,
  296 char        *input_filename,
  297 FILE        *ifh_passed,
  298 long         starting_offset
  299 );
  300 
  301 int mod_gzip_sendfile2(
  302 request_rec   *r,
  303 mod_gzip_conf *dconf,
  304 char          *input_filename
  305 );
  306 
  307 int mod_gzip_dyn1_getfdo1(
  308 request_rec *r,
  309 char        *filename
  310 );
  311 
  312 int mod_gzip_redir1_handler(
  313 request_rec   *r,
  314 mod_gzip_conf *dconf
  315 );
  316 
  317 long mod_gzip_send(
  318 char        *buf,
  319 long         buflen,
  320 request_rec *r
  321 );
  322 
  323 int mod_gzip_encode_and_transmit(
  324 request_rec   *r,
  325 mod_gzip_conf *dconf,
  326 char          *source,
  327 int            source_is_a_file,
  328 long           input_size,
  329 int            nodecline,
  330 long           header_length,
  331 char          *result_prefix_string
  332 );
  333 
  334 typedef struct _GZP_CONTROL {
  335 
  336     int   decompress;
  337 
  338     int   input_ismem;          
  339     char *input_ismem_ibuf;     
  340     long  input_ismem_ibuflen;  
  341 
  342     char  input_filename[ MOD_GZIP_MAX_PATH_LEN + 2 ]; 
  343 
  344     long  input_offset;         
  345 
  346     int   output_ismem;         
  347     char *output_ismem_obuf;    
  348     long  output_ismem_obuflen; 
  349 
  350     char  output_filename[ MOD_GZIP_MAX_PATH_LEN + 2 ]; 
  351 
  352     int   result_code; 
  353     long  bytes_out;   
  354 
  355 } GZP_CONTROL;
  356 
  357 int gzp_main(request_rec *, GZP_CONTROL *); 
  358 char *mod_gzip_generate_vary_header(mod_gzip_conf *,struct pool *);
  359 int mod_gzip_compress_file(request_rec *,char *);
  360 
  361 
  362 struct _table {
  363     array_header a;
  364 #ifdef MAKE_TABLE_PROFILE
  365     void *creator;
  366 #endif
  367 };
  368 typedef struct _table _table;
  369 
  370 #endif