diff options
author | Jeremy Allison <jra@samba.org> | 1998-11-25 21:17:20 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-11-25 21:17:20 +0000 |
commit | bfc38ff872446e0ad365c22327c779e72a81bef9 (patch) | |
tree | b7178459d9b4ce5acc7dc636d81ac4cba745b723 /source3/lib/replace.c | |
parent | 59d4087160ba41aac724722dc29c4b6e4e3b69b0 (diff) | |
download | samba-bfc38ff872446e0ad365c22327c779e72a81bef9.tar.gz samba-bfc38ff872446e0ad365c22327c779e72a81bef9.tar.bz2 samba-bfc38ff872446e0ad365c22327c779e72a81bef9.zip |
Makefile.in: Added maintainer mode fixes.
aclocal.m4: Added AC_LIBTESTFUNC.
configure.in: Fixed -lsecurity -lsec problems.
client.c: dos_ fixes.
groupdb/aliasunix.c: Dead code removal.
include/includes.h: Added default PRINTCAP_NAME.
lib/genrand.c: dos_ fixes.
lib/replace.c: Added strtoul.
lib/system.c: dos_ fixes.
lib/util.c: dos_ fixes.
lib/util_sid.c: Signed/unsigned fixes.
lib/util_str.c: removed bad const.
locking/locking_slow.c: dos_ fixes.
printing/printing.c: dos_ fixes.
rpc_server/srv_samr.c: Dead code removal.
rpc_server/srv_sid.c: global_myworkgroup defined with wrong size AGAIN !
smbd/dir.c: dos_ fixes.
smbd/open.c: dos_ fixes.
smbd/oplock.c: dos_ fixes.
smbd/reply.c smbd/server.c smbd/service.c smbd/uid.c: dos_ fixes.
Jeremy.
(This used to be commit 6acb4b68f68d516e2ac3c47e500f5600d653435e)
Diffstat (limited to 'source3/lib/replace.c')
-rw-r--r-- | source3/lib/replace.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/source3/lib/replace.c b/source3/lib/replace.c index 2d4ed775a4..a768e9ce47 100644 --- a/source3/lib/replace.c +++ b/source3/lib/replace.c @@ -299,3 +299,71 @@ char *rep_inet_ntoa(struct in_addr ip) } #endif /* REPLACE_INET_NTOA */ +#ifndef HAVE_STRTOUL +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +/* + * Convert a string to an unsigned long integer. + * Taken from libg++ - libiberty code. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ + unsigned long strtoul(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int 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 = (int)((unsigned long)ULONG_MAX % (unsigned long)base); + for (acc = 0, any = 0;; c = *s++) { + 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); +} +#endif /* HAVE_STRTOUL */ |