-/* @(#) $Id: read_mysql_log.c,v 1.5 2009/06/24 17:06:27 dcid Exp $ */
+/* @(#) $Id: ./src/logcollector/read_mysql_log.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All rights 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
/* Getting new entry */
while(fgets(str, OS_MAXSTR - OS_LOG_HEADER, logff[pos].fp) != NULL)
{
-
+
/* Getting buffer size */
str_len = strlen(str);
-
+
/* Getting the last occurence of \n */
- if ((p = strrchr(str, '\n')) != NULL)
+ if ((p = strrchr(str, '\n')) != NULL)
{
*p = '\0';
{
need_clear = 1;
}
-
-
+
+
#ifdef WIN32
if ((p = strrchr(str, '\r')) != NULL)
{
}
#endif
-
+
/* Mysql messages have the following format:
* 070823 21:01:30 xx
*/
if((str_len > 18) &&
- (str[6] == ' ') &&
- (str[9] == ':') &&
- (str[12] == ':') &&
+ (str[6] == ' ') &&
+ (str[9] == ':') &&
+ (str[12] == ':') &&
isdigit((int)str[0]) &&
isdigit((int)str[1]) &&
isdigit((int)str[2]) &&
strncpy(__mysql_last_time, str, 16);
__mysql_last_time[15] = '\0';
-
+
/* Removing spaces and tabs */
p = str + 15;
while(*p == ' ' || *p == '\t')
{
p++;
}
-
-
+
+
/* Valid MySQL message */
- snprintf(buffer, OS_MAXSTR, "MySQL log: %s %s",
+ snprintf(buffer, OS_MAXSTR, "MySQL log: %s %s",
__mysql_last_time, p);
}
-
-
+
+
/* Multiple events at the same second share the same
* time stamp.
* 0909 2020 2020 2020 20
{
p++;
}
-
- /* Valid MySQL message */
- snprintf(buffer, OS_MAXSTR, "MySQL log: %s %s",
- __mysql_last_time, p);
+
+ /* Valid MySQL message */
+ snprintf(buffer, OS_MAXSTR, "MySQL log: %s %s",
+ __mysql_last_time, p);
}
else
{
continue;
}
-
-
+
+
debug2("%s: DEBUG: Reading mysql messages: '%s'", ARGV0, buffer);
-
+
/* Sending message to queue */
if(drop_it == 0)
{
}
}
}
-
+
continue;
}
- return(NULL);
+ return(NULL);
}
/* EOF */