diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-10-02 15:21:36 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-10-05 14:49:17 +0200 |
commit | 7500700777fa9b66d3bff94c6a0846d7ffdb2365 (patch) | |
tree | 5351b451683c641969e1ad13e08c6de3b5acdd21 /src/ogAdmServer.c | |
parent | a67f27a092d947c3d1eb57b02fc461dd855fbd45 (diff) |
#988 remove legacy configuration file
Add getopt parser and use json configuration file instead.
Diffstat (limited to 'src/ogAdmServer.c')
-rw-r--r-- | src/ogAdmServer.c | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/src/ogAdmServer.c b/src/ogAdmServer.c index de7fa61..1568386 100644 --- a/src/ogAdmServer.c +++ b/src/ogAdmServer.c @@ -41,101 +41,6 @@ struct og_dbi_config dbi_config = { .database = catalog, }; -//________________________________________________________________________________________________________ -// Función: tomaConfiguracion -// -// Descripción: -// Lee el fichero de configuración del servicio -// Parámetros: -// filecfg : Ruta completa al fichero de configuración -// Devuelve: -// true: Si el proceso es correcto -// false: En caso de ocurrir algún error -//________________________________________________________________________________________________________ -bool tomaConfiguracion(const char *filecfg) -{ - char buf[1024], *line; - char *key, *value; - FILE *fcfg; - - if (filecfg == NULL || strlen(filecfg) == 0) { - syslog(LOG_ERR, "No configuration file has been specified\n"); - return false; - } - - fcfg = fopen(filecfg, "rt"); - if (fcfg == NULL) { - syslog(LOG_ERR, "Cannot open configuration file `%s'\n", - filecfg); - return false; - } - - servidoradm[0] = '\0'; //inicializar variables globales - - line = fgets(buf, sizeof(buf), fcfg); - while (line != NULL) { - const char *delim = "="; - - line[strlen(line) - 1] = '\0'; - - key = strtok(line, delim); - value = strtok(NULL, delim); - - if (!strcmp(str_toupper(key), "SERVIDORADM")) - snprintf(servidoradm, sizeof(servidoradm), "%s", value); - else if (!strcmp(str_toupper(key), "PUERTO")) - snprintf(puerto, sizeof(puerto), "%s", value); - else if (!strcmp(str_toupper(key), "USUARIO")) - snprintf(usuario, sizeof(usuario), "%s", value); - else if (!strcmp(str_toupper(key), "PASSWORD")) - snprintf(pasguor, sizeof(pasguor), "%s", value); - else if (!strcmp(str_toupper(key), "DATASOURCE")) - snprintf(datasource, sizeof(datasource), "%s", value); - else if (!strcmp(str_toupper(key), "CATALOG")) - snprintf(catalog, sizeof(catalog), "%s", value); - else if (!strcmp(str_toupper(key), "INTERFACE")) - snprintf(interface, sizeof(interface), "%s", value); - else if (!strcmp(str_toupper(key), "APITOKEN")) - snprintf(auth_token, sizeof(auth_token), "%s", value); - - line = fgets(buf, sizeof(buf), fcfg); - } - - /* Default value to preserve legacy config file support */ - snprintf(db_port, sizeof(db_port), "3306"); - - fclose(fcfg); - - if (!servidoradm[0]) { - syslog(LOG_ERR, "Missing SERVIDORADM in configuration file\n"); - return false; - } - if (!puerto[0]) { - syslog(LOG_ERR, "Missing PUERTO in configuration file\n"); - return false; - } - if (!usuario[0]) { - syslog(LOG_ERR, "Missing USUARIO in configuration file\n"); - return false; - } - if (!pasguor[0]) { - syslog(LOG_ERR, "Missing PASSWORD in configuration file\n"); - return false; - } - if (!datasource[0]) { - syslog(LOG_ERR, "Missing DATASOURCE in configuration file\n"); - return false; - } - if (!catalog[0]) { - syslog(LOG_ERR, "Missing CATALOG in configuration file\n"); - return false; - } - if (!interface[0]) - syslog(LOG_ERR, "Missing INTERFACE in configuration file\n"); - - return true; -} - #define OG_CMD_MAXLEN 64 // ________________________________________________________________________________________________________ |