home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-26 | 30.0 KB | 1,279 lines |
- Newsgroups: comp.sources.unix
- From: panos@cs.colorado.edu (Panos Tsirigotis)
- Subject: v26i253: xinetd-2.1.1 - inetd replacement with access control and logging, Part09/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 253
- Archive-Name: xinetd-2.1.1/part09
-
- #! /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 9 (of 31)."
- # Contents: libs/src/sio/Makefile libs/src/sio/suite/copytest.c
- # libs/src/str/strparse.3 libs/src/str/strs.3 xinetd/itox.c
- # xinetd/parsesup.c
- # 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/sio/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/sio/Makefile'\"
- else
- echo shar: Extracting \"'libs/src/sio/Makefile'\" \(4227 characters\)
- sed "s/^X//" >'libs/src/sio/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 8.6 1993/03/30 21:34:09 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 = sio
- XVERSION = 1.6.2
- X
- XHEADERS = sio.h impl.h events.h sioconf.h
- XSOURCES = sprint.c sio.c siosup.c
- XOBJECTS = sprint.o sio.o siosup.o
- X
- XMANFILES = sio.3 Sprint.3
- XINCLUDEFILES = sio.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/includes
- XINCLUDEDIR = $(HOME)/.links/manpages/man3
- X
- X#
- X# Available flags:
- X# -DDEBUG : enables assertions in the code. A failed assertion
- X# terminates the program
- X# -DEVENTS : enables code that records events (currently limited
- X# to which functions have been called on a given fd)
- X# and code that accesses the event buffers.
- X# -DLITTLE_ENDIAN : says that the machine is a little endian. This is
- X# needed if you enable EVENTS and your machine is a
- X# little endian (big endian is the default).
- X#
- X
- X#
- X# DEFS should be set from the command line; the current group of defs
- X# is for SunOS 4.x
- X#
- XDEFS = -DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY
- X
- XDEBUG = -g # -g or -O
- XVERSION_DEF = -DVERSION=\"SIO\ 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 $(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 = $(HEADERS) $(SOURCES) $(MANFILES) README COPYRIGHT
- XDIRS = suite
- 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#
- Xsprint.o: sio.h impl.h sioconf.h
- Xsio.o: sio.h impl.h sioconf.h events.h
- Xsiosup.o: sio.h impl.h sioconf.h events.h
- X
- END_OF_FILE
- if test 4227 -ne `wc -c <'libs/src/sio/Makefile'`; then
- echo shar: \"'libs/src/sio/Makefile'\" unpacked with wrong size!
- fi
- # end of 'libs/src/sio/Makefile'
- fi
- if test -f 'libs/src/sio/suite/copytest.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/sio/suite/copytest.c'\"
- else
- echo shar: Extracting \"'libs/src/sio/suite/copytest.c'\" \(4262 characters\)
- sed "s/^X//" >'libs/src/sio/suite/copytest.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: copytest.c,v 8.1 1993/03/13 01:21:48 panos Exp $" ;
- X
- X#include "sio.h"
- X#include <stdio.h>
- X#include <syscall.h>
- X
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sread
- X
- X#define BUFFER_SIZE 4096
- X
- Xmain()
- X{
- X char buf[ BUFFER_SIZE ] ;
- X int cc ;
- X int nbytes ;
- X
- X for ( ;; )
- X {
- X nbytes = random() & ( BUFFER_SIZE - 1 ) ;
- X if ( nbytes == 0 )
- X nbytes = 1 ;
- X cc = Sread( 0, buf, nbytes ) ;
- X if ( cc == 0 )
- X break ;
- X if ( cc == SIO_ERR )
- X exit( 1 ) ;
- X write( 1, buf, cc ) ;
- X }
- X exit( 0 ) ;
- X}
- X#endif /* TEST_Sread */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Swrite
- X
- X#define BUFFER_SIZE 4096
- X
- Xmain()
- X{
- X char buf[ BUFFER_SIZE ] ;
- X int cc ;
- X int nbytes ;
- X
- X for ( ;; )
- X {
- X nbytes = random() & ( BUFFER_SIZE - 1 ) ;
- X if ( nbytes == 0 )
- X nbytes = 1 ;
- X cc = read( 0, buf, nbytes ) ;
- X if ( cc == 0 )
- X break ;
- X if ( Swrite( 1, buf, cc ) != cc )
- X exit( 1 ) ;
- X }
- X exit( 0 ) ;
- X}
- X#endif /* TEST_Swrite */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Srdline
- X
- Xmain()
- X{
- X char *s ;
- X int count=0 ;
- X
- X while ( s = Srdline( 0 ) )
- X {
- X puts( s ) ;
- X count++ ;
- X }
- X Sdone( 0 ) ;
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Srdline */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sputchar
- X
- Xmain()
- X{
- X int c ;
- X
- X while ( ( c = getchar() ) != EOF )
- X if ( Sputchar( 1, c ) != c )
- X exit( 1 ) ;
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sputchar */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sgetchar
- X
- Xmain()
- X{
- X int c ;
- X
- X while ( ( c = Sgetchar( 0 ) ) != SIO_EOF )
- X putchar( c ) ;
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sgetchar */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sputc
- X
- Xmain()
- X{
- X int c ;
- X
- X while ( ( c = getchar() ) != EOF )
- X if ( Sputc( 1, c ) != c )
- X exit( 1 ) ;
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sputc */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sgetc
- X
- Xmain()
- X{
- X int c ;
- X
- X while ( ( c = Sgetc( 0 ) ) != SIO_EOF )
- X putchar( c ) ;
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sgetc */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sfetch
- X
- Xmain()
- X{
- X char *s ;
- X int len ;
- X
- X while ( s = Sfetch( 0, &len ) )
- X fwrite( s, 1, len, stdout ) ;
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sfetch */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sflush
- X
- X#define MAX_COUNT 100
- X
- Xmain()
- X{
- X int c ;
- X int errval ;
- X int count = 0 ;
- X int max_count = random() % MAX_COUNT + 1 ;
- X
- X while ( ( c = getchar() ) != EOF )
- X if ( Sputchar( 1, c ) != c )
- X exit( errval ) ;
- X else
- X {
- X count++ ;
- X if ( count >= max_count )
- X {
- X errval = Sflush( 1 ) ;
- X if ( errval != 0 )
- X exit( 1 ) ;
- X max_count = random() % MAX_COUNT + 1 ;
- X count = 0 ;
- X }
- X }
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sflush */
- X
- X/*************************************************************/
- X
- X#ifdef TEST_Sundo
- X
- Xmain()
- X{
- X int c ;
- X char *s ;
- X int errval ;
- X
- X for ( ;; )
- X {
- X if ( random() % 1 )
- X {
- X s = Srdline( 0 ) ;
- X if ( s == NULL )
- X break ;
- X if ( random() % 16 < 5 )
- X {
- X errval = Sundo( 0, SIO_UNDO_LINE ) ;
- X if ( errval == SIO_ERR )
- X exit( 1 ) ;
- X }
- X else
- X puts( s ) ;
- X }
- X else
- X {
- X c = Sgetchar( 0 ) ;
- X if ( c == SIO_EOF )
- X break ;
- X if ( random() % 16 < 5 )
- X {
- X errval = Sundo( 0, SIO_UNDO_CHAR ) ;
- X if ( errval == SIO_ERR )
- X exit( 2 ) ;
- X }
- X else
- X putchar( c ) ;
- X }
- X }
- X exit( 0 ) ;
- X}
- X
- X#endif /* TEST_Sundo */
- X
- X
- X#if defined( TEST_switch ) || defined( TEST_switch2 )
- X
- Xmain()
- X{
- X int c ;
- X char *s ;
- X int lines = 4000 ;
- X
- X for ( ;; )
- X {
- X c = Sgetchar( 0 ) ;
- X if ( c == SIO_EOF )
- X exit( 0 ) ;
- X if ( c == SIO_ERR )
- X exit( 1 ) ;
- X putchar( c ) ;
- X if ( c == '\n' )
- X {
- X lines-- ;
- X if ( lines == 0 )
- X break ;
- X }
- X }
- X while ( s = Srdline( 0 ) )
- X puts( s ) ;
- X exit( 0 ) ;
- X}
- X
- X#ifdef TEST_switch2
- X
- Xchar *mmap( addr, len, prot, type, fd, off )
- X char *addr ;
- X int len, prot, type, fd, off ;
- X{
- X return( (char *)-1 ) ;
- X}
- X
- X#endif /* TEST_switch2 */
- X
- X#endif /* TEST_switch */
- X
- X
- X
- END_OF_FILE
- if test 4262 -ne `wc -c <'libs/src/sio/suite/copytest.c'`; then
- echo shar: \"'libs/src/sio/suite/copytest.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/sio/suite/copytest.c'
- 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/str/strs.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/strs.3'\"
- else
- echo shar: Extracting \"'libs/src/str/strs.3'\" \(4394 characters\)
- sed "s/^X//" >'libs/src/str/strs.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: strs.3,v 3.1 1993/06/13 02:49:50 panos Exp $
- X.TH STRS 3X "12 June 1993"
- X.SH NAME
- Xstrs_setup, strs_match, strs_done, strs_search - string matching functions
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "str.h"
- X.LP
- X.ft B
- Xstrs_h strs_setup( flags, pattern [, patlen] )
- Xint flags ;
- Xchar *pattern ;
- X.LP
- X.ft B
- Xchar *strs_match( handle, str, len )
- Xstrs_h handle ;
- Xchar *str ;
- Xint len ;
- X.LP
- X.ft B
- Xvoid strs_done( handle )
- Xstrs_h handle ;
- X.LP
- X.ft B
- Xchar *strs_search( flags, str, len, pattern [, patlen] )
- Xint flags ;
- Xchar *str ;
- Xint len ;
- Xchar *pattern ;
- X.SH DESCRIPTION
- X.LP
- XThese functions perform string matching. They have been designed with
- Xthe assumption that one needs to find a certain pattern in a set of
- Xstrings. It is also possible to use them to find if a pattern occurs
- Xin a specific string.
- X.LP
- X.B strs_setup()
- Xis used to specify the pattern to look for. It returns a
- X.I handle
- Xwhich is used in subsequent string matching operations against
- Xthe specified
- X.I pattern.
- XThe
- X.I flags
- Xargument has two parts: a search method and generic flags.
- XThe available search methods include the following algorithms:
- X.RS
- X.TP 15
- X.SB STRS_BF
- Xbrute force algorithm (also called naive in the literature).
- X.TP
- X.SB STRS_RK
- XRabin-Karp algorithm (probabilistic).
- X.TP
- X.SB STRS_KMP
- XKnuth-Morris-Pratt algorithm.
- X.TP
- X.SB STRS_SBM
- XSimple Boyer-Moore (uses only the last occurrence heuristic).
- X.TP
- X.SB STRS_BMH
- XThis is the Boyer-Moore algorithm using the last occurrence heuristic
- Xas modified by Horspool (this is faster than the simple Boyer-Moore).
- X.TP
- X.SB STRS_SO
- XShift-Or algorithm (this algorithm works only for patterns whose length
- Xdoes not exceed the number of bits in a word).
- X.RE
- X.LP
- XThe default algorithm is the brute force method.
- XIn practice, the fastest algorithm is the
- XBoyer-Moore-Horspool one.
- X.LP
- XThe flags that can be specified include:
- X.RS
- X.TP 15
- X.SB STRS_NOMALLOC
- Xdo not allocate space for the pattern. This can be specified if
- Xthe pattern space will be available during the matching phase
- X(i.e. do not use this flag if the pattern space was malloc'ed and
- Xyou free it before doing any matching).
- X.TP
- X.SB STRS_IGNCASE
- Xperform case-insensitive string matching
- X(the default is case-sensitive matching).
- X.TP
- X.SB STRS_NOSWITCH
- Xdisallows switching to another search method; a switch to the brute
- Xforce algorithm happens if the length of the pattern is less than 4
- Xor if the initialization of the specified search algorithm fails (for
- Xexample, when using the shift-or algorithm with a very long pattern).
- XWhen this flag is used, no switch happens.
- X.TP
- X.SB STRS_PATLEN
- Xis used to explicitly specify the length of the pattern
- X(with the
- X.I patlen
- Xargument); normally the pattern is assumed to be NUL-terminated.
- X.RE
- X.LP
- X.B strs_match()
- Xtries to match the string specified by
- X.I str
- Xagainst the pattern identified by
- X.I handle.
- XSince the length of the string is given by the
- X.I len
- Xargument the string does not need to be NUL-terminated.
- X.B strs_done()
- Xshould be invoked after all matching against the pattern identified by
- X.I handle
- Xis done.
- X.LP
- X.B strs_search()
- Xis equivalent to:
- X.LP
- X.PD .1v
- X.nf
- X.RS
- Xh = strs_setup( flags, pattern ) ;
- Xp = strs_match( h, str, len ) ;
- Xstrs_done( h ) ;
- Xreturn( p ) ;
- X.RE
- X.PD
- X.SH "RETURN VALUES"
- X.LP
- X.B strs_setup()
- Xreturns a search handle on success or
- X.SM NULL
- Xon failure.
- X.LP
- X.B strs_match()
- Xand
- X.B strs_search()
- Xreturn a pointer to the first occurrence of the pattern in the string or
- X.SM NULL
- Xif the pattern does not occur in the string.
- X.SH "SEE ALSO"
- XDonald E. Knuth, James H. Morris, Vaughan R. Pratt.
- XFast pattern matching in strings.
- XSIAM Journal on Computing, 6(2):323-350, 1977.
- X.LP
- XRichard M. Karp, Michael O. Rabin.
- XEfficient randomized pattern-matching algorithms.
- XTechnical Report TR-31-81,
- XAiken Computation Laboratory, Harvard University, 1981.
- X.LP
- XRobert S. Boyer, J. Strother Moore.
- XA fast string-searching algorithm.
- XCommunications of the ACM, 20(10):762-772, 1977.
- X.LP
- XN. Horspool.
- XPractical fast searching in strings.
- XSoftware - Practice and Experience, 10:501-506, 1980.
- X.LP
- XR. Baeza-Yates, G.H. Gonnet.
- XA new approach to text searching.
- XProceedings of 12th SIGIR, June 1989.
- X.LP
- XThomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest.
- XIntroduction to Algorithms.
- XMcGraw-Hill 1990.
- END_OF_FILE
- if test 4394 -ne `wc -c <'libs/src/str/strs.3'`; then
- echo shar: \"'libs/src/str/strs.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/strs.3'
- fi
- if test -f 'xinetd/itox.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xinetd/itox.c'\"
- else
- echo shar: Extracting \"'xinetd/itox.c'\" \(4131 characters\)
- sed "s/^X//" >'xinetd/itox.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: itox.c,v 6.1 1993/06/20 21:17:37 panos Exp $" ;
- X
- X#define EQ( s1, s2 ) ( strcmp( s1, s2 ) == 0 )
- X
- X#define NUL '\0'
- X#define NULL 0
- X#define PRIVATE static
- X
- X#define FIELD_WIDTH 15
- X#define DAEMON_DIR_OPTION "-daemon_dir"
- X#define TCPD_NAME "tcpd"
- X
- X#include "sio.h"
- X#include "str.h"
- X#include "misc.h"
- X
- Xchar *strchr() ;
- X
- Xstr_h strp ;
- Xint line_count ;
- X
- X/*
- X * This program works only as a filter.
- X * Options:
- X * -daemon_dir <dir_name> : if you use tcpd, this option specifies the
- X * directory where all the daemons are.
- X * You must specify this option if you use tcpd
- X *
- X * Note that we don't bother to free the memory we malloc.
- X */
- Xint main( argc, argv )
- X int argc ;
- X char *argv[] ;
- X{
- X char *s ;
- X int uses_tcpd ;
- X char *daemon_dirpath ;
- X void print_line() ;
- X char *next_word() ;
- X
- X if ( argc != 1 && argc != 3 )
- X {
- X Sprint( 2, "Usage: %s [%s dir_path]\n",
- X basename( argv[ 0 ] ), DAEMON_DIR_OPTION ) ;
- X exit( 1 ) ;
- X }
- X
- X uses_tcpd = ( argc == 3 ) ;
- X
- X if ( uses_tcpd )
- X {
- X int len ;
- X
- X daemon_dirpath = argv[ 2 ] ;
- X len = strlen( daemon_dirpath ) ;
- X if ( daemon_dirpath[ len-1 ] == '/' )
- X daemon_dirpath[ --len ] = NUL ;
- X }
- X
- X strp = str_parse( (char *)0, " \t", STR_NOFLAGS, (int *)0 ) ;
- X
- X while ( s = Srdline( 0 ) )
- X {
- X char *word ;
- X char *p ;
- X char *socket_type, *protocol ;
- X char *service ;
- X int is_rpc ;
- X
- X line_count++ ;
- X
- X if ( SIOLINELEN( 0 ) == 0 || s[ 0 ] == '#' )
- X continue ;
- X
- X str_setstr( strp, s ) ;
- X
- X service = word = next_word( "service name" ) ;
- X
- X /*
- X * Check if it is an RPC service
- X */
- X p = strchr( word, '/' ) ;
- X if ( p != NULL )
- X *p = 0 ;
- X Sprint( 1, "service %s\n{\n", word ) ;
- X if ( is_rpc = ( p != NULL ) )
- X {
- X print_line( "type", "RPC" ) ;
- X print_line( "rpc_version", p+1 ) ;
- X }
- X
- X socket_type = word = next_word( "socket type" ) ;
- X print_line( "socket_type", socket_type ) ;
- X
- X word = next_word( "protocol" ) ;
- X p = strchr( word, '/' ) ;
- X protocol = ( p == NULL ) ? word : p+1 ;
- X
- X print_line( "protocol", protocol ) ;
- X
- X word = next_word( "wait/nowait" ) ;
- X print_line( "wait", EQ( word, "wait" ) ? "yes" : "no" ) ;
- X
- X word = next_word( "user" ) ;
- X print_line( "user", word ) ;
- X
- X word = next_word( "server" ) ;
- X if ( EQ( word, "internal" ) )
- X {
- X /*
- X * We are in trouble if this is an RPC service
- X */
- X if ( is_rpc )
- X {
- X Sprint( 2,
- X "The entry for service %s will be wrong because\n", service ) ;
- X Sprint( 2, "we can't handle internal RPC services\n" ) ;
- X }
- X else
- X {
- X print_line( "type", "INTERNAL" ) ;
- X print_line( "id", make_string( 3, service, "-", socket_type ) ) ;
- X }
- X }
- X else
- X {
- X char *server_path = word ; /* from inetd.conf */
- X char *server_of_server_path = basename( server_path ) ;
- X char *server_name = next_word( "server name" ) ;
- X char *server ; /* for xinetd config file */
- X
- X if ( EQ( server_of_server_path, TCPD_NAME ) )
- X {
- X if ( ! uses_tcpd )
- X {
- X Sprint( 2, "You must use option %s if you use %s\n",
- X DAEMON_DIR_OPTION, TCPD_NAME ) ;
- X exit( 1 ) ;
- X }
- X if ( server_name[ 0 ] == '/' )
- X server = server_name ;
- X else
- X server = make_pathname( 2, daemon_dirpath, server_name ) ;
- X }
- X else
- X server = server_path ;
- X
- X print_line( "server", server ) ;
- X
- X word = str_component( strp ) ; /* 1st arg */
- X if ( word != NULL )
- X {
- X Sprint( 1, "\t%-*s = %s", FIELD_WIDTH, "server_args", word ) ;
- X while ( word = str_component( strp ) )
- X Sprint( 1, " %s", word ) ;
- X Sputchar( 1, '\n' ) ;
- X }
- X }
- X
- X Sprint( 1, "}\n\n" ) ;
- X }
- X Sflush( 1 ) ;
- X exit( 0 ) ;
- X}
- X
- X
- XPRIVATE void print_line( name, value )
- X char *name, *value ;
- X{
- X Sprint( 1, "\t%-*s = %s\n", FIELD_WIDTH, name, value ) ;
- X}
- X
- X
- XPRIVATE char *next_word( description )
- X char *description ;
- X{
- X char *word = str_component( strp ) ;
- X
- X if ( word == NULL )
- X {
- X Sprint( 2, "Line %d: %s missing \n", line_count, description ) ;
- X exit( 1 ) ;
- X }
- X return( word ) ;
- X}
- X
- END_OF_FILE
- if test 4131 -ne `wc -c <'xinetd/itox.c'`; then
- echo shar: \"'xinetd/itox.c'\" unpacked with wrong size!
- fi
- # end of 'xinetd/itox.c'
- fi
- if test -f 'xinetd/parsesup.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xinetd/parsesup.c'\"
- else
- echo shar: Extracting \"'xinetd/parsesup.c'\" \(4301 characters\)
- sed "s/^X//" >'xinetd/parsesup.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 <ctype.h>
- X#include <syslog.h>
- X
- X#include "str.h"
- X#include "pset.h"
- X#include "sio.h"
- X
- X#include "defs.h"
- X#include "parse.h"
- X
- Xvoid parsemsg() ;
- X
- Xextern int line_count ;
- X
- X/*
- X * next_line returns the next line of the file or NULL if the end of file
- X * is reached.
- X * Comment lines and empty lines are skipped.
- X */
- Xchar *next_line( fd )
- X int fd ;
- X{
- X for ( ;; )
- X {
- X register char *p ;
- X register char *line = Srdline( fd ) ;
- X
- X if ( line == NULL )
- X return( NULL ) ;
- X
- X line_count++ ;
- X
- X for ( p = line ;; p++ )
- X if ( *p == NUL || *p == COMMENT_BEGIN )
- X break ; /* skip this line */
- X else if ( isspace( *p ) )
- X continue ; /* skip white space */
- X else
- X return( line ) ;
- X }
- X}
- X
- X
- X
- X/*
- X * Input:
- X * a line of the form
- X * name [SPACE] OP [SPACE] value [SPACE] value ...
- X *
- X * Recognize the attribute name and operator and place them in *attrp, *opp
- X *
- X * Currently, we allow any non-space character to be used in the
- X * attribute name.
- X *
- X * Return value: a pointer to the character after OP.
- X */
- XPRIVATE char *get_attr_op( line, attrp, opp )
- X char *line ;
- X char **attrp ;
- X enum assign_op *opp ;
- X{
- X register char *p ;
- X char *attr ;
- X enum assign_op op ;
- X char *func = "get_attr_op" ;
- X
- X /*
- X * First get the attribute name
- X */
- X for ( p = line ; isspace( *p ) ; p++ ) ; /* skip spaces */
- X if ( *p == NUL )
- X {
- X parsemsg( LOG_ERR, func, "Empty line" ) ;
- X return( NULL ) ;
- X }
- X
- X attr = p ;
- X for ( ; ! isspace( *p ) ; p++ ) ; /* skip attribute name */
- X if ( *p == NUL )
- X {
- X parsemsg( LOG_ERR, func, "Nothing after attribute: %s", attr ) ;
- X return( NULL ) ;
- X }
- X *p++ = NUL ; /* now attribute name is NUL terminated */
- X
- X while ( isspace( *p ) ) p++ ; /* skip spaces */
- X
- X switch ( *p )
- X {
- X case NUL:
- X parsemsg( LOG_ERR, func, "Nothing after attribute: %s", attr ) ;
- X return( NULL ) ;
- X
- X case '=':
- X op = SET_EQ ;
- X break ;
- X
- X case '+':
- X case '-':
- X op = ( *p++ == '+' ) ? PLUS_EQ : MINUS_EQ ;
- X if ( *p == '=' )
- X break ;
- X
- X /* FALL THROUGH if there is no '=' after the '+' or '-' */
- X
- X default:
- X parsemsg( LOG_ERR, func, "Bad operator for attribute: %s", attr ) ;
- X return( NULL ) ;
- X }
- X *attrp = attr ;
- X *opp = op ;
- X return( ++p ) ; /* skip the '=' */
- X}
- X
- X
- X/*
- X * Parse a line of the form:
- X * name OP value value value ...
- X * where each value is a string and OP can be '=', '+=', '-='
- X *
- X * NOTE: We do not allocate space for the name and values. Instead we keep
- X * pointers to the line.
- X */
- Xstatus_e parse_line( line, namep, opp, values )
- X char *line ;
- X char **namep ;
- X enum assign_op *opp ;
- X pset_h values ;
- X{
- X char *value ;
- X char *values_string ;
- X char *attribute ;
- X str_h strp ;
- X char *func = "parse_line" ;
- X
- X if ( ( values_string = get_attr_op( line, &attribute, opp ) ) == NULL )
- X return( FAILED ) ;
- X
- X /*
- X * Now grab the values
- X */
- X strp = str_parse( values_string, " \t", STR_RETURN_ERROR, (int *)0 ) ;
- X if ( strp == NULL )
- X {
- X parsemsg( LOG_CRIT, func, ES_NOMEM ) ;
- X return( FAILED ) ;
- X }
- X
- X while ( value = str_component( strp ) )
- X {
- X if ( pset_add( values, value ) == NULL )
- X {
- X parsemsg( LOG_CRIT, func, ES_NOMEM ) ;
- X str_endparse( strp ) ;
- X return( FAILED ) ;
- X }
- X }
- X
- X str_endparse( strp ) ;
- X *namep = attribute ;
- X return( OK ) ;
- X}
- X
- X
- Xvoid skip_entry( fd )
- X register int fd ;
- X{
- X for ( ;; )
- X {
- X register char *line = next_line( fd ) ;
- X
- X if ( line == NULL ) /* reached EOF ? */
- X {
- X parsemsg( LOG_WARNING, "skip_entry",
- X "missing %c in last service entry", ENTRY_END ) ;
- X break ;
- X }
- X
- X if ( line_has_only_1_char( line, ENTRY_END ) )
- X break ;
- X }
- X}
- X
- X
- X
- X/*
- X * Returns TRUE if the given line contains a single instance of the
- X * specified character and no other non-space characters
- X */
- Xint line_has_only_1_char( line, ch )
- X char *line ;
- X char ch ;
- X{
- X register char *p ;
- X register char target_char = ch ;
- X
- X for ( p = line ; *p ; p++ )
- X if ( *p == target_char )
- X target_char = NUL ;
- X else if ( ! isspace( *p ) )
- X return( FALSE ) ;
- X return( target_char != ch ) ;
- X}
- X
- X
- END_OF_FILE
- if test 4301 -ne `wc -c <'xinetd/parsesup.c'`; then
- echo shar: \"'xinetd/parsesup.c'\" unpacked with wrong size!
- fi
- # end of 'xinetd/parsesup.c'
- fi
- echo shar: End of archive 9 \(of 31\).
- cp /dev/null ark9isdone
- 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
-