/* Collect command-line arguments as a string consisting of the arguments, separated by spaces.  */
char* get_args_as_string(int argc, char **argv, int optindex)
/* Collect command-line arguments as a string consisting of the arguments, separated by spaces.  */
char* get_args_as_string(int argc, char **argv, int optindex)
{
    int len;
    int i;
    char *argstring;
    len = 0;
    for (i = optindex; i < argc; i++) {
        len += (int) strlen(argv[i]);
        len++;
    }
    argstring = (char *)g_malloc(len);
    argstring[0] = '\0';
    i = optindex;
    for (;;) {
        g_strlcat(argstring, argv[i], len);
        i++;
        if (i == argc)
            break;
        g_strlcat(argstring, " ", len);
    }
    return argstring;
}