just making things look a bit nicer

This commit is contained in:
snit 2024-10-04 00:15:23 -05:00
parent 174ed1ed30
commit 96ce1aa0fe

View File

@ -15,26 +15,23 @@ struct options_t {
bool daemonise;
};
enum error_t parse_arguments(struct options_t *options, int argc, char **argv) {
static struct option long_options[] = {
static enum error_t parse_arguments(
struct options_t *options,
int argc, char **argv
) {
static struct option const long_options[] = {
{ "daemon", no_argument, 0, 'd' },
{ 0, 0, 0, 0 },
};
while (true) {
int option_index = 0;
int c = getopt_long(argc, argv, "d", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'd':
options->daemonise = true;
break;
default:
return ERR_INPUT;
case 'd': options->daemonise = true; break;
default: return ERR_INPUT;
}
}
@ -56,11 +53,13 @@ int main(int argc, char **argv) {
syslog(LOG_NOTICE, "Daemon initialised");
}
if (options.daemonise) closelog();
return EXIT_SUCCESS;
goto handle_exit;
// Is this the best way to do this? I didn't want to duplicate
// closing the syslog
handle_error:
printf("ERROR: %s\n", ERROR_STRS[err]);
handle_exit:
if (options.daemonise) closelog();
return err;
}