Skip to content
Snippets Groups Projects
Commit e5d7915b authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Use fnopen() instead of fopen() to open can/cfg files for searching/appending

parent 1e9b2b32
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
#include "genwrap.h"
#include "findstr.h"
#include "nopen.h"
/****************************************************************************/
/* Pattern matching string search of 'search' in 'pattern'. */
......@@ -200,7 +201,7 @@ BOOL find2strs(const char* str1, const char* str2, const char* fname)
if(fname == NULL || *fname == '\0')
return FALSE;
if((fp=fopen(fname,"r"))==NULL)
if ((fp = fnopen(NULL, fname, O_RDONLY)) == NULL)
return FALSE;
ip_addr1 = parse_ipv4_address(str1);
......@@ -236,7 +237,7 @@ str_list_t findstr_list(const char* fname)
FILE* fp;
str_list_t list;
if((fp=fopen(fname,"r"))==NULL)
if ((fp = fnopen(NULL, fname, O_RDONLY)) == NULL)
return NULL;
list=strListReadFile(fp, NULL, /* Max line length: */255);
......
......@@ -3037,7 +3037,7 @@ char* alias(scfg_t* cfg, const char* name, char* buf)
p=(char*)name;
SAFEPRINTF(fname,"%salias.cfg",cfg->ctrl_dir);
if((fp=fopen(fname,"r"))==NULL)
if((fp = fnopen(NULL, fname, O_RDONLY)) == NULL)
return((char*)name);
while(!feof(fp)) {
......@@ -3629,7 +3629,7 @@ BOOL filter_ip(scfg_t* cfg, const char* prot, const char* reason, const char* ho
if(findstr(ip_addr, fname)) /* Already filtered? */
return(TRUE);
if((fp=fopen(fname,"a"))==NULL)
if((fp = fnopen(NULL, fname, O_CREAT|O_APPEND|O_WRONLY)) == NULL)
return(FALSE);
fprintf(fp, "\n; %s %s ", prot, reason);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment