diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-02-22 07:07:55 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-02-22 07:07:55 +0000 |
commit | ca9d89b2ba18889c3c2e68a4c8825067b701d0f7 (patch) | |
tree | 104d10ff0c595478c9d602d94105d6426c2f9e25 /util.c | |
parent | 7dbd7d73f60e4e11b1fb785978ee49e4ad7927ad (diff) |
In Tethereal, allow capture filters and read filters either to be
specifies with "-f" and "-R" flags, respectively, or specified with
non-flag command-line arguments, as tcpdump and snoop allow.
svn path=/trunk/; revision=1663
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 42 |
1 files changed, 41 insertions, 1 deletions
@@ -1,7 +1,7 @@ /* util.c * Utility routines * - * $Id: util.c,v 1.36 2000/02/09 19:17:52 gram Exp $ + * $Id: util.c,v 1.37 2000/02/22 07:07:46 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -183,6 +183,46 @@ get_dirname(char *path) return path; } +/* + * Collect command-line arguments as a string consisting of the arguments, + * separated by spaces. + */ +char * +get_args_as_string(int argc, char **argv, int optind) +{ + int len; + int i; + char *argstring; + + /* + * Find out how long the string will be. + */ + len = 0; + for (i = optind; i < argc; i++) { + len += strlen(argv[i]); + len++; /* space, or '\0' if this is the last argument */ + } + + /* + * Allocate the buffer for the string. + */ + argstring = g_malloc(len); + + /* + * Now construct the string. + */ + strcpy(argstring, ""); + i = optind; + for (;;) { + strcat(argstring, argv[i]); + i++; + if (i == argc) + break; + strcat(argstring, " "); + } + return argstring; +} + static char * setup_tmpdir(char *dir) { |