improved version of split_args()
[paraslash.git] / audiod.c
index 7029ea9..7596c5c 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -811,6 +811,7 @@ static void check_stat_line(char *line)
        struct timeval tv;
        char *tmp;
 
+       PARA_INFO_LOG("line: %s\n", line);
        if (!line)
                return;
        itemnum = stat_line_valid(line);
@@ -1107,7 +1108,7 @@ out:
 
 static int init_stream_io(void)
 {
-       int i, ret, receiver_num;
+       int i, ret, receiver_num, nf;
        char *cmd;
 
        for (i = 0; i < conf.stream_write_cmd_given; i++) {
@@ -1156,9 +1157,11 @@ static int init_stream_io(void)
        free(cmd);
        /* filters */
        filter_init(filters);
+       nf = MAX(2,  conf.filter_given) + 1;
+       PARA_INFO_LOG("allocating space for %d filters\n", nf);
        FOR_EACH_AUDIO_FORMAT(i) {
-               afi[i].filter_conf = para_malloc((conf.filter_given + 1) * sizeof(char *));
-               afi[i].filters = para_malloc((conf.filter_given + 1) * sizeof(struct filter *));
+               afi[i].filter_conf = para_malloc(nf * sizeof(char *));
+               afi[i].filters = para_malloc(nf * sizeof(struct filter *));
        }
        if (!conf.no_default_filters_given)
                return setup_default_filters();
@@ -1445,12 +1448,12 @@ static int handle_connect(void)
        ret = check_perms(&c);
        if (ret < 0)
                goto out;
-       argc = split_args(buf, &argv, '\n');
-       PARA_INFO_LOG("argv[0]: %s\n", argv[0]);
+       argc = split_args(buf, &argv, "\n");
+       PARA_INFO_LOG("argv[0]: %s, argc= %d\n", argv[0], argc);
        for (i = 0; cmds[i].name; i++) {
                if (strcmp(cmds[i].name, argv[0]))
                        continue;
-               ret = cmds[i].handler(clifd, argc + 1, argv);
+               ret = cmds[i].handler(clifd, argc, argv);
                goto out;
        }
        ret = -E_INVALID_AUDIOD_CMD; /* cmd not found */
@@ -1643,6 +1646,7 @@ int __noreturn main(int argc, char *argv[])
        char *cf;
        int i;
 
+       fprintf(stderr, "argc: %d\n", argc);
        valid_fd_012();
        hostname = para_hostname();
        cmdline_parser(argc, argv, &conf);