1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
14 #include <sys/types.h>
19 #include "os_regex/os_regex.h"
21 #define OSSECCONF "ossec.conf"
22 #define OS_MAXSTR 1024
25 /* Check if a file exists */
26 int fileexist(char *file)
31 fp = fopen(file, "r");
40 /* Grep for a string in a file */
41 int dogrep(char *file, char *str)
43 char line[OS_MAXSTR + 1];
47 fp = fopen(file, "r");
53 memset(line, '\0', OS_MAXSTR + 1);
55 /* Read file and look for str */
56 while (fgets(line, OS_MAXSTR, fp) != NULL) {
57 if (OS_Match(str, line)) {
67 /* Check if dir exists */
68 int direxist(char *dir)
82 /* Get Windows main directory */
83 void get_win_dir(char *file, int f_size)
85 ExpandEnvironmentStrings("%WINDIR%", file, f_size);
87 if (!direxist(file)) {
88 strncpy(file, "C:\\WINDOWS", f_size);