#! /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 <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 7 (of 31)."
# Contents:  libs/src/misc/Makefile libs/src/misc/ftwx.c
#   libs/src/str/str.h libs/src/str/strprint.c libs/src/str/strutil.c
#   libs/src/timer/timemacros.h libs/src/xlog/Makefile
# Wrapped by panos@mystique on Mon Jun 21 14:51:22 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'libs/src/misc/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/misc/Makefile'\"
else
echo shar: Extracting \"'libs/src/misc/Makefile'\" \(3674 characters\)
sed "s/^X//" >'libs/src/misc/Makefile' <<'END_OF_FILE'
X# (c) Copyright 1992 by Panagiotis Tsirigotis
X# All rights reserved.  The file named COPYRIGHT specifies the terms 
X# and conditions for redistribution.
X
X#
X# $Id: Makefile,v 2.9 1992/11/06 02:20:41 panos Exp $
X#
X# Based on Library makefile template: *Revision: 1.15 *
X#
X
X# 
X# Available entries:
X# 		lib 			--> creates the library
X#		install		--> installs the library (archive, man page(s), header(s))
X#		uninstall	--> uninstall the library
X#		clean			--> removes all .o and .a files
X#		spotless		--> clean + uninstall
X# 		lint			--> lints a file (usage: make lint MODULE=foo.c)
X#		tags			--> creates a tags file (from the SOURCES and HEADERS)
X#		checkout 	--> checkout all files
X#		dist			--> distribution support
X#
X
XNAME				= misc
XVERSION			= 1.2.2
X
XHEADERS			= misc.h ftwx.h env.h
XSOURCES			= misc.c ftwx.c env.c
XOBJECTS			= misc.o ftwx.o env.o
X
XMANFILES			= misc.3 ftwx.3 env.3
XINCLUDEFILES	= $(HEADERS)
X
X# The following variables are used by the 'install' entry and
X# should be customized:
X#     LIBDIR:     where the library will be placed
X#     INCUDEDIR:  where the include files will be placed
X#     MANDIR:     where the man pages will be placed
X#
XLIBDIR			= $(HOME)/.links/libraries/$(ARCH)
XMANDIR			= $(HOME)/.links/manpages/man3
XINCLUDEDIR		= $(HOME)/.links/includes
X
X#
X# Possible flags:
X#     -DOLD_DIR         : must include <sys/dir.h> instead of <dirent.h>
X#     -D__FTWX_NO_FTW   : does not have <ftw.h>
X#
XDEFS				=				# used for command line defined flags
X
XDEBUG				= -g				# -g or -O
XVERSION_DEF		= -DVERSION=\"MISC\ Version\ $(VERSION)\"
X
XCPP_DEFS			= $(VERSION_DEF) $(DEFS)
X
X#
X# The following variables shouldn't need to be changed
X#
XLINT_FLAGS		= -hbux
XCPP_FLAGS		= $(CPP_DEFS)
XCC_FLAGS			= $(DEBUG)
XCFLAGS			= $(CPP_FLAGS) $(CC_FLAGS)
X
XINSTALL			= install -c
XFMODE				= -m 640			# used by install
XRANLIB			= ranlib
X
XPAGER				= less
X
X
XLIBNAME			= lib$(NAME).a
X
Xlib: $(LIBNAME)
X
Xlibopt: clean
X	make DEBUG=-O lib
X	mv $(LIBNAME) $(LIBDIR)/optimized
X
X
X$(LIBNAME): $(OBJECTS)
X	ar r $@ $?
X	$(RANLIB) $@
X
Xlint:
X	lint $(CPP_FLAGS) $(LINT_FLAGS) $(MODULE) 2>&1 | $(PAGER)
X
Xinstall: $(LIBNAME)
X	@if test "$(LIBDIR)" -a "$(INCLUDEDIR)" -a "$(MANDIR)" ;\
X	then \
X		$(INSTALL) $(FMODE) $(LIBNAME) $(LIBDIR) ;\
X		echo "Installed $(LIBNAME) to $(LIBDIR)" ;\
X		for i in $(INCLUDEFILES); do $(INSTALL) $(FMODE) $$i $(INCLUDEDIR) ; done ;\
X		echo Installed $(INCLUDEFILES) to $(INCLUDEDIR) ;\
X		for i in $(MANFILES) ; do $(INSTALL) $(FMODE) $$i $(MANDIR) ; done ;\
X		echo Installed $(MANFILES) to $(MANDIR) ;\
X	else \
X		echo "You forgot to set one of the following variables: LIBDIR,INCLUDEDIR,MANDIR" ;\
X	fi
X
Xuninstall:
X	a=`pwd` ; cd $(INCLUDEDIR) ;\
X	if test $$a != `pwd` ; then rm -f $(INCLUDEFILES) ; fi
X	a=`pwd` ; cd $(LIBDIR) ;\
X	if test $$a != `pwd` ; then rm -f $(LIBNAME) ; fi
X	a=`pwd` ; cd $(MANDIR) ;\
X	if test $$a != `pwd` ; then rm -f $(MANFILES) ; fi
X
Xclean:
X	rm -f $(OBJECTS) $(LIBNAME) core
X
Xspotless: clean uninstall
X
Xtags: $(SOURCES) $(HEADERS)
X	ctags -w $(SOURCES) $(HEADERS)
X
Xcheckout:
X	co $(SOURCES) $(HEADERS) $(MANFILES)
X
X#
X# Distribution section
X# This section contains the 2 targets for distribution support: dist, dirs
X# "dist" checks out all files to be distributed
X# "dirs" prints a list of directories to be included in the distribution.
X# These directories should have a Makefile with a "dist" target
X#
XDISTRIBUTION_FILES	= $(HEADERS) $(SOURCES) $(MANFILES) README
XDIRS						=
X
Xdist:
X	-co -q $(DISTRIBUTION_FILES)
X
Xdirs:
X	@echo $(DIRS)
X
X#
X# PUT HERE THE RULES TO MAKE THE OBJECT FILES
X#
Xmisc.o:		misc.h
Xftwx.o:		ftwx.h misc.h
Xenv.o:		env.h misc.h
X
X
X#
X# Test program
X#
Xtt: tt.c $(LIBNAME)
X	$(CC) -g tt.c -o $@ $(LIBNAME) -L$(LIBDIR) -ltest
X
END_OF_FILE
if test 3674 -ne `wc -c <'libs/src/misc/Makefile'`; then
    echo shar: \"'libs/src/misc/Makefile'\" unpacked with wrong size!
