/** * Creates a new configuration parser, making a copy of the supplied * configuration structure. * * @param cfg * @return A pointer to a newly created htp_connp_t instance. */ htp_connp_t *htp_connp_create_copycfg(htp_cfg_t *cfg) { htp_connp_t *connp = htp_connp_create(cfg); if (connp == NULL) return NULL; connp->cfg = htp_config_copy(cfg); connp->is_cfg_private = 1; return connp; }
VALUE rbhtp_config_copy( VALUE self ) { // We create one too many copies here. VALUE new_config = rb_funcall( cCfg, rb_intern( "new" ), 0 ); htp_cfg_t* cfg = NULL; Data_Get_Struct( rb_iv_get( self, "@cfg" ), htp_cfg_t, cfg ); // Note that the existing new_config @cfg will be garbage collected as a // result of this set. rb_iv_set( new_config, "@cfg", Data_Wrap_Struct( rb_cObject, 0, rbhtp_config_free, htp_config_copy( cfg ) ) ); // Now copy over all our callbacks. char* const* v = &rbhtp_config_pvars[0]; while ( *v[0] != '\0' ) { rb_iv_set( new_config, *v, rb_iv_get( self, *v ) ); ++v; } return new_config; }