home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-28 | 31.9 KB | 1,187 lines |
- Newsgroups: comp.sources.unix
- From: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
- Subject: v27i112: clc - C Libraries Collection, Part06/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 112
- Archive-Name: clc/part06
-
- #! /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 6 (of 20)."
- # Contents: libs/src/dict/ht.3 libs/src/fsma/Makefile
- # libs/src/fsma/fsma.3 libs/src/misc/misc.c libs/src/pq/pq.3
- # libs/src/pset/Makefile libs/src/sio/events.h libs/src/str/README
- # 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/dict/ht.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/dict/ht.3'\"
- else
- echo shar: Extracting \"'libs/src/dict/ht.3'\" \(3388 characters\)
- sed "s/^X//" >'libs/src/dict/ht.3' <<'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.\" $Id: ht.3,v 3.4 93/11/23 20:07:28 panos Exp $
- X.TH HT 3X "23 April 1993"
- X.SH NAME
- Xht_create, ht_destroy, ht_insert, ht_insert_uniq, ht_delete, ht_search, ht_minimum, ht_maximum, ht_successor, ht_predecessor, ht_iterate, ht_nextobj - hash table management functions
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "dict.h"
- X#include "ht.h"
- X.LP
- X.ft B
- Xdict_h ht_create( oo_compare, ko_compare, flags, errnop, argsp )
- Xint (*oo_compare)( dict_obj, dict_obj ) ;
- Xint (*ko_compare)( dict_key, dict_obj ) ;
- Xint flags ;
- Xint *errnop ;
- Xstruct ht_args *argsp ;
- X.LP
- X.ft B
- Xvoid ht_destroy( handle )
- Xdict_h handle ;
- X.LP
- X.ft B
- Xint ht_insert( handle, object )
- Xdict_h handle ;
- Xdict_obj object ;
- X.LP
- X.ft B
- Xint ht_insert_uniq( handle, object, objectp )
- Xdict_h handle ;
- Xdict_obj object ;
- Xdict_obj *objectp ;
- X.LP
- X.ft B
- Xint ht_delete( handle, object )
- Xdict_h handle ;
- Xdict_obj object ;
- X.LP
- X.ft B
- Xdict_obj ht_search( handle, key )
- Xdict_h handle ;
- Xdict_key key ;
- X.LP
- X.ft B
- Xdict_obj ht_minimum( handle )
- Xdict_h handle ;
- X.LP
- X.ft B
- Xdict_obj ht_maximum( handle )
- Xdict_h handle ;
- X.LP
- X.ft B
- Xdict_obj ht_successor( handle, object )
- Xdict_h handle ;
- Xdict_obj object ;
- X.LP
- X.ft B
- Xdict_obj ht_predecessor( handle, object )
- Xdict_h handle ;
- Xdict_obj object ;
- X.LP
- X.ft B
- Xvoid ht_iterate( handle, direction )
- Xdict_h handle ;
- Xenum dict_direction direction ;
- X.LP
- X.ft B
- Xdict_obj ht_nextobj( handle )
- Xdict_h handle ;
- X.SH DESCRIPTION
- XThis library supports dictionary functions using hash tables.
- XA hash table is an array of linked lists which contain objects with the
- Xsame hash value.
- X.LP
- X.B ht_create()
- Xsupports the following flags:
- X.RS
- X.TP
- X.SB DICT_RETURN_ERROR
- X.TP
- X.SB DICT_UNIQUE_KEYS
- X.TP
- X.SB DICT_UNORDERED
- X.RE
- X.LP
- XThe
- X.I argsp
- Xargument points to this structure:
- X.RS
- X.LP
- X.nf
- Xstruct ht_args
- X{
- X.RS
- Xunsigned ht_table_entries ;
- Xunsigned ht_bucket_entries ;
- Xht_func ht_objvalue ;
- Xht_func ht_keyvalue ;
- X.RE
- X} ;
- X.RE
- X.fi
- X.LP
- Xwhere
- X.I ht_func
- Xis defined as:
- X.LP
- X.nf
- X.RS
- Xtypedef ht_val (*ht_func)() ;
- X.RE
- X.fi
- X.LP
- XThe
- X.I ht_table_entries
- Xfield determines the number of entries in the hash table.
- XThe hash function used is a modulo function, so
- Xin order to make sure that a proper number is used, the
- X.I ht_table_entries
- Xis treated as a hint about the order of the number of entries of the table.
- XIf it is
- X.B 0
- Xthen a default number of entries will be used.
- XEvery entry in the table points to a linked list of buckets where the
- Xobjects are kept. The
- X.I ht_bucket_entries
- Xfield determines the number of objects in each bucket. If it is
- X.B 0
- Xa default number will be used. Otherwise, it is treated as a hint
- Xfor the number of entries in each bucket.
- XThe fields
- X.I ht_table_entries
- Xand
- X.I ht_bucket_entries
- Xare treated as value-result parameters. On return from this function
- Xthey will contain the actual values that will be used for this hash
- Xtable.
- X.LP
- XA hash table does not order the objects stored in it; therefore the
- X.I direction
- Xargument in the
- X.B "ht_iterate()"
- Xcall is ignored.
- XFurthermore, the
- X.B ht_minimum(),
- X.B ht_maxumim(),
- X.B ht_successor(),
- Xand
- X.B ht_predecessor()
- Xoperations can be used to enumerate the objects in a hash table but the
- Xenumeration order is arbitrary.
- X.SH "SEE ALSO"
- Xdict(3)
- X.SH "RETURN VALUES"
- XCheck
- X.I "dict(3)"
- Xfor function return values and error codes.
- END_OF_FILE
- if test 3388 -ne `wc -c <'libs/src/dict/ht.3'`; then
- echo shar: \"'libs/src/dict/ht.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/dict/ht.3'
- fi
- if test -f 'libs/src/fsma/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/fsma/Makefile'\"
- else
- echo shar: Extracting \"'libs/src/fsma/Makefile'\" \(3441 characters\)
- sed "s/^X//" >'libs/src/fsma/Makefile' <<'END_OF_FILE'
- X# (c) Copyright 1992 by Panagiotis Tsirigotis
- X# All rights reserved. The file named COPYRIGHT specifies the terms
- X# and conditions for redistribution.
- X
- X#
- X# $Id: Makefile,v 5.6 1993/09/16 22:14: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 = fsma
- XVERSION = 2.0.2
- X
- XHEADERS = fsma.h impl.h
- XSOURCES = fsma.c
- XOBJECTS = fsma.o
- X
- XMANFILES = fsma.3
- XINCLUDEFILES = fsma.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
- XDEFS = # used for command line defined flags
- XDEBUG = -g # -g or -O
- XVERSION_DEF = -DVERSION=\"FSMA\ 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 = $(SOURCES) $(HEADERS) $(MANFILES)
- 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#
- Xfsma.o: fsma.h impl.h
- X
- X#
- X# Test program
- X#
- Xftest: ftest.c $(LIBNAME)
- X $(CC) -g ftest.c -o $@ $(LIBNAME)
- X
- END_OF_FILE
- if test 3441 -ne `wc -c <'libs/src/fsma/Makefile'`; then
- echo shar: \"'libs/src/fsma/Makefile'\" unpacked with wrong size!
- fi
- # end of 'libs/src/fsma/Makefile'
- fi
- if test -f 'libs/src/fsma/fsma.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/fsma/fsma.3'\"
- else
- echo shar: Extracting \"'libs/src/fsma/fsma.3'\" \(3227 characters\)
- sed "s/^X//" >'libs/src/fsma/fsma.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: fsma.3,v 5.1 1992/10/10 07:23:18 panos Exp $
- X.TH FSMA 3X "10 October 1992"
- X.SH NAME
- Xfsm_create, fsm_destroy, fsm_alloc, fsm_free, fsm_size - fixed size memory allocator
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "fsma.h"
- X.LP
- X.ft B
- Xfsma_h fsm_create( size, slots_per_chunk, flags )
- Xunsigned size ;
- Xunsigned slots_per_chunk ;
- Xint flags ;
- X.LP
- X.ft B
- Xvoid fsm_destroy( handle )
- Xfsma_h handle ;
- X.LP
- X.ft B
- Xchar *fsm_alloc( handle )
- Xfsma_h handle ;
- X.LP
- X.ft B
- Xvoid fsm_free( handle, ptr )
- Xfsma_h handle ;
- Xchar *ptr ;
- X.LP
- X.ft B
- Xunsigned fsm_size( handle )
- Xfsma_h handle ;
- X.SH DESCRIPTION
- XThe fixed-size memory allocator routines allocate and free memory in
- Xfixed-size quantities.
- XThe basic operation is as follows: first \fBfsm_create()\fR
- Xis called to create an allocator for objects that are \fIsize\fR
- Xbytes big. It returns an allocator handle (whose type is \fIfsma_h\fR).
- XEverytime \fBfsm_alloc()\fR
- Xis called with that handle as an argument, it will return a pointer
- Xto a memory block of \fIsize\fR bytes.
- X.B fsm_alloc()
- Xworks by allocating big chunks of memory, breaking them into
- Xblocks of \fIsize\fR bytes
- Xand then allocating from that pool of blocks.
- X.LP
- X.B fsm_create()
- Xcreates a memory allocator for objects of \fIsize\fR bytes. The second
- Xargument determines the size of the chunks that are allocated
- Xbecause it defines how many objects should fit in a chunk. If
- X\fIslots_per_chunk\fR is 0, \fBfsm_create()\fR will use a default chunk size.
- XThe \fIflags\fR argument is formed by ORing one or more of the following
- Xconstants:
- X.TP 20
- X.SB FSM_RETURN_ERROR
- Xdetermines the behavior of the particular allocator
- Xin case of a \fBmalloc()\fR failure. When used, the call that
- Xfailed will return a value that indicates failure
- X(the default behavior is to terminate the process)
- X.TP
- X.SB FSM_ZERO_ALLOC
- Xwill cause memory blocks returned from the specified allocator
- Xby \fBfsm_alloc()\fR to be zeroed.
- X.TP
- X.SB FSM_ZERO_FREE
- Xwill cause memory blocks returned to the specified allocator by
- X\fBfsm_free()\fR to be zeroed.
- X(this will help catch references to an object after free'ing it).
- X.TP
- X.SB FSM_ZERO_DESTROY
- Xwill cause all memory associated with the allocator to be zeroed
- Xwhen the allocator is destroyed.
- X.LP
- XThe constant \fBFSM_NOFLAGS\fR can be used to specify no flags.
- X.LP
- X.B fsm_destroy()
- Xdestroys an allocator and frees all memory allocated by it.
- X.LP
- X.B fsm_alloc()
- Xallocates a memory block from the specified allocator. The block
- Xwill be properly aligned.
- X.LP
- X.B fsm_free()
- Xreturns a block to the specified allocator.
- X.LP
- X.B fsm_size()
- Xreturns the size of blocks that are handed out by the specified allocator.
- X.SH RETURN VALUES
- X.LP
- X.B fsm_create()
- Xreturns an allocator handle, or
- X.SM NULL
- Xif the request fails.
- X.LP
- X.B fsm_alloc()
- Xreturns a pointer to a memory block of the appropriate size or
- X.SM NULL
- Xif the request fails.
- X.SH NOTES
- X.B fsm_alloc(),
- X.B fsm_free()
- Xand
- X.B fsm_size()
- Xare macros, so the & operator cannot be applied to them
- X(if that is needed, you can use the functions
- X.B _fsm_alloc()
- Xand
- X.B _fsm_free()
- Xthat perform the same job as the macros).
- END_OF_FILE
- if test 3227 -ne `wc -c <'libs/src/fsma/fsma.3'`; then
- echo shar: \"'libs/src/fsma/fsma.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/fsma/fsma.3'
- fi
- if test -f 'libs/src/misc/misc.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/misc/misc.c'\"
- else
- echo shar: Extracting \"'libs/src/misc/misc.c'\" \(3395 characters\)
- sed "s/^X//" >'libs/src/misc/misc.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: misc.c,v 2.1 1992/10/01 00:38:29 panos Exp $" ;
- Xstatic char misc_version[] = VERSION ;
- X
- X#include <varargs.h>
- X
- X/*
- X * MISCELLANEOUS FUNCTIONS
- X */
- X
- X#include "misc.h"
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- Xchar *strncpy() ;
- Xchar *strrchr() ;
- X
- X
- X/*
- X * Create a new argv array,
- X * copy the original to the new one,
- X * and clear the old one
- X */
- Xchar **argv_copy_and_clear( org_argv, start, count )
- X char **org_argv ; /* original argv */
- X int start ; /* from where to start copy/clear */
- X int count ; /* how many entries to copy/clear */
- X{
- X char **new_argv ;
- X char *p ;
- X int i ;
- X int j ;
- X char *malloc() ;
- X
- X new_argv = (char **) malloc( count * sizeof( char * ) ) ;
- X if ( new_argv == NULL )
- X return( NULL ) ;
- X
- X for ( i = 0 ; i < count ; i++ )
- X {
- X new_argv[ i ] = make_string( 1, org_argv[ start+i ] ) ;
- X if ( new_argv[ i ] == NULL )
- X {
- X for ( j = i-1 ; j >= 0 ; j-- )
- X free( new_argv[ j ] ) ;
- X free( (char *) new_argv ) ;
- X return( NULL ) ;
- X }
- X for ( p = org_argv[ start+i ] ; *p ; p++ )
- X *p = ' ' ;
- X }
- X return( new_argv ) ;
- X}
- X
- X
- X/*
- X * We always return a pointer in pathname
- X */
- Xchar *basename( pathname )
- X char *pathname ;
- X{
- X char *s = strrchr( pathname, '/' ) ;
- X
- X if ( s == NULL )
- X return( pathname ) ;
- X else
- X return( s+1 ) ;
- X}
- X
- X
- X/*
- X * We always return a malloced string
- X *
- X * There are 2 special cases:
- X *
- X * 1) pathname == "/"
- X * In this case we return "/"
- X * 2) pathname does not contain a '/'
- X * In this case we return "."
- X */
- Xchar *dirname( pathname )
- X char *pathname ;
- X{
- X int len ;
- X char *s = strrchr( pathname, '/' ) ;
- X char *p ;
- X char *malloc() ;
- X
- X if ( s == NULL )
- X return( make_string( 1, "." ) ) ;
- X else
- X {
- X len = s - pathname ;
- X if ( len == 0 )
- X return( make_string( 1, "/" ) ) ;
- X }
- X
- X p = malloc( len+1 ) ;
- X if ( p == NULL )
- X return( NULL ) ;
- X else
- X {
- X strncpy( p, pathname, len )[ len ] = '\0' ;
- X return( p ) ;
- X }
- X}
- X
- X
- Xchar *make_string( count, va_alist )
- X register unsigned count ;
- X va_dcl
- X{
- X va_list ap ;
- X register unsigned i ;
- X register unsigned len = 0 ;
- X register char *s, *p ;
- X char *new_string ;
- X
- X if ( count == 0 )
- X return( NULL ) ;
- X
- X va_start( ap ) ;
- X for ( i = 0 ; i < count ; i++ )
- X {
- X s = va_arg( ap, char * ) ;
- X if ( s == NULL )
- X continue ;
- X len += strlen( s ) ;
- X }
- X va_end( ap ) ;
- X
- X new_string = malloc( len + 1 ) ;
- X if ( new_string == NULL )
- X return( NULL ) ;
- X
- X p = new_string ;
- X va_start( ap ) ;
- X for ( i = 0 ; i < count ; i++ )
- X {
- X s = va_arg( ap, char * ) ;
- X if ( s == NULL )
- X continue ;
- X while ( *p++ = *s++ ) ;
- X p-- ;
- X }
- X va_end( ap ) ;
- X return( new_string ) ;
- X}
- X
- X
- Xchar *make_pathname( count, va_alist )
- X register unsigned count ;
- X va_dcl
- X{
- X va_list ap ;
- X register unsigned i ;
- X register unsigned len = 0 ;
- X register char *s, *p ;
- X char *pathname ;
- X
- X if ( count == 0 )
- X return( NULL ) ;
- X
- X va_start( ap ) ;
- X for ( i = 0 ; i < count ; i++ )
- X {
- X s = va_arg( ap, char * ) ;
- X len += strlen( s ) ;
- X }
- X va_end( ap ) ;
- X
- X pathname = malloc( len + count ) ;
- X if ( pathname == NULL )
- X return( NULL ) ;
- X
- X p = pathname ;
- X va_start( ap ) ;
- X for ( i = 0 ; i < count ; i++ )
- X {
- X s = va_arg( ap, char * ) ;
- X while ( *p++ = *s++ ) ;
- X *(p-1) = '/' ; /* change '\0' to '/' */
- X }
- X *(p-1) = '\0' ;
- X return( pathname ) ;
- X}
- X
- END_OF_FILE
- if test 3395 -ne `wc -c <'libs/src/misc/misc.c'`; then
- echo shar: \"'libs/src/misc/misc.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/misc/misc.c'
- fi
- if test -f 'libs/src/pq/pq.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/pq/pq.3'\"
- else
- echo shar: Extracting \"'libs/src/pq/pq.3'\" \(3310 characters\)
- sed "s/^X//" >'libs/src/pq/pq.3' <<'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.\" $Id: pq.3,v 1.4 1993/05/06 06:52:47 panos Exp $
- X.TH PQ 3PT "22 December 1991"
- X.SH NAME
- Xpq_create, pq_destroy, pq_head, pq_extract_head, pq_insert, pq_delete - functions that manage priority queues
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "pq.h"
- X.LP
- X.ft B
- Xpq_h pq_create( func, flags, errnop )
- Xint (*func)() ;
- Xint flags ;
- Xint *errnop ;
- X.LP
- X.ft B
- Xvoid pq_destroy( pq )
- Xpq_h pq ;
- X.LP
- X.ft B
- Xpq_obj pq_head( pq )
- Xpq_h pq ;
- X.LP
- X.ft B
- Xpq_obj pq_extract_head( pq )
- Xpq_h pq ;
- X.LP
- X.ft B
- Xint pq_insert( pq, object )
- Xpq_h pq ;
- Xpq_obj object ;
- X.LP
- X.ft B
- Xint pq_delete( pq, object )
- Xpq_h pq ;
- Xpq_obj object ;
- X.SH DESCRIPTION
- X.LP
- XThis library handles priority queues that contain objects. Objects are
- Xof type
- X.I pq_obj
- Xwhich is a pointer type.
- XThe object at the head of a priority queue is the
- X.I best
- Xobject. The
- Xuser defines the ordering by providing a function that compares objects
- Xwhen the priority queue is created.
- X.LP
- X.B pq_create()
- Xcreates a priority queue and returns a handle to be used for operations
- Xon that queue. \fIfunc\fR is a pointer to a function that takes 2 objects
- Xas arguments and returns 1 if the first object is
- X.I "better"
- Xthan the
- Xsecond and 0 otherwise. The only possible value for the \fIflags\fR
- Xargument is \fBPQ_RETURN_ERROR\fR which if used will cause queue
- Xoperations applied on the specific priority queue to return an error
- Xstatus if they fail (the default is to terminate the program with
- Xan appropriate error message). The value \fBPQ_NOFLAGS\fR can be
- Xused to specify no flags.
- XThe \fIerrnop\fR argument is a pointer to an integer where an
- Xerror code will be stored if an operation fails
- X(and \fBPQ_RETURN_ERROR\fR is used). If no pointer is specified,
- Xerror codes are placed in the global variable \fIpq_error\fR.
- X.LP
- X.B pq_destroy()
- Xis used to destroy a priority queue.
- X.LP
- X.B pq_head()
- Xreturns the object at the head of the priority queue.
- X.LP
- X.B pq_extract_head()
- Xextracts and returns the object at the head of the priority queue.
- X.LP
- X.B pq_insert()
- Xinserts the given \fIobject\fR in the priority queue.
- X.LP
- X.B pq_delete()
- Xdeletes the given \fIobject\fR from the priority queue.
- X.SH "RETURN VALUES"
- X.LP
- XIn the following, values for \fIpq_errno\fR will be stored in the
- Xuser-specified variable if one was provided.
- X.LP
- X.B pq_create()
- Xreturns a priority queue handle if successful, or
- X.SM NULL
- Xif it fails.
- XPossible \fIpq_errno\fR values:
- X.RS
- X.TP 20
- X.SB PQ_ENOFUNC
- XThe object comparison function is missing.
- X.TP
- X.SB PQ_ENOMEM
- XThe program ran out of memory.
- X.RE
- X.LP
- X.B pq_insert()
- Xreturns \fBPQ_OK\fR if successful and \fBPQ_ERR\fR if it fails.
- XPossible \fIpq_errno\fR values:
- X.RS
- X.TP 20
- X.SB PQ_ENULLOBJECT
- XThe object value is
- X.SM NULL.
- X.TP
- X.SB PQ_ENOMEM
- XThe program ran out of memory.
- X.RE
- X.LP
- X.B pq_head()
- Xreturns the object at the head of the queue or
- X.SM NULL
- Xif the queue is empty.
- X.LP
- X.B pq_extract_head()
- Xreturns the object at the head of the queue or
- X.SM NULL
- Xif the queue is empty.
- X.LP
- X.B pq_delete()
- Xreturns \fBPQ_OK\fR if successful and \fBPQ_ERR\fR if it fails.
- XPossible \fIpq_errno\fR values:
- X.RS
- X.TP 20
- X.SB PQ_ENULLOBJECT
- XThe object value is
- X.SM NULL.
- X.TP
- X.SB PQ_ENOTFOUND
- XThe object is not in the queue.
- X.RE
- END_OF_FILE
- if test 3310 -ne `wc -c <'libs/src/pq/pq.3'`; then
- echo shar: \"'libs/src/pq/pq.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/pq/pq.3'
- fi
- if test -f 'libs/src/pset/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/pset/Makefile'\"
- else
- echo shar: Extracting \"'libs/src/pset/Makefile'\" \(3361 characters\)
- sed "s/^X//" >'libs/src/pset/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 3.3 93/11/23 19:49:23 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 = pset
- XVERSION = 1.2.1
- X
- XHEADERS = pset.h
- XSOURCES = pset.c ops.c
- XOBJECTS = pset.o ops.o
- X
- XMANFILES = pset.3 psi.3
- XINCLUDEFILES = pset.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
- XDEFS = # used for command line defined flags
- XDEBUG = -g # -g or -O
- XVERSION_DEF = -DVERSION=\"PSET\ Version\ $(VERSION)\"
- X
- XCPP_DEFS = $(VERSION_DEF) $(DEFS)
- X
- X#
- X# The following variables shouldn't need to be changed
- X#
- XLINT_FLAGS = -hbux
- XCPP_FLAGS = $(CPP_DEFS)
- XCC_FLAGS = $(DEBUG)
- XCFLAGS = $(CPP_FLAGS) $(CC_FLAGS)
- X
- XINSTALL = install -c
- XFMODE = -m 640 # used by install
- XRANLIB = ranlib
- X
- XPAGER = less
- X
- X
- XLIBNAME = lib$(NAME).a
- X
- Xlib: $(LIBNAME)
- X
- Xlibopt: clean
- X make DEBUG=-O lib
- X mv $(LIBNAME) $(LIBDIR)/optimized
- X
- X$(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
- 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#
- Xpset.o: pset.h
- X
- END_OF_FILE
- if test 3361 -ne `wc -c <'libs/src/pset/Makefile'`; then
- echo shar: \"'libs/src/pset/Makefile'\" unpacked with wrong size!
- fi
- # end of 'libs/src/pset/Makefile'
- 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'\" \(3369 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 substrings.
- 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 got this library as part of a program distribution,
- Xthen the SIO library should also be part of that distribution if the
- Xprogram requires it. If the SIO library is not present, then you
- Xhave the following options:
- Xa) If you don't want to bother with it, you can define the
- X flag NO_SIO in the Makefile (check the Makefile comments on how to do
- X this) which will turn all string printing functions to no-ops.
- Xb) You can get the SIO library via anonymous FTP from any site that
- X archives comp.sources.unix; SIO is part of the xinetd distribution
- X which appeared in Volume 26 of comp.sources.unix
- Xc) You can send email to me (panos@cs.colorado.edu) and I will mail it to you
- X
- XNote that if you do find SIO via some other way, or if you already have
- Xit, make sure that the version you use is 1.6.2 or later; versions
- Xprior to 1.6.2 will result in identical behavior between the
- Xstrx_*print* and the str_*print* functions.
- 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
- 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 3369 -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
- echo shar: End of archive 6 \(of 20\).
- cp /dev/null ark6isdone
- 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
-