fi
# end of 'libs/src/misc/Makefile'
fi
if test -f 'libs/src/misc/ftwx.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/misc/ftwx.c'\"
else
echo shar: Extracting \"'libs/src/misc/ftwx.c'\" \(3822 characters\)
sed "s/^X//" >'libs/src/misc/ftwx.c' <<'END_OF_FILE'
X/*
X * (c) Copyright 1992 by Panagiotis Tsirigotis
X * All rights reserved.  The file named COPYRIGHT specifies the terms 
X * and conditions for redistribution.
X */
X
Xstatic char RCSid[] = "$Id: ftwx.c,v 2.1 1992/10/01 00:41:02 panos Exp $" ;
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/file.h>
X#ifndef OLD_DIR
X#include <dirent.h>
X#else
X#include <sys/dir.h>
X#define dirent direct
X#endif
X
Xextern int errno ;
X
X#include "misc.h"
X#include "ftwx.h"
X
X#define PRIVATE			static
X
X#define NUL					'\0'
X
X
Xtypedef enum { NO, YES } boolean_e ;
X
Xstatic struct
X{
X	int (*stat_func)() ;
X	int (*user_func)() ;
X} ftwx_data ;
X
X/*
X * ftwx is an extension to ftw, that optionally follows symlinks (the
X * default is NOT to follow them).
X *
X * Possible flag values:
X *		FTWX_FOLLOW: 		follow symlinks
X *
X * Possible depth values:
X *		0			: means only the specified path
X *		positive : means go as deep as specified
X *		FTWX_ALL : no depth limitation
X *
X * User function return value:
X *		negative : means an error occured and the traversal should stop
X *		0			: OK
X *		positive : means that if the current object is a directory it
X *					  should not be traversed.
X *
X * Return value:
X *		-1 		: if an error occurs
X *  frv			: frv is the function return value if it is negative (it
X *					  should not be -1).
X *		0			: if successful
X */
Xint ftwx( path, func, depth, flags )
X	char *path ;
X	int (*func)() ;
X	int depth ;
X	int flags ;
X{
X	int stat(), lstat() ;
X
X	/*
X	 * Initialize the data structure
X	 */
X	ftwx_data.stat_func = ( flags & FTWX_FOLLOW ) ? stat : lstat ;
X	ftwx_data.user_func = func ;
X
X	return( ftwx_traverse( path, depth ) ) ;
X}
X
X
X
X
X/*
X * ftwx_traverse works in two phases:
X *
X * Phase 1: process the current path
X *
X * Phase 2: if the current path is a directory, it invokes ftwx_traverse
X *				for each directory entry
X */
XPRIVATE int ftwx_traverse( path, depth )
X	char *path ;
X	int depth ;
X{
X	DIR *dirp ;
X	struct stat st ;
X	int ftw_flag = 0 ;
X	boolean_e traverse = YES ;
X	int retval ;
X	int save_errno ;
X
X	if ( (*ftwx_data.stat_func)( path, &st ) == -1 )
X		ftw_flag = FTW_NS ;
X	else
X	{
X		/*
X		 * If it is a directory and determine if it is readable
X		 * (if it is not readable, we don't traverse it
X		 */
X		if ( S_ISDIR( st.st_mode ) )
X			if ( access( path, R_OK ) == 0 )
X				ftw_flag = FTW_D ;
X			else
X				ftw_flag = FTW_DNR ;
X		else
X			ftw_flag = FTW_F ;
X	}
X	retval = (*ftwx_data.user_func)( path, &st, ftw_flag ) ;
X	if ( retval < 0 )
X		return( retval ) ;
X	else if ( retval > 0 && ftw_flag == FTW_D )
X		traverse = NO ;
X
X	/*
X	 * Stop traversal if:
X	 *		a. depth reached 0
X	 *		b. the current path is not a readable directory
X	 *		c. the user doesn't want us to traverse this directory tree
X	 */
X	if ( depth == 0 || ftw_flag != FTW_D || traverse == NO )
X		return( 0 ) ;
X
X	if ( depth != FTWX_ALL )
X		depth-- ;
X
X	if ( ( dirp = opendir( path ) ) == NULL )
X		return( -1 ) ;
X
X	for ( ;; )
X	{
X		struct dirent *dp ;
X		char *filename ;
X
X		errno = 0 ;			/* to detect readdir errors */
X		dp = readdir( dirp ) ;
X		if ( dp == NULL )
X		{
X			retval = ( errno == 0 ) ? 0 : -1 ;
X			break ;
X		}
X
X		/*
X		 * The special names: "." and ".." are skipped
X		 */
X		if ( dp->d_name[ 0 ] == '.' )
X			if ( dp->d_name[ 1 ] == NUL ||
X						dp->d_name[ 1 ] == '.' && dp->d_name[ 2 ] == NUL )
X				continue ;
X
X		filename = make_pathname( 2, path, dp->d_name ) ;
X		if ( filename == NULL )
X		{
X			retval = -1 ;
X			break ;
X		}
X		
X		retval = ftwx_traverse( filename, depth ) ;
X		free( filename ) ;
X
X		/*
X		 * Check for a negative value instead of -1 because the
X		 * user function may use any negative value
X		 */
X		if ( retval < 0 )
X			break ;
X	}
X	/*
X	 * Make sure we don't trash errno; we should only do this if
X	 * retval is negative, but we are lazy...
X	 */
X	save_errno = errno ;
X	(void) closedir( dirp ) ;
X	errno = save_errno ;
X	return( retval ) ;
X}
X
END_OF_FILE
if test 3822 -ne `wc -c <'libs/src/misc/ftwx.c'`; then
    echo shar: \"'libs/src/misc/ftwx.c'\" unpacked with wrong size!
