mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-04-20 13:59:11 +00:00
correctly handle filter file loading error, small tweak
This commit is contained in:
parent
897dcbd350
commit
e933a9b806
3 changed files with 13 additions and 3 deletions
|
@ -496,10 +496,12 @@ static void filters_prepare(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadfilterfile(const char *fname)
|
static bool loadfilterfile(const char *fname)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
FILE *f = fopen(fname,"r");
|
FILE *f = fopen(fname,"r");
|
||||||
|
if (!f)
|
||||||
|
return false;
|
||||||
while (fgets(buf,sizeof(buf),f)) {
|
while (fgets(buf,sizeof(buf),f)) {
|
||||||
for (char *p = buf;*p;++p) {
|
for (char *p = buf;*p;++p) {
|
||||||
if (*p == '\n') {
|
if (*p == '\n') {
|
||||||
|
@ -510,4 +512,5 @@ static void loadfilterfile(const char *fname)
|
||||||
if (*buf && *buf != '#' && memcmp(buf,"//",2) != 0)
|
if (*buf && *buf != '#' && memcmp(buf,"//",2) != 0)
|
||||||
filters_add(buf);
|
filters_add(buf);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
1
ioutil.c
1
ioutil.c
|
@ -95,6 +95,7 @@ int closefile(FH fd)
|
||||||
int createdir(const char *path,int secret)
|
int createdir(const char *path,int secret)
|
||||||
{
|
{
|
||||||
// XXX don't know how to handle secret argument
|
// XXX don't know how to handle secret argument
|
||||||
|
(void) secret;
|
||||||
return CreateDirectoryA(path,0) ? 0 : -1;
|
return CreateDirectoryA(path,0) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
main.c
10
main.c
|
@ -3,6 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@ -256,8 +257,13 @@ int main(int argc,char **argv)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (*arg == 'f') {
|
else if (*arg == 'f') {
|
||||||
if (argc--)
|
if (argc--) {
|
||||||
loadfilterfile(*argv++);
|
const char *filename = *argv++;
|
||||||
|
if (!loadfilterfile(filename)) {
|
||||||
|
fprintf(stderr,"failed to load filter file %s\n",filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
e_additional();
|
e_additional();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue