aboutsummaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
authorMichael McVady <femtonaut@gmail.com>2023-01-02 06:44:07 -0600
committerMichael McVady <femtonaut@gmail.com>2023-01-02 06:44:07 -0600
commit1a2cd155e99c30921d27a2680bc450f14fbb6853 (patch)
tree78e9e25595cada9ee47a3edbb1291a33f0f65c2e /src/init.c
parent98ebceffed8c6ae95d4de3f75680612348014871 (diff)
clean up init
Diffstat (limited to 'src/init.c')
-rw-r--r--src/init.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/init.c b/src/init.c
index 0dbeada..1664ed6 100644
--- a/src/init.c
+++ b/src/init.c
@@ -16,7 +16,6 @@ kore_parent_configure(int argc, char **argv)
err = init_db();
if (err != KORE_RESULT_OK) {
kore_log(LOG_ERR, "Error registering the database.");
- // FIXME How to terminate?
exit(1);
}
}
@@ -25,7 +24,18 @@ int
init_db(void)
{
int err = 0;
+
+ const char *pg_config = NULL;
+
+ const char *host = "host=localhost ";
+ const char *port = "port=5432 ";
+ const char *user = "user=clog ";
+ const char *dbname = "dbname=clog ";
+ // FIXME: Should be configurable.
+ const char *sslmode = "sslmode=disable ";
+
const char *env = NULL;
+
struct kore_buf *pg_config_buf = kore_buf_alloc(0);
// Parse env vars and build PostgreSQL config string
@@ -36,7 +46,6 @@ init_db(void)
}
else
{
- const char *host = "host=localhost ";
kore_buf_append(pg_config_buf, host, strlen(host));
}
@@ -47,7 +56,6 @@ init_db(void)
}
else
{
- const char *port = "port=5432 ";
kore_buf_append(pg_config_buf, port, strlen(port));
}
@@ -58,7 +66,6 @@ init_db(void)
}
else
{
- const char *user = "user=clog ";
kore_buf_append(pg_config_buf, user, strlen(user));
}
@@ -75,16 +82,13 @@ init_db(void)
}
else
{
- const char *dbname = "dbname=clog ";
kore_buf_append(pg_config_buf, dbname, strlen(dbname));
}
- // FIXME: Should be configurable.
- const char *sslmode = "sslmode=disable ";
kore_buf_append(pg_config_buf, sslmode, strlen(sslmode));
// Register the database
- const char *pg_config = kore_buf_stringify(pg_config_buf, NULL);
+ pg_config = kore_buf_stringify(pg_config_buf, NULL);
kore_log(LOG_INFO, "%s", pg_config);
err = kore_pgsql_register(
database,