#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'MANIFEST' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X MANIFEST 1 This shipping list X Makefile 1 X README 1 X stdlib 1 X stdlib/Makefile 1 X stdlib/abort.c 1 X stdlib/atof.c 1 X stdlib/atoi.c 1 X stdlib/atol.c 1 X stdlib/div.c 1 X stdlib/labs.c 1 X stdlib/ldiv.c 1 X stdlib/strtod.c 2 X stdlib/strtol.c 2 X stdlib/strtoul.c 1 X string 1 X string/Makefile 1 X string/memchr.c 2 X string/memcmp.c 2 X string/memcpy.c 2 X string/memmove.c 1 X string/memset.c 1 X string/strchr.c 1 X string/strcspn.c 1 X string/strdup.c 1 X string/strpbrk.c 1 X string/strrchr.c 1 X string/strspn.c 1 X string/strstr.c 1 X string/strtok.c 1 X test 1 X test/memtst.c 1 X test/strtest.c 1 END_OF_FILE if test 1137 -ne `wc -c <'MANIFEST'`; then echo shar: \"'MANIFEST'\" unpacked with wrong size! fi # end of 'MANIFEST' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(1095 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# X# Makefile for X# Author: X# Date: X# X# Loader XLD= ld68k X# X# Binaries go here. XBIN= /ELDORA/vx/bin X# X# Directories to build XDIRS= stdlib string X X.KEEP_STATE: X Xobjs: X -for i in $(DIRS); \ X do (cd $$i; echo "Making in $$i"; make objs; cp *.o ..); \ X done; X -rm ansiLib.o X $(LD) -X -r -o ansiLib.a *.o X -rm *.o X -mv ansiLib.a $(BIN)/ansiLib.o X Xforce: X -for i in $(DIRS); \ X do (cd $$i; echo "Making in $$i"; touch *.c; make objs; cp *.o ..); \ X done; X -rm ansiLib.o X $(LD) -X -r -o ansiLib.a *.o X -rm *.o X -mv ansiLib.a ansiLib.o X X Xasm: X -for i in $(DIRS); \ X do (cd $$i; make asm;); \ X done; X Xget_rcs: X -for i in $(DIRS); \ X do (cd $$i; make get_rcs;); \ X done; X Xget_rcs_locked: X -for i in $(DIRS); \ X do (cd $$i; make get_rcs_locked;); \ X done; X Xput_rcs: X -for i in $(DIRS); \ X do (cd $$i; make put_rcs;); \ X done; X X# Modify this to include an access list if desired. Xset_rcs: X -for i in $(DIRS); \ X do (cd $$i; make set_rcs;); \ X done; X Xclean: X -for i in $(DIRS); \ X do (cd $$i; make clean;); \ X done; X Xreal_clean: X -for i in $(DIRS); \ X do (cd $$i; make real_clean;); \ X done; X X X X X X X END_OF_FILE if test 1095 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1750 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XThis a set of ANSI standard library routines that are missing in XVxWorks. There are 3 subdirectories here: X X Xstdlib holds the string to numeric routines (atof, atoi, etc.) and Xthe extended integer divisions routines. I did not port qsort, bsearch, Xthe multibyte or random number functions, since the first 3 seem out of Xplace in real-time and there are much better random number routines. X Xstring contains the new mem* memory handling routines and Xall the missing str* routines except strerror, strcoll and strxfrm, Xwhich I deemed to UNIX bound to port. X Xtest holds code to test the various parts. X XTo use these routines with VxWorks you will have to edit stdlib.h and Xstring.h, uncommenting the appropriate routines. In string.h you will Xalso need to handle the defines that currently implement the mem* Xroutines and str(r)chr. Either remove them or add a conditional Xdefine: X X#ifndef USE_ANSI X..current WRS method... X#endif X XTo build edit the makefile to reflect your compiler and linker and Xthen just do a make. This will leave a file ansiLib.o containing all Xthe needed code. The most important define is for stdlib/abort.c, Xsince it determines how REG_SET is defined. If your compiler does not Xgenerate a cpu define (ala gcc) you will have to do so. Also you may Xneed to edit abort.c if your target is not a 680x0. X XMemcpy has code to use the new move16 instruction, but I don't have an Xassembler that can handle it, so it may be completely whacked. X XHave fun. X XRichard Neitzel thor@thor.atd.ucar.edu Torren med sitt skjegg XNational Center For Atmospheric Research lokkar borni under sole-vegg XBox 3000 Boulder, CO 80307-3000 Gjo'i med sitt shinn X303-497-2057 jagar borni inn. END_OF_FILE if test 1750 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test ! -d 'stdlib' ; then echo shar: Creating directory \"'stdlib'\" mkdir 'stdlib' fi if test -f 'stdlib/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/Makefile'\" else echo shar: Extracting \"'stdlib/Makefile'\" \(1043 characters\) sed "s/^X//" >'stdlib/Makefile' <<'END_OF_FILE' X# X# Makefile for X# Author: X# Date: X# X# GNU C XCC= gcc68 X# Cross linker XLD = ld68k X# X# Totally agressive optimization. XOPT= -O2 X# XDEFINES= X# X# Drag in includes from here. XINCLUDES= -I/vx/h X# XCFLAGS= $(OPT) $(DEFINES) $(INCLUDES) X# XLIBS= X# XOBJS= abort.o atof.o atoi.o atol.o labs.o strtod.o strtol.o strtoul.o div.o \ X ldiv.c X# XSRCS= abort.c atof.c atoi.c atol.c labs.c strtod.c strtol.c strtoul.c div.c \ X ldiv.c X# XHEADERS= X# X# Include files go here. XINC= X# X# Binaries go here. XBIN= X X.KEEP_STATE: X Xobjs: $(OBJS) X Xasm: X for i in $(SRCS); \ X do (echo "$(CC) -S $(CFLAGS) $$i";$(CC) -S $(CFLAGS) $$i); \ X done; X Xget_rcs: X for i in $(SRCS); \ X do (echo "co $$i";co $$i); \ X done; X Xget_rcs_locked: X for i in $(SRCS); \ X do (echo "co -l $$i";co -l $$i); \ X done; X Xput_rcs: X for i in $(SRCS); \ X do (echo "ci $$i";ci $$i); \ X done; X X# Modify this to include an access list if desired. Xset_rcs: X for i in $(SRCS); \ X do (echo "rcs -c\" * \" -L $$i";rcs -c" * " -L $$i); \ X done; X Xclean: X rm -f *.o *~ core X Xreal_clean: clean X rm -f *.c *.h X X X X X X END_OF_FILE if test 1043 -ne `wc -c <'stdlib/Makefile'`; then echo shar: \"'stdlib/Makefile'\" unpacked with wrong size! fi # end of 'stdlib/Makefile' fi if test -f 'stdlib/abort.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/abort.c'\" else echo shar: Extracting \"'stdlib/abort.c'\" \(859 characters\) sed "s/^X//" >'stdlib/abort.c' <<'END_OF_FILE' X/* X * $Id: abort.c,v 1.2 1992/06/11 16:10:06 thor Exp thor $ X * X * Module: abort.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/06/11 16:10:06 $ X * X * revision history X * ---------------- X * $Log: abort.c,v $ X * Revision 1.2 1992/06/11 16:10:06 thor X * Added code to correctly get definition of REG_SET. X * X * Revision 1.1 1992/05/22 17:35:45 thor X * Initial revision X * X * X * description: X * Raises SIGABRT. If you are tracking it you should cause your X * task to die. X * X */ Xstatic char rcsid[] = "$Date: 1992/06/11 16:10:06 $ $RCSfile: abort.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#ifdef mc68000 X#include "68k/regs.h" X#endif X#include "sigLib.h" X#include "taskLib.h" X#include "stdlib.h" X Xvoid abort(void) X{ X sigRaise(taskIdSelf(),SIGABRT,0); X} END_OF_FILE if test 859 -ne `wc -c <'stdlib/abort.c'`; then echo shar: \"'stdlib/abort.c'\" unpacked with wrong size! fi # end of 'stdlib/abort.c' fi if test -f 'stdlib/atof.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/atof.c'\" else echo shar: Extracting \"'stdlib/atof.c'\" \(731 characters\) sed "s/^X//" >'stdlib/atof.c' <<'END_OF_FILE' X/* X * $Id: atof.c,v 1.2 1992/06/08 17:39:03 thor Exp thor $ X * X * Module: atof.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/06/08 17:39:03 $ X * X * revision history X * ---------------- X * $Log: atof.c,v $ X * Revision 1.2 1992/06/08 17:39:03 thor X * Don't know why, but wouldn't work unless done this way! X * X * Revision 1.1 1992/05/22 16:34:30 thor X * Initial revision X * X * X * description: X * Convert string to double. X */ Xstatic char rcsid[] = "$Date: 1992/06/08 17:39:03 $ $RCSfile: atof.c,v $ $Revision: 1.2 $"; X X#include "stdlib.h" X Xdouble atof(const char *ptr) X{ X double d = strtod(ptr,(char **)NULL); X return(d); X} END_OF_FILE if test 731 -ne `wc -c <'stdlib/atof.c'`; then echo shar: \"'stdlib/atof.c'\" unpacked with wrong size! fi # end of 'stdlib/atof.c' fi if test -f 'stdlib/atoi.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/atoi.c'\" else echo shar: Extracting \"'stdlib/atoi.c'\" \(613 characters\) sed "s/^X//" >'stdlib/atoi.c' <<'END_OF_FILE' X/* X * $Id: atoi.c,v 1.1 1992/05/22 16:34:32 thor Exp thor $ X * X * Module: atoi.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 16:34:32 $ X * X * revision history X * ---------------- X * $Log: atoi.c,v $ X * Revision 1.1 1992/05/22 16:34:32 thor X * Initial revision X * X * X * description: X * Convert string to int. X */ Xstatic char rcsid[] = "$Date: 1992/05/22 16:34:32 $ $RCSfile: atoi.c,v $ $Revision: 1.1 $"; X X#include "stdlib.h" X Xint atoi(const char *ptr) X{ X return((int) strtol(ptr, (char **) NULL, 10)); X} END_OF_FILE if test 613 -ne `wc -c <'stdlib/atoi.c'`; then echo shar: \"'stdlib/atoi.c'\" unpacked with wrong size! fi # end of 'stdlib/atoi.c' fi if test -f 'stdlib/atol.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/atol.c'\" else echo shar: Extracting \"'stdlib/atol.c'\" \(609 characters\) sed "s/^X//" >'stdlib/atol.c' <<'END_OF_FILE' X/* X * $Id: atol.c,v 1.1 1992/05/22 16:34:33 thor Exp thor $ X * X * Module: atoi.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 16:34:33 $ X * X * revision history X * ---------------- X * $Log: atol.c,v $ X * Revision 1.1 1992/05/22 16:34:33 thor X * Initial revision X * X * X * description: X * Convert string to long. X */ Xstatic char rcsid[] = "$Date: 1992/05/22 16:34:33 $ $RCSfile: atol.c,v $ $Revision: 1.1 $"; X X#include "stdlib.h" X Xlong atol(const char *ptr) X{ X return(strtol(ptr, (char **) NULL, 10)); X} END_OF_FILE if test 609 -ne `wc -c <'stdlib/atol.c'`; then echo shar: \"'stdlib/atol.c'\" unpacked with wrong size! fi # end of 'stdlib/atol.c' fi if test -f 'stdlib/div.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/div.c'\" else echo shar: Extracting \"'stdlib/div.c'\" \(893 characters\) sed "s/^X//" >'stdlib/div.c' <<'END_OF_FILE' X/* X * $Id: div.c,v 1.1 1992/05/22 16:34:37 thor Exp thor $ X * X * Module: div.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 16:34:37 $ X * X * revision history X * ---------------- X * $Log: div.c,v $ X * Revision 1.1 1992/05/22 16:34:37 thor X * Initial revision X * X * X * description: X * Return the proper numerator and denominator for two ints. X */ Xstatic char rcsid[] = "$Date: 1992/05/22 16:34:37 $ $RCSfile: div.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "stdlib.h" X Xdiv_t div(int numer, int denom) X{ X FAST int sign = (numer < 0) == (denom < 0) ? 1 : -1; X div_t answer; X X numer = numer < 0 ? -numer : numer; X denom = denom < 0 ? -denom : denom; X X answer.quot = (numer / denom) * sign; X answer.rem = (numer % denom) * sign; X X return(answer); X} END_OF_FILE if test 893 -ne `wc -c <'stdlib/div.c'`; then echo shar: \"'stdlib/div.c'\" unpacked with wrong size! fi # end of 'stdlib/div.c' fi if test -f 'stdlib/labs.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/labs.c'\" else echo shar: Extracting \"'stdlib/labs.c'\" \(612 characters\) sed "s/^X//" >'stdlib/labs.c' <<'END_OF_FILE' X/* X * $Id: labs.c,v 1.1 1992/05/22 17:35:45 thor Exp thor $ X * X * Module: labs.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 17:35:45 $ X * X * revision history X * ---------------- X * $Log: labs.c,v $ X * Revision 1.1 1992/05/22 17:35:45 thor X * Initial revision X * X * X * description: X * Return absolute value of i. X */ Xstatic char rcsid[] = "$Date: 1992/05/22 17:35:45 $ $RCSfile: labs.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "stdlib.h" X Xlong labsi(FAST long i) X{ X return(i < 0 ? -i : i); X} END_OF_FILE if test 612 -ne `wc -c <'stdlib/labs.c'`; then echo shar: \"'stdlib/labs.c'\" unpacked with wrong size! fi # end of 'stdlib/labs.c' fi if test -f 'stdlib/ldiv.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/ldiv.c'\" else echo shar: Extracting \"'stdlib/ldiv.c'\" \(915 characters\) sed "s/^X//" >'stdlib/ldiv.c' <<'END_OF_FILE' X/* X * $Id: ldiv.c,v 1.1 1992/05/22 16:34:38 thor Exp thor $ X * X * Module: ldiv.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 16:34:38 $ X * X * revision history X * ---------------- X * $Log: ldiv.c,v $ X * Revision 1.1 1992/05/22 16:34:38 thor X * Initial revision X * X * X * description: X * Return the numerator and denominator for two longs. X */ Xstatic char rcsid[] = "$Date: 1992/05/22 16:34:38 $ $RCSfile: ldiv.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "stdlib.h" X Xldiv_t ldiv(long int numer, long int denom) X{ X FAST long int sign = (numer < 0L) == (denom < 0L) ? 1L : -1L; X ldiv_t answer; X X numer = numer < 0L ? -numer : numer; X denom = denom < 0L ? -denom : denom; X X answer.quot = (numer / denom) * sign; X answer.rem = (numer % denom) * sign; X X return(answer); X} END_OF_FILE if test 915 -ne `wc -c <'stdlib/ldiv.c'`; then echo shar: \"'stdlib/ldiv.c'\" unpacked with wrong size! fi # end of 'stdlib/ldiv.c' fi if test -f 'stdlib/strtoul.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdlib/strtoul.c'\" else echo shar: Extracting \"'stdlib/strtoul.c'\" \(39 characters\) sed "s/^X//" >'stdlib/strtoul.c' <<'END_OF_FILE' X#define STRTOUL 1 X X#include "strtol.c" END_OF_FILE if test 39 -ne `wc -c <'stdlib/strtoul.c'`; then echo shar: \"'stdlib/strtoul.c'\" unpacked with wrong size! fi # end of 'stdlib/strtoul.c' fi if test ! -d 'string' ; then echo shar: Creating directory \"'string'\" mkdir 'string' fi if test -f 'string/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/Makefile'\" else echo shar: Extracting \"'string/Makefile'\" \(1166 characters\) sed "s/^X//" >'string/Makefile' <<'END_OF_FILE' X# X# Makefile for X# Author: X# Date: X# X# GNU C XCC= gcc68 X# Cross linker XLD = ld68k X# X# Totally agressive optimization. XOPT= -O2 X# XDEFINES= -DUSE_ANSI X# X# Drag in includes from here. XINCLUDES= -I/vx/h X# XCFLAGS= $(OPT) $(DEFINES) $(INCLUDES) X# XLIBS= X# XOBJS= memchr.o memcmp.o memset.o memcpy.o memmove.o \ X strchr.o strcspn.o strdup.o strpbrk.o strrchr.o strspn.o strstr.o \ X strtok.o X# XSRCS= memchr.c memcmp.c memset.c memcpy.c memmove.c \ X strchr.c strcspn.c strdup.c strpbrk.c strrchr.c strspn.c strstr.c \ X strtok.c X# XHEADERS= X# X# Include files go here. XINC= X# X# Binaries go here. XBIN= X X.KEEP_STATE: X Xobjs: $(OBJS) X Xasm: X echo $(SRCS) "." X for i in $(SRCS); \ X do (echo "$(CC) -S $(CFLAGS) $$i";$(CC) -S $(CFLAGS) $$i); \ X done; X Xget_rcs: X for i in $(SRCS); \ X do (echo "co $$i";co $$i); \ X done; X Xget_rcs_locked: X for i in $(SRCS); \ X do (echo "co -l $$i";co -l $$i); \ X done; X Xput_rcs: X for i in $(SRCS); \ X do (echo "ci $$i";ci $$i); \ X done; X X# Modify this to include an access list if desired. Xset_rcs: X for i in $(SRCS); \ X do (echo "rcs -c\" * \" -L $$i";rcs -c" * " -L $$i); \ X done; X Xclean: X rm -f *.o *~ core X Xreal_clean: clean X rm -f *.c *.h X X X X X X END_OF_FILE if test 1166 -ne `wc -c <'string/Makefile'`; then echo shar: \"'string/Makefile'\" unpacked with wrong size! fi # end of 'string/Makefile' fi if test -f 'string/memmove.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/memmove.c'\" else echo shar: Extracting \"'string/memmove.c'\" \(837 characters\) sed "s/^X//" >'string/memmove.c' <<'END_OF_FILE' X/* X * $Id: memmove.c,v 1.2 1992/06/12 19:21:10 thor Exp thor $ X * X * Module: memmove.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/06/12 19:21:10 $ X * X * revision history X * ---------------- X * $Log: memmove.c,v $ X * Revision 1.2 1992/06/12 19:21:10 thor X * Removed USE_ANSI. X * X * Revision 1.1 1992/05/21 19:00:26 thor X * Initial revision X * X * X * description: X * Move data from s2 to s1 without clobbering anything if there X * is any overlap. We do this for memcpy, so why duplicate code? X * X */ Xstatic char rcsid[] = "$Date: 1992/06/12 19:21:10 $ $RCSfile: memmove.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#include "string.h" X Xvoid *memmove(FAST void *s1, FAST const void *s2, FAST size_t n) X{ X return(memcpy(s1,s2,n)); X} END_OF_FILE if test 837 -ne `wc -c <'string/memmove.c'`; then echo shar: \"'string/memmove.c'\" unpacked with wrong size! fi # end of 'string/memmove.c' fi if test -f 'string/memset.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/memset.c'\" else echo shar: Extracting \"'string/memset.c'\" \(1934 characters\) sed "s/^X//" >'string/memset.c' <<'END_OF_FILE' X/* X * $Id: memset.c,v 1.2 1992/06/12 19:21:10 thor Exp thor $ X * X * Module: memset.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/06/12 19:21:10 $ X * X * revision history X * ---------------- X * $Log: memset.c,v $ X * Revision 1.2 1992/06/12 19:21:10 thor X * Removed USE_ANSI. X * X * Revision 1.1 1992/05/21 19:00:22 thor X * Initial revision X * X * X * description: X * Sets the specified number of bytes to the lower 8 bits of X * the pattern. X * X */ Xstatic char rcsid[] = "$Date: 1992/06/12 19:21:10 $ $RCSfile: memset.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#include "string.h" X Xvoid *memset(FAST void *s, FAST int c, FAST size_t n) X{ X if (n) /* Otherwise why bother? */ X { X if (n <= sizeof(long) * 5) X { X FAST unsigned char *ptr = (unsigned char *)s; X X do X { X *ptr++ = (unsigned char)c; X } while (--n); X } X else { X FAST long *ptr = (long *)s; X FAST long i; X FAST long j; X FAST int rump; X X if ((j = (int)ptr & 3)) /* Align to longword. */ X { X FAST char *cptr = (char *)ptr; X X n -= j; X X do { X *cptr++ = (unsigned char)i; X } while (--j); X X ptr = (long *)cptr; X } X X i = c & 0xff; /* Make a big pattern. */ X j = i; X i <<= 8; X j |= i; X i = j << 16; X j |= i; X X rump = n & 3; /* Any odd bytes? */ X X n /= sizeof(long); /* How many longwords? */ X X while (n > 10) X { X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X *ptr++ = j; X n -= 10; X } X X while (n) X { X *ptr++ = j; X --n; X } X X if (rump) /* Finish odd bytes. */ X { X FAST unsigned char *cptr = (unsigned char *)ptr; X X do X { X *cptr++ = (unsigned char)j; X } while (--rump); X } X } X } X return(s); X} END_OF_FILE if test 1934 -ne `wc -c <'string/memset.c'`; then echo shar: \"'string/memset.c'\" unpacked with wrong size! fi # end of 'string/memset.c' fi if test -f 'string/strchr.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strchr.c'\" else echo shar: Extracting \"'string/strchr.c'\" \(924 characters\) sed "s/^X//" >'string/strchr.c' <<'END_OF_FILE' X/* X * $Id: strchr.c,v 1.2 1992/06/12 19:21:10 thor Exp thor $ X * X * Module: strchar.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/06/12 19:21:10 $ X * X * revision history X * ---------------- X * $Log: strchr.c,v $ X * Revision 1.2 1992/06/12 19:21:10 thor X * Removed USE_ANSI. X * X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Return a pointer to the first occurrence of c in string s. X * We only use the lower 8 bits of c. If not found return NULL. X * X */ Xstatic char rcsid[] = "$Date: 1992/06/12 19:21:10 $ $RCSfile: strchr.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#include "string.h" X Xchar *strchr(FAST const char *s, FAST int c) X{ X FAST size_t length = (size_t)strlen(s); X X length++; /* Because the eos character is significant. */ X X return(memchr(s,c,length)); X} END_OF_FILE if test 924 -ne `wc -c <'string/strchr.c'`; then echo shar: \"'string/strchr.c'\" unpacked with wrong size! fi # end of 'string/strchr.c' fi if test -f 'string/strcspn.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strcspn.c'\" else echo shar: Extracting \"'string/strcspn.c'\" \(917 characters\) sed "s/^X//" >'string/strcspn.c' <<'END_OF_FILE' X/* X * $Id: strcspn.c,v 1.2 1992/05/22 16:31:20 thor Exp thor $ X * X * Module: strcspn.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 16:31:20 $ X * X * revision history X * ---------------- X * $Log: strcspn.c,v $ X * Revision 1.2 1992/05/22 16:31:20 thor X * Changed test to terser style. X * X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Return the length of string s1 containing no characters from X * string s2. X * X */ Xstatic char rcsid[] = "$Date: 1992/05/22 16:31:20 $ $RCSfile: strcspn.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#include "string.h" X Xsize_t strcspn(FAST const char *s1, FAST const char *s2) X{ X FAST size_t count = 0; X X while (*s1) X { X if (strchr(s2, *s1++) == NULL) X count++; X else X return(count); X } X X return(count); X} END_OF_FILE if test 917 -ne `wc -c <'string/strcspn.c'`; then echo shar: \"'string/strcspn.c'\" unpacked with wrong size! fi # end of 'string/strcspn.c' fi if test -f 'string/strdup.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strdup.c'\" else echo shar: Extracting \"'string/strdup.c'\" \(866 characters\) sed "s/^X//" >'string/strdup.c' <<'END_OF_FILE' X/* X * $Id: strdup.c,v 1.1 1992/05/22 15:36:56 thor Exp thor $ X * X * Module: strdup.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 15:36:56 $ X * X * revision history X * ---------------- X * $Log: strdup.c,v $ X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Allocate storage to hold old string and copy into place. X * X */ Xstatic char rcsid[] = "$Date: 1992/05/22 15:36:56 $ $RCSfile: strdup.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "stdlib.h" X#include "string.h" X X Xchar *strdup(FAST const char *s) X{ X FAST int len = strlen(s); X FAST char *newstr; X X len++; X newstr = (char *)malloc(len); X X if (newstr == NULL) X return(newstr); X X memcpy(newstr,s,len); X X return(newstr); X} END_OF_FILE if test 866 -ne `wc -c <'string/strdup.c'`; then echo shar: \"'string/strdup.c'\" unpacked with wrong size! fi # end of 'string/strdup.c' fi if test -f 'string/strpbrk.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strpbrk.c'\" else echo shar: Extracting \"'string/strpbrk.c'\" \(837 characters\) sed "s/^X//" >'string/strpbrk.c' <<'END_OF_FILE' X/* X * $Id: strpbrk.c,v 1.1 1992/05/22 15:36:56 thor Exp thor $ X * X * Module: strpbrk.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 15:36:56 $ X * X * revision history X * ---------------- X * $Log: strpbrk.c,v $ X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Return a pointer to the first character in string s2 found X * in string s1 or NULL if none match. X * X */ Xstatic char rcsid[] = "$Date: 1992/05/22 15:36:56 $ $RCSfile: strpbrk.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "string.h" X Xchar *strpbrk(FAST const char *s1, FAST const char *s2) X{ X while (*s1 != '\0') X { X if (strchr(s2, *s1) == NULL) X s1++; X else X return((char *)s1); X } X return(NULL); X} END_OF_FILE if test 837 -ne `wc -c <'string/strpbrk.c'`; then echo shar: \"'string/strpbrk.c'\" unpacked with wrong size! fi # end of 'string/strpbrk.c' fi if test -f 'string/strrchr.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strrchr.c'\" else echo shar: Extracting \"'string/strrchr.c'\" \(1112 characters\) sed "s/^X//" >'string/strrchr.c' <<'END_OF_FILE' X/* X * $Id: strrchr.c,v 1.2 1992/06/12 19:21:10 thor Exp thor $ X * X * Module: strrchar.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/06/12 19:21:10 $ X * X * revision history X * ---------------- X * $Log: strrchr.c,v $ X * Revision 1.2 1992/06/12 19:21:10 thor X * Removed USE_ANSI. X * X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Return a pointer to the last occurrence of c in string s. X * We only use the lower 8 bits of c. If not found return NULL. X * X */ Xstatic char rcsid[] = "$Date: 1992/06/12 19:21:10 $ $RCSfile: strrchr.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#include "string.h" X Xchar *strrchr(FAST const char *s, FAST int c) X{ X FAST const char *last = NULL; X FAST const char *tmp = s; X FAST size_t length = (size_t)strlen(tmp); X X length++; /* Because the eos character is significant. */ X X while ((tmp = memchr(tmp,c,length)) != NULL) X { X last = tmp; X tmp++; X length = (size_t)strlen(tmp); X } X X return((char *)last); X} END_OF_FILE if test 1112 -ne `wc -c <'string/strrchr.c'`; then echo shar: \"'string/strrchr.c'\" unpacked with wrong size! fi # end of 'string/strrchr.c' fi if test -f 'string/strspn.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strspn.c'\" else echo shar: Extracting \"'string/strspn.c'\" \(932 characters\) sed "s/^X//" >'string/strspn.c' <<'END_OF_FILE' X/* X * $Id: strspn.c,v 1.2 1992/05/22 16:32:02 thor Exp thor $ X * X * Module: strspn.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 16:32:02 $ X * X * revision history X * ---------------- X * $Log: strspn.c,v $ X * Revision 1.2 1992/05/22 16:32:02 thor X * Complete redo - first cut was just too buggy. X * X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Return the length of string s1 that contains only X * characters from string s2. X * X */ Xstatic char rcsid[] = "$Date: 1992/05/22 16:32:02 $ $RCSfile: strspn.c,v $ $Revision: 1.2 $"; X X#include "vxWorks.h" X#include "string.h" X Xsize_t strspn(FAST const char *s1, FAST const char *s2) X{ X FAST size_t count = 0; X X while (*s1) X { X if (strchr(s2,*s1++) != NULL) X count++; X else X return(count); X } X X return(count); X} END_OF_FILE if test 932 -ne `wc -c <'string/strspn.c'`; then echo shar: \"'string/strspn.c'\" unpacked with wrong size! fi # end of 'string/strspn.c' fi if test -f 'string/strstr.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strstr.c'\" else echo shar: Extracting \"'string/strstr.c'\" \(1261 characters\) sed "s/^X//" >'string/strstr.c' <<'END_OF_FILE' X/* X * $Id: strstr.c,v 1.1 1992/05/22 15:36:56 thor Exp thor $ X * X * Module: strstr.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 15:36:56 $ X * X * revision history X * ---------------- X * $Log: strstr.c,v $ X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Return pojnter to start of first occurrence of s1 in s2 or X * NULL. X * X */ Xstatic char rcsid[] = "$Date: 1992/05/22 15:36:56 $ $RCSfile: strstr.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "string.h" X Xchar *strstr(FAST const char *s1, FAST const char *s2) X{ X FAST int length1 = strlen(s1); X FAST int length2 = strlen(s2); X FAST int times; /* How many times to search. */ X X if (length2 == 0) X return((char *)(s1 + length1)); X X if (length1 < length2) /* Impossible match. */ X return(NULL); X X times = length1 - length2; X X for (; times >= 0; --times, s1++) X { X FAST const char *cmp1 = s1; X FAST const char *cmp2 = s2; X FAST int i; X X for (i = 0; i < length2; i++, cmp1++, cmp2++) X { X if (*cmp1 != *cmp2) X break; X } X X if (i == length2) X return((char *)s1); X } X X return NULL; X} END_OF_FILE if test 1261 -ne `wc -c <'string/strstr.c'`; then echo shar: \"'string/strstr.c'\" unpacked with wrong size! fi # end of 'string/strstr.c' fi if test -f 'string/strtok.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'string/strtok.c'\" else echo shar: Extracting \"'string/strtok.c'\" \(1540 characters\) sed "s/^X//" >'string/strtok.c' <<'END_OF_FILE' X/* X * $Id: strtok.c,v 1.1 1992/05/22 15:36:56 thor Exp thor $ X * X * Module: strtok.c X * Original Author: Richard E. K. Neitzel X * Copywrited by the National Center for Atmospheric Research X * Date: $Date: 1992/05/22 15:36:56 $ X * X * revision history X * ---------------- X * $Log: strtok.c,v $ X * Revision 1.1 1992/05/22 15:36:56 thor X * Initial revision X * X * X * description: X * Given a string s1, parse it into tokens seperated by one or X * more characters from string s2. This means return a pointer to the X * next segment of s1 ending in at such a point. The first call must X * specify s1, subsequent calls must pass a NULL pointer in its place. X * X */ Xstatic char rcsid[] = "$Date: 1992/05/22 15:36:56 $ $RCSfile: strtok.c,v $ $Revision: 1.1 $"; X X#include "vxWorks.h" X#include "errno.h" X#include "string.h" X Xstatic char *oldstring = NULL; X Xchar *strtok(FAST char *s1, FAST const char *s2) X{ X FAST char *token; X X if (s1 == NULL) X { X if (oldstring == NULL) X { X errno = EINVAL; X return(NULL); X } X else X s1 = oldstring; X } X X X s1 += strspn(s1, s2); /* Skip leading delimiters. */ X X if (!*s1) X { X oldstring = NULL; X return NULL; X } X X token = s1; /* Save current start point. */ X X s1 = strpbrk(token, s2); /* Now get end point. */ X X if (s1 == NULL) /* One big token. */ X oldstring = NULL; X else X { X *s1 = 0; /* Mark off token's end. */ X oldstring = s1 + 1; /* Bump up saved string for next pass. */ X } X return(token); X} END_OF_FILE if test 1540 -ne `wc -c <'string/strtok.c'`; then echo shar: \"'string/strtok.c'\" unpacked with wrong size! fi # end of 'string/strtok.c' fi if test ! -d 'test' ; then echo shar: Creating directory \"'test'\" mkdir 'test' fi if test -f 'test/memtst.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'test/memtst.c'\" else echo shar: Extracting \"'test/memtst.c'\" \(907 characters\) sed "s/^X//" >'test/memtst.c' <<'END_OF_FILE' X#include "vxWorks.h" X#define USE_ANSI X#include "string.h" X#include "stdioLib.h" X#include "timexLib.h" X#include "taskLib.h" X Xlong a1[1000]; Xlong a2[1000]; X Xvoid memtest(int i); X Xvoid memtest(FAST int i) X{ X printf("Setting times\n"); X X timexN((FUNCPTR)bfill,(int)&a2,4000,0xf0); X X taskDelay(60); X X timexN((FUNCPTR)memset,(int)&a1,0xf0,4000); X X printf("\nChecking chr routine\n"); X X printf("0x%x 0x%x\n",a1,memchr(a1,0xf0,4000)); X X printf("\nTiming compar routines\n"); X X if (i) X a1[999] = 0xf0f0f0f1; X X timexN((FUNCPTR)bcmp,(int)&a1,(int)&a2,4000); X X taskDelay(60); X X timexN((FUNCPTR)memcmp,(int)&a1,(int)&a2,4000); X X printf("Results %d %d\n",memcmp(a1,a2,4000),bcmp(a1,a2,4000)); X X printf("\nCopying timing\n"); X X timexN((FUNCPTR)bcopy,(int)&a1,(int)&a2,4000); X taskDelay(60); X timexN((FUNCPTR)memcpy,(int)&a2,(int)&a1,4000); X X printf("0x%x\n",&a1); X} END_OF_FILE if test 907 -ne `wc -c <'test/memtst.c'`; then echo shar: \"'test/memtst.c'\" unpacked with wrong size! fi # end of 'test/memtst.c' fi if test -f 'test/strtest.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'test/strtest.c'\" else echo shar: Extracting \"'test/strtest.c'\" \(1259 characters\) sed "s/^X//" >'test/strtest.c' <<'END_OF_FILE' X#include "vxWorks.h" X#include "stdioLib.h" X#define USE_ANSI X#include "string.h" X Xvoid strtest(void); X Xstatic char *tststr = "This is our test string for the added ANSI routines"; X Xvoid strtest(void) X{ X FAST char *dup; X X printf("Result of strchr for `s` 0x%x, %s\n for `A` 0x%x %s\n", X strchr(tststr,'s'),strchr(tststr,'s'),strchr(tststr,'A'), X strchr(tststr,'A')); X X printf("Result of strrchr for `s` 0x%x, %s\n for `A` 0x%x %s\n", X strrchr(tststr,'s'),strrchr(tststr,'s'),strrchr(tststr,'A'), X strrchr(tststr,'A')); X X dup = strdup(tststr); X X printf("Strdup test:\n%s\n%s\n",tststr,dup); X X free(dup); X X printf("Strspn using 'This is': %d\n",strspn(tststr,"This is")); X X printf("Strcspn using 'qwg': %d\n",strcspn(tststr,"qwg")); X X printf("Strpbrk:\nusing 'mqwn': 0x%x %s\nusing 'qw': 0x%x %s\n", X strpbrk(tststr,"mqwn"),strpbrk(tststr,"mqwn"),strpbrk(tststr,"qw"), X strpbrk(tststr,"qw")); X X printf("Strstr:\nusing 'the': 0x%x %s\nusing 'sam': 0x%x %s\n", X strstr(tststr,"the"),strstr(tststr,"the"),strstr(tststr,"sam"), X strstr(tststr,"sam")); X X printf("Strtok using ' ':\n"); X X dup = strtok(tststr," "); X X while (dup != NULL) X { X printf("%s\n",dup); X X dup = strtok(NULL," "); X } X} END_OF_FILE if test 1259 -ne `wc -c <'test/strtest.c'`; then echo shar: \"'test/strtest.c'\" unpacked with wrong size! fi # end of 'test/strtest.c' fi echo shar: End of archive 1 \(of 2\). cp /dev/null ark1isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0