fi
# end of 'libs/src/misc/ftwx.c'
fi
if test -f 'libs/src/str/str.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/str/str.h'\"
else
echo shar: Extracting \"'libs/src/str/str.h'\" \(3551 characters\)
sed "s/^X//" >'libs/src/str/str.h' <<'END_OF_FILE'
X/*
X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
X * All rights reserved.  The file named COPYRIGHT specifies the terms 
X * and conditions for redistribution.
X */
X
X
X#ifndef __STR_H
X#define __STR_H
X
X/*
X * $Id: str.h,v 3.1 1993/06/13 02:47:14 panos Exp $
X */
X
X#include <varargs.h>
X
X
X#ifdef __ARGS
X#undef __ARGS
X#endif
X
X#ifdef PROTOTYPES
X#   define __ARGS( s )               s
X#else
X#   define __ARGS( s )               ()
X#endif
X
X
X/*
X * strprint(3) functions
X */
Xchar *str_sprint __ARGS( ( char *buf, char *fmt, ... ) ) ;
Xint str_nprint __ARGS( ( char *buf, char *fmt, ... ) ) ;
Xvoid str_print __ARGS( ( int *count, char *buf, char *fmt, ... ) ) ;
X
Xchar *str_sprintv __ARGS( ( char *buf, char *fmt, va_list ) ) ;
Xint str_nprintv __ARGS( ( char *buf, char *fmt, va_list ) ) ;
Xvoid str_printv __ARGS( ( int *count, char *buf, char *fmt, va_list ) ) ;
X
Xchar *strx_sprint __ARGS( ( char *buf, int len, char *fmt, ... ) ) ;
Xint strx_nprint __ARGS( ( char *buf, int len, char *fmt, ... ) ) ;
Xvoid strx_print __ARGS( ( int *count, char *buf, int len, char *fmt, ... ) ) ;
X
Xchar *strx_sprintv __ARGS( ( char *buf, int len, char *fmt, va_list ) ) ;
Xint strx_nprintv __ARGS( ( char *buf, int len, char *fmt, va_list ) ) ;
Xvoid strx_printv __ARGS(( int *cnt, char *buf, int len, char *fmt, va_list )) ;
X
X
X/*
X * strparse(3) functions
X */
X
X/*
X * Return values
X */
X#define STR_OK						0
X#define STR_ERR					(-1)
X
X
X/* 
X * Flags for the string parsing functions
X */
X#define STR_NOFLAGS				0x0
X#define STR_RETURN_ERROR		0x1
X#define STR_NULL_START			0x2
X#define STR_NULL_END				0x4
X#define STR_MALLOC				0x8
X
Xextern int str_errno ;
X
X/*
X * Error values
X */
X#define STR_ENULLSEPAR			1
X#define STR_ENULLSTRING			2
X#define STR_ENOMEM				3
X
Xtypedef void *str_h ;
X
Xstr_h str_parse __ARGS( ( char *str, char *separ, int flags, int *errnop ) ) ;
Xvoid str_endparse __ARGS( ( str_h handle ) ) ;
Xchar *str_component __ARGS( ( str_h handle ) ) ;
Xint str_setstr __ARGS( ( str_h handle, char *newstr ) ) ;
Xint str_separator __ARGS( ( str_h handle, char *separ ) ) ;
Xchar *str_nextpos __ARGS( ( str_h handle ) ) ;
X
X/*
X * For backwards compatibility
X */
X#define str_process( s, sep, flags )	str_parse( s, sep, flags, (int *)0 )
X#define str_endprocess( handle )			str_endparse( handle )
X
X
X/*
X * strutil(3) functions
X */
Xchar *str_find __ARGS( ( char *s1, char *s2 ) ) ;
Xchar *str_casefind __ARGS( ( char *s1, char *s2 ) ) ;
Xvoid str_fill __ARGS( ( char *s, char c ) ) ;
Xchar *str_lower __ARGS( ( char *s ) ) ;
Xchar *str_upper __ARGS( ( char *s ) ) ;
X
X
X/*
X * strsearch(3) functions
X */
X
X/*
X * Methods
X */
X#define STRS_BF								0			/* brute force				*/
X#define STRS_RK								1			/* Rabin-Karp				*/
X#define STRS_KMP								2			/* Knuth-Morris-Pratt	*/
X#define STRS_SBM								3			/* Simple Boyer-Moore	*/
X#define STRS_BMH								4			/* Boyer-Moore-Horspool */
X#define STRS_SO								5			/* Shift-Or					*/
X
X#define __STRS_METHOD_BITS					5
X#define STRS_METHODS_MAX					( 1 << __STRS_METHOD_BITS )
X
X/*
X * Flags
X */
X#define __STRS_MAKEFLAG( v )				( (v) << __STRS_METHOD_BITS )
X#define STRS_IGNCASE							__STRS_MAKEFLAG( 0x1 )
X#define STRS_NOMALLOC						__STRS_MAKEFLAG( 0x2 )
X#define STRS_NOSWITCH						__STRS_MAKEFLAG( 0x4 )
X#define STRS_PATLEN							__STRS_MAKEFLAG( 0x8 )
X
X
Xtypedef void *strs_h ;
X
Xchar *strs_search __ARGS( ( int flags, char *str, int len, char *pat, ... ) ) ;
Xstrs_h strs_setup __ARGS( ( int flags, char *pattern, ... ) ) ;
Xchar *strs_match	__ARGS( ( strs_h handle, char *str, int len ) ) ;
Xvoid strs_done		__ARGS( ( strs_h handle ) ) ;
X
X#endif 	/* __STR_H */
X
END_OF_FILE
if test 3551 -ne `wc -c <'libs/src/str/str.h'`; then
    echo shar: \"'libs/src/str/str.h'\" unpacked with wrong size!
