From 1a2cd155e99c30921d27a2680bc450f14fbb6853 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Mon, 2 Jan 2023 06:44:07 -0600 Subject: clean up init --- src/init.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/init.c') 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, -- cgit v1.2.3