-static char *task_exec(char *opts)
-{
- FILE *f;
- int ret, s;
- char *str, *tmp, *cmd, buf[1024];
-
- str = NULL;
-
- cmd = malloc(strlen("task rc.json.array=on ") + strlen(opts) + 1);
- strcpy(cmd, "task rc.json.array=on ");
- strcat(cmd, opts);
-
- printf("execute: %s\n", cmd);
-
- f = popen(cmd, "r");
-
- if (!f) {
- perror("popen");
- goto exit_free;
- }
-
- str = malloc(1);
- str[0] = '\0';
- while ((s = fread(buf, 1, 1024, f))) {
- tmp = malloc(strlen(str) + s + 1);
- memcpy(tmp, str, strlen(str));
- memcpy(tmp + strlen(str), buf, s);
- tmp[strlen(str) + s] = '\0';
- free(str);
- str = tmp;
- }
-
- ret = pclose(f);
-
- if (ret == -1) {
- printf("pclose fails\n");
- perror("pclose");
- }
-
- exit_free:
- free(cmd);
-
- return str;
-}
+static struct option long_options[] = {
+ {"version", no_argument, 0, 'v'},
+ {"help", no_argument, 0, 'h'},
+ {"debug", required_argument, 0, 'd'},
+ {0, 0, 0, 0}
+};