#include "xalloc.h"
#include "closestream.h"
-#define EXIT_BAD_VALUE 3
-#define EXIT_LP_IO_ERR 4
+#define STRTOXX_EXIT_CODE 3
+#define EXIT_LP_IO_ERR 4
+
+#include "strutils.h"
struct command {
long op;
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
-static long get_val(char *val)
-{
- long ret;
- if (!(sscanf(val, "%ld", &ret) == 1))
- errx(EXIT_BAD_VALUE, _("bad value"));
- return ret;
-}
-
static long get_onoff(char *val)
{
if (!strncasecmp("on", val, 2))
break;
case 'i':
cmds->op = LPSETIRQ;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 't':
cmds->op = LPTIME;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 'c':
cmds->op = LPCHAR;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;
break;
case 'w':
cmds->op = LPWAIT;
- cmds->val = get_val(optarg);
+ cmds->val = strtol_or_err(optarg, _("argument error"));
cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next;
cmds->next = 0;