3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
14 #include "os_zlib/os_zlib.h"
17 /* gzips a log file */
18 void OS_CompressLog(char *logfile)
23 char logfileGZ[OS_FLSIZE + 1];
26 char buf[OS_MAXSTR + 1];
30 if(mond.compress == 0)
34 /* Clearing the memory */
35 memset(logfileGZ,'\0',OS_FLSIZE +1);
36 memset(buf, '\0', OS_MAXSTR + 1);
39 /* Setting the umask */
43 /* Creating the gzip file name */
44 snprintf(logfileGZ, OS_FLSIZE, "%s.gz", logfile);
47 /* Reading log file */
48 log = fopen(logfile, "r");
51 /* Do not warn in here, since the alert file may not exist. */
55 /* Opening compressed file */
56 zlog = gzopen(logfileGZ, "w");
60 merror(FOPEN_ERROR, ARGV0, logfileGZ);
66 len = fread(buf, 1, OS_MAXSTR, log);
69 if(gzwrite(zlog, buf, (unsigned)len) != len)
70 merror("%s: Compression error: %s", ARGV0, gzerror(zlog, &err));
77 /* Removing uncompressed file */