Added a field type for signed integers. This is required when handling
touchscreen calibration values, which is about to be implemented in wsconsctl (see PR kern/45872). Reviewed by uwe@ (thank you!)
This commit is contained in:
parent
63f8748ee9
commit
0033dc95e8
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: util.c,v 1.30 2011/12/15 14:25:12 phx Exp $ */
|
||||
/* $NetBSD: util.c,v 1.31 2012/12/24 01:20:12 khorben Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -257,6 +257,9 @@ pr_field(struct field *f, const char *sep)
|
||||
case FMT_UINT:
|
||||
(void)printf("%u", *((unsigned int *) f->valp));
|
||||
break;
|
||||
case FMT_INT:
|
||||
(void)printf("%d", *((int *) f->valp));
|
||||
break;
|
||||
case FMT_STRING:
|
||||
(void)printf("\"%s\"", *((char **) f->valp));
|
||||
break;
|
||||
@ -361,6 +364,14 @@ rd_field(struct field *f, char *val, int merge)
|
||||
else
|
||||
*((unsigned int *) f->valp) = u;
|
||||
break;
|
||||
case FMT_INT:
|
||||
if (sscanf(val, "%d", &i) != 1)
|
||||
errx(EXIT_FAILURE, "%s: not a number", val);
|
||||
if (merge)
|
||||
*((int *) f->valp) += i;
|
||||
else
|
||||
*((int *) f->valp) = i;
|
||||
break;
|
||||
case FMT_STRING:
|
||||
if ((*((char **) f->valp) = strdup(val)) == NULL)
|
||||
err(EXIT_FAILURE, "strdup");
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: wsconsctl.h,v 1.11 2011/08/27 19:01:34 joerg Exp $ */
|
||||
/* $NetBSD: wsconsctl.h,v 1.12 2012/12/24 01:20:44 khorben Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1998, 2004, 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -55,6 +55,7 @@ struct field {
|
||||
#define FMT_UINT 1 /* unsigned integer */
|
||||
#define FMT_STRING 2 /* zero terminated string */
|
||||
#define FMT_BITFIELD 3 /* bit field */
|
||||
#define FMT_INT 4 /* signed integer */
|
||||
#define FMT_KBDTYPE 101 /* keyboard type */
|
||||
#define FMT_MSTYPE 102 /* mouse type */
|
||||
#define FMT_DPYTYPE 103 /* display type */
|
||||
|
Loading…
Reference in New Issue
Block a user