commit - 127f376a4797636687374f562e7a65cae3586040
commit + 6576093aa0f0a23c584d95c79c03c4ea9a390aaa
blob - f291251e0884125eb6c5005512407a7e5dfb58df
blob + dd7b94f7ce9191b416561e685a269a2fd1c3ccad
--- ctl.c
+++ ctl.c
}
static int
-parse(int argc, char **argv)
+parse(struct parse_result *res, int argc, char **argv)
{
struct ctl_command *ctl = NULL;
- struct parse_result res;
const char *argv0;
int i, status;
- memset(&res, 0, sizeof(res));
-
if ((argv0 = argv[0]) == NULL)
argv0 = "status";
usage();
}
- res.action = ctl->action;
- res.ctl = ctl;
+ res->action = ctl->action;
+ res->ctl = ctl;
if (!ctl->has_pledge) {
/* pledge(2) default if command doesn't have its own */
fatal("pledge");
}
- status = ctl->main(&res, argc, argv);
+ status = ctl->main(res, argc, argv);
close(ibuf->fd);
free(ibuf);
return status;
static int
ctl_status(struct parse_result *res, int argc, char **argv)
{
- const char *fmt = NULL;
int ch;
while ((ch = getopt(argc, argv, "f:")) != -1) {
switch (ch) {
case 'f':
- fmt = optarg;
+ res->status_format = optarg;
break;
default:
ctl_usage(res->ctl);
if (argc > 0)
ctl_usage(res->ctl);
- if (fmt == NULL && (fmt = getenv("AMUSED_STATUS_FORMAT")) == NULL)
- fmt = "status,time,repeat";
- res->status_format = fmt;
return ctlaction(res);
}
__dead void
ctl(int argc, char **argv)
{
+ struct parse_result res;
+ const char *fmt;
int ctl_sock;
+ memset(&res, 0, sizeof(res));
+ if ((fmt = getenv("AMUSED_STATUS_FORMAT")) == NULL)
+ fmt = "status,time,repeat";
+ res.status_format = fmt;
+
log_init(1, LOG_DAEMON);
log_setverbose(verbose);
optreset = 1;
optind = 1;
- exit(parse(argc, argv));
+ exit(parse(&res, argc, argv));
}