Initial import
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/libtiff_2007@1 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#! smake
|
||||
# $Header: /home/cvsroot/libtiff/port/Makefile.in,v 1.1.1.1 2000/06/24 19:10:16 tshead Exp $
|
||||
#
|
||||
# @WARNING@
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1995-1997 Sam Leffler
|
||||
# Copyright (c) 1995-1997 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
SRCDIR = @RELSRCDIR@/port
|
||||
VPATH = @RELSRCDIR@/port
|
||||
|
||||
#
|
||||
# VERSION: @VERSION@
|
||||
# DATE: @DATE@
|
||||
# TARGET: @TARGET@
|
||||
# CCOMPILER: @CCOMPILER@
|
||||
#
|
||||
|
||||
SHELL = @SCRIPT_SH@
|
||||
NULL =
|
||||
CC = @CCOMPILER@
|
||||
AR = @AR@
|
||||
AROPTS = @AROPTS@
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
IPATH = -I. -I${SRCDIR}
|
||||
COPTS = @GCOPTS@
|
||||
OPTIMIZER=-O
|
||||
CFLAGS = @ENVOPTS@ ${COPTS} ${OPTIMIZER} ${IPATH}
|
||||
|
||||
CFILES = @PORTFUNCS@
|
||||
OBJECTS = ${CFILES:.c=.o}
|
||||
TARGETS = libport.a
|
||||
|
||||
default all: ${TARGETS}
|
||||
|
||||
libport.a: ${OBJECTS}
|
||||
@rm -f $@;
|
||||
${AR} ${AROPTS} $@ ${OBJECTS}
|
||||
${RANLIB} $@
|
||||
${PORT}/libport.a: libport.a
|
||||
|
||||
install: default
|
||||
|
||||
clean:
|
||||
rm -f ${TARGETS} ${OBJS} core a.out
|
||||
Executable
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 1987 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[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* get option letter from argument vector
|
||||
*/
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt; /* character checked for validity */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define EMSG ""
|
||||
|
||||
int
|
||||
getopt(int nargc, char** nargv, char* ostr)
|
||||
{
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
register char *oli; /* option letter list index */
|
||||
char *p;
|
||||
|
||||
if (!*place) { /* update scanning pointer */
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return(EOF);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return(EOF);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int)*place++) == (int)':' ||
|
||||
!(oli = strchr(ostr, optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means EOF.
|
||||
*/
|
||||
if (optopt == (int)'-')
|
||||
return(EOF);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr) {
|
||||
if (!(p = strrchr(*nargv, '/')))
|
||||
p = *nargv;
|
||||
else
|
||||
++p;
|
||||
(void)fprintf(stderr, "%s: illegal option -- %c\n",
|
||||
p, optopt);
|
||||
}
|
||||
return(BADCH);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
}
|
||||
else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (!(p = strrchr(*nargv, '/')))
|
||||
p = *nargv;
|
||||
else
|
||||
++p;
|
||||
if (opterr)
|
||||
(void)fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
p, optopt);
|
||||
return(BADCH);
|
||||
}
|
||||
else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return(optopt); /* dump back option letter */
|
||||
}
|
||||
Executable
+246
@@ -0,0 +1,246 @@
|
||||
#! @SCRIPT_SH@
|
||||
# $Header: /home/cvsroot/libtiff/port/install.sh.in,v 1.1.1.1 2000/06/24 19:10:16 tshead Exp $
|
||||
#
|
||||
# @WARNING@
|
||||
#
|
||||
# HylaFAX Facsimile Software
|
||||
#
|
||||
# Copyright (c) 1990-1997 Sam Leffler
|
||||
# Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
# HylaFAX is a trademark of Silicon Graphics
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
#
|
||||
# Warning, this file was automatically created by the HylaFAX configure script
|
||||
#
|
||||
# VERSION: @VERSION@
|
||||
# DATE: @DATE@
|
||||
# TARGET: @TARGET@
|
||||
#
|
||||
|
||||
#
|
||||
# Shell script to emulate Silicon Graphics install program.
|
||||
# We emulate the non-standard interface used by install so
|
||||
# that we can build SGI inst packages on SGI systems. Note
|
||||
# that we cannot emulate everything because we don't maintain
|
||||
# a history of installed software; thus we cannot tell when
|
||||
# configuration files have been modified and save old copies.
|
||||
#
|
||||
# NB: we don't do chown/chmod/chgrp by default; it must be
|
||||
# explicitly set on the command line.
|
||||
#
|
||||
|
||||
#
|
||||
# install [options] files ...
|
||||
#
|
||||
# Options are:
|
||||
#
|
||||
# -o save existing target foo as OLDfoo
|
||||
# -O remove existing target foo, if it fails save as OLDfoo
|
||||
# -m mode set mode of installed target
|
||||
# -u uid set uid of installed target
|
||||
# -g gid set gid of installed target
|
||||
# -root path set ROOT directory for target pathnames
|
||||
# -dir create directories
|
||||
# -fifo create FIFO special files
|
||||
# -ln path create hard link
|
||||
# -lns path create symbolic link
|
||||
# -src path source pathname different from target
|
||||
# -f dir install files in the target directory ROOT/dir
|
||||
# -F dir like -f, but create directories that do not exist
|
||||
# -v echo actions
|
||||
# -idb stuff specify package and, optionally, do special work
|
||||
#
|
||||
preopts=
|
||||
postopts=
|
||||
SaveFirst=no
|
||||
HasSource=yes
|
||||
RemoveFirst=no
|
||||
NoUpdate=no
|
||||
Suggested=no
|
||||
Updated=no
|
||||
|
||||
CMD=cp
|
||||
SRC=
|
||||
FILES=
|
||||
DESTDIR=
|
||||
CHMOD=":"
|
||||
CHOWN=":"
|
||||
CHGRP=":"
|
||||
RM="rm -f"
|
||||
MV="mv @MV_F@"
|
||||
ECHO=echo
|
||||
VERBOSE=":"
|
||||
STRIP="@STRIP@"
|
||||
CMP=cmp
|
||||
|
||||
TARGETS=
|
||||
while [ x"$1" != x ]
|
||||
do
|
||||
arg=$1
|
||||
case $arg in
|
||||
-m) shift; CHMOD="@CHMOD@ $1";;
|
||||
-u) shift; CHOWN="@CHOWN@ $1";;
|
||||
-g) shift; CHGRP="@CHGRP@ $1";;
|
||||
-o) SaveFirst=yes;;
|
||||
-O) RemoveFirst=yes; SaveFirst=yes;;
|
||||
-root) shift; ROOT=$1;;
|
||||
-dir) CMD=mkdir; HasSource=no;
|
||||
RM=":"; STRIP=":"
|
||||
;;
|
||||
-fifo) CMD=@MKFIFO@; HasSource=no;
|
||||
x=`echo $CMD | @SED@ 's;.*/;;'`;
|
||||
test $x = mknod && postopts="p";
|
||||
STRIP=":"
|
||||
;;
|
||||
-ln) shift; CMD=@LN@; SRC="$1"
|
||||
STRIP=":"
|
||||
;;
|
||||
-lns) shift; CMD=@LN@; preopts="@LN_S@"; SRC="$1"
|
||||
STRIP=":"
|
||||
;;
|
||||
-src) shift; SRC="$1";;
|
||||
-[fF]) shift; DESTDIR="$1";;
|
||||
-idb) shift; opt="$1"
|
||||
case "$opt" in
|
||||
*config\(update\)*) Updated=yes;;
|
||||
*config\(suggest\)*) Suggested=yes;;
|
||||
*config\(noupdate\)*) NoUpdate=yes;;
|
||||
*nostrip*) STRIP=":";;
|
||||
esac
|
||||
;;
|
||||
# these are skipped/not handled
|
||||
-new|-rawidb|-blk|-chr) shift;;
|
||||
-v) VERBOSE=$ECHO;;
|
||||
-*) ;;
|
||||
*) TARGETS="$TARGETS $arg";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
#
|
||||
# Install the specified target.
|
||||
#
|
||||
install()
|
||||
{
|
||||
src=$1 target=$2
|
||||
if [ $RemoveFirst = yes -a -f $target ]; then
|
||||
$VERBOSE "$RM $target"
|
||||
$RM $target
|
||||
fi
|
||||
if [ $SaveFirst = yes -a -f $target ]; then
|
||||
bf=`echo $src | @SED@ 's;.*/;;'`
|
||||
$VERBOSE "$MV $target $ROOT/$DESTDIR/OLD$bf"
|
||||
$MV $target $ROOT/$DESTDIR/OLD$bf
|
||||
fi
|
||||
if [ -z "$SRC" -a $HasSource = yes ]; then
|
||||
$VERBOSE "$CMD $preopts $src $target $postopts"
|
||||
$CMD $preopts $f $target $postopts
|
||||
else
|
||||
$VERBOSE "$CMD $preopts $SRC $target $postopts"
|
||||
$CMD $preopts $SRC $target $postopts
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
$VERBOSE "$CHOWN $target"
|
||||
$CHOWN $target
|
||||
$VERBOSE "$CHGRP $target"
|
||||
$CHGRP $target
|
||||
$VERBOSE "$CHMOD $target"
|
||||
$CHMOD $target
|
||||
if [ $STRIP != ":" -a -x $ROOT/$DESTDIR/$f ]; then
|
||||
$STRIP $target >/dev/null 2>&1 || true
|
||||
$VERBOSE "$STRIP $target"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $Suggested = yes ]; then
|
||||
#
|
||||
# A suggested file. If an existing target does
|
||||
# not exist, then install it. Otherwise, install
|
||||
# it as target.N if it's different from the current
|
||||
# installed target.
|
||||
#
|
||||
# NB: cannot be used with a special file 'cuz we
|
||||
# use test -f to see if the file exists.
|
||||
#
|
||||
for f in $TARGETS; do
|
||||
t=$ROOT/$DESTDIR/$f
|
||||
if [ -f $t ]; then
|
||||
if [ -z "$SRC" -a $HasSource = yes ]; then
|
||||
$CMP -s $f $t || {
|
||||
$ECHO "*** Warning, target has local changes, installing $f as $t.N"
|
||||
install $f $t.N;
|
||||
}
|
||||
else
|
||||
$CMP -s $SRC $t || {
|
||||
$ECHO "*** Warning, target has local changes, installing $f as $t.N"
|
||||
install $f $t.N
|
||||
}
|
||||
fi
|
||||
else
|
||||
install $f $t
|
||||
fi
|
||||
done
|
||||
elif [ $Updated = yes ]; then
|
||||
#
|
||||
# A file to be updated. If an existing target does
|
||||
# not exist, then install it. Otherwise, install
|
||||
# it as target and save the old version as target.O
|
||||
# if the old version is different from the current
|
||||
# installed target.
|
||||
#
|
||||
# NB: cannot be used with a special file 'cuz we
|
||||
# use test -f to see if the file exists.
|
||||
#
|
||||
for f in $TARGETS; do
|
||||
t=$ROOT/$DESTDIR/$f
|
||||
if [ -f $t ]; then
|
||||
if [ -z "$SRC" -a $HasSource = yes ]; then
|
||||
$CMP -s $f $t || $MV $t $t.O
|
||||
else
|
||||
$CMP -s $SRC $t || $MV $t $t.O
|
||||
fi
|
||||
fi
|
||||
install $f $t
|
||||
done
|
||||
elif [ $NoUpdate = yes ]; then
|
||||
#
|
||||
# A file that is never to be updated; the target
|
||||
# is created only if it does not exist.
|
||||
#
|
||||
# NB: cannot be used with a special file 'cuz we
|
||||
# use test -f to see if the file exists.
|
||||
#
|
||||
for f in $TARGETS; do
|
||||
t=$ROOT/$DESTDIR/$f
|
||||
test -f $t || install $f $t
|
||||
done
|
||||
else
|
||||
#
|
||||
# Normal case, a target that should be installed
|
||||
# with the existing copy, optionally, saved first.
|
||||
#
|
||||
for f in $TARGETS; do
|
||||
install $f $ROOT/$DESTDIR/$f
|
||||
done
|
||||
fi
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
libtiff.so \
|
||||
:st = .text 0x5ff70000, 0x00030000:\
|
||||
:st = .data 0x5ffd0000, 0x00030000:\
|
||||
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 1987 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char sccsid[] = "@(#)strcasecmp.c 5.9 (Berkeley) 6/1/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
* This array is designed for mapping upper and lower case letter
|
||||
* together for a case independent comparison. The mappings are
|
||||
* based upon ascii character sequences.
|
||||
*/
|
||||
static const unsigned char charmap[] = {
|
||||
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
||||
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
||||
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
||||
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
||||
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
|
||||
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
|
||||
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
|
||||
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
|
||||
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
||||
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
||||
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
||||
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
|
||||
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
||||
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
||||
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
||||
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
|
||||
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
|
||||
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
|
||||
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
|
||||
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
|
||||
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
|
||||
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
|
||||
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
|
||||
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
|
||||
'\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
|
||||
'\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
|
||||
'\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
|
||||
'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
|
||||
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
||||
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
||||
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
|
||||
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
|
||||
};
|
||||
|
||||
int
|
||||
strcasecmp(s1, s2)
|
||||
const char *s1, *s2;
|
||||
{
|
||||
register const unsigned char *cm = charmap,
|
||||
*us1 = (const unsigned char *)s1,
|
||||
*us2 = (const unsigned char *)s2;
|
||||
|
||||
while (cm[*us1] == cm[*us2++])
|
||||
if (*us1++ == '\0')
|
||||
return (0);
|
||||
return (cm[*us1] - cm[*--us2]);
|
||||
}
|
||||
|
||||
int
|
||||
strncasecmp(s1, s2, n)
|
||||
const char *s1, *s2;
|
||||
register size_t n;
|
||||
{
|
||||
if (n != 0) {
|
||||
register const unsigned char *cm = charmap,
|
||||
*us1 = (const unsigned char *)s1,
|
||||
*us2 = (const unsigned char *)s2;
|
||||
|
||||
do {
|
||||
if (cm[*us1] != cm[*us2++])
|
||||
return (cm[*us1] - cm[*--us2]);
|
||||
if (*us1++ == '\0')
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Executable
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 1990 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 5.3 (Berkeley) 2/23/91";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <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
|
||||
strtoul(nptr, endptr, base)
|
||||
const char *nptr;
|
||||
char **endptr;
|
||||
register int base;
|
||||
{
|
||||
register const char *s = nptr;
|
||||
register unsigned long acc;
|
||||
register int c;
|
||||
register unsigned long cutoff;
|
||||
register 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 (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 = any ? s - 1 : (char *)nptr;
|
||||
return (acc);
|
||||
}
|
||||
Reference in New Issue
Block a user