mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-27 11:50:34 +05:00
nfqws,tpws: remove unneeded code
This commit is contained in:
parent
228572afb5
commit
8b4b8c3fb0
@ -8,8 +8,6 @@
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <libgen.h>
|
||||
#include <wordexp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "params.h"
|
||||
|
||||
@ -505,48 +503,3 @@ bool parse_cidr6(char *s, struct cidr6 *cidr)
|
||||
if (p) *p=d; // restore char
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
void free_command_line(char **argv, int argc)
|
||||
{
|
||||
int i;
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
if (argv[i]) free(argv[i]);
|
||||
free(argv);
|
||||
}
|
||||
}
|
||||
|
||||
char **split_command_line(const char *cmdline, int *argc)
|
||||
{
|
||||
int i;
|
||||
char **argv = NULL;
|
||||
wordexp_t p;
|
||||
|
||||
*argc=0;
|
||||
|
||||
// Note! This expands shell variables.
|
||||
if (!cmdline || wordexp(cmdline, &p, WRDE_NOCMD))
|
||||
return NULL;
|
||||
|
||||
if (!(argv = malloc(p.we_wordc * sizeof(char *))))
|
||||
{
|
||||
wordfree(&p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < p.we_wordc; i++)
|
||||
{
|
||||
if (!(argv[i] = strdup(p.we_wordv[i])))
|
||||
{
|
||||
wordfree(&p);
|
||||
free_command_line(argv,i);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*argc=i;
|
||||
|
||||
wordfree(&p);
|
||||
return argv;
|
||||
}
|
||||
|
@ -107,6 +107,3 @@ static inline const struct in6_addr *mask_from_preflen6(uint8_t preflen)
|
||||
{
|
||||
return ip6_mask+preflen;
|
||||
}
|
||||
|
||||
void free_command_line(char **argv, int argc);
|
||||
char **split_command_line(const char *cmdline, int *argc);
|
||||
|
11
nfq/nfqws.c
11
nfq/nfqws.c
@ -554,9 +554,7 @@ static bool parse_ws_scale_factor(char *s, uint16_t *wsize, uint8_t *wscale)
|
||||
|
||||
static void cleanup_args()
|
||||
{
|
||||
free_command_line(params.argv,params.argc);
|
||||
params.argv = NULL;
|
||||
params.argc = 0;
|
||||
wordfree(¶ms.wexp);
|
||||
}
|
||||
|
||||
static void cleanup_params(void)
|
||||
@ -1066,14 +1064,13 @@ int main(int argc, char **argv)
|
||||
replace_char(buf,'\n',' ');
|
||||
replace_char(buf,'\r',' ');
|
||||
replace_char(buf,'\t',' ');
|
||||
params.argv = split_command_line(buf,¶ms.argc);
|
||||
if (!params.argv)
|
||||
if (wordexp(buf, ¶ms.wexp, WRDE_NOCMD))
|
||||
{
|
||||
DLOG_ERR("failed to split command line options from file '%s'\n",argv[1]+1);
|
||||
exit_clean(1);
|
||||
}
|
||||
argv=params.argv;
|
||||
argc=params.argc;
|
||||
argv=params.wexp.we_wordv;
|
||||
argc=params.wexp.we_wordc;
|
||||
}
|
||||
|
||||
const struct option long_options[] = {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <sys/queue.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#define TLS_PARTIALS_ENABLE true
|
||||
|
||||
@ -95,8 +96,7 @@ bool dp_list_have_autohostlist(struct desync_profile_list_head *head);
|
||||
|
||||
struct params_s
|
||||
{
|
||||
char **argv; // for file based config
|
||||
int argc;
|
||||
wordexp_t wexp; // for file based config
|
||||
|
||||
enum log_target debug_target;
|
||||
char debug_logfile[PATH_MAX];
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include <ifaddrs.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <wordexp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void rtrim(char *s)
|
||||
{
|
||||
@ -420,48 +418,3 @@ bool parse_cidr6(char *s, struct cidr6 *cidr)
|
||||
if (p) *p=d; // restore char
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
void free_command_line(char **argv, int argc)
|
||||
{
|
||||
int i;
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
if (argv[i]) free(argv[i]);
|
||||
free(argv);
|
||||
}
|
||||
}
|
||||
|
||||
char **split_command_line(const char *cmdline, int *argc)
|
||||
{
|
||||
int i;
|
||||
char **argv = NULL;
|
||||
wordexp_t p;
|
||||
|
||||
*argc=0;
|
||||
|
||||
// Note! This expands shell variables.
|
||||
if (!cmdline || wordexp(cmdline, &p, WRDE_NOCMD))
|
||||
return NULL;
|
||||
|
||||
if (!(argv = malloc(p.we_wordc * sizeof(char *))))
|
||||
{
|
||||
wordfree(&p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < p.we_wordc; i++)
|
||||
{
|
||||
if (!(argv[i] = strdup(p.we_wordv[i])))
|
||||
{
|
||||
wordfree(&p);
|
||||
free_command_line(argv,i);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*argc=i;
|
||||
|
||||
wordfree(&p);
|
||||
return argv;
|
||||
}
|
||||
|
@ -112,6 +112,3 @@ static inline const struct in6_addr *mask_from_preflen6(uint8_t preflen)
|
||||
{
|
||||
return ip6_mask+preflen;
|
||||
}
|
||||
|
||||
void free_command_line(char **argv, int argc);
|
||||
char **split_command_line(const char *cmdline, int *argc);
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <time.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "tpws.h"
|
||||
#include "pools.h"
|
||||
#include "helpers.h"
|
||||
@ -79,8 +81,7 @@ void dp_list_destroy(struct desync_profile_list_head *head);
|
||||
|
||||
struct params_s
|
||||
{
|
||||
char **argv; // for file based config
|
||||
int argc;
|
||||
wordexp_t wexp; // for file based config
|
||||
|
||||
int debug;
|
||||
enum log_target debug_target;
|
||||
|
11
tpws/tpws.c
11
tpws/tpws.c
@ -217,9 +217,7 @@ static void exithelp(void)
|
||||
}
|
||||
static void cleanup_args()
|
||||
{
|
||||
free_command_line(params.argv,params.argc);
|
||||
params.argv = NULL;
|
||||
params.argc = 0;
|
||||
wordfree(¶ms.wexp);
|
||||
}
|
||||
static void cleanup_params(void)
|
||||
{
|
||||
@ -423,14 +421,13 @@ void parse_params(int argc, char *argv[])
|
||||
replace_char(buf,'\n',' ');
|
||||
replace_char(buf,'\r',' ');
|
||||
replace_char(buf,'\t',' ');
|
||||
params.argv = split_command_line(buf,¶ms.argc);
|
||||
if (!params.argv)
|
||||
if (wordexp(buf, ¶ms.wexp, WRDE_NOCMD))
|
||||
{
|
||||
DLOG_ERR("failed to split command line options from file '%s'\n",argv[1]+1);
|
||||
exit_clean(1);
|
||||
}
|
||||
argv=params.argv;
|
||||
argc=params.argc;
|
||||
argv=params.wexp.we_wordv;
|
||||
argc=params.wexp.we_wordc;
|
||||
}
|
||||
|
||||
const struct option long_options[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user