X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fconfig%2Fdbd-config.c;h=1dfa4ccb53e5363e3be4291ed29ed6e2595e4c3f;hp=949ef5dd5f90f5e34ea2cfaef82cdc1fe0a9a680;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/config/dbd-config.c b/src/config/dbd-config.c index 949ef5d..1dfa4cc 100644 --- a/src/config/dbd-config.c +++ b/src/config/dbd-config.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/config/dbd-config.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -10,102 +7,68 @@ * Foundation */ -/* Functions to handle the dbd configuration files - */ - - #include "shared.h" #include "dbd-config.h" +#include "config.h" -int Read_DB(XML_NODE node, void *config1, void *config2) +int Read_DB(XML_NODE node, __attribute__((unused)) void *config1, void *config2) { int i = 0; DBConfig *db_config; - /* XML definitions */ - char *xml_dbhost = "hostname"; - char *xml_dbuser = "username"; - char *xml_dbpass = "password"; - char *xml_dbdb = "database"; - char *xml_dbport = "port"; - char *xml_dbsock = "socket"; - char *xml_dbtype = "type"; - + const char *xml_dbhost = "hostname"; + const char *xml_dbuser = "username"; + const char *xml_dbpass = "password"; + const char *xml_dbdb = "database"; + const char *xml_dbport = "port"; + const char *xml_dbsock = "socket"; + const char *xml_dbtype = "type"; db_config = (DBConfig *)config2; - if(!db_config) - { - return(0); + if (!db_config) { + return (0); } - - /* Reading the xml */ - while(node[i]) - { - if(!node[i]->element) - { - merror(XML_ELEMNULL, ARGV0); - return(OS_INVALID); - } - else if(!node[i]->content) - { - merror(XML_VALUENULL, ARGV0, node[i]->element); - return(OS_INVALID); + /* Read the xml */ + while (node[i]) { + if (!node[i]->element) { + merror(XML_ELEMNULL, __local_name); + return (OS_INVALID); + } else if (!node[i]->content) { + merror(XML_VALUENULL, __local_name, node[i]->element); + return (OS_INVALID); } /* Mail notification */ - else if(strcmp(node[i]->element, xml_dbhost) == 0) - { + else if (strcmp(node[i]->element, xml_dbhost) == 0) { os_strdup(node[i]->content, db_config->host); - } - else if(strcmp(node[i]->element, xml_dbuser) == 0) - { + } else if (strcmp(node[i]->element, xml_dbuser) == 0) { os_strdup(node[i]->content, db_config->user); - } - else if(strcmp(node[i]->element, xml_dbpass) == 0) - { + } else if (strcmp(node[i]->element, xml_dbpass) == 0) { os_strdup(node[i]->content, db_config->pass); - } - else if(strcmp(node[i]->element, xml_dbdb) == 0) - { + } else if (strcmp(node[i]->element, xml_dbdb) == 0) { os_strdup(node[i]->content, db_config->db); - } - else if(strcmp(node[i]->element, xml_dbport) == 0) - { - db_config->port = atoi(node[i]->content); - } - else if(strcmp(node[i]->element, xml_dbsock) == 0) - { + } else if (strcmp(node[i]->element, xml_dbport) == 0) { + db_config->port = (unsigned int) atoi(node[i]->content); + } else if (strcmp(node[i]->element, xml_dbsock) == 0) { os_strdup(node[i]->content, db_config->sock); - } - else if(strcmp(node[i]->element, xml_dbtype) == 0) - { - if(strcmp(node[i]->content, "mysql") == 0) - { + } else if (strcmp(node[i]->element, xml_dbtype) == 0) { + if (strcmp(node[i]->content, "mysql") == 0) { db_config->db_type = MYSQLDB; - } - else if(strcmp(node[i]->content, "postgresql") == 0) - { + } else if (strcmp(node[i]->content, "postgresql") == 0) { db_config->db_type = POSTGDB; + } else { + merror(XML_VALUEERR, __local_name, node[i]->element, node[i]->content); + return (OS_INVALID); } - else - { - merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content); - return(OS_INVALID); - } - } - else - { - merror(XML_INVELEM, ARGV0, node[i]->element); - return(OS_INVALID); + } else { + merror(XML_INVELEM, __local_name, node[i]->element); + return (OS_INVALID); } i++; } - - return(0); + return (0); } - -/* EOF */