X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_dbd%2Fdbd.c;h=3cf3b7aadae4fe95e28b9b62612360d25adb6e02;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=925e01ba28f5abee1cde652101f951f8e8b6024d;hpb=301048b51990573e58a30dc4a5bb4ec285cad554;p=ossec-hids.git diff --git a/src/os_dbd/dbd.c b/src/os_dbd/dbd.c old mode 100755 new mode 100644 index 925e01b..3cf3b7a --- a/src/os_dbd/dbd.c +++ b/src/os_dbd/dbd.c @@ -1,5 +1,3 @@ -/* @(#) $Id$ */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * @@ -7,82 +5,60 @@ * and/or modify it under the terms of the GNU General Public * License (version 2) as published by the FSF - Free Software * Foundation. - * - * License details at the LICENSE file included with OSSEC or - * online at: http://www.ossec.net/en/licensing.html */ - -#ifndef DBD - #define DBD -#endif - -#ifndef ARGV0 - #define ARGV0 "ossec-dbd" -#endif - #include "shared.h" #include "dbd.h" +#ifndef ARGV0 +#define ARGV0 "ossec-dbd" +#endif -/* OS_DBD: Monitor the alerts and insert them into the database. - * Only return in case of error. +/* Monitor the alerts and insert them into the database + * Only returns in case of error */ void OS_DBD(DBConfig *db_config) { - time_t tm; - struct tm *p; - + time_t tm; + struct tm *p; file_queue *fileq; alert_data *al_data; - - /* Getting currently time before starting */ + /* Get current time before starting */ tm = time(NULL); - p = localtime(&tm); - + p = localtime(&tm); - /* Initating file queue - to read the alerts */ + /* Initialize file queue to read the alerts */ os_calloc(1, sizeof(file_queue), fileq); Init_FileQueue(fileq, p, 0); - - /* Creating location hash */ + /* Create location hash */ db_config->location_hash = OSHash_Create(); - if(!db_config->location_hash) - { - ErrorExit(MEM_ERROR, ARGV0); + if (!db_config->location_hash) { + ErrorExit(MEM_ERROR, ARGV0, errno, strerror(errno)); } - - /* Getting maximum ID */ + /* Get maximum ID */ db_config->alert_id = OS_SelectMaxID(db_config); db_config->alert_id++; - - /* Infinite loop reading the alerts and inserting them. */ - while(1) - { + /* Infinite loop reading the alerts and inserting them */ + while (1) { tm = time(NULL); p = localtime(&tm); - /* Get message if available (timeout of 5 seconds) */ al_data = Read_FileMon(fileq, p, 5); - if(!al_data) - { + if (!al_data) { continue; } - - /* Inserting into the db */ + /* Insert into the db */ OS_Alert_InsertDB(al_data, db_config); - - /* Clearing the memory */ + /* Clear the memory */ FreeAlertData(al_data); } } -/* EOF */