fi
# end of 'libs/src/str/str.h'
fi
if test -f 'libs/src/str/strprint.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/str/strprint.c'\"
else
echo shar: Extracting \"'libs/src/str/strprint.c'\" \(3569 characters\)
sed "s/^X//" >'libs/src/str/strprint.c' <<'END_OF_FILE'
X/*
X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
X * All rights reserved.  The file named COPYRIGHT specifies the terms 
X * and conditions for redistribution.
X */
X
Xstatic char RCSid[] = "$Id: strprint.c,v 3.1 1993/06/13 02:50:11 panos Exp $" ;
X
X#ifndef NO_SIO
X#include "sio.h"
X#endif
X
X#include "str.h"
X
X#define INT_NULL						((int *)0)
X
X/*
X * The strx_* functions will never overwrite the buffer
X * The str_* functions may overwrite the buffer
X */
X
X/*
X * Group 1: the strx_* functions
X */
X
X/*
X * This is the general purpose conversion function. It is invoked
X * by all the other str[x]_* functions
X */
Xvoid strx_printv( ccp, buf, len, format, ap )
X	int *ccp ;
X	char *buf ;
X	int len ;
X	char *format ;
X	va_list ap ;
X{
X#ifndef NO_SIO
X	__sio_od_t od ;
X	int cc ;
X
X   /*
X    * First initialize the descriptor
X	 * Notice that if no length is given, we initialize buf_end to the
X	 * highest possible address.
X    */
X   od.buf = buf ;                						/* NOT NEEDED        */
X   od.buf_end = len ? &buf[ len ] : (char *) ~0 ;	/* NEEDED				*/
X   od.buffer_size = 0 ;          						/* NOT NEEDED        */
X   od.start = buf ;              						/* NOT NEEDED        */
X   od.nextb = buf ;              						/* NEEDED            */
X   od.buftype = 0 ;              						/* NOT NEEDED        */
X
X   /*
X    * Do the conversion
X    */
X   cc = __sio_converter( &od, -1, format, ap ) ;
X	if ( len == 0 || od.nextb < od.buf_end )
X		*(od.nextb) = '\0' ;
X   if ( ccp )
X      *ccp = cc ;
X#endif	/* ! NO_SIO */
X}
X
X
Xvoid strx_print( ccp, buf, len, format, va_alist )
X	int *ccp ;
X	char *buf ;
X	int len ;
X	char *format ;
X	va_dcl
X{
X	va_list ap ;
X
X	va_start( ap ) ;
X	strx_printv( ccp, buf, len, format, ap ) ;
X	va_end( ap ) ;
X}
X
X
Xchar *strx_sprint( buf, len, format, va_alist )
X	char *buf ;
X	int len ;
X	char *format ;
X	va_dcl
X{
X	va_list ap ;
X
X	va_start( ap ) ;
X	strx_printv( INT_NULL, buf, len, format, ap ) ;
X	va_end( ap ) ;
X	return( buf ) ;
X}
X
X
Xchar *strx_sprintv( buf, len, format, ap )
X	char *buf ;
X	int len ;
X	char *format ;
X	va_list ap ;
X{
X	strx_printv( INT_NULL, buf, len, format, ap ) ;
X	return( buf ) ;
X}
X
X
Xint strx_nprint( buf, len, format, va_alist )
X	char *buf ;
X	int len ;
X	char *format ;
X	va_dcl
X{
X	int cc ;
X	va_list ap ;
X
X	va_start( ap ) ;
X	strx_printv( &cc, buf, len, format, ap ) ;
X	va_end( ap ) ;
X	return( cc ) ;
X}
X
X
Xint strx_nprintv( buf, len, format, ap )
X	char *buf ;
X	int len ;
X	char *format ;
X	va_list ap ;
X{
X	int cc ;
X
X	strx_printv( &cc, buf, len, format, ap ) ;
X	return( cc ) ;
X}
X
X
X
X/*
X * Group 2: the str_* functions
X */
X
Xvoid str_print( ccp, buf, format, va_alist )
X	int *ccp ;
X	char *buf ;
X	char *format ;
X	va_dcl
X{
X	va_list ap ;
X
X	va_start( ap ) ;
X	strx_printv( ccp, buf, 0, format, ap ) ;
X	va_end( ap ) ;
X}
X
X
Xvoid str_printv( ccp, buf, format, ap )
X	int *ccp ;
X	char *buf ;
X	char *format ;
X	va_list ap ;
X{
X	strx_printv( ccp, buf, 0, format, ap ) ;
X}
X
X
Xchar *str_sprint( buf, format, va_alist )
X	char *buf ;
X	char *format ;
X	va_dcl
X{
X	va_list ap ;
X
X	va_start( ap ) ;
X	strx_printv( INT_NULL, buf, 0, format, ap ) ;
X	va_end( ap ) ;
X	return( buf ) ;
X}
X
X
Xchar *str_sprintv( buf, format, ap )
X	char *buf ;
X	char *format ;
X	va_list ap ;
X{
X	strx_printv( INT_NULL, buf, 0, format, ap ) ;
X	return( buf ) ;
X}
X
X
Xint str_nprint( buf, format, va_alist )
X	char *buf ;
X	char *format ;
X	va_dcl
X{
X	int cc ;
X	va_list ap ;
X
X	va_start( ap ) ;
X	strx_printv( &cc, buf, 0, format, ap ) ;
X	va_end( ap ) ;
X	return( cc ) ;
X}
X
X
X
Xint str_nprintv( buf, format, ap )
X	char *buf ;
X	char *format ;
X	va_list ap ;
X{
X	int cc ;
X
X	strx_printv( &cc, buf, 0, format, ap ) ;
X	return( cc ) ;
X}
X
X
END_OF_FILE
if test 3569 -ne `wc -c <'libs/src/str/strprint.c'`; then
    echo shar: \"'libs/src/str/strprint.c'\" unpacked with wrong size!
