1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
11 #include "dbd-config.h"
15 int Read_DB(XML_NODE node, __attribute__((unused)) void *config1, void *config2)
21 const char *xml_dbhost = "hostname";
22 const char *xml_dbuser = "username";
23 const char *xml_dbpass = "password";
24 const char *xml_dbdb = "database";
25 const char *xml_dbport = "port";
26 const char *xml_dbsock = "socket";
27 const char *xml_dbtype = "type";
29 db_config = (DBConfig *)config2;
36 if (!node[i]->element) {
37 merror(XML_ELEMNULL, __local_name);
39 } else if (!node[i]->content) {
40 merror(XML_VALUENULL, __local_name, node[i]->element);
43 /* Mail notification */
44 else if (strcmp(node[i]->element, xml_dbhost) == 0) {
45 os_strdup(node[i]->content, db_config->host);
46 } else if (strcmp(node[i]->element, xml_dbuser) == 0) {
47 os_strdup(node[i]->content, db_config->user);
48 } else if (strcmp(node[i]->element, xml_dbpass) == 0) {
49 os_strdup(node[i]->content, db_config->pass);
50 } else if (strcmp(node[i]->element, xml_dbdb) == 0) {
51 os_strdup(node[i]->content, db_config->db);
52 } else if (strcmp(node[i]->element, xml_dbport) == 0) {
53 db_config->port = (unsigned int) atoi(node[i]->content);
54 } else if (strcmp(node[i]->element, xml_dbsock) == 0) {
55 os_strdup(node[i]->content, db_config->sock);
56 } else if (strcmp(node[i]->element, xml_dbtype) == 0) {
57 if (strcmp(node[i]->content, "mysql") == 0) {
58 db_config->db_type = MYSQLDB;
59 } else if (strcmp(node[i]->content, "postgresql") == 0) {
60 db_config->db_type = POSTGDB;
62 merror(XML_VALUEERR, __local_name, node[i]->element, node[i]->content);
66 merror(XML_INVELEM, __local_name, node[i]->element);