blob: 717e0beed9a6eed9686c989f792d75e028adf01d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/************************************************
util.c -
$Author$
$Date$
created at: Fri Mar 10 17:22:34 JST 1995
Copyright (C) 1993-1996 Yukihiro Matsumoto
************************************************/
#include "defines.h"
#include "config.h"
#include "util.h"
#ifdef HAVE_STRING_H
# include <string.h>
#else
char *strchr();
#endif
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;
}
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;
}
|