fi
# end of 'libs/src/str/strprint.c'
fi
if test -f 'libs/src/str/strutil.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/str/strutil.c'\"
else
echo shar: Extracting \"'libs/src/str/strutil.c'\" \(3554 characters\)
sed "s/^X//" >'libs/src/str/strutil.c' <<'END_OF_FILE'
X/*
X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
X * All rights reserved.  The file named COPYRIGHT specifies the terms 
X * and conditions for redistribution.
X */
X
Xstatic char RCSid[] = "$Id: strutil.c,v 3.1 1993/06/13 02:50:22 panos Exp $" ;
X
X
X#include <ctype.h>
X
X#define NULL				0
X
X
X#ifndef TRIVIAL_STR_FIND
X
X/*
X * look for an instance of s2 in s1
X * Returns a pointer to the beginning of s2 in s1
X */
Xchar *str_find( str, sstr )
X	register char *str ;
X	register char *sstr ;
X{
X   register int ssfc = *sstr++ ;    /* sub-string first char */
X
X	if ( ssfc == 0 )			/* empty string is always a match */
X		return( str ) ;
X
X	while ( *str )
X	{
X		char *current = str ;
X		register int strc = *str++ ;
X		register char *sp ;                    /* string pointer */
X		register char *ssp ;                   /* sub-string pointer */
X
X		if ( strc != ssfc )
X			continue ;
X		
X		/*
X		 * We don't need to make the end of str a special case since
X		 * the comparison of *sp against *ssp is guaranteed to fail
X		 */
X		for ( sp = str, ssp = sstr ;; sp++, ssp++ )
X		{
X			if ( *ssp == 0 )
X				return( current ) ;
X			if ( *sp != *ssp )
X				break ;
X		}
X	}
X
X	return( 0 ) ;
X}
X
X
X#define LOWER_CASE( c )					( (c) + 'a' - 'A' )
X
X/*
X * str_casefind is similar to str_find except that it ignores the
X * case of the alphabetic characters
X */
Xchar *str_casefind( str, sstr )
X	register char *str ;
X	char *sstr ;
X{
X	register int ssfc = *sstr++ ;		/* sub-string first char */
X
X	if ( ssfc == 0 )
X		return( str ) ;
X
X	if ( isalpha( ssfc ) && isupper( ssfc ) )
X		ssfc = LOWER_CASE( ssfc ) ;
X
X	while ( *str )
X	{
X		char *current = str ;
X		register int strc = *str++ ;
X		char *sp ;							/* string pointer */
X		char *ssp ;							/* sub-string pointer */
X
X		if ( isalpha( strc ) && isupper( strc ) )
X			strc = LOWER_CASE( strc ) ;
X		if ( strc != ssfc )
X			continue ;
X		
X		for ( sp = str, ssp = sstr ;; sp++, ssp++ )
X		{
X			register int sc = *sp ;				/* string char */
X			register int ssc = *ssp ;			/* substring char */
X
X			/*
X			 * End-of-substring means we got a match
X			 */
X			if ( ssc == 0 )
X				return( current ) ;
X
X			/*
X			 * Convert to lower case if alphanumeric
X			 */
X			if ( isalpha( sc ) && isupper( sc ) )
X				sc = LOWER_CASE( sc ) ;
X			if ( isalpha( ssc ) && isupper( ssc ) )
X				ssc = LOWER_CASE( ssc ) ;
X			if ( sc != ssc )
X				break ;
X		}
X	}
X
X	return( 0 ) ;
X}
X
X
X#else		/* defined( TRIVIAL_STR_FIND ) */
X
X/*
X * look for an instance of s2 in s1
X * Returns a pointer to the beginning of s2 in s1
X */
Xchar *str_find( s1, s2 )
X	char *s1 ;
X	char *s2 ;
X{
X   int i ;
X   int l1 = strlen( s1 ) ;
X   int l2 = strlen( s2 ) ;
X
X   for ( i = 0 ; i < l1 - l2 + 1 ; i++ )
X      if ( strncmp( &s1[ i ], s2, l2 ) == 0 )
X         return( &s1[ i ] ) ;
X   return( NULL ) ;
X}
X
X
Xchar *str_casefind( s1, s2 )
X	char *s1 ;
X	char *s2 ;
X{
X   int i ;
X   int l1 = strlen( s1 ) ;
X   int l2 = strlen( s2 ) ;
X
X   for ( i = 0 ; i < l1 - l2 + 1 ; i++ )
X      if ( strncasecmp( &s1[ i ], s2, l2 ) == 0 )
X         return( &s1[ i ] ) ;
X   return( NULL ) ;
X}
X
X#endif 	/* TRIVIAL_STR_FIND */
X
X
X/*
X * Fill string s with character c
X */
Xvoid str_fill( s, c )
X	register char *s ;
X	register char c ;
X{
X	while ( *s ) *s++ = c ;
X}
X
X
Xchar *str_lower( s )
X	char *s ;
X{
X	register char *p ;
X	register int offset = 'a' - 'A' ;
X
X	for ( p = s ; *p ; p++ )
X		if ( isascii( *p ) && isupper( *p ) )
X			*p += offset ;
X	return( s ) ;
X}
X
X
Xchar *str_upper( s )
X	char *s ;
X{
X	register char *p ;
X	register int offset = 'a' - 'A' ;
X
X	for ( p = s ; *p ; p++ )
X		if ( isascii( *p ) && islower( *p ) )
X			*p -= offset ;
X	return( s ) ;
X}
X
X
END_OF_FILE
if test 3554 -ne `wc -c <'libs/src/str/strutil.c'`; then
    echo shar: \"'libs/src/str/strutil.c'\" unpacked with wrong size!
