diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2015-11-07 16:55:15 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-11-09 13:33:21 +0100 |
commit | c6aeff438d452be679cc3ba0a600db1d204b49a6 (patch) | |
tree | 03ad8f1576111b88d08dfec2c1615abab5bd4ff7 /netsniff-ng.c | |
parent | a2a169affeb57a42e27dd4893da0bdb52542dae9 (diff) |
str: Add converting cmdline args vector to str module
Move piece of code which converts cmdline args vector to string
from netsniff-ng.c to str.c as function.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'netsniff-ng.c')
-rw-r--r-- | netsniff-ng.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c index e5d1886..5119ad5 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -1506,22 +1506,8 @@ int main(int argc, char **argv) } } - if (!ctx.filter && optind != argc) { - int ret; - off_t offset = 0; - - for (i = optind; i < argc; ++i) { - size_t alen = strlen(argv[i]) + 2; - size_t flen = ctx.filter ? strlen(ctx.filter) : 0; - - ctx.filter = xrealloc(ctx.filter, flen + alen); - ret = slprintf(ctx.filter + offset, strlen(argv[i]) + 2, "%s ", argv[i]); - if (ret < 0) - panic("Cannot concatenate filter string!\n"); - else - offset += ret; - } - } + if (!ctx.filter && optind != argc) + ctx.filter = argv2str(optind, argc, argv); if (!ctx.device_in) ctx.device_in = xstrdup("any"); |