home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-26 | 33.1 KB | 1,255 lines |
- Newsgroups: comp.sources.unix
- From: panos@cs.colorado.edu (Panos Tsirigotis)
- Subject: v26i249: xinetd-2.1.1 - inetd replacement with access control and logging, Part05/31
- Sender: unix-sources-moderator@gw.home.vix.com
- Approved: vixie@gw.home.vix.com
-
- Submitted-By: panos@cs.colorado.edu (Panos Tsirigotis)
- Posting-Number: Volume 26, Issue 249
- Archive-Name: xinetd-2.1.1/part05
-
- #! /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 5 (of 31)."
- # Contents: libs/src/misc/env.3 libs/src/pset/pset.h
- # libs/src/sio/events.h libs/src/str/README libs/src/str/ss_impl.h
- # libs/src/str/ss_so.c libs/src/str/strprint.3 libs/src/xlog/impl.h
- # xinetd/options.c
- # Wrapped by panos@mystique on Mon Jun 21 14:51:21 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'libs/src/misc/env.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/misc/env.3'\"
- else
- echo shar: Extracting \"'libs/src/misc/env.3'\" \(2942 characters\)
- sed "s/^X//" >'libs/src/misc/env.3' <<'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.\" $Id: env.3,v 1.1 1992/10/20 20:44:30 panos Exp $
- X.TH ENV 3L "20 October 1992"
- X.SH NAME
- Xenv_create, env_destroy, env_make, env_addvar, env_addstr, env_remvar, env_lookup, env_getvars -- environment manipulation functions
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "env.h"
- X.LP
- X.ft B
- Xenv_h env_create( env )
- Xenv_h env ;
- X.LP
- X.ft B
- Xvoid env_destroy( env )
- Xenv_h env ;
- X.LP
- X.ft B
- Xenv_h env_make( env_strings )
- Xchar **env_strings ;
- X.LP
- X.ft B
- Xint env_addvar( env, from_env, var )
- Xenv_h env ;
- Xenv_h from_env ;
- Xchar *var ;
- X.LP
- X.ft B
- Xint env_addstr( env, str )
- Xenv_h env ;
- Xchar *str ;
- X.LP
- X.ft B
- Xint env_remvar( env, var )
- Xenv_h env ;
- Xchar *var ;
- X.LP
- X.ft B
- Xchar **env_getvars( env )
- Xenv_h env ;
- X.SH DESCRIPTION
- XThis library handles environments. An environment is a set of strings
- Xof the form
- X.I "name=value".
- XIn the following, we will use the term string as a synonym of
- XNUL-terminated array of
- X.I char.
- X.LP
- X.B env_create()
- Xcreates a new environment. The new environment will be empty unless
- Xthe argument
- X.I env
- Xis not
- X.SB ENV_NULL.
- XIn that case, the new environment will be a duplicate of
- X.I env
- X(i.e. they will contain the same strings).
- X.LP
- X.B env_destroy()
- Xdestroys the specified environment.
- X.LP
- X.B env_make()
- Xcreates a new environment which includes the
- X.I env_strings.
- X.I env_strings
- Xshould be a NULL-terminated array of strings.
- X.LP
- X.B env_addvar()
- Xadds the specified variable
- X.I var
- Xto
- X.I env.
- XThe variable value is obtained from the environment
- X.I from_env.
- XIf the variable exists already in
- X.I env
- Xthe old value is replaced with the new value.
- X.LP
- X.B env_addstr()
- Xadds a string of the form
- X.I "name=value"
- Xto
- X.I env.
- X.LP
- X.B env_remvar()
- Xremoves the specified variable
- X.I var
- Xfrom the environment
- X.I env.
- X.LP
- X.B env_lookup()
- Xsearches
- X.I env
- Xfor variable
- X.I var.
- XIt returns a string of the form
- X.I "name=value"
- Xwhere
- X.I name
- Xis the name of the variable
- X(i.e. it is equal to
- X.I var).
- X.LP
- X.B env_getvars
- Xreturns a NULL-terminated array of strings of the form
- X.I "name=value".
- X.SH "RETURN VALUES"
- XIn case of error, all calls will place an error code in the global variable
- X.I env_errno.
- XPossible error codes:
- X.TP 15
- X.SB ENV_ENOMEM
- Xout of memory
- X.TP
- X.SB ENV_EBADVAR
- Xvariable is not in environment
- X.TP
- X.SB ENV_EBADSTRING
- Xstring is not well-formed (i.e. is not of the form \fIname=value\fR).
- X.LP
- X.B env_create()
- Xreturns a handle or
- X.SM ENV_NULL
- Xif it fails.
- X.LP
- X.B env_make()
- Xreturns a handle or
- X.SM ENV_NULL
- Xif it fails.
- X.LP
- X.B env_addvar()
- Xreturns
- X.SM ENV_OK
- Xon success or
- X.SM ENV_ERR
- Xon failure.
- X.LP
- X.B env_addstr()
- Xreturns
- X.SM ENV_OK
- Xon success or
- X.SM ENV_ERR
- Xon failure.
- X.LP
- X.B env_remvar()
- Xreturns
- X.SM ENV_OK
- Xon success or
- X.SM ENV_ERR
- Xif the variable is not part of the environment.
- X.LP
- X.B env_loopkup()
- Xreturns a string on success or
- X.SM NULL
- Xon failure.
- X.SH "SEE ALSO"
- Xenviron(5)
- END_OF_FILE
- if test 2942 -ne `wc -c <'libs/src/misc/env.3'`; then
- echo shar: \"'libs/src/misc/env.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/misc/env.3'
- fi
- if test -f 'libs/src/pset/pset.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/pset/pset.h'\"
- else
- echo shar: Extracting \"'libs/src/pset/pset.h'\" \(3125 characters\)
- sed "s/^X//" >'libs/src/pset/pset.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#ifndef __PSET_H
- X#define __PSET_H
- X
- X/*
- X * $Id: pset.h,v 3.1 1993/03/06 18:50:18 panos Exp $
- X */
- X
- Xtypedef void *__pset_pointer ;
- X
- Xstruct __pset
- X{
- X unsigned alloc_step ;
- X __pset_pointer *ptrs ;
- X unsigned max ;
- X unsigned count ;
- X} ;
- X
- X
- X/*
- X * INTERFACE
- 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
- Xtypedef struct __pset *pset_h ;
- X
- Xpset_h pset_create __ARGS( ( unsigned start, unsigned step ) ) ;
- Xvoid pset_destroy __ARGS( ( pset_h ) ) ;
- X
- X__pset_pointer pset_insert __ARGS( ( pset_h, __pset_pointer ) ) ;
- Xvoid pset_delete __ARGS( ( pset_h, __pset_pointer ) ) ;
- X
- Xvoid pset_compact __ARGS( ( pset_h ) ) ;
- Xvoid pset_uniq __ARGS( ( pset_h, void (*func)(), void *arg ) ) ;
- Xvoid pset_apply __ARGS( ( pset_h, void (*func)(), void *arg ) ) ;
- X
- X/*
- X * Macros
- X */
- X#define pset_add( pset, ptr ) \
- X ( \
- X ( (pset)->count < (pset)->max ) \
- X ? (pset)->ptrs[ (pset)->count++ ] = (__pset_pointer) ptr \
- X : pset_insert( (pset), (__pset_pointer) ptr ) \
- X )
- X
- X#define pset_remove( pset, ptr ) pset_delete( pset, (__pset_pointer)ptr )
- X
- X#define pset_remove_index( pset, i ) \
- X { \
- X if ( (i) < (pset)->count ) \
- X (pset)->ptrs[ i ] = (pset)->ptrs[ --(pset)->count ] ; \
- X }
- X
- X#define pset_clear( pset ) (pset)->count = 0
- X#define pset_count( pset ) (pset)->count
- X#define pset_pointer( pset, i ) (pset)->ptrs[ i ]
- X
- X#define pset_sort( pset, compfunc ) \
- X (void) qsort( (char *) &pset_pointer( pset, 0 ), \
- X pset_count( pset ), sizeof( __pset_pointer ), compfunc )
- X
- X/*
- X * PSET iterators
- X *
- X * Note that the iterators do NOT use any knowledge about the internals
- X * of pset's.
- X */
- Xstruct __pset_iterator
- X{
- X pset_h pset ;
- X unsigned current ;
- X int step ;
- X} ;
- X
- Xtypedef struct __pset_iterator *psi_h ;
- X
- X
- X#define __psi_current( iter ) \
- X ( (iter)->current < pset_count( (iter)->pset ) \
- X ? pset_pointer( (iter)->pset, (iter)->current ) \
- X : NULL )
- X
- X#define psi_start( iter ) \
- X ( (iter)->current = 0, (iter)->step = 1, \
- X __psi_current( iter ) )
- X
- X#define psi_next( iter ) \
- X ( (iter)->current += (iter)->step, (iter)->step = 1, \
- X __psi_current( iter ) )
- X
- X#define psi_remove( iter ) \
- X { \
- X if ( (iter)->current < pset_count( (iter)->pset ) ) \
- X { \
- X pset_remove_index( (iter)->pset, (iter)->current ) ; \
- X (iter)->step = 0 ; \
- X } \
- X }
- X
- X#define psi_reset( iter, newpset ) (iter)->pset = (newpset)
- X
- X#define psi_destroy( iter ) free( (char *) iter )
- X
- Xpsi_h psi_create __ARGS( ( pset_h ) ) ;
- X
- X#endif /* __PSET_H */
- X
- END_OF_FILE
- if test 3125 -ne `wc -c <'libs/src/pset/pset.h'`; then
- echo shar: \"'libs/src/pset/pset.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/pset/pset.h'
- fi
- if test -f 'libs/src/sio/events.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/sio/events.h'\"
- else
- echo shar: Extracting \"'libs/src/sio/events.h'\" \(3168 characters\)
- sed "s/^X//" >'libs/src/sio/events.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/*
- X * $Id: events.h,v 8.1 1993/03/13 01:13:58 panos Exp $
- X */
- X
- X/*
- X * Event codes
- X *
- X * We use a 2 letter code so that events that accumulate in a buffer
- X * can be displayed as a string
- X * We follow the convention that the first event letter is a capitalized
- X * and the second letter is in lower case. This allows one to easily
- X * recognize events in an event string.
- X */
- X
- X/*
- X * The ENCODE macro takes 2 characters and creates a short integer
- X * The size of the short integer is assumed to be 16-bits.
- X * The macro makes sure that regardless of the endianess of the machine,
- X * the low order byte contains the 1st character and the high order byte
- X * contains the 2nd character.
- X */
- X#ifdef LITTLE_ENDIAN
- X#define ENCODE( c1, c2 ) ( (c1) + ( (c2) << 8 ) )
- X#else /* BIG_ENDIAN */
- X#define ENCODE( c1, c2 ) ( (c2) + ( (c1) << 8 ) )
- X#endif
- X
- X/*
- X * Event codes for SIO interface functions
- X * We use the first 2 lettes after the initial 'S'
- X */
- X#define EV_SGETC ENCODE( 'G', 'e' )
- X#define EV_SPUTC ENCODE( 'P', 'u' )
- X#define EV_SREAD ENCODE( 'R', 'e' )
- X#define EV_SWRITE ENCODE( 'W', 'r' )
- X#define EV_SRDLINE ENCODE( 'R', 'd' )
- X#define EV_SFETCH ENCODE( 'F', 'e' )
- X#define EV_SUNDO ENCODE( 'U', 'n' )
- X#define EV_SDONE ENCODE( 'D', 'o' )
- X#define EV_SFLUSH ENCODE( 'F', 'l' )
- X#define EV_SCLOSE ENCODE( 'C', 'l' )
- X#define EV_STIE ENCODE( 'T', 'i' )
- X#define EV_SUNTIE ENCODE( 'U', 't' )
- X#define EV_SBUFTYPE ENCODE( 'B', 'u' )
- X
- X/*
- X * Event codes for internal functions
- X * For the __sio_<name> functions we use 'S' and the first letter of <name>
- X * For the rest we use the first letter from the first two components of
- X * their name, for example for try_memory_mapping we use Tm.
- X */
- X#define EV_SIO_INIT ENCODE( 'S', 'i' )
- X#define EV_SIO_SWITCH ENCODE( 'S', 's' )
- X#define EV_SIO_READF ENCODE( 'S', 'r' )
- X#define EV_SIO_WRITEF ENCODE( 'S', 'w' )
- X#define EV_SIO_EXTEND_BUFFER ENCODE( 'S', 'e' )
- X#define EV_SIO_MORE ENCODE( 'S', 'm' )
- X#define EV_TRY_MEMORY_MAPPING ENCODE( 'T', 'm' )
- X#define EV_INITIAL_MAP ENCODE( 'I', 'm' )
- X#define EV_MAP_UNIT ENCODE( 'M', 'u' )
- X#define EV_INIT_INPUT_STREAM ENCODE( 'I', 'i' )
- X#define EV_INIT_OUTPUT_STREAM ENCODE( 'I', 'o' )
- X
- X/*
- X * The # of entries must be a power of 2
- X */
- X#define EVENT_ENTRIES 512
- X
- Xstruct events
- X{
- X short next ;
- X short start ;
- X short *codes ; /* malloc'ed memory */
- X} ;
- X
- Xtypedef struct events events_s ;
- X
- Xextern events_s *__sio_events ;
- X
- X
- X#define ADD( index, x ) (index) += x ; \
- X (index) &= ( EVENT_ENTRIES - 1 )
- X
- X#define EVENT( fd, code ) \
- X { \
- X events_s *evp = &__sio_events[ fd ] ; \
- X \
- X if ( evp->codes != NULL ) \
- X { \
- X evp->codes[ evp->next ] = code ; \
- X ADD( evp->next, 1 ) ; \
- X if ( evp->next == evp->start ) \
- X { ADD( evp->start, 1 ) ; } \
- X } \
- X }
- X
- END_OF_FILE
- if test 3168 -ne `wc -c <'libs/src/sio/events.h'`; then
- echo shar: \"'libs/src/sio/events.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/sio/events.h'
- fi
- if test -f 'libs/src/str/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/README'\"
- else
- echo shar: Extracting \"'libs/src/str/README'\" \(3029 characters\)
- sed "s/^X//" >'libs/src/str/README' <<'END_OF_FILE'
- X======================================================================
- XNOTE: I use vi with a tabstop value of 3. Using the same tabstop
- X value will make the text/code look properly indented.
- X======================================================================
- X
- X
- X1. What is this library about ?
- X
- XThe STR library consists of string handling functions. These
- Xfunctions can be separated into 4 groups:
- X
- XA. String matching functions. A variety of algorithms are available
- X for string matching:
- X brute force
- X Rabin-Karp
- X Knuth-Morris-Pratt
- X Boyer-Moore
- X Shift-or
- X
- XB. String printing functions (similar to sprintf). These functions offer
- X 2 significant advantages over sprintf:
- X 1) they include functions that will *not* overrun the string buffer
- X provided
- X 2) they include functions returning "char *" as well as functions
- X returning "int" so that one can pick the most appropriate one.
- X
- XC. String parsing functions. These functions offer an easy way of breaking
- X a string into pieces.
- X
- XD. String utility functions. This group includes functions that will
- X convert a string to upper/lower case etc.
- X
- X
- X2. Setting up the STR library
- X
- XAll you need to do is type 'make'. This will create the library in the
- Xcurrent directory. The string printing functions use (and therefore
- Xrequire) the underlying format conversion facility of my SIO (Stream
- XI/O) library. If you don't want to bother with it, you can define the
- Xflag NO_SIO in the Makefile (check the Makefile comments on how to do
- Xthis) which will turn all string printing functions to no-ops. The SIO
- Xlibrary is available from mystique.cs.colorado.edu in the directory
- Xpub/libs (it may also be available at other places). Make sure you get
- XSIO version 1.6.2 or later; versions prior to 1.6.2 will result in
- Xidentical behavior between the strx_*print* and the str_*print*
- Xfunctions.
- X
- XTo install the library and the associated man pages and include files
- Xtype 'make install'. This will install the library in LIBDIR, the man
- Xpages in MANDIR and the include files in INCLUDEDIR. LIBDIR,
- XINCLUDEDIR, and MANDIR are Makefile variables that you can edit in the
- XMakefile or override when you invoke 'make'.
- X
- X
- X
- X3. Epilogue
- X
- XPlease send bug-reports/comments to panos@cs.colorado.edu
- X
- XYou can obtain the latest version of this library from
- Xmystique.cs.colorado.edu in the directory pub/libs.
- X
- XFeel free to modify the library to suit your needs. If you want to
- Xdistribute modifications to this library, please read the COPYRIGHT
- Xfile. It basically says that you are free to redistribute as long as
- Xyou retain the original copyright notice and you make sure that your
- Xmodifications are identifiable. In order to achieve this I have
- Xreserved the first 3 components of the version number (for example,
- X1.4.2) and you can identify your mods by appending another component to
- Xthat version number (for example, 1.4.2.A2). Also, if you distribute a
- Xmodified version of the library, you take full responsibility for any
- Xbugs in the code (not just your code; the whole thing).
- X
- END_OF_FILE
- if test 3029 -ne `wc -c <'libs/src/str/README'`; then
- echo shar: \"'libs/src/str/README'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/README'
- fi
- if test -f 'libs/src/str/ss_impl.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/ss_impl.h'\"
- else
- echo shar: Extracting \"'libs/src/str/ss_impl.h'\" \(2969 characters\)
- sed "s/^X//" >'libs/src/str/ss_impl.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#ifndef SS_IMPL_H
- X#define SS_IMPL_H
- X
- X/*
- X * $Id: ss_impl.h,v 3.2 1993/06/16 00:06:34 panos Exp $
- X */
- X
- X/*
- X * NBIC is the Number-of-Bits-In-a-Char
- X */
- X#ifndef NBIC
- X#define NBIC 8
- X#endif
- X
- X#define ALPHABET_SIZE ( 1 << NBIC )
- X
- X#ifndef WIDE_INT
- X#define WIDE_INT long
- X#define WIDE_INT_SIZE 32 /* bits */
- X#endif
- X
- Xtypedef WIDE_INT wide_int ;
- Xtypedef unsigned WIDE_INT u_wide_int ;
- X
- X
- X#include "ss_rk.h"
- X#include "ss_kmp.h"
- X#include "ss_sbm.h"
- X#include "ss_bmh.h"
- X#include "ss_so.h"
- X
- X#include "str.h"
- X
- Xstruct ss_ops
- X{
- X int (*so_setup)() ;
- X char *(*so_match)() ;
- X void (*so_done)() ;
- X} ;
- X
- X
- Xstruct ss_header
- X{
- X char *ss_pattern ;
- X int ss_patlen ;
- X int ss_flags ;
- X char *ss_map ; /* either identity or upper->lower */
- X struct ss_ops *ss_ops ;
- X union ss_headers
- X {
- X struct rk_header rkh ;
- X struct kmp_header kmph ;
- X struct sbm_header sbmh ;
- X struct bmh_header bmhh ;
- X struct so_header soh ;
- X } ss_h ;
- X} ;
- X
- Xtypedef struct ss_header header_s ;
- X
- X#define HP( p ) ((header_s *)(p))
- X
- X/*
- X * Structure field access
- X */
- X#define SS_PATTERN( hp ) (hp)->ss_pattern
- X#define SS_PATLEN( hp ) (hp)->ss_patlen
- X#define SS_FLAGS( hp ) (hp)->ss_flags
- X#define SS_OPS( hp ) (hp)->ss_ops
- X#define SS_SETMAP( hp, map ) (hp)->ss_map = map
- X#define SS_MAP( hp, c ) (hp)->ss_map[ (unsigned char) (c) ]
- X
- X/*
- X * Predicates
- X */
- X#define SS_MALLOC( hp ) ( ! ( SS_FLAGS( hp ) & STRS_NOMALLOC ) )
- X#define SS_IGNCASE( hp ) ( SS_FLAGS( hp ) & STRS_IGNCASE )
- X#define SS_SWITCH( hp ) ( ! ( SS_FLAGS( hp ) & STRS_NOSWITCH ) )
- X#define SS_SETMALLOC( hp ) SS_FLAGS( hp ) &= ~ STRS_NOMALLOC
- X
- X/*
- X * Indirect op invocation
- X */
- X#define SS_SETUP( hp ) (*SS_OPS( hp )->so_setup)( hp )
- X#define SS_MATCH( hp, str, len ) (*SS_OPS( hp )->so_match)( hp, str, len )
- X#define SS_DONE( hp ) (*SS_OPS( hp )->so_done)( hp )
- X
- X/*
- X * Header extraction
- X */
- X#define RK_HEADER( hp ) (&(hp)->ss_h.rkh)
- X#define KMP_HEADER( hp ) (&(hp)->ss_h.kmph)
- X#define SBM_HEADER( hp ) (&(hp)->ss_h.sbmh)
- X#define BMH_HEADER( hp ) (&(hp)->ss_h.bmhh)
- X#define SO_HEADER( hp ) (&(hp)->ss_h.soh)
- X
- X/*
- X * Macros to extract method and flags from the 'flags' argument
- X */
- X#define METHOD_BITS 5 /* flag bits devoted to methods */
- X#define METHOD_MASK ( ( 1 << METHOD_BITS ) - 1 )
- X#define SS_GETMETHOD( x ) ( (x) & METHOD_MASK )
- X#define SS_GETFLAGS( x ) ( (x) & ~METHOD_MASK )
- X
- X
- Xstruct ss_select
- X{
- X int sel_method ;
- X struct ss_ops *sel_ops ;
- X} ;
- X
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- X#ifndef FALSE
- X#define FALSE 0
- X#define TRUE 1
- X#endif
- X
- X#define CHAR_NULL ((char *)0)
- X#define NULL_HANDLE ((strs_h)0)
- X
- X#define PRIVATE static
- X
- X
- X/*
- X * Return values
- X */
- X#define SS_OK 0
- X#define SS_ERR (-1)
- X
- X#endif /* SS_IMPL_H */
- X
- END_OF_FILE
- if test 2969 -ne `wc -c <'libs/src/str/ss_impl.h'`; then
- echo shar: \"'libs/src/str/ss_impl.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/ss_impl.h'
- fi
- if test -f 'libs/src/str/ss_so.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/ss_so.c'\"
- else
- echo shar: Extracting \"'libs/src/str/ss_so.c'\" \(2898 characters\)
- sed "s/^X//" >'libs/src/str/ss_so.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: ss_so.c,v 3.1 1993/06/13 02:46:12 panos Exp $" ;
- X
- Xchar *malloc() ;
- X
- X#include "ss_impl.h"
- X
- XPRIVATE int so_setup() ;
- XPRIVATE char *so_match() ;
- XPRIVATE void so_done() ;
- X
- Xstruct ss_ops __strs_soops = { so_setup, so_match, so_done } ;
- X
- X/*
- X * There is a single twist in this implementation of the shift-or algorithm:
- X * To make the check for complete match faster, we are using the sign-bit
- X * of the word. This means that everything is shifted to the left by
- X * (word_size - pattern_length)
- X */
- X
- XPRIVATE int so_setup( hp )
- X header_s *hp ;
- X{
- X register wide_int *maskbuf ;
- X register wide_int mask ;
- X register wide_int offset_mask ;
- X register int i ;
- X int offset ;
- X register int patlen = SS_PATLEN( hp ) ;
- X register char *pattern = SS_PATTERN( hp ) ;
- X
- X if ( patlen > WIDE_INT_SIZE )
- X return( SS_ERR ) ;
- X
- X maskbuf = (wide_int *) malloc( ALPHABET_SIZE * sizeof( wide_int ) ) ;
- X if ( maskbuf == (wide_int *)NULL )
- X return( SS_ERR ) ;
- X
- X offset = WIDE_INT_SIZE - patlen ;
- X offset_mask = ( (~0) << offset ) ;
- X
- X /*
- X * The bits of each word that won't be used must be set to 0
- X */
- X for ( i = 0 ; i < ALPHABET_SIZE ; i++ )
- X maskbuf[ i ] = offset_mask ;
- X
- X for ( i = 0, mask = 1 << offset ; i < patlen ; i++, mask <<= 1 )
- X maskbuf[ (unsigned char) pattern[ i ] ] &= ~mask ;
- X
- X SO_HEADER( hp )->mask = maskbuf ;
- X SO_HEADER( hp )->offset_mask = offset_mask ;
- X return( SS_OK ) ;
- X}
- X
- X
- XPRIVATE char *so_match( hp, str, len )
- X register header_s *hp ;
- X char *str ;
- X int len ;
- X{
- X register char *p ;
- X register char pfc = SS_PATTERN( hp )[ 0 ] ;
- X register wide_int *mask = SO_HEADER( hp )->mask ;
- X register char *endmatch = &str[ len - SS_PATLEN( hp ) + 1 ] ;
- X char *endstr = &str[ len ] ;
- X wide_int no_match_state = ~0 & SO_HEADER( hp )->offset_mask ;
- X
- X /*
- X * The shift-or algorithm can be described by the following for-loop:
- X *
- X * for ( p = str ; p < endstr ; p++ )
- X * {
- X * state = ( state << 1 ) | mask[ (unsigned char) SS_MAP( hp, *p ) ] ;
- X * if ( state >= 0 )
- X * return( &p[ -SS_PATLEN( hp ) + 1 ] ) ;
- X * }
- X *
- X * For efficiency reasons, the algorithm is used only after the first
- X * character of the pattern is matched against a character of the string.
- X */
- X
- X for ( p = str ; p < endmatch ; p++ )
- X {
- X register wide_int state ;
- X
- X if ( SS_MAP( hp, *p ) != pfc )
- X continue ;
- X
- X for ( state = no_match_state ; p < endstr ; p++ )
- X {
- X state = ( state << 1 ) | mask[ (unsigned char) SS_MAP( hp, *p ) ] ;
- X if ( state >= 0 )
- X return( &p[ -SS_PATLEN( hp ) + 1 ] ) ;
- X if ( state == no_match_state )
- X break ;
- X }
- X }
- X return( CHAR_NULL ) ;
- X}
- X
- X
- XPRIVATE void so_done( hp )
- X header_s *hp ;
- X{
- X (void) free( (char *) SO_HEADER( hp )->mask ) ;
- X}
- X
- END_OF_FILE
- if test 2898 -ne `wc -c <'libs/src/str/ss_so.c'`; then
- echo shar: \"'libs/src/str/ss_so.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/ss_so.c'
- fi
- if test -f 'libs/src/str/strprint.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/strprint.3'\"
- else
- echo shar: Extracting \"'libs/src/str/strprint.3'\" \(3148 characters\)
- sed "s/^X//" >'libs/src/str/strprint.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: strprint.3,v 3.1 1993/06/13 02:48:55 panos Exp $
- X.TH STRPRINT 3X "30 September 1992"
- X.SH NAME
- Xstr_sprint, tr_sprintv, str_nprint, str_nprintv, str_print, str_printv, strx_sprint, strx_sprintv, strx_nprint, strx_nprintv, strx_print, strx_printv -- formatted conversion to string
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "str.h"
- X.LP
- X.ft B
- Xchar *str_sprint( buf, format, ... )
- Xchar *buf ;
- Xchar *format ;
- X.LP
- X.ft B
- Xchar *str_sprintv( buf, format, ap )
- Xchar *buf ;
- Xchar *format ;
- Xva_list ap ;
- X.LP
- X.ft B
- Xint str_nprint( buf, format, ... )
- Xchar *buf ;
- Xchar *format ;
- X.LP
- X.ft B
- Xint str_nprintv( buf, format, ap )
- Xchar *buf ;
- Xchar *format ;
- Xva_list ap ;
- X.LP
- X.ft B
- Xvoid str_print( countp, buf, format, ... )
- Xint *countp ;
- Xchar *buf ;
- Xchar *format ;
- X.LP
- X.ft B
- Xvoid str_printv( countp, buf, format, ap )
- Xint *countp ;
- Xchar *buf ;
- Xchar *format ;
- Xva_list ap ;
- X.LP
- X.ft B
- Xchar *strx_sprint( buf, len, format, ... )
- Xchar *buf ;
- Xint len ;
- Xchar *format ;
- X.LP
- X.ft B
- Xchar *strx_sprintv( buf, len, format, ap )
- Xchar *buf ;
- Xint len ;
- Xchar *format ;
- Xva_list ap ;
- X.LP
- X.ft B
- Xint strx_nprint( buf, len, format, ... )
- Xchar *buf ;
- Xint len ;
- Xchar *format ;
- X.LP
- X.ft B
- Xint strx_nprintv( buf, len, format, ap )
- Xchar *buf ;
- Xint len ;
- Xchar *format ;
- Xva_list ap ;
- X.LP
- X.ft B
- Xvoid strx_print( countp, buf, len, format, ... )
- Xint *countp ;
- Xchar *buf ;
- Xint len ;
- Xchar *format ;
- X.LP
- X.ft B
- Xvoid strx_printv( countp, buf, len, format, ap )
- Xint *countp ;
- Xchar *buf ;
- Xint len ;
- Xchar *format ;
- Xva_list ap ;
- X.SH DESCRIPTION
- X.LP
- XAll functions are similar in functionality to \fIsprintf()\fR.
- XTheir only difference is in their return values. For information about their
- Xconversion capabilities, check \fISprint(3)\fR.
- X.LP
- XThe difference between the \fIstr_*\fR and the \fIstrx_*\fR functions
- Xis that the latter take an extra argument, the size of the buffer, so
- Xthat they will never write beyond the end of the buffer. Writing
- Xbeyond the end of the buffer is possible with the \fIstr_*\fR functions.
- XInvoking any of the \fIstrx_*\fR functions with the
- X.I len
- Xargument set to 0
- Xis the same as calling the equivalent \fIstr_*\fR function.
- X.LP
- XAll functions will append a
- X.SM NUL
- Xat the end of
- X.I buf
- X(the \fIstrx_*\fR functions will not do this if it would cause
- Xa buffer overrun).
- X.LP
- X.B str_print(),
- X.B str_printv(),
- X.B strx_print(),
- Xand
- X.B strx_printv()
- Xwill put in
- X.I "*countp"
- Xthe number of characters placed in
- X.I buf
- Xexcluding the ending
- X.SM NUL
- X(this happens only if
- X.I "*countp"
- Xis not
- X.SM NULL
- X).
- X.LP
- XThe functions that have a name ending in 'v' are similar to those without
- Xthe 'v' at the end of their name
- Xexcept that instead of accepting a variable number of arguments, they
- Xexpect a \fIvarargs(3)\fR argument list.
- X.SH "RETURN VALUES"
- X.LP
- X.B str_sprint(),
- X.B str_sprintv(),
- X.B strx_sprint(),
- Xand
- X.B strx_sprintv()
- Xreturn
- X.I buf.
- X.LP
- X.B str_nprint(),
- X.B str_nprintv(),
- X.B strx_nprint(),
- Xand
- X.B strx_nprintv()
- Xreturn the number of characters placed in
- X.I buf
- Xexcluding the ending
- X.SM NUL.
- X.SH "SEE ALSO"
- XSprint(3)
- END_OF_FILE
- if test 3148 -ne `wc -c <'libs/src/str/strprint.3'`; then
- echo shar: \"'libs/src/str/strprint.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/strprint.3'
- fi
- if test -f 'libs/src/xlog/impl.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/xlog/impl.h'\"
- else
- echo shar: Extracting \"'libs/src/xlog/impl.h'\" \(2862 characters\)
- sed "s/^X//" >'libs/src/xlog/impl.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/*
- X * $Id: impl.h,v 2.1 1993/05/06 07:40:05 panos Exp $
- X */
- X
- X
- X#define DEFINE_LINK_TYPE( type, name ) struct { type *next, *prev ; } name
- X
- X
- X#define NEXT( obj, field ) (obj)->field.next
- X#define PREV( obj, field ) (obj)->field.prev
- X
- X#define INIT_LINKS( obj, field ) \
- X { \
- X NEXT( obj, field ) = obj ; \
- X PREV( obj, field ) = obj ; \
- X }
- X
- X/*
- X * Link new object after object using the specified field
- X */
- X#define LINK( obj, new_obj, field ) \
- X { \
- X NEXT( new_obj, field ) = NEXT( obj, field ) ; \
- X PREV( new_obj, field ) = obj ; \
- X NEXT( obj, field ) = new_obj ; \
- X PREV( NEXT( obj, field ), field ) = new_obj ; \
- X }
- X
- X#define UNLINK( obj, field ) \
- X { \
- X NEXT( PREV( obj, field ), field ) = NEXT( obj, field ) ; \
- X PREV( NEXT( obj, field ), field ) = PREV( obj, field ) ; \
- X }
- X
- X
- X/*
- X * xlog linking:
- X * When xlog1 is linked to xlog2 (i.e. errors on xlog1 are reported to
- X * xlog2) we use the xl_clients field on xlog2 and the xl_other_users
- X * field on xlog1
- X */
- Xstruct xlog
- X{
- X xlog_e xl_type ;
- X char *xl_id ;
- X int xl_flags ;
- X void (*xl_callback)() ;
- X void *xl_callback_arg ;
- X struct xlog *xl_use ; /* xlog we report errors to */
- X struct xlog *xl_clients ; /* linked list of xlogs that use */
- X /* this xlog to report errors */
- X DEFINE_LINK_TYPE( struct xlog, xl_other_users ) ;
- X struct xlog_ops
- X {
- X int (*init) __ARGS( ( struct xlog *, va_list ) ) ;
- X void (*fini) __ARGS( ( struct xlog * ) ) ;
- X int (*write) __ARGS( ( struct xlog *, char *, int, int, va_list ) ) ;
- X int (*control) __ARGS( ( struct xlog *, xlog_cmd_e, va_list ) ) ;
- X int (*parms) __ARGS( ( va_list ) ) ;
- X } *xl_ops ;
- X void *xl_data ;
- X} ;
- X
- X#define XL_INIT( xp, ap ) (*(xp)->xl_ops->init)( (xp), (ap) )
- X#define XL_FINI( xp ) (*(xp)->xl_ops->fini)( xp )
- X#define XL_WRITE( xp, buf, size, flags, ap ) \
- X (*(xp)->xl_ops->write)( (xp), (buf), (size), (flags), (ap ) )
- X#define XL_CONTROL( xp, cmd, ap ) \
- X (*(xp)->xl_ops->control)( (xp), (cmd), (ap) )
- X
- Xtypedef struct xlog xlog_s ;
- X
- Xtypedef void (*voidfunc)() ;
- Xtypedef int bool_int ;
- X
- X#define XP( p ) ((struct xlog *)(p))
- X
- X#define XLOG_NULL XP( NULL )
- X
- X#ifndef FALSE
- X#define FALSE 0
- X#define TRUE 1
- X#endif
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- X#define NEW( type ) (type *) malloc( sizeof( type ) )
- X#define FREE( p ) (void) free( (char *)p )
- X
- X#define PRIVATE static
- X
- Xchar *__xlog_add_errno() ;
- Xchar *__xlog_explain_errno() ;
- Xchar *__xlog_new_string() ;
- X
- Xchar *malloc() ;
- X
- END_OF_FILE
- if test 2862 -ne `wc -c <'libs/src/xlog/impl.h'`; then
- echo shar: \"'libs/src/xlog/impl.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/xlog/impl.h'
- fi
- if test -f 'xinetd/options.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xinetd/options.c'\"
- else
- echo shar: Extracting \"'xinetd/options.c'\" \(3203 characters\)
- sed "s/^X//" >'xinetd/options.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
- X#include "options.h"
- X
- X/*
- X * $Id: options.opt,v 6.2 1993/04/22 23:37:23 panos Exp $
- X */
- X
- X
- X#define NULL 0
- X
- Xvoid exit() ;
- X
- Xint d_option ;
- Xint f_option ;
- Xchar * f_option_arg_1 ;
- Xint filelog_option ;
- Xchar * filelog_option_arg_1 ;
- Xint syslog_option ;
- Xchar * syslog_option_arg_1 ;
- Xint reuse_option ;
- Xint limit_option ;
- Xunsigned limit_option_arg_1 ;
- Xint loop_option ;
- Xunsigned loop_option_arg_1 ;
- Xint pid_option ;
- Xint logprocs_option ;
- Xunsigned logprocs_option_arg_1 ;
- Xint shutdownprocs_option ;
- Xunsigned shutdownprocs_option_arg_1 ;
- Xint cc_option ;
- Xunsigned cc_option_arg_1 ;
- X
- Xchar *program_name ;
- X
- Xint opt_recognize( argc, argv )
- X int argc ;
- X char *argv[] ;
- X{
- X int arg ;
- X char *strrchr() ;
- X
- X program_name = strrchr( argv[ 0 ], '/' ) ;
- X program_name = ( program_name == NULL ) ? argv[ 0 ] : program_name + 1 ;
- X
- X for ( arg = 1 ; arg < argc ; arg++ )
- X if ( argv[ arg ][ 0 ] == '-' && argv[ arg ][ 1 ] != 0 )
- X {
- X if ( strcmp( &argv[ arg ][ 1 ], "d" ) == 0 )
- X d_option = 1 ;
- X else if ( strcmp( &argv[ arg ][ 1 ], "f" ) == 0 )
- X {
- X if ( ++arg == argc )
- X usage() ;
- X f_option_arg_1 = ( argv[ arg ] ) ;
- X f_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "filelog" ) == 0 )
- X {
- X if ( ++arg == argc )
- X usage() ;
- X filelog_option_arg_1 = ( argv[ arg ] ) ;
- X filelog_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "syslog" ) == 0 )
- X {
- X if ( ++arg == argc )
- X usage() ;
- X syslog_option_arg_1 = ( argv[ arg ] ) ;
- X syslog_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "reuse" ) == 0 )
- X reuse_option = 1 ;
- X else if ( strcmp( &argv[ arg ][ 1 ], "limit" ) == 0 )
- X {
- X int atoi() ;
- X
- X if ( ++arg == argc )
- X usage() ;
- X limit_option_arg_1 = atoi( argv[ arg ] ) ;
- X limit_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "loop" ) == 0 )
- X {
- X int atoi() ;
- X
- X if ( ++arg == argc )
- X usage() ;
- X loop_option_arg_1 = atoi( argv[ arg ] ) ;
- X loop_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "pid" ) == 0 )
- X pid_option = 1 ;
- X else if ( strcmp( &argv[ arg ][ 1 ], "logprocs" ) == 0 )
- X {
- X int atoi() ;
- X
- X if ( ++arg == argc )
- X usage() ;
- X logprocs_option_arg_1 = atoi( argv[ arg ] ) ;
- X logprocs_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "shutdownprocs" ) == 0 )
- X {
- X int atoi() ;
- X
- X if ( ++arg == argc )
- X usage() ;
- X shutdownprocs_option_arg_1 = atoi( argv[ arg ] ) ;
- X shutdownprocs_option = 1 ;
- X }
- X else if ( strcmp( &argv[ arg ][ 1 ], "cc" ) == 0 )
- X {
- X int atoi() ;
- X
- X if ( ++arg == argc )
- X usage() ;
- X cc_option_arg_1 = atoi( argv[ arg ] ) ;
- X cc_option = 1 ;
- X }
- X }
- X else
- X break ;
- X
- X if ( filelog_option + syslog_option > 1 )
- X usage() ;
- X
- X
- X if ( argc - arg != 0 )
- X usage() ;
- X return( arg ) ;
- X}
- X
- Xvoid usage()
- X{
- X Sprint( 2, "Usage: %s [-d] [-f config_file] [-filelog filename] [-syslog facility] [-reuse] [-limit proc_limit] [-loop loop_rate] [-pid] [-logprocs limit] [-shutdownprocs limit] [-cc interval]\n", program_name ) ;
- X exit( 1 ) ;
- X}
- END_OF_FILE
- if test 3203 -ne `wc -c <'xinetd/options.c'`; then
- echo shar: \"'xinetd/options.c'\" unpacked with wrong size!
- fi
- # end of 'xinetd/options.c'
- fi
- echo shar: End of archive 5 \(of 31\).
- cp /dev/null ark5isdone
- 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
-