static const char *set_dbparam_slot(cmd_parms *cmd, void *struct_ptr, const char *arg) { const char *param = (char *)cmd->info; set_dbparam(cmd,NULL,param,arg); return NULL; }
/* Sets basic connection info */ static const char *set_log_sql_info(cmd_parms *cmd, void *dummy, const char *host, const char *user, const char *pwd) { if (!user) { /* user is null, so only one arg passed */ /* TODO: to more error checking/force all params to be set */ apr_uri_t uri; apr_uri_parse(cmd->pool, host, &uri); if (uri.scheme) { set_dbparam(cmd, NULL, "driver", uri.scheme); } if (uri.hostname) { set_dbparam(cmd, NULL, "hostname", uri.hostname); } if (uri.user) { set_dbparam(cmd, NULL, "username", uri.user); } if (uri.password) { set_dbparam(cmd, NULL, "password", uri.password); } if (uri.port_str) { set_dbparam(cmd, NULL, "port", uri.port_str); } if (uri.path) { /* extract Database name */ char *off = ap_strchr(++uri.path,'/'); if (off) *off='\0'; set_dbparam(cmd, NULL, "database", uri.path); } } else { if (*host != '.') { set_dbparam(cmd, NULL, "hostname", host); } if (*user != '.') { set_dbparam(cmd, NULL, "username", user); } if (*pwd != '.') { set_dbparam(cmd, NULL, "password", pwd); } } return NULL; }
/* Set the on-disk database parameters from enabled options in the config file. */ void tc_db_get_params (char *params, const char *path) { int len = 0; long xmmap = conf.xmmap; uint32_t lcnum, ncnum, lmemb, nmemb, bnum; /* copy path name to buffer */ len += set_dbparam (params, len, "%s", path); /* caching parameters of a B+ tree database object */ lcnum = conf.cache_lcnum > 0 ? conf.cache_lcnum : TC_LCNUM; len += set_dbparam (params, len, "#%s=%d", "lcnum", lcnum); ncnum = conf.cache_ncnum > 0 ? conf.cache_ncnum : TC_NCNUM; len += set_dbparam (params, len, "#%s=%d", "ncnum", ncnum); /* set the size of the extra mapped memory */ if (xmmap > 0) len += set_dbparam (params, len, "#%s=%ld", "xmsiz", xmmap); lmemb = conf.tune_lmemb > 0 ? conf.tune_lmemb : TC_LMEMB; len += set_dbparam (params, len, "#%s=%d", "lmemb", lmemb); nmemb = conf.tune_nmemb > 0 ? conf.tune_nmemb : TC_NMEMB; len += set_dbparam (params, len, "#%s=%d", "nmemb", nmemb); bnum = conf.tune_bnum > 0 ? conf.tune_bnum : TC_BNUM; len += set_dbparam (params, len, "#%s=%d", "bnum", bnum); /* compression */ len += set_dbparam (params, len, "#%s=%c", "opts", 'l'); if (conf.compression == TC_BZ2) { len += set_dbparam (params, len, "%c", 'b'); } else if (conf.compression == TC_ZLIB) { len += set_dbparam (params, len, "%c", 'd'); } /* open flags. create a new database if not exist, otherwise read it */ len += set_dbparam (params, len, "#%s=%s", "mode", "wc"); /* if not loading from disk, truncate regardless if a db file exists */ if (!conf.load_from_disk) len += set_dbparam (params, len, "%c", 't'); LOG_DEBUG (("%s\n", path)); LOG_DEBUG (("params: %s\n", params)); }