summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..62e34f5
--- /dev/null
+++ b/util.c
@@ -0,0 +1,53 @@
+/************************************************
+
+ util.c -
+
+ $Author$
+ $Revision$
+ $Date$
+ created at: Fri Mar 10 17:22:34 JST 1995
+
+************************************************/
+
+#include "defines.h"
+#include "config.h"
+#include "util.h"
+
+unsigned long
+scan_oct(start, len, retlen)
+char *start;
+int len;
+int *retlen;
+{
+ register char *s = start;
+ register unsigned long retval = 0;
+
+ while (len-- && *s >= '0' && *s <= '7') {
+ retval <<= 3;
+ retval |= *s++ - '0';
+ }
+ *retlen = s - start;
+ return retval;
+}
+
+extern char *strchr();
+
+unsigned long
+scan_hex(start, len, retlen)
+char *start;
+int len;
+int *retlen;
+{
+ static char hexdigit[] = "0123456789abcdef0123456789ABCDEFx";
+ register char *s = start;
+ register unsigned long retval = 0;
+ char *tmp;
+
+ while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
+ retval <<= 4;
+ retval |= (tmp - hexdigit) & 15;
+ s++;
+ }
+ *retlen = s - start;
+ return retval;
+}