/* standard foobar code */ static int sqlhpwippool_instantiate(CONF_SECTION *conf, void **instance) { rlm_sqlhpwippool_t *data; module_instance_t *modinst; /* set up a storage area for instance data */ data = rad_malloc(sizeof(*data)); if (!data) return -1; memset(data, 0, sizeof(*data)); /* so _detach will know what to free */ /* fail if the configuration parameters can't be parsed */ if (cf_section_parse(conf, data, module_config) < 0) { sqlhpwippool_detach(*instance); return -1; } /* save my name */ data->myname = cf_section_name2(conf); if (!data->myname) { data->myname = "(no name)"; } data->sincesync = 0; modinst = find_module_instance(cf_section_find("modules"), (data->sqlinst_name), 1 ); if (!modinst) { nvp_log(__LINE__, data, L_ERR, "sqlhpwippool_instantiate(): cannot find module instance " "named \"%s\"", data->sqlinst_name); return -1; } /* check if the given instance is really a rlm_sql instance */ if (strcmp(modinst->entry->name, "rlm_sql") != 0) { nvp_log(__LINE__, data, L_ERR, "sqlhpwippool_instantiate(): given instance (%s) is not " "an instance of the rlm_sql module", data->sqlinst_name); return -1; } /* save pointers to useful "objects" */ data->sqlinst = (SQL_INST *) modinst->insthandle; data->db = (rlm_sql_module_t *) data->sqlinst->module; /* everything went ok, cleanup pool */ *instance = data; return ((nvp_cleanup(data)) ? 0 : -1); }
/* standard foobar code */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { rlm_sqlhpwippool_t *inst = instance; module_instance_t *sqlinst; /* save my name */ inst->myname = cf_section_name2(conf); if (!inst->myname) { inst->myname = "(no name)"; } inst->sincesync = 0; sqlinst = find_module_instance(cf_section_find("modules"), (inst->sql_module_instance), 1 ); if (!sqlinst) { nvp_log(__LINE__, inst, L_ERR, "mod_instantiate(): cannot find module instance " "named \"%s\"", inst->sql_module_instance); return -1; } /* check if the given instance is really a rlm_sql instance */ if (strcmp(sqlinst->entry->name, "rlm_sql") != 0) { nvp_log(__LINE__, inst, L_ERR, "mod_instantiate(): given instance (%s) is not " "an instance of the rlm_sql module", inst->sql_module_instance); return -1; } /* save pointers to useful "objects" */ inst->sqlinst = (rlm_sql_t *) sqlinst->insthandle; inst->db = (rlm_sql_module_t *) inst->sqlinst->module; return ((nvp_cleanup(inst)) ? 0 : -1); }