Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-19 15:55:48 +00:00

nfqws2: deduplicate code

This commit is contained in:
bol-van
2026-01-19 16:28:12 +03:00
parent 36ee42bc8c
commit 1359986d29
4 changed files with 348 additions and 497 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <libgen.h>
#include <errno.h>
#define UNIQ_SORT \
{ \
@@ -125,7 +126,26 @@ bool load_file(const char *filename, off_t offset, void *buffer, size_t *buffer_
fclose(F);
return true;
}
bool save_file(const char *filename, const void *buffer, size_t buffer_size)
{
FILE *F;
F = fopen(filename, "wb");
if (!F) return false;
size_t wr = fwrite(buffer, 1, buffer_size, F);
if (ferror(F))
{
fclose(F);
return false;
}
fclose(F);
if (wr!=buffer_size)
{
errno = EIO;
return false;
}
return true;
}
bool append_to_list_file(const char *filename, const char *s)
{
FILE *F = fopen(filename,"at");

View File

@@ -34,6 +34,7 @@ char *strncasestr(const char *s,const char *find, size_t slen);
bool is_identifier(const char *p);
bool load_file(const char *filename, off_t offset, void *buffer, size_t *buffer_size);
bool save_file(const char *filename, const void *buffer, size_t buffer_size);
bool append_to_list_file(const char *filename, const char *s);
void expand_bits(void *target, const void *source, unsigned int source_bitlen, unsigned int target_bytelen);

View File

@@ -2059,6 +2059,11 @@ int main(int argc, char **argv)
break;
case IDX_LUA_GC:
params.lua_gc = atoi(optarg);
if (params.lua_gc<0)
{
DLOG_ERR("lua-gc must be >=0\n");
exit_clean(1);
}
break;
case IDX_HOSTLIST:
if (bSkip) break;