Fixed the section used for sub-engines
This commit is contained in:
parent
b54a872e09
commit
de19906181
|
@ -85,8 +85,10 @@ DatabasePluginDefinition database =
|
||||||
/* private */
|
/* private */
|
||||||
/* functions */
|
/* functions */
|
||||||
/* _pdo_init */
|
/* _pdo_init */
|
||||||
static char const * _init_pgsql(char const * dsn, Config * config);
|
static char const * _init_pgsql(char const * dsn, Config * config,
|
||||||
static char const * _init_sqlite3(char const * dsn, Config * config);
|
char const ** section);
|
||||||
|
static char const * _init_sqlite3(char const * dsn, Config * config,
|
||||||
|
char const ** section);
|
||||||
|
|
||||||
static PDO * _pdo_init(Config * config, char const * section)
|
static PDO * _pdo_init(Config * config, char const * section)
|
||||||
{
|
{
|
||||||
|
@ -104,9 +106,11 @@ static PDO * _pdo_init(Config * config, char const * section)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* FIXME implement more backends */
|
/* FIXME implement more backends */
|
||||||
if(strncmp(dsn, sqlite3, sizeof(sqlite3) - 1) == 0)
|
if(strncmp(dsn, sqlite3, sizeof(sqlite3) - 1) == 0)
|
||||||
backend = _init_sqlite3(&dsn[sizeof(sqlite3) - 1], config);
|
backend = _init_sqlite3(&dsn[sizeof(sqlite3) - 1], config,
|
||||||
|
§ion);
|
||||||
else if(strncmp(dsn, pgsql, sizeof(pgsql) - 1) == 0)
|
else if(strncmp(dsn, pgsql, sizeof(pgsql) - 1) == 0)
|
||||||
backend = _init_pgsql(&dsn[sizeof(pgsql) - 1], config);
|
backend = _init_pgsql(&dsn[sizeof(pgsql) - 1], config,
|
||||||
|
§ion);
|
||||||
else
|
else
|
||||||
/* XXX report error */
|
/* XXX report error */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -131,9 +135,9 @@ static PDO * _pdo_init(Config * config, char const * section)
|
||||||
return pdo;
|
return pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const * _init_pgsql(char const * dsn, Config * config)
|
static char const * _init_pgsql(char const * dsn, Config * config,
|
||||||
|
char const ** section)
|
||||||
{
|
{
|
||||||
char const * section = "database::pgsql";
|
|
||||||
char * p;
|
char * p;
|
||||||
char const * name;
|
char const * name;
|
||||||
char * r;
|
char * r;
|
||||||
|
@ -141,6 +145,7 @@ static char const * _init_pgsql(char const * dsn, Config * config)
|
||||||
|
|
||||||
if((p = strdup(dsn)) == NULL)
|
if((p = strdup(dsn)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
*section = "database::pgsql";
|
||||||
/* parse the DSN */
|
/* parse the DSN */
|
||||||
for(name = p, r = p; *r != '\0'; name = r)
|
for(name = p, r = p; *r != '\0'; name = r)
|
||||||
{
|
{
|
||||||
|
@ -159,7 +164,7 @@ static char const * _init_pgsql(char const * dsn, Config * config)
|
||||||
name = "username";
|
name = "username";
|
||||||
else if(strcmp(name, "dbname") == 0)
|
else if(strcmp(name, "dbname") == 0)
|
||||||
name = "database";
|
name = "database";
|
||||||
if(config_set(config, section, name, value) != 0)
|
if(config_set(config, *section, name, value) != 0)
|
||||||
{
|
{
|
||||||
r = NULL;
|
r = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -171,11 +176,14 @@ static char const * _init_pgsql(char const * dsn, Config * config)
|
||||||
return "pgsql";
|
return "pgsql";
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const * _init_sqlite3(char const * dsn, Config * config)
|
static char const * _init_sqlite3(char const * dsn, Config * config,
|
||||||
|
char const ** section)
|
||||||
{
|
{
|
||||||
char const * section = "database::sqlite3";
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() %s=%s\n", __func__, "filename", dsn);
|
||||||
if(config_set(config, section, "filename", dsn) != 0)
|
#endif
|
||||||
|
*section = "database::sqlite3";
|
||||||
|
if(config_set(config, *section, "filename", dsn) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return "sqlite3";
|
return "sqlite3";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user