[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ossec-cvs] ossec-hids: dbd-config.c (NEW) dbd-config.h (NEW) [dcid]




Module name:	ossec-hids
Changes by:	dcid	07/08/14 17:03:18

Added files:
	dbd-config.c dbd-config.h

Log message:
Description: Adding files...
Reviewed by: dcid
Bug:

--- NEW FILE: dbd-config.c ---
/* @(#) $Id: dbd-config.c,v 1.1 2007/08/14 20:03:17 dcid Exp $ */

/* Copyright (C) 2007 Daniel B. Cid <dcid@xxxxxxxxx>
 * All right reserved.
 *
 * This program is a free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 3) as published by the FSF - Free Software
 * Foundation
 */

/* Functions to handle the dbd configuration files
 */


#include "shared.h"
#include "dbd-config.h"


int Read_DB(XML_NODE node, 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_dbtype = "type";

    
    db_config = (DBConfig *)config2;
    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);
        }
        /* Mail notification */
        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)
        {
            os_strdup(node[i]->content, db_config->user);
        }
        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)
        {
            os_strdup(node[i]->content, db_config->db);
        }
        else if(strcmp(node[i]->element, xml_dbtype) == 0)
        {
            if(strcmp(node[i]->content, "mysql") == 0)
            {
            }
            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);
        }
        i++;
    }


    return(0);
}


/* EOF */

--- NEW FILE: dbd-config.h ---
/* @(#) $Id: dbd-config.h,v 1.1 2007/08/14 20:03:17 dcid Exp $ */

/* Copyright (C) 2003-2007 Daniel B. Cid <dcid@xxxxxxxxx>
 * All right reserved.
 *
 * This program is a free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 3) as published by the FSF - Free Software
 * Foundation
 */

 

#ifndef _DBDCONFIG__H
#define _DBDONFIG__H


/* Database config structure */
typedef struct _DBConfig
{
    char *host;
    char *user;
    char *pass;
    char *db;

    void *conn;

    char **includes;
}DBConfig;


#endif


OSSEC home | Main Index | Thread Index


OSSEC project: www.ossec.net.
Mailling list information: http://www.ossec.net/en/mailing_lists.html.