Friday, July 26, 2013

Apache Module Config Merge

An example apache module merge routine :
    
    static void *mod_gzip_merge_dconfig(
    apr_pool_t *p,
    void *parent_conf,
    void *newloc_conf
    )
    {
     mod_gzip_conf *merged_config = (mod_gzip_conf *) apr_pcalloc(p, sizeof(mod_gzip_conf));
     mod_gzip_conf *pconf         = (mod_gzip_conf *) parent_conf;
     mod_gzip_conf *nconf         = (mod_gzip_conf *) newloc_conf;
    
     mod_gzip_merge1(
     ( apr_pool_t    * ) p,
     ( mod_gzip_conf * ) merged_config,
     ( mod_gzip_conf * ) pconf,
     ( mod_gzip_conf * ) nconf
     );
    
    
    
    static int mod_gzip_handler( request_rec *r ) {
     mod_gzip_conf *mgc; /* Location/Directory configuration */
     mgc = ( mod_gzip_conf * )
     ap_get_module_config( r->per_dir_config, &gzip_module );
    }
    
    register_hooks() {
      ap_hook_insert_filter( mod_gzip_insert_output_filter, NULL, NULL, APR_HOOK_MIDDLE );
     ap_register_output_filter( mod_gzip_filter_name, mod_gzip_output_filter, AP_FTYPE_CONTENT );
     return;
    }
    

No comments:

Post a Comment