]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1474. [port] Provide strtoul() and memmove() for platforms
authorMark Andrews <marka@isc.org>
Tue, 24 Jun 2003 05:11:53 +0000 (05:11 +0000)
committerMark Andrews <marka@isc.org>
Tue, 24 Jun 2003 05:11:53 +0000 (05:11 +0000)
                        without them.

16 files changed:
CHANGES
bin/dig/host.c
bin/tests/genrandom.c
bin/tests/serial_test.c
configure
configure.in
lib/dns/rdata.c
lib/isc/Makefile.in
lib/isc/include/isc/platform.h.in
lib/isc/include/isc/stdlib.h [new file with mode: 0644]
lib/isc/include/isc/string.h
lib/isc/parseint.c
lib/isc/print.c
lib/isc/strtoul.c [new file with mode: 0644]
lib/isccc/cc.c
util/copyrights

diff --git a/CHANGES b/CHANGES
index 0819e9153b4041b6a6634d230401158ce3d0b0ab..55923de7348d9aff706fbb9e3d0cfcfcf292213e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1474.  [port]          Provide strtoul() and memmove() for platforms
+                       without them.
+
 1473.  [bug]           free_map() and free_string() failed to handle out
                        of memory cleanup.  [RT #6813]
 
index 366ca458f6b7d1d5ee3268083b2010dde6ca11cf..64c8e871aa648d81a8f6dde1b1f30f87681eb276 100644 (file)
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: host.c,v 1.91 2002/12/11 06:31:37 marka Exp $ */
+/* $Id: host.c,v 1.92 2003/06/24 05:10:31 marka Exp $ */
 
 #include <config.h>
-#include <stdlib.h>
 #include <limits.h>
 
 #include <isc/app.h>
@@ -28,6 +27,7 @@
 #include <isc/string.h>
 #include <isc/util.h>
 #include <isc/task.h>
+#include <isc/stdlib.h>
 
 #include <dns/byaddr.h>
 #include <dns/fixedname.h>
index 800623ccaf2df70a128c51c6530326e6a0219538..794ce785fcbb1120ac3899e0a141155789199f0f 100644 (file)
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: genrandom.c,v 1.9 2002/12/04 01:19:28 marka Exp $ */
+/* $Id: genrandom.c,v 1.10 2003/06/24 05:10:31 marka Exp $ */
 
 #include <config.h>
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <time.h>
 
+#include <isc/stdlib.h>
+
 int
 main(int argc, char **argv) {
        unsigned int bytes;
index 8dc209fb288932981774cffde64bbbab2a22b45c..63520d05b4dcc9306722599df27ea6ffbc463a07 100644 (file)
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: serial_test.c,v 1.11 2001/11/27 01:55:22 gson Exp $ */
+/* $Id: serial_test.c,v 1.12 2003/06/24 05:10:31 marka Exp $ */
 
 #include <config.h>
 
 #include <stdio.h>
-#include <stdlib.h>
 
 #include <isc/serial.h>
+#include <isc/stdlib.h>
 
 int
 main() {
index 5f8135809410729468fa17c687561ad970df4bea..55af0318f6311a415e55aa103373b81bf38bf210 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.342 .
+# From configure.in Revision: 1.343 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53.
 #
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 
+echo "$as_me:$LINENO: checking for memmove" >&5
+echo $ECHO_N "checking for memmove... $ECHO_C" >&6
+if test "${ac_cv_func_memmove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+/* From autoconf 2.57 */
+/* Define memmove to an innocuous variant, in case <limits.h> declares memmove.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define memmove innocuous_memmove
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char memmove (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef memmove
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char memmove ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_memmove) || defined (__stub___memmove)
+choke me
+#else
+char (*f) () = memmove;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+return f != memmove;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_memmove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_memmove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_memmove" >&5
+echo "${ECHO_T}$ac_cv_func_memmove" >&6
+if test $ac_cv_func_memmove = yes; then
+  ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"
+else
+  ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"
+fi
+
+
+
+echo "$as_me:$LINENO: checking for strtoul" >&5
+echo $ECHO_N "checking for strtoul... $ECHO_C" >&6
+if test "${ac_cv_func_strtoul+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+/* From autoconf 2.57 */
+/* Define strtoul to an innocuous variant, in case <limits.h> declares strtoul.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define strtoul innocuous_strtoul
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char strtoul (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef strtoul
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char strtoul ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_strtoul) || defined (__stub___strtoul)
+choke me
+#else
+char (*f) () = strtoul;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+return f != strtoul;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_strtoul=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_strtoul=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_strtoul" >&5
+echo "${ECHO_T}$ac_cv_func_strtoul" >&6
+if test $ac_cv_func_strtoul = yes; then
+  ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"
+else
+  ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"
+fi
+
+
+
 echo "$as_me:$LINENO: checking for strlcpy" >&5
 echo $ECHO_N "checking for strlcpy... $ECHO_C" >&6
 if test "${ac_cv_func_strlcpy+set}" = set; then
@@ -15406,6 +15586,8 @@ s,@ISC_LWRES_GETIPNODEPROTO@,$ISC_LWRES_GETIPNODEPROTO,;t t
 s,@ISC_LWRES_GETADDRINFOPROTO@,$ISC_LWRES_GETADDRINFOPROTO,;t t
 s,@ISC_LWRES_GETNAMEINFOPROTO@,$ISC_LWRES_GETNAMEINFOPROTO,;t t
 s,@ISC_PLATFORM_NEEDSTRSEP@,$ISC_PLATFORM_NEEDSTRSEP,;t t
+s,@ISC_PLATFORM_NEEDMEMMOVE@,$ISC_PLATFORM_NEEDMEMMOVE,;t t
+s,@ISC_PLATFORM_NEEDSTRTOUL@,$ISC_PLATFORM_NEEDSTRTOUL,;t t
 s,@ISC_PLATFORM_NEEDSTRLCPY@,$ISC_PLATFORM_NEEDSTRLCPY,;t t
 s,@ISC_PLATFORM_NEEDSTRLCAT@,$ISC_PLATFORM_NEEDSTRLCAT,;t t
 s,@ISC_PLATFORM_NEEDVSNPRINTF@,$ISC_PLATFORM_NEEDVSNPRINTF,;t t
index 2ebfe3b30a8d96ff8780f8653e762a28181cc07d..dd2624b289daebe3e50d367cffbce88c423cc63e 100644 (file)
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 esyscmd([sed "s/^/# /" COPYRIGHT])dnl
 AC_DIVERT_POP()dnl
 
-AC_REVISION($Revision: 1.342 $)
+AC_REVISION($Revision: 1.343 $)
 
 AC_INIT(lib/dns/name.c)
 AC_PREREQ(2.13)
@@ -1575,6 +1575,16 @@ AC_TRY_LINK([#include <string.h>], [char *sp; char *foo = strsep(&sp, ".");],
        [AC_MSG_RESULT(no); ISC_PLATFORM_NEEDSTRSEP="#define ISC_PLATFORM_NEEDSTRSEP 1"])
 AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
 
+AC_CHECK_FUNC(memmove,
+       [ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
+       [ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
+AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
+
+AC_CHECK_FUNC(strtoul,
+       [ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"],
+       [ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"])
+AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
+
 AC_CHECK_FUNC(strlcpy,
        [ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"],
        [ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"])
index d2c9c2cd74565bd2f46bd0a01eeed59c8ae25694..9ad903a670b0aeb949a48401f9b3a8c990452b23 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rdata.c,v 1.174 2003/04/11 07:25:25 marka Exp $ */
+/* $Id: rdata.c,v 1.175 2003/06/24 05:10:32 marka Exp $ */
 
 #include <config.h>
 #include <ctype.h>
@@ -27,6 +27,7 @@
 #include <isc/parseint.h>
 #include <isc/print.h>
 #include <isc/string.h>
+#include <isc/stdlib.h>
 #include <isc/util.h>
 
 #include <dns/callbacks.h>
index c5121505e1ea2465677cf473e2986be6adb709d5..e826ba7bf117037cf8b201ce768765e2b958d52c 100644 (file)
@@ -13,7 +13,7 @@
 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.76 2002/10/24 03:52:32 marka Exp $
+# $Id: Makefile.in,v 1.77 2003/06/24 05:10:32 marka Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -57,8 +57,8 @@ OBJS =                @ISC_EXTRA_OBJS@ \
                mem.@O@ mutexblock.@O@ netaddr.@O@ netscope.@O@ ondestroy.@O@ \
                parseint.@O@ quota.@O@ random.@O@ \
                ratelimiter.@O@ region.@O@ result.@O@ rwlock.@O@ \
-               serial.@O@ sha1.@O@ sockaddr.@O@ string.@O@ symtab.@O@ \
-               task.@O@ taskpool.@O@ timer.@O@ version.@O@ \
+               serial.@O@ sha1.@O@ sockaddr.@O@ string.@O@ strtoul.@O@ \
+               symtab.@O@ task.@O@ taskpool.@O@ timer.@O@ version.@O@ \
                ${UNIXOBJS} ${NLSOBJS} ${THREADOBJS}
 
 # Alphabetically
@@ -70,7 +70,7 @@ SRCS =                @ISC_EXTRA_SRCS@ \
                md5.c mem.c mutexblock.c netaddr.c netscope.c ondestroy.c \
                parseint.c quota.c random.c \
                ratelimiter.c result.c rwlock.c \
-               serial.c sha1.c sockaddr.c string.c symtab.c \
+               serial.c sha1.c sockaddr.c string.c strtoul.c symtab.c \
                task.c taskpool.c timer.c version.c
 
 LIBS =         @LIBS@
index 836b372dc7f5a2b853374958b986856d699611b2..6c9edb46df50e0b3b7cd776f0bfe85dcf2a6f978 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: platform.h.in,v 1.31 2003/04/10 04:46:27 marka Exp $ */
+/* $Id: platform.h.in,v 1.32 2003/06/24 05:10:33 marka Exp $ */
 
 #ifndef ISC_PLATFORM_H
 #define ISC_PLATFORM_H 1
  */
 @ISC_PLATFORM_HAVEIFNAMETOINDEX@
 
+/*
+ * Define if this system needs strtoul.
+ */
+@ISC_PLATFORM_NEEDSTRTOUL@
+
+/*
+ * Define if this system needs memmove.
+ */
+@ISC_PLATFORM_NEEDMEMMOVE@
+
 #ifndef ISC_PLATFORM_USEDECLSPEC
 #define LIBISC_EXTERNAL_DATA
 #define LIBDNS_EXTERNAL_DATA
diff --git a/lib/isc/include/isc/stdlib.h b/lib/isc/include/isc/stdlib.h
new file mode 100644 (file)
index 0000000..afec137
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2003  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $Id: stdlib.h,v 1.1 2003/06/24 05:10:33 marka Exp $ */
+
+#ifndef ISC_STDLIB_H
+#define ISC_STDLIB_H 1
+
+#include <stdlib.h>
+
+#include <isc/lang.h>
+#include <isc/platform.h>
+
+#ifdef ISC_PLATFORM_NEEDSTRTOUL
+#define strtoul isc_strtoul
+#endif
+
+ISC_LANG_BEGINDECLS
+
+unsigned long isc_strtoul(const char *, char **, int);
+
+ISC_LANG_ENDDECLS
+
+#endif
index 4c34629f751952bd94d93f37c8daeb681f105b64..dacacd90cfbf725f4015236ae660d52d314ac3b1 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: string.h,v 1.10 2003/04/10 04:46:27 marka Exp $ */
+/* $Id: string.h,v 1.11 2003/06/24 05:10:33 marka Exp $ */
 
 #ifndef ISC_STRING_H
 #define ISC_STRING_H 1
@@ -51,6 +51,10 @@ isc_string_separate(char **stringp, const char *delim);
 #define strsep isc_string_separate
 #endif
 
+#ifdef ISC_PLATFORM_NEEDMEMMOVE
+#define memmove(a,b,c) bcopy(b,a,c)
+#endif
+
 size_t
 isc_string_strlcpy(char *dst, const char *src, size_t size);
 
index 8450f0fdcb712119af7db014acd91b069ed75ac9..1f6b2e46c3cb0381c2271d418ae3ec8b749a7750 100644 (file)
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: parseint.c,v 1.2 2002/02/28 20:08:05 bwelling Exp $ */
+/* $Id: parseint.c,v 1.3 2003/06/24 05:10:32 marka Exp $ */
 
 #include <config.h>
 
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
-#include <stdlib.h>
 
 #include <isc/parseint.h>
 #include <isc/result.h>
+#include <isc/stdlib.h>
 
 isc_result_t
 isc_parse_uint32(isc_uint32_t *uip, const char *string, int base) {
index d15b434625f10e3949d5fec1fe98f523ad942c1a..ec953fd1bae99a719d0a151513a6a7e7e68c8ba4 100644 (file)
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: print.c,v 1.23 2003/02/25 21:32:07 marka Exp $ */
+/* $Id: print.c,v 1.24 2003/06/24 05:10:32 marka Exp $ */
 
 #include <config.h>
 
 #include <ctype.h>
 #include <stdio.h>             /* for sprintf */
-#include <stdlib.h>
 
 #define        ISC__PRINT_SOURCE       /* Used to get the isc_print_* prototypes. */
 
@@ -29,6 +28,7 @@
 #include <isc/int.h>
 #include <isc/msgs.h>
 #include <isc/print.h>
+#include <isc/stdlib.h>
 #include <isc/util.h>
 
 /*
diff --git a/lib/isc/strtoul.c b/lib/isc/strtoul.c
new file mode 100644 (file)
index 0000000..8c27f0d
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Portions Copyright (C) 2003  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strtoul.c  8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+/* $Id: strtoul.c,v 1.1 2003/06/24 05:10:32 marka Exp $ */
+
+#include <config.h>
+
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include <isc/stdlib.h>
+
+/*
+ * Convert a string to an unsigned long integer.
+ *
+ * Ignores `locale' stuff.  Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long
+isc_strtoul(const char *nptr, char **endptr, int base) {
+       const char *s = nptr;
+       unsigned long acc;
+       unsigned char c;
+       unsigned long cutoff;
+       int neg = 0, any, cutlim;
+
+       /*
+        * See strtol for comments as to the logic used.
+        */
+       do {
+               c = *s++;
+       } while (isspace(c));
+       if (c == '-') {
+               neg = 1;
+               c = *s++;
+       } else if (c == '+')
+               c = *s++;
+       if ((base == 0 || base == 16) &&
+           c == '0' && (*s == 'x' || *s == 'X')) {
+               c = s[1];
+               s += 2;
+               base = 16;
+       }
+       if (base == 0)
+               base = c == '0' ? 8 : 10;
+       cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
+       cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
+       for (acc = 0, any = 0;; c = *s++) {
+               if (!isascii(c))
+                       break;
+               if (isdigit(c))
+                       c -= '0';
+               else if (isalpha(c))
+                       c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+               else
+                       break;
+               if (c >= base)
+                       break;
+               if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+                       any = -1;
+               else {
+                       any = 1;
+                       acc *= base;
+                       acc += c;
+               }
+       }
+       if (any < 0) {
+               acc = ULONG_MAX;
+               errno = ERANGE;
+       } else if (neg)
+               acc = -acc;
+       if (endptr != 0)
+               *endptr = (char *)(any ? s - 1 : nptr);
+       return (acc);
+}
index 5ddc4c74599853e972fc9631fcd39297bce0beac..cd322a4c5a9c4409d657a9b08caf3da992bde5e3 100644 (file)
  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: cc.c,v 1.7 2003/04/11 07:25:28 marka Exp $ */
+/* $Id: cc.c,v 1.8 2003/06/24 05:10:34 marka Exp $ */
 
 #include <config.h>
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 
-#include <isccc/alist.h>
 #include <isc/assertions.h>
+#include <isc/hmacmd5.h>
+#include <isc/stdlib.h>
+
+#include <isccc/alist.h>
 #include <isccc/base64.h>
 #include <isccc/cc.h>
-#include <isc/hmacmd5.h>
 #include <isccc/result.h>
 #include <isccc/sexpr.h>
 #include <isccc/symtab.h>
index 6d8bb669c43b0155073325b01643c41795b8a02a..1692f450f0cd23e0dbc3c63a6766038521c8c77f 100644 (file)
 ./lib/isc/include/isc/sockaddr.h               C       1998,1999,2000,2001,2002
 ./lib/isc/include/isc/socket.h                 C       1998,1999,2000,2001
 ./lib/isc/include/isc/stdio.h                  C       2000,2001
+./lib/isc/include/isc/stdlib.h                 C       2003
 ./lib/isc/include/isc/string.h                 C       2000,2001
 ./lib/isc/include/isc/symtab.h                 C       1996,1997,1998,1999,2000,2001
 ./lib/isc/include/isc/task.h                   C       1998,1999,2000,2001
 ./lib/isc/sha1.c                               C       2000,2001
 ./lib/isc/sockaddr.c                           C       1999,2000,2001,2002
 ./lib/isc/string.c                             C       1999,2000,2001
+./lib/isc/strtoul.c                            C.PORTION       2003
 ./lib/isc/symtab.c                             C       1996,1997,1998,1999,2000,2001
 ./lib/isc/task.c                               C       1998,1999,2000,2001
 ./lib/isc/task_p.h                             C       2000,2001