X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fwin32%2Fsetup-shared.c;h=01b36e506801a88f9ac455269bccfc4e0cb81fa4;hb=HEAD;hp=837768a2e3f8cd3e779010246bf57a5d770436d4;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/win32/setup-shared.c b/src/win32/setup-shared.c old mode 100755 new mode 100644 index 837768a..01b36e5 --- a/src/win32/setup-shared.c +++ b/src/win32/setup-shared.c @@ -1,14 +1,11 @@ -/* @(#) $Id: setup-shared.c,v 1.3 2009/06/24 18:53:10 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 */ - #include #include @@ -18,81 +15,76 @@ #include #include #include + #include "os_regex/os_regex.h" #define OSSECCONF "ossec.conf" #define OS_MAXSTR 1024 -/* Checks if a file exist. */ +/* Check if a file exists */ int fileexist(char *file) { FILE *fp; - /* Opening file */ + /* Open file */ fp = fopen(file, "r"); - if(!fp) - return(0); + if (!fp) { + return (0); + } fclose(fp); - return(1); + return (1); } - -/* Grep for a string in a file. */ +/* Grep for a string in a file */ int dogrep(char *file, char *str) { - char line[OS_MAXSTR +1]; + char line[OS_MAXSTR + 1]; FILE *fp; - /* Opening file */ + /* Open file */ fp = fopen(file, "r"); - if(!fp) - return(0); + if (!fp) { + return (0); + } - /* Clearing memory */ - memset(line, '\0', OS_MAXSTR +1); + /* Clear memory */ + memset(line, '\0', OS_MAXSTR + 1); - /* Reading file and looking for str */ - while(fgets(line, OS_MAXSTR, fp) != NULL) - { - if(OS_Match(str, line)) - { + /* Read file and look for str */ + while (fgets(line, OS_MAXSTR, fp) != NULL) { + if (OS_Match(str, line)) { fclose(fp); - return(1); + return (1); } } fclose(fp); - return(0); + return (0); } - /* Check if dir exists */ int direxist(char *dir) { DIR *dp; - /* Opening dir */ + /* Open dir */ dp = opendir(dir); - if(dp == NULL) - return(0); + if (dp == NULL) { + return (0); + } closedir(dp); - return(1); + return (1); } - /* Get Windows main directory */ void get_win_dir(char *file, int f_size) { ExpandEnvironmentStrings("%WINDIR%", file, f_size); - if(!direxist(file)) - { + if (!direxist(file)) { strncpy(file, "C:\\WINDOWS", f_size); } } - - -/* EOF */