summaryrefslogtreecommitdiffstats
path: root/sys-utils/tunelp.c
diff options
context:
space:
mode:
authorSami Kerola2015-01-10 16:04:27 +0100
committerKarel Zak2015-03-05 10:31:18 +0100
commit7e5dd0e5bed95f3da369a912732ab500c3c15c5f (patch)
tree2893feceb17c6f42747fd0f43e0a1c6e28225808 /sys-utils/tunelp.c
parentflock: improve timeout handling (diff)
downloadkernel-qcow2-util-linux-7e5dd0e5bed95f3da369a912732ab500c3c15c5f.tar.gz
kernel-qcow2-util-linux-7e5dd0e5bed95f3da369a912732ab500c3c15c5f.tar.xz
kernel-qcow2-util-linux-7e5dd0e5bed95f3da369a912732ab500c3c15c5f.zip
tunelp: use parse_switch()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/tunelp.c')
-rw-r--r--sys-utils/tunelp.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 8c70268d6..8ea5c0238 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -116,13 +116,6 @@ static void __attribute__((__noreturn__)) print_usage(FILE *out)
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
-static long get_onoff(char *val)
-{
- if (!strncasecmp("on", val, 2))
- return 1;
- return 0;
-}
-
int main(int argc, char **argv)
{
int c, fd, irq, status, show_irq, offset = 0, retval;
@@ -193,28 +186,24 @@ int main(int argc, char **argv)
break;
case 'a':
cmds->op = LPABORT;
- cmds->val = get_onoff(optarg);
+ cmds->val = parse_switch(optarg, _("argument error"), "on", "off", NULL);
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 'q':
- if (get_onoff(optarg)) {
- show_irq = 1;
- } else {
- show_irq = 0;
- }
+ show_irq = parse_switch(optarg, _("argument error"), "on", "off", NULL);
break;
case 'o':
cmds->op = LPABORTOPEN;
- cmds->val = get_onoff(optarg);
+ cmds->val = parse_switch(optarg, _("argument error"), "on", "off", NULL);
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 'C':
cmds->op = LPCAREFUL;
- cmds->val = get_onoff(optarg);
+ cmds->val = parse_switch(optarg, _("argument error"), "on", "off", NULL);
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
@@ -239,7 +228,7 @@ int main(int argc, char **argv)
* 2.0.36 when compiled under 2.2.x
*/
cmds->op = LPTRUSTIRQ;
- cmds->val = get_onoff(optarg);
+ cmds->val = parse_switch(optarg, _("argument error"), "on", "off", NULL);
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;