diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2012-05-23 23:27:42 +0200 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2012-05-23 23:27:42 +0200 |
commit | 0907c31db34713f0e74b90f725fabb5c91c5f45f (patch) | |
tree | 16874dabcd4e4ee0cc534fde44009ee7d1df7723 /src/ui.c | |
parent | 4b913c17499935074c6ef33cea79cdb6abd097d1 (diff) |
Allow saving to/restoring from a file without shell redirection
Mathieu Bridon suggested that in some environments where there is no
access to a full shell with input/output redirection, it'd be useful
to read from/write to directly a file (bugzilla #788).
The patch adds the new "-file" option to specify a filename to print
into when listing/saving sets or read from when restoring sets.
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -154,6 +154,37 @@ ipset_match_cmd(const char *arg, const char * const name[]) (name[1] != NULL && tolower(arg[0]) == name[1][0]); } +/* Used up so far + * + * -A add + * -D del + * -E rename + * -f -file + * -F flush + * -h help + * -H help + * -L list + * -n -name + * -N create + * -o -output + * -r -resolve + * -R restore + * -s -sorted + * -S save + * -t -terse + * -T test + * -q -quiet + * -X destroy + * -v version + * -V version + * -W swap + * -! -exist + */ + +int +ipset_parse_file(struct ipset_session *session, + int opt, const char *str); + const struct ipset_envopts ipset_envopts[] = { { .name = { "-o", "-output" }, .has_arg = IPSET_MANDATORY_ARG, .flag = IPSET_OPT_MAX, @@ -202,6 +233,14 @@ const struct ipset_envopts ipset_envopts[] = { " When listing, list setnames and set headers\n" " from kernel only.", }, + { .name = { "-f", "-file" }, + .parse = ipset_parse_file, + .has_arg = IPSET_MANDATORY_ARG, .flag = IPSET_OPT_MAX, + .help = "\n" + " Read from the given file instead of standard\n" + " input (restore) or write to given file instead\n" + " of standard output (list/save).", + }, { }, }; |