From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/bascnvrt.c | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/bascnvrt.c (limited to 'reference/C/CONTRIB/SNIP/bascnvrt.c') diff --git a/reference/C/CONTRIB/SNIP/bascnvrt.c b/reference/C/CONTRIB/SNIP/bascnvrt.c new file mode 100755 index 0000000..1d685ef --- /dev/null +++ b/reference/C/CONTRIB/SNIP/bascnvrt.c @@ -0,0 +1,49 @@ +/* +** BASCNVRT.C - Convert between number bases +** +** public domain demo by Bob Stout +*/ + +#include +#ifdef TEST + #include +#endif + +/* +** Calling parameters: 1 - Number string to be converted +** 2 - Buffer for the converted output +** 3 - Radix (base) of the input +** 4 - Radix of the output +** +** Returns: Pointer to converted output +*/ + +char *base_convert(const char *in, char *out, int rin, int rout) +{ + long n; + char *dummy; + + n = strtol(in, &dummy, rin); + return ltoa(n, out, rout); +} + +#ifdef TEST + +int main(int argc, char *argv[]) +{ + int rin, rout; + char buf[40]; + + if (4 > argc) + { + puts("Usage: BASCNVRT "); + return(-1); + } + rin = atoi(argv[2]); + rout = atoi(argv[3]); + printf("%s (base %d) = %s (base %d)\n", argv[1], rin, + base_convert((const char *)argv[1], buf, rin, rout), rout); + return 0; +} + +#endif -- cgit v1.2.3-54-g00ecf inux/net-next.git/log/?h=packet-loop-back'>logtreecommitdiff
ected'>3
ModeNameSize
space:
mode: