diff options
author | John Denker <jsd@av8n.com> | 2012-07-31 22:34:58 -0700 |
---|---|---|
committer | John Denker <jsd@av8n.com> | 2012-07-31 22:36:28 -0700 |
commit | ef6722750b4518fcb29bf983755b5f02451ef224 (patch) | |
tree | 966e94ffd01cd8abb59e16a6992e142db345aa9f /ucspi-tcp-0.88/scan_xlong.c | |
parent | b95f5ec1d83519c603f6e2145865c14932c4a813 (diff) |
a bunch of files added by the ipv6 patch
Diffstat (limited to 'ucspi-tcp-0.88/scan_xlong.c')
-rw-r--r-- | ucspi-tcp-0.88/scan_xlong.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ucspi-tcp-0.88/scan_xlong.c b/ucspi-tcp-0.88/scan_xlong.c new file mode 100644 index 0000000..6e46d74 --- /dev/null +++ b/ucspi-tcp-0.88/scan_xlong.c @@ -0,0 +1,23 @@ +#include "scan.h" + +static int fromhex(unsigned char c) { + if (c>='0' && c<='9') + return c-'0'; + else if (c>='A' && c<='F') + return c-'A'+10; + else if (c>='a' && c<='f') + return c-'a'+10; + return -1; +} + +unsigned int scan_xlong(char *src,unsigned long *dest) { + register const char *tmp=src; + register int l=0; + register unsigned char c; + while ((c=fromhex(*tmp))<16) { + l=(l<<4)+c; + ++tmp; + } + *dest=l; + return tmp-src; +} |