aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/util.c b/util.c
index 70d86d82ee..8b94d3b1dd 100644
--- a/util.c
+++ b/util.c
@@ -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)
{