nfqws,tpws: remove unneeded code

This commit is contained in:
bol-van
2024-10-31 19:59:26 +03:00
parent 228572afb5
commit 8b4b8c3fb0
8 changed files with 13 additions and 118 deletions

View File

@@ -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;
}