fi
# end of 'libs/src/str/strutil.c'
fi
if test -f 'libs/src/timer/timemacros.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/timer/timemacros.h'\"
else
echo shar: Extracting \"'libs/src/timer/timemacros.h'\" \(3580 characters\)
sed "s/^X//" >'libs/src/timer/timemacros.h' <<'END_OF_FILE'
X/*
X * (c) Copyright 1993 by Panagiotis Tsirigotis
X * All rights reserved.  The file named COPYRIGHT specifies the terms 
X * and conditions for redistribution.
X */
X
X#ifndef __TIMEMACROS_H
X#define __TIMEMACROS_H
X
X/*
X * $Id: timemacros.h,v 3.1 1992/11/23 16:22:53 panos Exp $
X */
X
X#include <sys/types.h>
X#include <sys/time.h>
X
X/*
X * Define a few relevant NULL values
X */
X#ifndef TIMEZONE_NULL
X#define TIMEZONE_NULL		((struct timezone *)0)
X#endif
X#ifndef TIMEVAL_NULL
X#define TIMEVAL_NULL			((struct timeval *)0)
X#endif
X#ifndef ITIMERVAL_NULL
X#define ITIMERVAL_NULL		((struct itimerval *)0)
X#endif
X
X/*
X * The TV_* macros work with timeval structures.
X * The TVP_* macros work with pointers to timeval structures.
X *
X * We support the following operations:
X *
X *			EQ( tv1, tv2 )			: tv1 == tv2
X *			NE( tv1, tv2 )			: tv1 != tv2
X *			LT( tv1, tv2 )			: tv1 <  tv2
X *			LE( tv1, tv2 )			: tv1 <= tv2
X *			GT( tv1, tv2 )			: tv1 >  tv2
X *			GE( tv1, tv2 )			: tv1 >= tv2
X *			ISZERO( tv )			: tv == 0
X *			ZERO( tv )				: tv = 0
X *			ADD( res, tv1, tv2 ) : res = tv1 + tv2
X *			SUB( res, tv1, tv2 ) : res = tv1 = tv2
X *
X * We normalize the result after addition and subtraction.
X */
X
X#define __ONE_MILLION					1000000
X
X#define TV_ADD( tv_res, tv1, tv2 )									\
X	{																			\
X		(tv_res).tv_sec = (tv1).tv_sec + (tv2).tv_sec ;			\
X		(tv_res).tv_usec = (tv1).tv_usec + (tv2).tv_usec ;		\
X		if ( (tv_res).tv_usec >= __ONE_MILLION )					\
X		{																		\
X			(tv_res).tv_sec++ ;											\
X			(tv_res).tv_usec -= __ONE_MILLION ;						\
X		}																		\
X	}
X
X#define TV_SUB( tv_res, tv1, tv2 )									\
X	{																			\
X		(tv_res).tv_sec = (tv1).tv_sec - (tv2).tv_sec ;			\
X		(tv_res).tv_usec = (tv1).tv_usec - (tv2).tv_usec ;		\
X		if ( (tv_res).tv_usec < 0 )									\
X		{																		\
X			(tv_res).tv_usec += __ONE_MILLION ;						\
X			(tv_res).tv_sec-- ;											\
X		}																		\
X	}
X
X#define TV_LT( tv1, tv2 )																	\
X		( (tv1).tv_sec < (tv2).tv_sec ||													\
X		  (tv1).tv_sec == (tv2).tv_sec && (tv1).tv_usec < (tv2).tv_usec )
X
X#define TV_LE( tv1, tv2 )																	\
X		( (tv1).tv_sec < (tv2).tv_sec ||													\
X		  (tv1).tv_sec == (tv2).tv_sec && (tv1).tv_usec <= (tv2).tv_usec )
X
X#define TV_GT( tv1, tv2 )																	\
X		( (tv1).tv_sec > (tv2).tv_sec ||													\
X		  (tv1).tv_sec == (tv2).tv_sec && (tv1).tv_usec > (tv2).tv_usec )
X
X#define TV_GE( tv1, tv2 )																	\
X		( (tv1).tv_sec > (tv2).tv_sec ||													\
X		  (tv1).tv_sec == (tv2).tv_sec && (tv1).tv_usec >= (tv2).tv_usec )
X
X#define TV_EQ( tv1, tv2 )																	\
X		( (tv1).tv_sec == (tv2).tv_sec && (tv1).tv_usec == (tv2).tv_usec )
X
X#define TV_NE( tv1, tv2 )																	\
X		( (tv1).tv_sec != (tv2).tv_sec || (tv1).tv_usec != (tv2).tv_usec )
X
X#define TV_ISZERO( tv )			( (tv).tv_sec == 0 && (tv).tv_usec == 0 )
X
X#define TV_ZERO( tv )			(tv).tv_sec = (tv).tv_usec = 0
X
X
X/*
X * Pointer macros
X */
X
X#define TVP_ADD( tvp_res, tvp1, tvp2 )	TV_ADD( *(tvp_res), *(tvp1), *(tvp2) )
X#define TVP_SUB( tvp_res, tvp1, tvp2 )	TV_SUB( *(tvp_res), *(tvp1), *(tvp2) )
X#define TVP_LT( tvp1, tvp2 )				TV_LT( *(tvp1), *(tvp2) )
X#define TVP_LE( tvp1, tpv2 )				TV_LE( *(tvp1), *(tvp2) )
X#define TVP_GT( tvp1, tvp2 )				TV_GT( *(tvp1), *(tvp2) )
X#define TVP_GE( tvp1, tvp2 )				TV_GE( *(tvp1), *(tvp2) )
X#define TVP_EQ( tvp1, tvp2 )				TV_EQ( *(tvp1), *(tvp2) )
X#define TVP_NE( tvp1, tvp2 )				TV_NE( *(tvp1), *(tvp2) )
X#define TVP_ISZERO( tvp )					TV_ISZERO( *(tvp) )
X#define TVP_ZERO( tvp )						TV_ZERO( *(tvp) )
X
X#endif	/* __TIMEMACROS_H */
END_OF_FILE
if test 3580 -ne `wc -c <'libs/src/timer/timemacros.h'`; then
    echo shar: \"'libs/src/timer/timemacros.h'\" unpacked with wrong size!
