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 /lib | |
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 'lib')
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/libipset.map | 5 | ||||
-rw-r--r-- | lib/session.c | 13 |
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index fd853dd..392b5f9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -19,7 +19,7 @@ lib_LTLIBRARIES = libipset.la include $(top_srcdir)/lib/Make_extra.am -libipset_la_LDFLAGS = -Wl,--version-script=$(top_srcdir)/lib/libipset.map -version-info $(LIBVERSION) +libipset_la_LDFLAGS = -Wl,--version-script=$(top_srcdir)/lib/libipset.map -version-number $(LIBVERSION) libipset_la_LIBADD = ${libmnl_LIBS} $(IPSET_SETTYPE_STATIC_OBJECTS) libipset_la_SOURCES = \ data.c \ diff --git a/lib/libipset.map b/lib/libipset.map index fd6b8c0..74370b2 100644 --- a/lib/libipset.map +++ b/lib/libipset.map @@ -117,3 +117,8 @@ global: ipset_parse_timeout; ipset_data_test_ignored; } LIBIPSET_1.0; + +LIBIPSET_3.0 { +global: + ipset_session_outfn; +} LIBIPSET_2.0; diff --git a/lib/session.c b/lib/session.c index 6700ea1..3803bfa 100644 --- a/lib/session.c +++ b/lib/session.c @@ -1941,6 +1941,19 @@ cleanup: } /** + * ipset_session_outfn - set session output printing function + * + * Set the session printing function. + * + */ +int +ipset_session_outfn(struct ipset_session *session, ipset_outfn outfn) +{ + session->outfn = outfn ? outfn : printf; + return 0; +} + +/** * ipset_session_init - initialize an ipset session * * Initialize an ipset session by allocating a session structure |