Skip to content

Commit

Permalink
Apparently the options where a mess, thus clean them up, sort them al…
Browse files Browse the repository at this point in the history
…phabettically.

Noted at Jille@84a5b76
  • Loading branch information
massar committed Nov 22, 2012
1 parent 6db6951 commit d9daa84
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
2 changes: 2 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ empcd (2012.11.22) stable; urgency=low
* Allow entering of numeric events, eg with: key 165 UP mpd_next
* Minor formatting fixups
* Add 'giveup' and 'dontgiveup' option for retry on device open
* Fixup options ordering (hinted by following github commit:
https://github.com/Jille/empcd/commit/84a5b76f3fdeda5169d3654c6d9c35978124cada)

Lee Dolsen (https://github.com/ldolse/empcd/)
* Updated keytable to reflect IR & Multimedia additions to the kernel
Expand Down
68 changes: 34 additions & 34 deletions empcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,47 +730,47 @@ void handle_event(struct input_event *ev)
static struct option const long_options[] = {
{"config", required_argument, NULL, 'c'},
{"daemonize", no_argument, NULL, 'd'},
{"eventdevice", required_argument, NULL, 'e'},
{"nodaemonize", no_argument, NULL, 'f'},
{"giveup", no_argument, NULL, 'g'},
{"dontgiveup", no_argument, NULL, 'G'},
{"eventdevice", required_argument, NULL, 'e'},
{"help", no_argument, NULL, 'h'},
{"list-keys", no_argument, NULL, 'K'},
{"list-functions", no_argument, NULL, 'L'},
{"quiet", no_argument, NULL, 'q'},
{"user", required_argument, NULL, 'u'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{"verbosity", required_argument, NULL, 'y'},
{"exclusive", no_argument, NULL, 'x'},
{"nonexclusive", no_argument, NULL, 'X'},
{"verbosity", required_argument, NULL, 'y'},
{NULL, no_argument, NULL, 0},
};

static char short_options[] = "c:de:fgGhKLqu:vVy:";
static char short_options[] = "c:de:fgGhKLqu:vVxXy:";

static struct
{
char *args;
char *desc;
} desc_options[] =
{
{"<file>", "Configuration File Location"},
{NULL, "Detach the program into the background"},
{NULL, "Don't detach, stay in the foreground"},
{NULL, "Give up when opening the device fails (default)"},
{NULL, "Do not give up when opening the device fails"},
{"<eventdevice>", "The event device to use (default: /dev/input/event0)"},
{NULL, "This help"},
{NULL, "List the keys that are known to this program"},
{NULL, "List the functions known to this program"},
{NULL, "Lower the verbosity level to 0 (quiet)"},
{"<username>", "Drop priveleges to <user>"},
{NULL, "Increase the verbosity level by 1"},
{NULL, "Show the version of this program"},
{"<level>", "Set the verbosity level to <level>"},
{NULL, "Exclusive device access (default)"},
{NULL, "Non-Exclusive device access"},
/* c: */ {"<file>", "Configuration File Location"},
/* d */ {NULL, "Detach the program into the background"},
/* e: */ {"<eventdevice>", "The event device to use (default: /dev/input/event0)"},
/* f */ {NULL, "Don't detach, stay in the foreground"},
/* g */ {NULL, "Give up when opening the device fails (default)"},
/* G: */ {NULL, "Do not give up when opening the device fails"},
/* h */ {NULL, "This help"},
/* K */ {NULL, "List the keys that are known to this program"},
/* L */ {NULL, "List the functions known to this program"},
/* q */ {NULL, "Lower the verbosity level to 0 (quiet)"},
/* u: */ {"<username>", "Drop priveleges to <user>"},
/* v */ {NULL, "Increase the verbosity level by 1"},
/* V */ {NULL, "Show the version of this program"},
/* x */ {NULL, "Exclusive device access (default)"},
/* X */ {NULL, "Non-Exclusive device access"},
/* y: */ {"<level>", "Set the verbosity level to <level>"},
{NULL, NULL}
};

Expand All @@ -794,6 +794,11 @@ int main (int argc, char **argv)
daemonize = true;
break;

case 'e':
if (device) free(device);
device = strdup(optarg);
break;

case 'f':
daemonize = false;
break;
Expand All @@ -806,11 +811,6 @@ int main (int argc, char **argv)
giveup = true;
break;

case 'e':
if (device) free(device);
device = strdup(optarg);
break;

case 'h':
fprintf(stderr, "usage: %s\n", argv[0]);

Expand All @@ -832,17 +832,17 @@ int main (int argc, char **argv)

return 1;

case 'L':
for (i=0; func_map[i].name; i++)
case 'K':
for (i=0; key_event_map[i].code != EMPCD_MAPPING_END; i++)
{
fprintf(stderr, "%-15s %20s %s\n", func_map[i].format, func_map[i].args ? func_map[i].args : "", func_map[i].label);
fprintf(stderr, "%-25s %s\n", key_event_map[i].name, key_event_map[i].label);
}
return 0;

case 'K':
for (i=0; key_event_map[i].code != EMPCD_MAPPING_END; i++)
case 'L':
for (i=0; func_map[i].name; i++)
{
fprintf(stderr, "%-25s %s\n", key_event_map[i].name, key_event_map[i].label);
fprintf(stderr, "%-15s %20s %s\n", func_map[i].format, func_map[i].args ? func_map[i].args : "", func_map[i].label);
}
return 0;

Expand Down Expand Up @@ -873,10 +873,6 @@ int main (int argc, char **argv)
verbosity++;
break;

case 'y':
verbosity = atoi(optarg);
break;

case 'V':
fprintf(stderr, EMPCD_VSTRING, EMPCD_VERSION);
return 1;
Expand All @@ -889,6 +885,10 @@ int main (int argc, char **argv)
exclusive = false;
break;

case 'y':
verbosity = atoi(optarg);
break;

default:
if (j != 0) fprintf(stderr, "Unknown short option '%c'\n", j);
else fprintf(stderr, "Unknown long option\n");
Expand Down

0 comments on commit d9daa84

Please sign in to comment.