fi
# end of 'libs/src/timer/timemacros.h'
fi
if test -f 'libs/src/xlog/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'libs/src/xlog/Makefile'\"
else
echo shar: Extracting \"'libs/src/xlog/Makefile'\" \(3670 characters\)
sed "s/^X//" >'libs/src/xlog/Makefile' <<'END_OF_FILE'
X# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
X# All rights reserved.  The file named COPYRIGHT specifies the terms 
X# and conditions for redistribution.
X
X#
X# $Id: Makefile,v 2.3 1993/06/15 18:08:29 panos Exp $
X#
X# Based on Library makefile template: *Revision: 1.15 *
X#
X
X# 
X# Available entries:
X# 		lib 			--> creates the library
X#		install		--> installs the library (archive, man page(s), header(s))
X#		uninstall	--> uninstall the library
X#		clean			--> removes all .o and .a files
X#		spotless		--> clean + uninstall
X# 		lint			--> lints a file (usage: make lint MODULE=foo.c)
X#		tags			--> creates a tags file (from the SOURCES and HEADERS)
X#		checkout 	--> checkout all files
X#		dist			--> distribution support
X#
X
XNAME				= xlog
XVERSION			= 1.1.2
X
XHEADERS			= xlog.h impl.h slog.h filelog.h
XSOURCES			= xlog.c filelog.c slog.c util.c
XOBJECTS			= xlog.o filelog.o slog.o util.o
X
XMANFILES			= xlog.3
XINCLUDEFILES	= xlog.h
X
X# The following variables are used by the 'install' entry and
X# should be customized:
X#     LIBDIR:     where the library will be placed
X#     INCUDEDIR:  where the include files will be placed
X#     MANDIR:     where the man pages will be placed
X#
XLIBDIR			= $(HOME)/.links/libraries/$(ARCH)
XMANDIR			= $(HOME)/.links/manpages/man3
XINCLUDEDIR		= $(HOME)/.links/includes
X
X#
X# Flags:
X#     -DNO_SYSLOG
X#
XDEFS				=
X
XDEBUG				= -g			# -g or -O
XVERSION_DEF		= -DVERSION=\"XLOG\ Version\ $(VERSION)\"
X
XCPP_DEFS			= $(VERSION_DEF) $(DEFS)
X
X#
X# The following variables shouldn't need to be changed
X#
XLINT_FLAGS		= -hbux
XCPP_FLAGS		= $(CPP_DEFS) -I$(INCLUDEDIR)
XCC_FLAGS			= $(DEBUG)
XCFLAGS			= $(CPP_FLAGS) $(CC_FLAGS)
X
XINSTALL			= install -c
XFMODE				= -m 640			# used by install
XRANLIB			= ranlib
X
XPAGER				= less
X
X
XLIBNAME			= lib$(NAME).a
X
Xlib: $(LIBNAME)
X
Xlibopt: clean
X	make DEBUG=-O "DEFS=$(DEFS)" lib
X	$(INSTALL) $(FMODE) $(LIBNAME) $(LIBDIR)/optimized
X
X$(LIBNAME): $(OBJECTS)
X	ar r $@ $?
X	$(RANLIB) $@
X
Xlint:
X	lint $(CPP_FLAGS) $(LINT_FLAGS) $(MODULE) 2>&1 | grep -v 'possible pointer alignment' | $(PAGER)
X
Xinstall: $(LIBNAME)
X	@if test "$(LIBDIR)" -a "$(INCLUDEDIR)" -a "$(MANDIR)" ;\
X	then \
X		$(INSTALL) $(FMODE) $(LIBNAME) $(LIBDIR) ;\
X		echo "Installed $(LIBNAME) to $(LIBDIR)" ;\
X		for i in $(INCLUDEFILES); do $(INSTALL) $(FMODE) $$i $(INCLUDEDIR) ; done ;\
X		echo Installed $(INCLUDEFILES) to $(INCLUDEDIR) ;\
X		for i in $(MANFILES) ; do $(INSTALL) $(FMODE) $$i $(MANDIR) ; done ;\
X		echo Installed $(MANFILES) to $(MANDIR) ;\
X	else \
X		echo "You forgot to set one of the following variables: LIBDIR,INCLUDEDIR,MANDIR" ;\
X	fi
X
Xuninstall:
X	a=`pwd` ; cd $(INCLUDEDIR) ;\
X	if test $$a != `pwd` ; then rm -f $(INCLUDEFILES) ; fi
X	a=`pwd` ; cd $(LIBDIR) ;\
X	if test $$a != `pwd` ; then rm -f $(LIBNAME) ; fi
X	a=`pwd` ; cd $(MANDIR) ;\
X	if test $$a != `pwd` ; then rm -f $(MANFILES) ; fi
X
Xclean:
X	rm -f $(OBJECTS) $(LIBNAME) core
X
Xspotless: clean uninstall
X
Xtags: $(SOURCES) $(HEADERS)
X	ctags -w $(SOURCES) $(HEADERS)
X
Xcheckout:
X	co $(SOURCES) $(HEADERS) $(MANFILES)
X
X#
X# Distribution section
X# This section contains the 2 targets for distribution support: dist, dirs
X# "dist" checks out all files to be distributed
X# "dirs" prints a list of directories to be included in the distribution.
X# These directories should have a Makefile with a "dist" target
X#
XDISTRIBUTION_FILES	= $(SOURCES) $(HEADERS) $(MANFILES) COPYRIGHT
XDIRS						=
X
Xdist:
X	-co -q $(DISTRIBUTION_FILES)
X
Xdirs:
X	@echo $(DIRS)
X
X#
X# PUT HERE THE RULES TO MAKE THE OBJECT FILES
X#
Xxlog.o:			xlog.h impl.h
Xfilelog.o:		xlog.h impl.h filelog.h
Xslog.o:			xlog.h impl.h slog.h
X
X#
X# Test program
X#
Xxlt: xlt.c $(LIBNAME)
X	$(CC) -g -o $@ xlt.c $(LIBNAME) -L$(LIBDIR) -lstr -lsio
X
X
END_OF_FILE
if test 3670 -ne `wc -c <'libs/src/xlog/Makefile'`; then
    echo shar: \"'libs/src/xlog/Makefile'\" unpacked with wrong size!
fi
# end of 'libs/src/xlog/Makefile'
fi
echo shar: End of archive 7 \(of 31\).
cp /dev/null ark7isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 31 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
