-/* @(#) $Id: file-queue.c,v 1.11 2009/06/24 18:53:08 dcid Exp $ */
+/* @(#) $Id: ./src/shared/file-queue.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* 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
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*
* License details at the LICENSE file included with OSSEC or
{
#ifndef WIN32
struct timeval fp_timeout;
-
+
fp_timeout.tv_sec = FQ_TIMEOUT;
fp_timeout.tv_usec = 0;
/* Waiting for the select timeout */
select(0, NULL, NULL, NULL, &fp_timeout);
-
+
#else
/* Windows don't like select that way */
Sleep((FQ_TIMEOUT + 2) * 1000);
ALERTS,
fileq->year,
fileq->mon,
- fileq->day);
+ fileq->day);
}
}
/** int Handle_Queue(file_queue *fileq)
* Re Handle the file queue.
*/
-int Handle_Queue(file_queue *fileq, int flags)
+int Handle_Queue(file_queue *fileq, int flags)
{
/* Closing if it is open */
if(!(flags & CRALERT_FP_SET))
}
}
-
+
/* File change time */
if(fstat(fileno(fileq->fp), &fileq->f_status) < 0)
{
fileq->fp = NULL;
return(-1);
}
-
+
fileq->last_change = fileq->f_status.st_mtime;
-
+
return(1);
}
}
fileq->last_change = 0;
fileq->flags = 0;
-
+
fileq->day = p->tm_mday;
fileq->year = p->tm_year+1900;
-
+
strncpy(fileq->mon, s_month[p->tm_mon], 4);
memset(fileq->file_name, '\0',MAX_FQUEUE + 1);
/* Setting the supplied flags */
fileq->flags = flags;
-
+
/* Getting latest file */
GetFile_Queue(fileq);
-
+
/* Always seek end when starting the queue */
if(Handle_Queue(fileq, fileq->flags) < 0)
{
return(-1);
}
- return(0);
+ return(0);
}
int i = 0;
alert_data *al_data;
-
+
/* If the file queue is not available, try to access it */
if(!fileq->fp)
{
}
}
-
+
/* Getting currently file */
if(p->tm_mday != fileq->day)
{
}
}
-
+
/* Try up to timeout times to get an event */
while(i < timeout)
{
{
return(al_data);
}
-
- i++;
+
+ i++;
file_sleep();
}
-
+
/* Returning NULL if timeout expires. */
return(NULL);
}