Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/audio/common add a decode_uint() function.



details:   https://anonhg.NetBSD.org/src/rev/4215065da833
branches:  trunk
changeset: 335206:4215065da833
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Dec 30 01:22:09 2014 +0000

description:
add a decode_uint() function.

diffstat:

 usr.bin/audio/common/audio.c    |  19 +++++++++++++++++--
 usr.bin/audio/common/libaudio.h |   3 ++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diffs (57 lines):

diff -r 9d5d37b7ece9 -r 4215065da833 usr.bin/audio/common/audio.c
--- a/usr.bin/audio/common/audio.c      Tue Dec 30 00:19:50 2014 +0000
+++ b/usr.bin/audio/common/audio.c      Tue Dec 30 01:22:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.22 2013/08/30 20:57:26 mrg Exp $   */
+/*     $NetBSD: audio.c,v 1.23 2014/12/30 01:22:09 mrg Exp $   */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -32,7 +32,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: audio.c,v 1.22 2013/08/30 20:57:26 mrg Exp $");
+__RCSID("$NetBSD: audio.c,v 1.23 2014/12/30 01:22:09 mrg Exp $");
 #endif
 
 
@@ -155,6 +155,21 @@
 }
 
 void
+decode_uint(const char *arg, unsigned *intp)
+{
+       char    *ep;
+       unsigned        ret;
+
+       ret = (unsigned)strtoul(arg, &ep, 10);
+
+       if (ep[0] == '\0') {
+               *intp = ret;
+               return;
+       }
+       errx(1, "argument `%s' not a valid integer", arg);
+}
+
+void
 decode_time(const char *arg, struct timeval *tvp)
 {
        char    *s, *colon, *dot;
diff -r 9d5d37b7ece9 -r 4215065da833 usr.bin/audio/common/libaudio.h
--- a/usr.bin/audio/common/libaudio.h   Tue Dec 30 00:19:50 2014 +0000
+++ b/usr.bin/audio/common/libaudio.h   Tue Dec 30 01:22:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libaudio.h,v 1.18 2013/08/30 20:57:26 mrg Exp $        */
+/*     $NetBSD: libaudio.h,v 1.19 2014/12/30 01:22:09 mrg Exp $        */
 
 /*
  * Copyright (c) 1999, 2009 Matthew R. Green
@@ -180,6 +180,7 @@
  * generic routines?
  */
 void   decode_int (const char *, int *);
+void   decode_uint (const char *, unsigned *);
 void   decode_time (const char *, struct timeval *);
 void   decode_encoding (const char *, int *);
 



Home | Main Index | Thread Index | Old Index