home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-28 | 32.7 KB | 1,291 lines |
- Newsgroups: comp.sources.unix
- From: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
- Subject: v27i114: clc - C Libraries Collection, Part08/20
- References: <1.754527080.23891@gw.home.vix.com>
- Sender: unix-sources-moderator@gw.home.vix.com
- Approved: vixie@gw.home.vix.com
-
- Submitted-By: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
- Posting-Number: Volume 27, Issue 114
- Archive-Name: clc/part08
-
- #! /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 8 (of 20)."
- # Contents: libs/src/misc/ftwx.c libs/src/sio/suite/tester
- # libs/src/str/strparse.3 libs/src/timer/Makefile
- # libs/src/timer/timemacros.h libs/src/xlog/Makefile
- # libs/src/xlog/slog.c
- # Wrapped by panos@eclipse on Sun Nov 28 14:48:16 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- 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/sio/suite/tester' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/sio/suite/tester'\"
- else
- echo shar: Extracting \"'libs/src/sio/suite/tester'\" \(3962 characters\)
- sed "s/^X//" >'libs/src/sio/suite/tester' <<'END_OF_FILE'
- X#!/bin/sh
- 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# $Id: tester,v 8.3 1993/09/08 05:59:30 panos Exp $
- X#
- X
- X#
- X# Usage:
- X# tester [all] [function-name function-name ...]
- X#
- X# function-name is the name of a sio function (or macro)
- X#
- X# If "all" is used, functions after it will *not* be tested.
- X#
- X
- Xscript_name=`basename $0`
- X
- Xcopy_file=/usr/dict/words
- Xtemp_file=/tmp/w
- Xmake_log=MAKE.LOG
- X
- Xif test ! -f $copy_file ; then
- X echo "The file '$copy_file' is not available."
- X echo "Please edit the '$script_name' script and change set the"
- X echo "variable 'copy_file' to the name of a publicly readable file"
- X echo "with at least a few tens of thousands of lines."
- X exit 1
- Xfi
- X
- Xtrap_function()
- X{
- X rm -f $temp_file $make_log
- X echo
- X exit 1
- X}
- X
- X
- Xmake_program()
- X{
- X target=$1
- X cflags="$2"
- X if test -f $1 -a ! -x $1 ; then rm -f $1 ; fi
- X if test "$cflags"
- X then
- X make -s "$cflags" $target >$make_log 2>&1
- X else
- X make -s $target >$make_log 2>&1
- X fi
- X exit_code=$?
- X if test $exit_code -eq 0 -a -x $1
- X then
- X rm -f $make_log
- X else
- X echo "FAILED"
- X echo " The make failed. Check the make log file << $make_log >>"
- X exit
- X fi
- X}
- X
- X
- X
- X#
- X# test_function expects a single argument, the name of the function
- X# it will test.
- X# It creates a program that has the name of the function by invoking
- X# make with the symbol -DTEST_<function_name>
- X#
- Xtest_function()
- X{
- X expression="echo $"$1
- X var=`eval $expression`
- X if test "$var" = "no" -o "$var" = "" -a "$all" = "no" ; then return ; fi
- X
- X echo -n "TESTING $1 "
- X make_program $1 "DEFS=-DTEST_$1"
- X
- X ./$1 < $copy_file >$temp_file
- X exit_code=$?
- X if test $exit_code -ne 0
- X then
- X echo "FAILED"
- X echo " Test program exited with exit code $exit_code"
- X echo " Temporary file << $temp_file >> not deleted"
- X exit
- X fi
- X cmp -s $copy_file $temp_file
- X if test $? -ne 0
- X then
- X echo "FAILED"
- X echo " The files << $copy_file >> and << $temp_file >> are not the same"
- X exit
- X else
- X echo PASSED
- X fi
- X rm -f $temp_file
- X}
- X
- X
- Xtest_sprint()
- X{
- X var=$Sprint
- X program=Sprint
- X if test "$var" = "no" -o "$var" = "" -a "$all" = "no" ; then return ; fi
- X
- X echo TESTING Sprint
- X make_program $program ""
- X $TESTSHELL sprint_test
- X}
- X
- X
- Xtest_smorefds()
- X{
- X var=$Smorefds
- X program=fdtest
- X if test "$var" = "no" -o "$var" = "" -a "$all" = "no" ; then return ; fi
- X
- X echo -n "TESTING Smorefds "
- X make_program $program "DEFS="
- X v=`fdtest 2>&1`
- X if test $? -eq 0 ; then
- X echo PASSED
- X else
- X echo "FAILED: $v"
- X fi
- X}
- X
- X
- Xtrap trap_function 1 2 3 15
- X
- X#
- X# There is a variable for every function to be tested. That variable
- X# can have the values "yes", "no" or "".
- X# When a function is specified, it takes the value of $run. Initially $run
- X# is "yes", so a specified function has its variable set to "yes".
- X# If "all" is specified, $run becomes "no", so subsequently specified
- X# functions, have their variables set to "no".
- X#
- X# We test a function iff:
- X# its variable is "yes" OR its variable is "" and $all is "yes"
- X# We don't test a function iff:
- X# its variable is "no" OR its variable is "" and $all is "no"
- X#
- X# Therefore, all functions specified after "all" will NOT be tested.
- X#
- Xrun=yes
- Xall=no
- X
- Xwhile test $# -gt 0
- Xdo
- X case $1 in
- X Sputchar) Sputchar=$run ;;
- X Sgetchar) Sgetchar=$run ;;
- X Srdline) Srdline=$run ;;
- X Sfetch) Sfetch=$run ;;
- X Sread) Sread=$run ;;
- X Swrite) Swrite=$run ;;
- X Sgetc) Sgetc=$run ;;
- X Sputc) Sputc=$run ;;
- X Sflush) Sflush=$run ;;
- X Sundo) Sundo=$run ;;
- X Sprint) Sprint=$run ;;
- X switch) switch=$run ;;
- X switch2) switch2=$run ;;
- X Smorefds) Smorefds=$run ;;
- X all) all=yes ; run="no" ;;
- X *) echo Bad argument: $1
- X esac
- X shift
- Xdone
- X
- Xtest_function Sgetchar
- Xtest_function Sputchar
- Xtest_function Sread
- Xtest_function Swrite
- Xtest_function Srdline
- Xtest_function Sfetch
- Xtest_function Sgetc
- Xtest_function Sputc
- Xtest_function Sflush
- Xtest_function Sundo
- Xtest_function switch
- Xtest_function switch2
- Xtest_smorefds
- Xtest_sprint
- X
- END_OF_FILE
- if test 3962 -ne `wc -c <'libs/src/sio/suite/tester'`; then
- echo shar: \"'libs/src/sio/suite/tester'\" unpacked with wrong size!
- fi
- # end of 'libs/src/sio/suite/tester'
- fi
- if test -f 'libs/src/str/strparse.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/strparse.3'\"
- else
- echo shar: Extracting \"'libs/src/str/strparse.3'\" \(4130 characters\)
- sed "s/^X//" >'libs/src/str/strparse.3' <<'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.\" $Id: strparse.3,v 3.1 1993/06/13 02:48:02 panos Exp $
- X.TH STRPARSE 3X "30 September 1992"
- X.SH NAME
- Xstr_parse, str_endparse, str_component, str_separator, str_nextpos
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "str.h"
- X.LP
- X.ft B
- Xstr_h str_parse( str, separ, flags, errnop )
- Xchar *str ;
- Xchar *separ ;
- Xint flags ;
- Xint *errnop ;
- X.LP
- X.ft B
- Xvoid str_endparse( handle )
- Xstr_h handle ;
- X.LP
- X.ft B
- Xchar *str_component( handle )
- Xstr_h handle ;
- X.LP
- X.ft B
- Xint str_setstr( handle, newstr )
- Xstr_h handle ;
- Xchar *newstr ;
- X.LP
- X.ft B
- Xint str_separator( handle, separ )
- Xstr_h handle ;
- Xchar *separ ;
- X.LP
- X.ft B
- Xchar *str_nextpos( handle )
- Xstr_h handle ;
- X.LP
- Xextern int str_errno ;
- X.SH DESCRIPTION
- X.LP
- XThese functions are useful for parsing strings. In this context
- Xparsing means breaking the string into substrings. The substrings are
- Xseparated by a list of possible separator characters.
- X.LP
- X.B str_component()
- Xreturns successive substrings of the string.
- X.B str_parse()
- Xcreates and initializes a string parser with the string
- Xthat will be processed, \fIstr\fR, the list of possible separator
- Xcharacters, \fIsepar\fR, and flags that control how the parser
- Xworks. The \fIflags\fR argument is formed by ORing one or more of
- Xthe following constants:
- X.TP 20
- X.SB STR_RETURN_ERROR
- XIf something goes wrong return a value that indicates that an error occured
- X(e.g. out of memory). The default is for the program to be terminated
- Xwith an appropriate error message.
- X.TP
- X.SB STR_NULL_START
- XIf \fIstr\fR starts with a separator then a zero-length string will be returned
- Xthe first time \fBstr_component()\fR is called.
- X.TP
- X.SB STR_NULL_END
- XIf \fIstr\fR ends with a separator then a zero-length string will be returned
- Xby \fBstr_component()\fR when the substrings of \fIstr\fR are exhausted.
- X.TP
- X.SB STR_MALLOC
- XThe strings returned by \fBstr_component()\fR will be in malloc'ed memory.
- XBy default the substrings are part of \fIstr\fR.
- XIf this option is not used \fIstr\fR will be modified
- Xby \fBstr_component()\fR.
- X.LP
- XFinally, \fBSTR_NOFLAGS\fR may be used to specify no flags.
- XThe \fIerrnop\fR argument points to an integer where the string processing
- Xfunctions will deposit an error code if an error occurs.
- XIf \fIerrnop\fR
- Xis
- X.SM NULL
- Xthe error codes will be placed in \fIstr_errno\fR.
- XThis is useful only if \fBSTR_RETURN_ERROR\fR is used in \fIflags\fR.
- XIt is possible that \fIstr\fP is
- X.SM NULL.
- XIn this case, a subsequent
- X.B str_setstr()
- Xshould be used to specify the string to be processed.
- X.LP
- X.B str_component()
- Xreturns successive substrings from the string associated with the
- Xparser specified by \fIhandle\fR.
- X.LP
- X.B str_endparse()
- Xdestroys the parser specified by \fIhandle\fR.
- X.LP
- X.B str_setstr()
- Xchanges the processed string to \fInewstr\fP.
- X.LP
- X.B str_separator()
- Xreplaces the list of separator characters with \fIsepar\fR.
- XProcessing continues from the current position.
- X.LP
- X.B str_nextpos()
- Xreturns a pointer to the rest of the string. The previous character
- Xis a separator character (if \fBSTR_MALLOC\fR is not set, then the
- Xprevious character is
- X.SM NUL
- X).
- X.SH "RETURN VALUES"
- X.LP
- X.B str_parse()
- Xreturns a parser handle or
- X.SM NULL
- Xif something goes wrong and \fIflags\fR & \fBSTR_RETURN_ERROR\fR is true.
- XPossible \fIstr_errno\fR values:
- X.RS
- X.TP 20
- X.SB STR_ENULLSEPAR
- X\fIsepar\fR is
- X.SM NULL
- X.TP
- X.SB STR_ENOMEM
- Xthe program ran out of memory
- X.RE
- X.LP
- X.B str_component()
- Xreturns a pointer to the next substring or
- X.SM NULL
- Xif something goes wrong and \fIflags\fR & \fBSTR_RETURN_ERROR\fR is true.
- X.LP
- X.B str_setstr()
- Xreturns
- X.SB STR_OK
- Xon success or
- X.SB STR_ERR
- Xon failure.
- X.LP
- X.B str_separator()
- Xreturns
- X.SB STR_OK
- Xon success or
- X.SB STR_ERR
- Xon failure.
- X.LP
- X.B str_nextpos()
- Xreturns a pointer or
- X.SM NULL
- Xif the end of string has been reached.
- X.SH BUGS
- X.B str_component()
- Xmodifies the string unless \fBSTR_MALLOC\fR is
- Xset in the parser.
- X.LP
- XThere should be only one parser active on a specific string. If there
- Xis more than
- Xone, they all must use the \fBSTR_MALLOC\fR option.
- X
- END_OF_FILE
- if test 4130 -ne `wc -c <'libs/src/str/strparse.3'`; then
- echo shar: \"'libs/src/str/strparse.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/strparse.3'
- fi
- if test -f 'libs/src/timer/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/timer/Makefile'\"
- else
- echo shar: Extracting \"'libs/src/timer/Makefile'\" \(4062 characters\)
- sed "s/^X//" >'libs/src/timer/Makefile' <<'END_OF_FILE'
- 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# $Id: Makefile,v 5.1 93/11/26 12:38:00 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 = timer
- XVERSION = 1.3.0
- X
- XHEADERS = timer.h impl.h ostimer.h timemacros.h defs.h
- XSOURCES = timer.c ostimer.c sysdep.c
- XOBJECTS = timer.o ostimer.o sysdep.o
- X
- XMANFILES = timer.3 timemacros.3
- XINCLUDEFILES = timer.h timemacros.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# Available flags:
- X#
- X# DEBUG : enable some debugging code; terminate in case
- X# of error
- X# DEBUG_REPORT_ERRORS : print debugging messages
- X# NO_POSIX_SIGS : sigaction is not available (but sigvec is)
- X# NO_ITIMER_REAL : don't use ITIMER_REAL timers
- X# NO_ITIMER_VIRTUAL : don't use ITIMER_VIRTUAL timers
- X# NO_ITIMER_PROF : don't use ITIMER_PROF timers
- X#
- XDEFS = -DDEBUG -DNO_POSIX_SIGS
- XDEBUG = -g # -g or -O
- XVERSION_DEF = -DVERSION=\"TIMER\ 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 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 | $(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 STATES
- 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#
- Xtimer.o: timemacros.h impl.h timer.h defs.h
- Xostimer.o: ostimer.h timemacros.h impl.h timer.h defs.h
- Xsysdep.o: ostimer.h timemacros.h impl.h timer.h defs.h
- X
- Xttest: ttest.c $(LIBNAME)
- X cc $(DEBUG) -o $@ ttest.c $(LIBNAME) -L$(LIBDIR) -lpq
- X
- END_OF_FILE
- if test 4062 -ne `wc -c <'libs/src/timer/Makefile'`; then
- echo shar: \"'libs/src/timer/Makefile'\" unpacked with wrong size!
- fi
- # end of 'libs/src/timer/Makefile'
- 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'\" \(3697 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 5.1 93/11/26 12:10:31 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 make sure the result is normalized 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/*
- X * We handle the possibility of underflow in advance in case
- X * tv_usec is an unsigned integer.
- X */
- X#define TV_SUB( tv_res, tv1, tv2 ) \
- X { \
- X if ( (tv1).tv_usec < (tv2).tv_usec ) \
- X { \
- X (tv1).tv_usec += __ONE_MILLION ; \
- X (tv1).tv_sec-- ; \
- X } \
- X (tv_res).tv_sec = (tv1).tv_sec - (tv2).tv_sec ; \
- X (tv_res).tv_usec = (tv1).tv_usec - (tv2).tv_usec ; \
- 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 3697 -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'\" \(3745 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.4 1993/10/28 01:39:07 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.3
- 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 : do not use syslog
- X# -DSYSLOG_IN_SYS : syslog.h is in /usr/include/sys
- 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 3745 -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
- if test -f 'libs/src/xlog/slog.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/xlog/slog.c'\"
- else
- echo shar: Extracting \"'libs/src/xlog/slog.c'\" \(4152 characters\)
- sed "s/^X//" >'libs/src/xlog/slog.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: slog.c,v 2.3 1993/10/28 01:37:48 panos Exp $" ;
- X
- X#include <varargs.h>
- X
- X#ifndef NO_SYSLOG
- X# ifndef SYSLOG_IN_SYS
- X# include <syslog.h>
- X# else
- X# include <sys/syslog.h>
- X# endif
- X#endif
- X
- X#include "xlog.h"
- X#include "impl.h"
- X#include "slog.h"
- X
- X#define MSGBUFSIZE 2048
- X
- X
- XPRIVATE int syslog_init() ;
- XPRIVATE void syslog_fini() ;
- XPRIVATE int syslog_control() ;
- XPRIVATE int syslog_write() ;
- XPRIVATE int syslog_parms() ;
- X
- Xstatic struct syslog_parms parms =
- X {
- X 0,
- X#ifndef NO_SYSLOG
- X
- X#ifdef LOG_PID
- X LOG_PID +
- X#endif
- X#ifdef LOG_NOWAIT
- X LOG_NOWAIT +
- X#endif
- X 0,
- X LOG_USER,
- X
- X#else /* NO_SYSLOG */
- X
- X 0,
- X 0,
- X
- X#endif /* ! NO_SYSLOG */
- X "XLOG"
- X } ;
- X
- X
- Xstruct xlog_ops __xlog_syslog_ops =
- X {
- X syslog_init,
- X syslog_fini,
- X syslog_write,
- X syslog_control,
- X syslog_parms
- X } ;
- X
- X#ifdef NO_SYSLOG
- X
- X/*
- X * Notice that the following functions will never be invoked since
- X * the xlog_* functions will not call them. However, we need to define
- X * them so that we don't have any unresolved references; and we define
- X * them without any arguments.
- X */
- XPRIVATE void syslog()
- X{
- X}
- X
- XPRIVATE void openlog()
- X{
- X}
- X
- XPRIVATE void closelog()
- X{
- X}
- X
- X#else
- X
- Xvoid closelog() ;
- X
- X#endif /* NO_SYSLOG */
- X
- X
- X/*
- X * Expected arguments:
- X * facility, level
- X */
- XPRIVATE int syslog_init( xp, ap )
- X xlog_s *xp ;
- X va_list ap ;
- X{
- X register struct syslog_parms *slp = &parms ;
- X struct syslog *sp ;
- X
- X sp = NEW( struct syslog ) ;
- X if ( sp == NULL )
- X return( XLOG_ENOMEM ) ;
- X
- X sp->sl_facility = va_arg( ap, int ) ;
- X sp->sl_default_level = va_arg( ap, int ) ;
- X if ( slp->slp_n_xlogs++ == 0 )
- X openlog( slp->slp_ident, slp->slp_logopts, slp->slp_facility ) ;
- X xp->xl_data = sp ;
- X return( XLOG_ENOERROR ) ;
- X}
- X
- X
- XPRIVATE void syslog_fini( xp )
- X xlog_s *xp ;
- X{
- X if ( --parms.slp_n_xlogs == 0 )
- X closelog() ;
- X FREE( SYSLOG( xp ) ) ;
- X xp->xl_data = NULL ;
- X}
- X
- X
- XPRIVATE int syslog_control( xp, cmd, ap )
- X xlog_s *xp ;
- X xlog_cmd_e cmd ;
- X va_list ap ;
- X{
- X switch ( cmd )
- X {
- X case XLOG_LEVEL:
- X SYSLOG( xp )->sl_default_level = va_arg( ap, int ) ;
- X break ;
- X
- X case XLOG_FACILITY:
- X SYSLOG( xp )->sl_facility = va_arg( ap, int ) ;
- X break ;
- X
- X case XLOG_PREEXEC:
- X closelog() ;
- X break ;
- X
- X case XLOG_POSTEXEC:
- X if ( parms.slp_n_xlogs )
- X openlog( parms.slp_ident, parms.slp_logopts, parms.slp_facility ) ;
- X break ;
- X
- X case XLOG_GETFD:
- X return( XLOG_EBADOP ) ;
- X }
- X return( XLOG_ENOERROR ) ;
- X}
- X
- X
- XPRIVATE int syslog_write( xp, buf, len, flags, ap )
- X xlog_s *xp ;
- X char buf[] ;
- X int len ;
- X int flags ;
- X va_list ap ;
- X{
- X int level ;
- X int syslog_arg ;
- X char prefix[ MSGBUFSIZE ] ;
- X int prefix_size = sizeof( prefix ) ;
- X int prefix_len = 0 ;
- X int cc ;
- X char *percent_m_pos ;
- X int action_flags = ( flags | xp->xl_flags ) ;
- X
- X if ( flags & XLOG_SET_LEVEL )
- X level = va_arg( ap, int ) ;
- X else
- X level = SYSLOG( xp )->sl_default_level ;
- X syslog_arg = SYSLOG( xp )->sl_facility + level ;
- X
- X if ( action_flags & XLOG_PRINT_ID )
- X {
- X cc = strx_nprint( &prefix[ prefix_len ], prefix_size, "%s: ",
- X xp->xl_id ) ;
- X prefix_len += cc ;
- X prefix_size -= cc ;
- X }
- X
- X if ( ( action_flags & XLOG_NO_ERRNO ) ||
- X ( percent_m_pos = __xlog_add_errno( buf, len ) ) == NULL )
- X syslog( syslog_arg, "%.*s%.*s", prefix_len, prefix, len, buf ) ;
- X else
- X {
- X int cc_before_errno = percent_m_pos - buf ;
- X int cc_after_errno = len - cc_before_errno - 2 ;
- X char *ep ;
- X char errno_buf[ 100 ] ;
- X unsigned size = sizeof( errno_buf ) ;
- X
- X ep = __xlog_explain_errno( errno_buf, &size ) ;
- X syslog( syslog_arg, "%.*s%.*s%.*s%.*s",
- X prefix_len, prefix,
- X cc_before_errno, buf,
- X (int)size, ep,
- X cc_after_errno, &percent_m_pos[ 2 ] ) ;
- X }
- X return( XLOG_ENOERROR ) ;
- X}
- X
- X
- XPRIVATE int syslog_parms( ap )
- X va_list ap ;
- X{
- X char *__xlog_new_string() ;
- X char *id = __xlog_new_string( va_arg( ap, char * ) ) ;
- X
- X if ( id == NULL )
- X return( XLOG_ENOMEM ) ;
- X parms.slp_ident = id ;
- X parms.slp_logopts = va_arg( ap, int ) ;
- X parms.slp_facility = va_arg( ap, int ) ;
- X return( XLOG_ENOERROR ) ;
- X}
- X
- END_OF_FILE
- if test 4152 -ne `wc -c <'libs/src/xlog/slog.c'`; then
- echo shar: \"'libs/src/xlog/slog.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/xlog/slog.c'
- fi
- echo shar: End of archive 8 \(of 20\).
- cp /dev/null ark8isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 20 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
-