chiark / gitweb /
util: add decchar()/undecchar() calls
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2010 00:41:03 +0000 (02:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2010 00:41:03 +0000 (02:41 +0200)
util.c
util.h

diff --git a/util.c b/util.c
index 9df6af953f0e13d9ce881f442e88a6894ad799c9..7306ddde34c4ee26db5cac1389f5647cfb05d409 100644 (file)
--- a/util.c
+++ b/util.c
@@ -701,6 +701,18 @@ int unoctchar(char c) {
         return -1;
 }
 
+char decchar(int x) {
+        return '0' + (x % 10);
+}
+
+int undecchar(char c) {
+
+        if (c >= '0' && c <= '9')
+                return c - '0';
+
+        return -1;
+}
+
 char *cescape(const char *s) {
         char *r, *t;
         const char *f;
diff --git a/util.h b/util.h
index 49abce1dbbbdeb5b5df5635f991ea48b03f41c5a..9f9bca86f2c44df00401069854b362e5408d0a67 100644 (file)
--- a/util.h
+++ b/util.h
@@ -136,6 +136,8 @@ char hexchar(int x);
 int unhexchar(char c);
 char octchar(int x);
 int unoctchar(char c);
+char decchar(int x);
+int undecchar(char c);
 
 char *cescape(const char *s);
 char *cunescape(const char *s);