1 /* @(#) $Id: dbd-config.c,v 1.7 2009/06/24 17:06:25 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
12 /* Functions to handle the dbd configuration files
17 #include "dbd-config.h"
20 int Read_DB(XML_NODE node, void *config1, void *config2)
27 char *xml_dbhost = "hostname";
28 char *xml_dbuser = "username";
29 char *xml_dbpass = "password";
30 char *xml_dbdb = "database";
31 char *xml_dbport = "port";
32 char *xml_dbsock = "socket";
33 char *xml_dbtype = "type";
36 db_config = (DBConfig *)config2;
48 merror(XML_ELEMNULL, ARGV0);
51 else if(!node[i]->content)
53 merror(XML_VALUENULL, ARGV0, node[i]->element);
56 /* Mail notification */
57 else if(strcmp(node[i]->element, xml_dbhost) == 0)
59 os_strdup(node[i]->content, db_config->host);
61 else if(strcmp(node[i]->element, xml_dbuser) == 0)
63 os_strdup(node[i]->content, db_config->user);
65 else if(strcmp(node[i]->element, xml_dbpass) == 0)
67 os_strdup(node[i]->content, db_config->pass);
69 else if(strcmp(node[i]->element, xml_dbdb) == 0)
71 os_strdup(node[i]->content, db_config->db);
73 else if(strcmp(node[i]->element, xml_dbport) == 0)
75 db_config->port = atoi(node[i]->content);
77 else if(strcmp(node[i]->element, xml_dbsock) == 0)
79 os_strdup(node[i]->content, db_config->sock);
81 else if(strcmp(node[i]->element, xml_dbtype) == 0)
83 if(strcmp(node[i]->content, "mysql") == 0)
85 db_config->db_type = MYSQLDB;
87 else if(strcmp(node[i]->content, "postgresql") == 0)
89 db_config->db_type = POSTGDB;
93 merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
99 merror(XML_INVELEM, ARGV0, node[i]->element);