Browse Source

klishd: Add 'DBs' option to config file

Serj Kalichev 2 years ago
parent
commit
677293a539
2 changed files with 12 additions and 0 deletions
  1. 10 0
      bin/klishd/opts.c
  2. 2 0
      bin/klishd/private.h

+ 10 - 0
bin/klishd/opts.c

@@ -41,6 +41,7 @@ struct options *opts_init(void)
 	opts->foreground = BOOL_FALSE; // Daemonize by default
 	opts->verbose = BOOL_FALSE;
 	opts->log_facility = LOG_DAEMON;
+	opts->dbs = faux_str_dup(DEFAULT_DBS);
 
 	return opts;
 }
@@ -53,6 +54,7 @@ void opts_free(struct options *opts)
 	faux_str_free(opts->pidfile);
 	faux_str_free(opts->cfgfile);
 	faux_str_free(opts->unix_socket_path);
+	faux_str_free(opts->dbs);
 	faux_free(opts);
 }
 
@@ -173,11 +175,18 @@ faux_ini_t *config_parse(const char *cfgfile, struct options *opts)
 		return NULL;
 	}
 
+	// UnixSocketPath
 	if ((tmp = faux_ini_find(ini, "UnixSocketPath"))) {
 		faux_str_free(opts->unix_socket_path);
 		opts->unix_socket_path = faux_str_dup(tmp);
 	}
 
+	// DBs
+	if ((tmp = faux_ini_find(ini, "DBs"))) {
+		faux_str_free(opts->dbs);
+		opts->dbs = faux_str_dup(tmp);
+	}
+
 	return ini;
 }
 
@@ -196,6 +205,7 @@ int opts_show(struct options *opts)
 	syslog(LOG_DEBUG, "opts: PIDPath = %s\n", opts->pidfile);
 	syslog(LOG_DEBUG, "opts: ConfigPath = %s\n", opts->cfgfile);
 	syslog(LOG_DEBUG, "opts: UnixSocketPath = %s\n", opts->unix_socket_path);
+	syslog(LOG_DEBUG, "opts: DBs = %s\n", opts->dbs);
 
 	return 0;
 }

+ 2 - 0
bin/klishd/private.h

@@ -7,6 +7,7 @@
 #define LOG_NAME "klishd"
 #define DEFAULT_PIDFILE "/var/run/klishd.pid"
 #define DEFAULT_CFGFILE "/etc/klish/klishd.conf"
+#define DEFAULT_DBS "libxml2"
 
 
 /** @brief Command line and config file options
@@ -15,6 +16,7 @@ struct options {
 	char *pidfile;
 	char *cfgfile;
 	char *unix_socket_path;
+	char *dbs;
 	bool_t cfgfile_userdefined;
 	bool_t foreground; // Don't daemonize
 	bool_t verbose;