home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-28 | 33.6 KB | 1,364 lines |
- Newsgroups: comp.sources.unix
- From: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
- Subject: v27i109: clc - C Libraries Collection, Part03/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 109
- Archive-Name: clc/part03
-
- #! /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 3 (of 20)."
- # Contents: libs/src/dict/bst.h libs/src/dict/bsttest.out
- # libs/src/dict/dictimpl.h libs/src/dict/htest.c
- # libs/src/dict/htimpl.h libs/src/pq/hpq.h libs/src/pset/psi.3
- # libs/src/sio/suite/README libs/src/str/ss_bmh.c
- # libs/src/str/ss_sbm.c libs/src/str/strparse.h
- # libs/src/str/strutil.3 libs/src/timer/impl.h libs/src/xlog/xlog.h
- # sysinc
- # Wrapped by panos@eclipse on Sun Nov 28 14:48:15 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'libs/src/dict/bst.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/dict/bst.h'\"
- else
- echo shar: Extracting \"'libs/src/dict/bst.h'\" \(1413 characters\)
- sed "s/^X//" >'libs/src/dict/bst.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1993 by Panagiotis Tsirigotis
- X * All rights reserved. The file named COPYRIGHT specifies the terms
- X * and conditions for redistribution.
- X */
- X
- X#ifndef __BST_H
- X#define __BST_H
- X
- X/*
- X * $Id: bst.h,v 3.1 93/04/23 17:47:42 panos Exp $
- X */
- X
- X#include "dict.h"
- X
- Xdict_h bst_create __ARGS( (
- X dict_function oo_compare,
- X dict_function ko_compare,
- X int flags,
- X int *errnop
- X ) ) ;
- Xvoid bst_destroy __ARGS( ( dict_h bh ) ) ;
- Xint bst_insert __ARGS( ( dict_h bh, dict_obj obj ) ) ;
- Xint bst_insert_uniq __ARGS( ( dict_h bh, dict_obj obj, dict_obj *objp ) ) ;
- Xint bst_delete __ARGS( ( dict_h bh, dict_obj obj ) ) ;
- Xdict_obj bst_search __ARGS( ( dict_h bh, dict_key key ) ) ;
- Xdict_obj bst_minimum __ARGS( ( dict_h bh ) ) ;
- Xdict_obj bst_maximum __ARGS( ( dict_h bh ) ) ;
- Xdict_obj bst_successor __ARGS( ( dict_h bh, dict_obj obj ) ) ;
- Xdict_obj bst_predecessor __ARGS( ( dict_h bh, dict_obj obj ) ) ;
- Xvoid bst_iterate __ARGS( ( dict_h bh, enum dict_direction ) ) ;
- Xdict_obj bst_nextobj __ARGS( ( dict_h bh ) ) ;
- X
- X
- X#ifdef BST_DEBUG
- X
- Xtypedef enum { BST_PREORDER, BST_INORDER, BST_POSTORDER } bst_order_e ;
- X
- Xstruct bst_depth
- X{
- X int depth_min ;
- X int depth_max ;
- X} ;
- X
- Xvoid bst_getdepth __ARGS( ( dict_h bh, struct bst_depth * ) ) ;
- Xvoid bst_traverse __ARGS( ( dict_h bh, bst_order_e, void (*)() ) ) ;
- X
- X#endif /* BST_DEBUG */
- X
- X#endif /* __BST_H */
- X
- END_OF_FILE
- if test 1413 -ne `wc -c <'libs/src/dict/bst.h'`; then
- echo shar: \"'libs/src/dict/bst.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/dict/bst.h'
- fi
- if test -f 'libs/src/dict/bsttest.out' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/dict/bsttest.out'\"
- else
- echo shar: Extracting \"'libs/src/dict/bsttest.out'\" \(1548 characters\)
- sed "s/^X//" >'libs/src/dict/bsttest.out' <<'END_OF_FILE'
- X1
- X2
- X3
- X4
- X5
- X6
- X7
- X8
- X9
- X10
- X11
- X12
- X13
- X14
- X15
- X16
- X17
- X18
- X19
- X20
- X21
- X22
- X23
- X24
- X25
- X26
- X27
- X28
- X29
- X30
- X31
- X32
- X33
- X34
- X35
- X36
- X37
- X38
- X39
- X40
- X41
- X42
- X43
- X44
- X45
- X46
- X47
- X48
- X49
- X50
- X51
- X52
- X53
- X54
- X55
- X56
- X57
- X58
- X59
- X60
- X61
- X62
- X63
- X64
- X65
- X66
- X67
- X68
- X69
- X70
- X71
- X72
- X73
- X74
- X75
- X76
- X77
- X78
- X79
- X80
- X81
- X82
- X83
- X84
- X85
- X86
- X87
- X88
- X89
- X90
- X91
- X92
- X93
- X94
- X95
- X96
- X97
- X98
- X99
- X100
- X
- XSuccessor test
- X1 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
- XPredecessor test
- X100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
- XSearch/delete test
- XSuccessor test 2
- X1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
- XPredecessor test 2
- X100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 6 5 4 3 2 1
- END_OF_FILE
- if test 1548 -ne `wc -c <'libs/src/dict/bsttest.out'`; then
- echo shar: \"'libs/src/dict/bsttest.out'\" unpacked with wrong size!
- fi
- # end of 'libs/src/dict/bsttest.out'
- fi
- if test -f 'libs/src/dict/dictimpl.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/dict/dictimpl.h'\"
- else
- echo shar: Extracting \"'libs/src/dict/dictimpl.h'\" \(1428 characters\)
- sed "s/^X//" >'libs/src/dict/dictimpl.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1993 by Panagiotis Tsirigotis
- X * All rights reserved. The file named COPYRIGHT specifies the terms
- X * and conditions for redistribution.
- X */
- X
- X
- X#ifndef __DICTIMPL_H
- X#define __DICTIMPL_H
- X
- X/*
- X * $Id: dictimpl.h,v 3.2 93/09/28 21:08:37 panos Exp $
- X */
- X
- X#include "dict.h"
- X
- Xstruct dict_header
- X{
- X dict_function oo_comp ;
- X dict_function ko_comp ;
- X int flags ;
- X int *errnop ;
- X} ;
- X
- Xtypedef struct dict_header dheader_s ;
- X
- Xtypedef int bool_int ;
- X
- X#define ERRNO( dhp ) (*((dhp)->errnop))
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- X#define INT_NULL ((int *)0)
- X
- X#define NULL_OBJ ((dict_obj)NULL)
- X#define NULL_HANDLE ((dict_h)NULL)
- X#define NULL_FUNC ((dict_function)NULL)
- X
- X#define PRIVATE static
- X
- X#ifndef FALSE
- X#define FALSE 0
- X#define TRUE 1
- X#endif
- X
- X#define ORDER_FLAGS ( DICT_ORDERED + DICT_UNORDERED )
- X
- X#define BAD_ORDER( flags ) ( ( flags & ORDER_FLAGS ) == ORDER_FLAGS )
- X
- X
- X#define HANDLE_ERROR( dhp, id, errval, retval ) \
- X if ( (dhp)->flags & DICT_RETURN_ERROR ) \
- X { \
- X ERRNO( dhp ) = errval ; \
- X return( retval ) ; \
- X } \
- X else \
- X __dict_fatal_error( id, errval )
- X
- Xvoid __dict_terminate() ;
- Xvoid __dict_fatal_error() ;
- Xvoid __dict_init_header() ;
- Xdict_h __dict_create_error() ;
- X
- Xchar *malloc() ;
- X
- X
- X#endif /* __DICTIMPL_H */
- X
- END_OF_FILE
- if test 1428 -ne `wc -c <'libs/src/dict/dictimpl.h'`; then
- echo shar: \"'libs/src/dict/dictimpl.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/dict/dictimpl.h'
- fi
- if test -f 'libs/src/dict/htest.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/dict/htest.c'\"
- else
- echo shar: Extracting \"'libs/src/dict/htest.c'\" \(1946 characters\)
- sed "s/^X//" >'libs/src/dict/htest.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1993 by Panagiotis Tsirigotis
- X * All rights reserved. The file named COPYRIGHT specifies the terms
- X * and conditions for redistribution.
- X */
- X
- Xstatic char RCSid[] = "$Id: htest.c,v 3.2 93/09/17 00:22:07 panos Exp $" ;
- X
- X#ifndef NULL
- X#define NULL 0
- X#endif
- X
- X#include "dict.h"
- X#include "ht.h"
- X
- X
- X#define COMPARE( i1, i2 ) \
- X if ( i1 < i2 ) \
- X return( -1 ) ; \
- X else if ( i1 == i2 ) \
- X return( 0 ) ; \
- X else \
- X return( 1 ) ;
- X
- X
- X#define INTP( p ) ((int *)(p))
- X
- Xstatic int int_comp( p1, p2 )
- X char *p1, *p2 ;
- X{
- X int i1 = *INTP( p1 ) ;
- X int i2 = *INTP( p2 ) ;
- X
- X COMPARE( i1, i2 ) ;
- X}
- X
- X
- Xstatic unsigned getval( p )
- X char *p ;
- X{
- X return ( *INTP( p ) ) ;
- X}
- X
- X
- X
- X#define N 10
- Xint nums[ N ] ;
- X
- Xmain()
- X{
- X dict_h lh ;
- X int i ;
- X int *ip ;
- X struct ht_args args ;
- X
- X args.ht_bucket_entries = 2 ;
- X args.ht_table_entries = 2 ;
- X args.ht_objvalue = getval ;
- X args.ht_keyvalue = getval ;
- X
- X lh = ht_create( int_comp, int_comp, 0, NULL, &args ) ;
- X
- X for ( i = 0 ; i < N ; i++ )
- X {
- X nums[ i ] = 10-i ;
- X if ( ht_insert( lh, &nums[ i ] ) != DICT_OK )
- X {
- X printf( "Failed at %d\n", i ) ;
- X exit( 1 ) ;
- X }
- X }
- X
- X printf( "Search/delete test\n" ) ;
- X i = 7 ;
- X ip = INTP( ht_search( lh, &i ) ) ;
- X if ( ip == NULL )
- X printf( "Search failed\n" ) ;
- X else
- X if ( ht_delete( lh, ip ) != DICT_OK )
- X {
- X printf( "Delete failed\n" ) ;
- X exit( 0 ) ;
- X }
- X
- X for ( i = 0 ; i < N ; i++ )
- X if ( ip = INTP( ht_search( lh, &nums[ i ] ) ) )
- X printf( "%d found\n", nums[ i ] ) ;
- X else
- X printf( "%d not found\n", nums[ i ] ) ;
- X
- X ht_iterate( lh ) ;
- X while ( ip = INTP( ht_nextobj( lh ) ) )
- X printf( "Object = %d\n", *ip ) ;
- X
- X for ( ip = INTP(ht_minimum( lh )) ; ip ; ip = INTP(ht_successor( lh, ip )) )
- X printf( "Object = %d\n", *ip ) ;
- X
- X for ( ip=INTP(ht_maximum( lh )) ; ip ; ip=INTP(ht_predecessor( lh, ip )) )
- X printf( "Object = %d\n", *ip ) ;
- X
- X exit( 0 ) ;
- X}
- END_OF_FILE
- if test 1946 -ne `wc -c <'libs/src/dict/htest.c'`; then
- echo shar: \"'libs/src/dict/htest.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/dict/htest.c'
- fi
- if test -f 'libs/src/dict/htimpl.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/dict/htimpl.h'\"
- else
- echo shar: Extracting \"'libs/src/dict/htimpl.h'\" \(1838 characters\)
- sed "s/^X//" >'libs/src/dict/htimpl.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1993 by Panagiotis Tsirigotis
- X * All rights reserved. The file named COPYRIGHT specifies the terms
- X * and conditions for redistribution.
- X */
- X
- X
- X/*
- X * $Id: htimpl.h,v 3.1 93/04/23 17:47:42 panos Exp $
- X */
- X
- X#include "dictimpl.h"
- X#include "ht.h"
- X
- X#include "fsma.h"
- X
- X
- X
- X/*
- X * The following definition is a little deceptive.
- X * The bucket really looks like this:
- X *
- X * -------------
- X * | next |
- X * |-------------|
- X * | |
- X * | data |
- X * | (variable) |
- X * | (size) |
- X * | |
- X * | |
- X * | |
- X * |_____________|
- X *
- X * This definition provides for the chain operations.
- X */
- Xstruct bucket
- X{
- X struct bucket *next ;
- X} ;
- X
- Xtypedef struct bucket bucket_s ;
- X
- X#define BP( p ) ((bucket_s *)(p))
- X
- X#define BUCKET_NULL BP(0)
- X
- X#define BUCKET_OBJECTS( bp ) ((dict_obj *)(&((bucket_s *)(&(bp)->next))[1]))
- X
- X/*
- X * Defaults
- X */
- X#define DEFAULT_TABLE_ENTRIES 8191
- X#define DEFAULT_BUCKET_ENTRIES 15
- X
- X
- X
- Xstruct table_entry
- X{
- X bucket_s *head_bucket ;
- X unsigned n_free ;
- X} ;
- X
- Xtypedef struct table_entry tabent_s ;
- X
- X#define TEP( p ) ((tabent_s *)(p))
- X
- X
- X#define ENTRY_HAS_CHAIN( tep ) ( (tep)->head_bucket != NULL )
- X#define ENTRY_IS_FULL( tep ) ( (tep)->n_free == 0 )
- X
- X
- Xstruct ht_iter
- X{
- X int current_table_entry ;
- X bucket_s *current_bucket ;
- X int next_bucket_offset ;
- X} ;
- X
- X
- X/*
- X * A hash table is implemented as an array of table entries, each
- X * pointing to a linked list of buckets containing the actual data
- X */
- Xstruct ht_header
- X{
- X dheader_s dh ;
- X fsma_h alloc ;
- X struct table_entry *table ;
- X struct ht_args args ;
- X struct ht_iter iter ;
- X} ;
- X
- Xtypedef struct ht_header header_s ;
- X
- X
- X#define HHP( p ) ((header_s *)p)
- X#define DHP( hp ) (&(hp->dh))
- X
- Xtypedef enum { KEY_SEARCH, OBJECT_SEARCH } search_e ;
- X
- END_OF_FILE
- if test 1838 -ne `wc -c <'libs/src/dict/htimpl.h'`; then
- echo shar: \"'libs/src/dict/htimpl.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/dict/htimpl.h'
- fi
- if test -f 'libs/src/pq/hpq.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/pq/hpq.h'\"
- else
- echo shar: Extracting \"'libs/src/pq/hpq.h'\" \(1635 characters\)
- sed "s/^X//" >'libs/src/pq/hpq.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1993 by Panagiotis Tsirigotis
- X * All rights reserved. The file named COPYRIGHT specifies the terms
- X * and conditions for redistribution.
- X */
- X
- X#ifndef __HPQ_H
- X#define __HPQ_H
- X
- X/*
- X * $Id: hpq.h,v 1.2 1993/04/01 02:15:32 panos Exp $
- X */
- X
- X/*
- X * Implementation of the PQ interface
- X */
- X
- X#define pq_create __hpq_create
- X#define pq_destroy __hpq_destroy
- X#define pq_insert __hpq_insert
- X#define pq_delete __hpq_delete
- X#define pq_head __hpq_head
- X#define pq_extract_head __hpq_extract_head
- X
- X/*
- X * The is_better function takes 2 arguments which are pointers to objects
- X * and returns:
- X * 1 if the first object is "better" than the second
- X * 0 otherwise
- X */
- X
- Xstruct __hpq_header
- X{
- X int (*is_better)() ;
- X int *errnop ;
- X int flags ;
- X pq_obj *objects ; /* array of objects */
- X unsigned cur_size ; /* # of objects in array */
- X unsigned max_size ; /* max # of objects that can fit in array */
- X} ;
- X
- X
- X#ifndef __ARGS
- X# ifdef PROTOTYPES
- X# define __ARGS( s ) s
- X# else
- X# define __ARGS( s ) ()
- X# endif
- X#endif
- X
- Xpq_h __hpq_create __ARGS( ( int (*func)(), int flags, int *errnop ) ) ;
- Xvoid __hpq_destroy __ARGS( ( pq_h handle ) ) ;
- Xint __hpq_insert __ARGS( ( pq_h handle, pq_obj object ) ) ;
- Xpq_obj __hpq_extract_head __ARGS( ( pq_h handle ) ) ;
- Xint __hpq_delete __ARGS( ( pq_h handle, pq_obj object ) ) ;
- X
- X#define __hpq_head( handle ) \
- X ( \
- X ((struct __hpq_header *)(handle))->cur_size \
- X ? ((struct __hpq_header *)(handle))->objects[ 0 ] \
- X : (pq_obj) 0 \
- X )
- X
- X#endif __HPQ_H
- X
- END_OF_FILE
- if test 1635 -ne `wc -c <'libs/src/pq/hpq.h'`; then
- echo shar: \"'libs/src/pq/hpq.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/pq/hpq.h'
- fi
- if test -f 'libs/src/pset/psi.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/pset/psi.3'\"
- else
- echo shar: Extracting \"'libs/src/pset/psi.3'\" \(1810 characters\)
- sed "s/^X//" >'libs/src/pset/psi.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: psi.3,v 3.1 93/03/06 18:46:38 panos Exp $
- X.TH PSET 3X "25 September 1992"
- X.SH NAME
- Xpsi_create, psi_destroy, psi_reset, psi_start, psi_next, psi_remove - pointer set iterator functions
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "pset.h"
- X.LP
- X.ft B
- Xpsi_h psi_create( pset )
- Xpset_h pset ;
- X.LP
- X.ft B
- Xvoid psi_destroy( iter )
- Xpsi_h iter ;
- X.LP
- X.ft B
- Xvoid psi_reset( iter, pset )
- Xpsi_h iter ;
- Xpset_h pset ;
- X.LP
- X.ft B
- Xvoid *psi_start( iter )
- Xpsi_h iter ;
- X.LP
- X.ft B
- Xvoid *psi_next( iter )
- Xpsi_h iter ;
- X.LP
- X.ft B
- Xvoid psi_remove( iter )
- Xpsi_h iter ;
- X.SH DESCRIPTION
- XThese functions provide a means to iterate over psets (pointer sets).
- X.LP
- X.B psi_create()
- Xcreates an iterator. The only operation that should be applied to
- Xan iterator after it is created is
- X.B psi_start().
- X.LP
- X.B psi_destroy()
- Xdestroys the iterator.
- X.LP
- X.B psi_reset()
- Xchanges the pset that is being iterated to
- X.I pset.
- X.LP
- X.B psi_start()
- Xstarts an iteration and returns the first pointer
- Xin the pointer set.
- X.LP
- X.B psi_next()
- Xreturns the next pointer in the set.
- X.LP
- X.B psi_remove()
- Xremoves the current pointer from the set. The current pointer is
- Xthe one returned most recently from either
- X.B psi_start()
- Xor
- X.B psi_next().
- X.SH "RETURN VALUES"
- X.LP
- X.B psi_create()
- Xreturns an iterator handle on success or
- X.SM NULL
- Xon failure.
- X.LP
- X.B psi_start()
- Xreturns the first pointer from the set or
- X.SM NULL
- Xif the set is empty.
- X.LP
- X.B psi_next()
- Xreturns a pointer or
- X.SM NULL
- Xif the end of the set is reached.
- X.SH WARNINGS
- X.B psi_create()
- Xis the only function in this library. The rest of the interface is macros.
- X.LP
- XThis interface may be eliminated in a future release of the
- X.I pset
- Xlibrary.
- END_OF_FILE
- if test 1810 -ne `wc -c <'libs/src/pset/psi.3'`; then
- echo shar: \"'libs/src/pset/psi.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/pset/psi.3'
- fi
- if test -f 'libs/src/sio/suite/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/sio/suite/README'\"
- else
- echo shar: Extracting \"'libs/src/sio/suite/README'\" \(1753 characters\)
- sed "s/^X//" >'libs/src/sio/suite/README' <<'END_OF_FILE'
- X
- XThe 'testlib' script will exercise most of the functions in the SIO
- Xlibrary. It invokes the 'tester' script which does the real work.
- X'tester' is a Bourne shell script. However, it expects that the shell
- Xsupports functions and /bin/sh does not support functions on all
- Xoperating systems. Therefore, 'testlib' decides what shell to use to
- Xexecute 'tester'. On Suns, it uses /bin/sh. On DECstations, it uses
- X/usr/bin/ksh. The decision is made by checking the ARCH environment
- Xvariable.
- X
- XExercising some of the SIO functions in an automatic fashion is a
- Xdifficult task, so you will have to do it manually by visually
- Xinspecting the results of programs that exercise them. The following
- Xis a list of functions and programs testing them (with a description of
- Xthe expected behavior):
- X
- X1. Sbuftype
- X
- X PROGRAM: buftest.c
- X DESCRIPTION:
- X This program prints two groups of lines. The first group is printed
- X using line-buffering while the second group is printed using
- X full-buffering.
- X The first group of lines should appear one line at a time every
- X 3 seconds. The second group of lines should appear all lines together
- X after about 10 seconds.
- X
- X2. Stie, Suntie
- X
- X PROGRAM: tietest.c
- X DESCRIPTION:
- X This program ties stdin to stdout and then prompts for input.
- X The prompts do *not* include a NEWLINE. Since the stdout is
- X *line buffered* when connected to a terminal, the Stie call
- X is what causes the prompt to appear.
- X The first 2 prompts happen with tied stdin, stdout. For the
- X 3rd prompt, stdin is untied from stdout. This will cause
- X the prompt to appear *after* you type something and hit RETURN.
- X
- X
- X
- XPS. If you can make testing of these functions automatic, please send
- X me your code so that I can include in a future SIO distribution.
- X
- END_OF_FILE
- if test 1753 -ne `wc -c <'libs/src/sio/suite/README'`; then
- echo shar: \"'libs/src/sio/suite/README'\" unpacked with wrong size!
- fi
- # end of 'libs/src/sio/suite/README'
- fi
- if test -f 'libs/src/str/ss_bmh.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/ss_bmh.c'\"
- else
- echo shar: Extracting \"'libs/src/str/ss_bmh.c'\" \(1721 characters\)
- sed "s/^X//" >'libs/src/str/ss_bmh.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" ;
- X
- Xchar *malloc() ;
- X
- X#include "ss_impl.h"
- X
- XPRIVATE int bmh_setup() ;
- XPRIVATE char *bmh_match() ;
- XPRIVATE void bmh_done() ;
- X
- Xstruct ss_ops __strs_bmhops = { bmh_setup, bmh_match, bmh_done } ;
- X
- X
- XPRIVATE int bmh_setup( hp )
- X header_s *hp ;
- X{
- X register int patlen = SS_PATLEN( hp ) ;
- X register int limit = patlen - 1 ; /* patlen is > 0 */
- X register char *pattern = SS_PATTERN( hp ) ;
- X register int i ;
- X shift_int *shift ;
- X
- X shift = (shift_int *) malloc( ALPHABET_SIZE * sizeof( shift_int ) ) ;
- X if ( shift == (shift_int *)NULL )
- X return( SS_ERR ) ;
- X
- X for ( i = 0 ; i < ALPHABET_SIZE ; i++ )
- X shift[ i ] = patlen ;
- X
- X for ( i = 0 ; i < limit ; i++ )
- X shift[ (unsigned char) pattern[ i ] ] = limit - i ;
- X
- X BMH_HEADER( hp )->shift = shift ;
- X return( SS_OK ) ;
- X}
- X
- X
- XPRIVATE char *bmh_match( hp, str, len )
- X header_s *hp ;
- X register char *str ;
- X int len ;
- X{
- X register int i ;
- X int patlen = SS_PATLEN( hp ) ;
- X char *pattern = SS_PATTERN( hp ) ;
- X register char lpc = pattern[ patlen-1 ] ; /* last pattern character */
- X shift_int *shift = BMH_HEADER( hp )->shift ;
- X
- X i = patlen - 1 ;
- X while ( i < len )
- X {
- X char c = SS_MAP( hp, str[ i ] ) ;
- X
- X if ( c == lpc )
- X {
- X int j, k ;
- X
- X for ( j = patlen-1, k = i ;; )
- X {
- X if ( j == 0 )
- X return( &str[ k ] ) ;
- X j--, k-- ;
- X if ( pattern[ j ] != SS_MAP( hp, str[ k ] ) )
- X break ;
- X }
- X }
- X i += shift[ (unsigned char) c ] ;
- X }
- X return( CHAR_NULL ) ;
- X}
- X
- X
- XPRIVATE void bmh_done( hp )
- X header_s *hp ;
- X{
- X (void) free( (char *)BMH_HEADER( hp )->shift ) ;
- X}
- X
- END_OF_FILE
- if test 1721 -ne `wc -c <'libs/src/str/ss_bmh.c'`; then
- echo shar: \"'libs/src/str/ss_bmh.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/ss_bmh.c'
- fi
- if test -f 'libs/src/str/ss_sbm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/ss_sbm.c'\"
- else
- echo shar: Extracting \"'libs/src/str/ss_sbm.c'\" \(1825 characters\)
- sed "s/^X//" >'libs/src/str/ss_sbm.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_sbm.c,v 3.1 1993/06/13 02:45:45 panos Exp $" ;
- X
- Xchar *malloc() ;
- X
- X#include "ss_impl.h"
- X#include "ss_sbm.h"
- X
- XPRIVATE int sbm_setup() ;
- XPRIVATE char *sbm_match() ;
- XPRIVATE void sbm_done() ;
- X
- X
- Xstruct ss_ops __strs_sbmops = { sbm_setup, sbm_match, sbm_done } ;
- X
- X
- XPRIVATE int sbm_setup( hp )
- X header_s *hp ;
- X{
- X last_int *last_occurrence ;
- X register int i ;
- X int patlen = SS_PATLEN( hp ) ;
- X char *pattern = SS_PATTERN( hp ) ;
- X
- X last_occurrence = (last_int *) malloc( ALPHABET_SIZE * sizeof( last_int ) ) ;
- X if ( last_occurrence == (last_int *)0 )
- X return( SS_ERR ) ;
- X
- X for ( i = 0 ; i < ALPHABET_SIZE ; i++ )
- X last_occurrence[ i ] = -1 ;
- X for ( i = 0 ; i < patlen ; i++ )
- X last_occurrence[ (unsigned char) pattern[ i ] ] = i ;
- X
- X SBM_HEADER( hp )->last_occurrence = last_occurrence ;
- X return( SS_OK ) ;
- X}
- X
- X
- X
- XPRIVATE char *sbm_match( hp, str, len )
- X header_s *hp ;
- X char *str ;
- X int len ;
- X{
- X register int j ;
- X register int s = 0 ;
- X char *pattern = SS_PATTERN( hp ) ;
- X int patlen = SS_PATLEN( hp ) ;
- X last_int *last_occurrence = SBM_HEADER( hp )->last_occurrence ;
- X
- X while ( s <= len - patlen )
- X {
- X register char c ;
- X last_int lo ;
- X
- X /*
- X * Try matching pattern right-to-left
- X */
- X for ( j = patlen-1 ;; )
- X {
- X c = SS_MAP( hp, str[ s+j ] ) ;
- X if ( pattern[ j ] == c )
- X if ( j )
- X j-- ;
- X else
- X return( &str[ s ] ) ;
- X else
- X break ;
- X }
- X lo = last_occurrence[ (unsigned char) c ] ;
- X if ( j > lo )
- X s += j - lo ;
- X else
- X s++ ;
- X }
- X return( CHAR_NULL ) ;
- X}
- X
- X
- XPRIVATE void sbm_done( hp )
- X header_s *hp ;
- X{
- X (void) free( (char *) SBM_HEADER( hp )->last_occurrence ) ;
- X}
- X
- END_OF_FILE
- if test 1825 -ne `wc -c <'libs/src/str/ss_sbm.c'`; then
- echo shar: \"'libs/src/str/ss_sbm.c'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/ss_sbm.c'
- fi
- if test -f 'libs/src/str/strparse.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/strparse.h'\"
- else
- echo shar: Extracting \"'libs/src/str/strparse.h'\" \(1514 characters\)
- sed "s/^X//" >'libs/src/str/strparse.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: strparse.h,v 3.1 1993/06/13 02:48:35 panos Exp $
- X */
- X
- Xstruct str_handle
- X{
- X char *string ;
- X char *separator ;
- X char *pos ;
- X int flags ;
- X int *errnop ;
- X int no_more ;
- X} ;
- X
- Xint str_errno ;
- 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 PRIVATE static
- X
- X#define TERMINATE( msg ) { \
- X char *s = msg ; \
- X \
- X (void) write( 2, s, strlen( s ) ) ; \
- X (void) abort() ; \
- X _exit( 1 ) ; \
- X /* NOTREACHED */ \
- X }
- X
- X
- X#define HANDLE_ERROR( flags, retval, errp, errval, msg ) \
- X if ( flags & STR_RETURN_ERROR ) \
- X { \
- X *errp = errval ; \
- X return( retval ) ; \
- X } \
- X else \
- X TERMINATE( msg )
- X
- X
- END_OF_FILE
- if test 1514 -ne `wc -c <'libs/src/str/strparse.h'`; then
- echo shar: \"'libs/src/str/strparse.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/strparse.h'
- fi
- if test -f 'libs/src/str/strutil.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/str/strutil.3'\"
- else
- echo shar: Extracting \"'libs/src/str/strutil.3'\" \(1367 characters\)
- sed "s/^X//" >'libs/src/str/strutil.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: strutil.3,v 3.1 1993/06/13 02:49:23 panos Exp $
- X.TH STRUTIL 3X "30 September 1992"
- X.SH NAME
- Xstr_find, str_casefind, str_fill, str_lower, str_upper -- string utility functions
- X.SH SYNOPSIS
- X.LP
- X.nf
- X.ft B
- X#include "str.h"
- X.LP
- X.ft B
- Xchar *str_find( s1, s2 )
- Xchar *s1, *s2 ;
- X.LP
- X.ft B
- Xchar *str_casefind( s1, s2 )
- Xchar *s1, *s2 ;
- X.LP
- X.ft B
- Xvoid str_fill( s, c )
- Xchar *s ;
- Xchar c ;
- X.LP
- X.ft B
- Xchar *str_lower( s )
- Xchar *s ;
- X.LP
- X.ft B
- Xchar *str_upper( s )
- Xchar *s ;
- X.SH DESCRIPTION
- X.B str_find()
- Xreturns a pointer to the first instance of string \fIs2\fR in string \fIs1\fR.
- XIf \fIs2\fR is the empty string a pointer to \fIs1\fR is returned.
- X.LP
- X.B str_casefind()
- Xperforms the same function as
- X.B str_find()
- Xexcept that it performs case insensitive character comparisons.
- X.LP
- X.B str_fill()
- Xfills the string \fIs\fR with the character \fIc\fR.
- X.LP
- X.B str_lower()
- Xand
- X.B str_upper()
- Xconvert their argument in place to a lower or upper case string respectively.
- X.SH "RETURN VALUES"
- X.LP
- X\fBstr_find()\fR
- Xand
- X.B str_casefind()
- Xreturn a pointer to the first occurrence of \fIs2\fR
- Xin \fIs1\fR or
- X.SM NULL
- Xif \fIs2\fR does not exist in \fIs1\fR.
- X.LP
- X\fBstr_lower()\fR and \fBstr_upper()\fR return \fIs\fR.
- END_OF_FILE
- if test 1367 -ne `wc -c <'libs/src/str/strutil.3'`; then
- echo shar: \"'libs/src/str/strutil.3'\" unpacked with wrong size!
- fi
- # end of 'libs/src/str/strutil.3'
- fi
- if test -f 'libs/src/timer/impl.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/timer/impl.h'\"
- else
- echo shar: Extracting \"'libs/src/timer/impl.h'\" \(1736 characters\)
- sed "s/^X//" >'libs/src/timer/impl.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1993 by Panagiotis Tsirigotis
- X * All rights reserved. The file named COPYRIGHT specifies the terms
- X * and conditions for redistribution.
- X */
- X
- X#ifndef IMPL_H
- X#define IMPL_H
- X
- X/*
- X * $Id: impl.h,v 5.1 93/11/26 12:07:39 panos Exp $
- X */
- X
- X#include <sys/time.h>
- X#include <setjmp.h>
- X
- X#include "pq.h"
- X#include "timer.h"
- X#include "ostimer.h"
- X
- Xenum timer_state { INACTIVE, TICKING, DESTROYED } ;
- Xenum action_state { IDLE, PENDING, SCHEDULED, INVOKED } ;
- X
- X
- Xstruct timer
- X{
- X enum timer_state t_state ;
- X enum action_state t_act ;
- X int t_blocked ;
- X
- X int t_flags ;
- X int *t_errnop ;
- X struct os_timer *t_ostimer ;
- X struct timer_action t_action ;
- X
- X /*
- X * The following fields are managed by the ostimer code.
- X * t_expiration is the (absolute) time when the timer will expire.
- X * t_interval is the repeat interval for the timer.
- X * t_expirations is the number of expirations of the timer when
- X * the function associated with the timer is invoked.
- X * t_count is the number of times that the timer has expired before
- X * the function was invoked.
- X */
- X struct timeval t_expiration ;
- X struct timeval t_interval ;
- X unsigned t_count ;
- X unsigned t_expirations ;
- X} ;
- X
- Xtypedef struct timer timer_s ;
- X
- X#define TP( p ) ( (struct timer *) (p) )
- X
- Xchar *malloc() ;
- X
- X#define TIMER_ALLOC() TP( malloc( sizeof( timer_s ) ) )
- X#define TIMER_FREE( tp ) (void) free( (char *)(tp) )
- X
- X/*
- X * The following are masks for the expected flags of timer_create and
- X * timer_start
- X */
- X#define TIMER_CREATE_FLAGS TIMER_RETURN_ERROR
- X#define TIMER_START_FLAGS \
- X ( TIMER_INC_VAR + TIMER_BLOCK_SAME + TIMER_BLOCK_ALL + TIMER_LONGJMP )
- X
- X
- Xenum timer_state __timer_invoke() ;
- Xvoid __timer_terminate() ;
- X
- X#endif /* IMPL_H */
- X
- END_OF_FILE
- if test 1736 -ne `wc -c <'libs/src/timer/impl.h'`; then
- echo shar: \"'libs/src/timer/impl.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/timer/impl.h'
- fi
- if test -f 'libs/src/xlog/xlog.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libs/src/xlog/xlog.h'\"
- else
- echo shar: Extracting \"'libs/src/xlog/xlog.h'\" \(1967 characters\)
- sed "s/^X//" >'libs/src/xlog/xlog.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 __XLOG_H
- X#define __XLOG_H
- X
- X/*
- X * $Id: xlog.h,v 2.2 1993/06/15 18:07:48 panos Exp $
- X */
- X
- X/*
- X * Flags
- X */
- X#define XLOG_NOFLAGS 0x0
- X#define XLOG_SET_LEVEL 0x1
- X#define XLOG_NO_SIZECHECK 0x2
- X#define XLOG_NO_ERRNO 0x4
- X/* #define XLOG_PRINT_TIMESTAMP 0x8 */
- X#define XLOG_PRINT_ID 0x10
- X#define XLOG_PRINT_PID 0x20
- X
- X/*
- X * Errors
- X */
- X#define XLOG_ENOERROR 0
- X#define XLOG_ESIZE 1
- X#define XLOG_EOPEN 2
- X#define XLOG_EFSTAT 3
- X#define XLOG_ENOMEM 4
- X#define XLOG_EBADOP 5
- 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 enum { XLOG_SYSLOG, XLOG_FILELOG } xlog_e ;
- X
- Xtypedef enum
- X {
- X XLOG_LINK, /* generic: link this log to another log */
- X XLOG_CALLBACK, /* generic: call this function in case of error */
- X XLOG_GETFLAG, /* generic: get value of specified flag */
- X XLOG_SETFLAG, /* generic: set value of specified flag */
- X XLOG_LEVEL, /* syslog: set the default syslog level */
- X XLOG_FACILITY, /* syslog: set the default syslog facility */
- X XLOG_PREEXEC, /* syslog: prepare the log for an exec(2) */
- X XLOG_POSTEXEC, /* syslog: exec(2) failed */
- X XLOG_SIZECHECK, /* filelog: check file size */
- X XLOG_GETFD, /* filelog: get file descriptor of log file */
- X XLOG_LIMITS /* filelog: set (new) soft/hard limits */
- X } xlog_cmd_e ;
- X
- Xtypedef void *xlog_h ;
- X
- Xxlog_h xlog_create __ARGS( ( xlog_e type, char *id, int flags, ... ) ) ;
- Xvoid xlog_destroy __ARGS( ( xlog_h ) ) ;
- Xvoid xlog_write __ARGS( ( xlog_h, char *buf, int len, int flags, ... ) ) ;
- Xint xlog_control __ARGS( ( xlog_h, xlog_cmd_e, ... ) ) ;
- Xint xlog_parms __ARGS( ( xlog_e type, ... ) ) ;
- X
- X#endif /* __XLOG_H */
- END_OF_FILE
- if test 1967 -ne `wc -c <'libs/src/xlog/xlog.h'`; then
- echo shar: \"'libs/src/xlog/xlog.h'\" unpacked with wrong size!
- fi
- # end of 'libs/src/xlog/xlog.h'
- fi
- if test -f 'sysinc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sysinc'\"
- else
- echo shar: Extracting \"'sysinc'\" \(1499 characters\)
- sed "s/^X//" >'sysinc' <<'END_OF_FILE'
- X#!/bin/sh
- X
- X#
- X# Copyright (c) 1993 by Panagiotis Tsirigotis
- X#
- X
- X#
- X# $Id: sysinc,v 1.3 1993/10/27 17:06:11 panos Exp panos $
- X#
- X
- X#
- X# Usage: sysinc -d clone_dir *.[ch]
- X#
- X
- Xscript_name=`basename $0`
- Xusage="Usage: $script_name [-d clone_dir] *.[ch]"
- X
- Xif test $# -eq 0 ; then echo "$usage" ; exit ; fi
- X
- Xif test "X$1" = "X-d" ; then
- X shift
- X if test $# -eq 0 ; then echo "$usage" ; exit ; fi
- X clone_dir=$1
- X shift
- Xfi
- X
- Xprefix=/tmp/si
- Xsuffix=$$
- X
- Xunique_names=$prefix.uniq.$suffix
- Xdir_names=$prefix.dir.$suffix
- X
- Xfiles="$*"
- X
- X#
- X# Step 1: find names of all system include files
- X#
- Xawk '/^#include/ { if ( substr( $2, 1, 1 ) == "<" ) print substr( $2, 2, length( $2 ) - 2 ) }' $files | sort | uniq > $unique_names
- X
- Xuniq_names=`cat $unique_names`
- Xrm $unique_names
- X
- Xif test "$clone_dir" = "" ; then
- X echo "$uniq_names"
- X exit
- Xfi
- X
- X#
- X# Step 2: Find names of subdirectories (we assume that all include files
- X# are specified as relative pathnames)
- X#
- Xrm -f $dir_names
- Xfor i in $uniq_names
- Xdo
- X path=$i
- X dir=`expr "$path" : "\(.*\)/.*"`
- X if test "$dir" ; then echo $dir >> $dir_names ; fi
- Xdone
- X
- Xuniq_dirs=`sort $dir_names | uniq`
- Xrm $dir_names
- X
- X#
- X# Step 3: Create clone tree
- X#
- Xmkdir $clone_dir
- X( cd $clone_dir ; mkdir $uniq_dirs )
- X
- Xstd_dir=/usr/include
- X
- Xfor i in $uniq_names
- Xdo
- X v=_XX_`echo $i | sed 's/\//_/g' | sed 's/\./_/' `
- X file=$clone_dir/$i
- X echo > $file
- X echo "#ifndef $v" >> $file
- X echo "#define $v" >> $file
- X if test -f $std_dir/$i ; then
- X echo "#include <$std_dir/$i>" >> $file
- X fi
- X echo "#endif" >> $file
- Xdone
- X
- END_OF_FILE
- if test 1499 -ne `wc -c <'sysinc'`; then
- echo shar: \"'sysinc'\" unpacked with wrong size!
- fi
- chmod +x 'sysinc'
- # end of 'sysinc'
- fi
- echo shar: End of archive 3 \(of 20\).
- cp /dev/null ark3isdone
- 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
-