int main(int argc, char *argv[]) { // Initialise the cfg structure (this sets up a linked list // of key / value pairs) struct Config *cfg = cfg_init("settings.cfg"); // Search for a key. Note that the return value is a pointer // in the cfg structure so should NOT be freed (it is freed // eventually by cfg_free.); char *value = cfg_get_string(cfg, "barney", "The default value"); printf("\"%s\"\n", value); // Search for a non-existent key to show default value being returned char *value2 = cfg_get_string(cfg, "non-existent", "A default value"); printf("\"%s\"\n", value2); // Get a number long num = cfg_get_long(cfg, "NuMbEr", 69); printf("Number is %ld\n", num); // Dump everything - showing the cfg_foreach() function printf("DEBUG dump all:\n"); cfg_foreach(cfg, callback); // Finally tear down the cfg structure. This will invalidate any // strings we've been returned, so we should make copies of // anything we want to keep first. cfg_free(cfg); return 0; }
int php3_minit_oracle(INIT_FUNC_ARGS) { if (cfg_get_long("oracle.allow_persistent", &ORACLE_GLOBAL(php3_oracle_module).allow_persistent) == FAILURE) { ORACLE_GLOBAL(php3_oracle_module).allow_persistent = -1; } if (cfg_get_long("oracle.max_persistent", &ORACLE_GLOBAL(php3_oracle_module).max_persistent) == FAILURE) { ORACLE_GLOBAL(php3_oracle_module).max_persistent = -1; } if (cfg_get_long("oracle.max_links", &ORACLE_GLOBAL(php3_oracle_module).max_links) == FAILURE) { ORACLE_GLOBAL(php3_oracle_module).max_links = -1; } ORACLE_GLOBAL(php3_oracle_module).num_persistent = 0; ORACLE_GLOBAL(php3_oracle_module).le_cursor = register_list_destructors(_close_oracur, NULL); ORACLE_GLOBAL(php3_oracle_module).le_conn = register_list_destructors(_close_oraconn, NULL); ORACLE_GLOBAL(php3_oracle_module).le_pconn = register_list_destructors(NULL, _close_orapconn); ORACLE_GLOBAL(php3_oracle_module).conns = malloc(sizeof(HashTable)); _php3_hash_init(ORACLE_GLOBAL(php3_oracle_module).conns, 13, NULL, NULL, 1); REGISTER_LONG_CONSTANT("ORA_BIND_INOUT", 0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_BIND_IN", 1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_BIND_OUT", 2, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_FETCHINTO_ASSOC",ORA_FETCHINTO_ASSOC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_FETCHINTO_NULLS",ORA_FETCHINTO_NULLS, CONST_CS | CONST_PERSISTENT); #if NEEDED opinit(OCI_EV_TSF); /* initialize threaded environment - must match the threaded mode of the oci8 driver if both are used at the same time!! */ #endif return SUCCESS; }