1 /* @(#) $Id: ./src/config/dbd-config.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
13 /* Functions to handle the dbd configuration files
18 #include "dbd-config.h"
21 int Read_DB(XML_NODE node, void *config1, void *config2)
28 char *xml_dbhost = "hostname";
29 char *xml_dbuser = "username";
30 char *xml_dbpass = "password";
31 char *xml_dbdb = "database";
32 char *xml_dbport = "port";
33 char *xml_dbsock = "socket";
34 char *xml_dbtype = "type";
37 db_config = (DBConfig *)config2;
49 merror(XML_ELEMNULL, ARGV0);
52 else if(!node[i]->content)
54 merror(XML_VALUENULL, ARGV0, node[i]->element);
57 /* Mail notification */
58 else if(strcmp(node[i]->element, xml_dbhost) == 0)
60 os_strdup(node[i]->content, db_config->host);
62 else if(strcmp(node[i]->element, xml_dbuser) == 0)
64 os_strdup(node[i]->content, db_config->user);
66 else if(strcmp(node[i]->element, xml_dbpass) == 0)
68 os_strdup(node[i]->content, db_config->pass);
70 else if(strcmp(node[i]->element, xml_dbdb) == 0)
72 os_strdup(node[i]->content, db_config->db);
74 else if(strcmp(node[i]->element, xml_dbport) == 0)
76 db_config->port = atoi(node[i]->content);
78 else if(strcmp(node[i]->element, xml_dbsock) == 0)
80 os_strdup(node[i]->content, db_config->sock);
82 else if(strcmp(node[i]->element, xml_dbtype) == 0)
84 if(strcmp(node[i]->content, "mysql") == 0)
86 db_config->db_type = MYSQLDB;
88 else if(strcmp(node[i]->content, "postgresql") == 0)
90 db_config->db_type = POSTGDB;
94 merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
100 merror(XML_INVELEM, ARGV0, node[i]->element);