home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1993-11-28 | 28.4 KB | 1,136 lines
Newsgroups: comp.sources.unix From: panos@anchor.cs.colorado.edu (Panos Tsirigotis) Subject: v27i116: clc - C Libraries Collection, Part10/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 116 Archive-Name: clc/part10 #! /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 10 (of 20)." # Contents: Makefile libs/src/misc/env.c libs/src/sio/README # libs/src/sio/sioconf.h libs/src/xlog/xlog.c # Wrapped by panos@eclipse on Sun Nov 28 14:48:16 1993 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(4827 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X X# X# $Id: Makefile,v 1.5 93/11/27 15:42:10 panos Exp $ X# X X# X# Makefile targets: X# install: install the libraries X# uninstall: uninstall the libraries X# clean: clean up X# X X# X# LIBNAMES is the list of library names that will be compiled. X# It may include any of the following: X# sio, str, xlog, misc, pset, fsma, dict, pq, timer X# X# Note that the order is important, so if you choose not to compile some X# of the libraries, the relative order of the ones you do compile should X# not change. X# XLIBNAMES = sio str xlog misc pset fsma dict pq timer X X# X# LIBDIR : directory where the ".a" libraries will be installed X# INCLUDEDIR : directory where the library include files will be installed X# MANDIR : directory where the library man pages will be installed X# XLIBDIR = ../../lib XINCLUDEDIR = ../../include XMANDIR = ../../man X XDEBUG = -O # either -g or -O X X# X# On System V systems, you should set RANLIB to "true" since "ar" does X# its job. X# On SVR4 systems (like Solaris 2.x), you should set INSTALL to X# "/usr/ucb/install -c" X# If your system does not have an 'install' command, set INSTALL to "cp" X# XRANLIB = ranlib XINSTALL = install -c XFMODE = -m 644 X X# X# SYSINC specified the absolute pathname for a directory that has shadow system X# include files (for example, -I/homes/user/clone). X# Check the INSTALL file for more info about this. X# XSYSINC = X X####################################################################### X# X# This section of the Makefile has instructions on what preprocessor X# flags need to be set for compiling the libraries. Specifically, X# there are instructions on how to set the following variables: X# X# SIO_DEFS : preprocessor flags for the SIO library X# TIMER_DEFS : preprocessor flags for the TIMER library X# XLOG_DEFS : preprocessor flags for the XLOG library X# MISC_DEFS : preprocessor flags for the MISC library X# X# The proper flag settings are provided for the following operating systems: X# X# SunOS 4.x, SunOS 5.x (aka Solaris 2.x), Ultrix 4.x X# X####################################################################### X X# X# The SIO library is the most OS-dependent part of the distribution, so X# unless your system is not among those listed below, you should read the X# README file in the SIO source directory before proceeding. X# For SunOS 4.x, use: X# -DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY X# For SunOS 5.x (aka, Solaris 2.x), use X# -DHAS_MMAP -DHAS_ATEXIT -DHAS_MEMOPS -DHAS_ISATTY X# For Ultrix 4.x, use: X# -DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY X# If your system is POSIX-compatible, use X# -DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY X# XSIO_DEFS = X X# X# Possible flags for the TIMER library: X# X# NO_POSIX_SIGS : the system does not support POSIX signals (but it does X# support the sigvec(2) interface). X# NO_ITIMER_REAL : do not use the ITIMER_REAL timer X# NO_ITIMER_VIRTUAL : do not use the ITIMER_VIRTUAL timer X# NO_ITIMER_PROF : do not use the ITIMER_PROF timer X# X# The last two flags are useful for systems that do not support the getrusage X# system call. X# For SunOS 4.x, use X# -DNO_POSIX_SIGS X# For SunOS 5.x (aka, Solaris 2.x), use X# -DNO_ITIMER_VIRTUAL -DNO_ITIMER_PROF X# For Ultrix 4.x, use X# -DNO_POSIX_SIGS X# XTIMER_DEFS = X X# X# Possible flags for the MISC library: X# X# OLD_DIR : system supports the old BSD 4.2 directory(3) X# interface (i.e. <sys/dir.h> must be included X# instead of <dirent.h>) X# __FTWX_NO_FTW : <ftw.h> is not available X# X# For SunOS 4.x, SunOS 5.x, Ultrix 4.x do not set any of these flags. X# For POSIX-compatible systems, you don't need to set the OLD_DIR flag. X# XMISC_DEFS = X X# X# Possible flags for the XLOG library: X# X# NO_SYSLOG : do not use syslog(3) X# SYSLOG_IN_SYS : the proper syslog.h file is in /usr/include/sys X# X# For SunOS 4.x, SunOS 5.x do not set any of these flags. X# For Ultrix 4.x, use X# -DSYSLOG_IN_SYS X# XXLOG_DEFS = X X X# X# SRCDIR is where the source code for the libraries can be found (for X# example the source for STR should be in $SRCDIR/str). X# You shouldn't need to change this variable. X# XSRCDIR = libs/src X X#---------------------------------------------------------------------- X# X# Do not change anything in this section of the makefile X# X#---------------------------------------------------------------------- X XLIB_DEFS = $(SIO_DEFS) $(XLOG_DEFS) $(MISC_DEFS) $(TIMER_DEFS) $(SYSINC) X Xinstall: X @cd $(SRCDIR) ;\ X for i in $(LIBNAMES) ; do ( cd $$i ; make "DEBUG=$(DEBUG)" "DEFS=$(LIB_DEFS)" LIBDIR=$(LIBDIR) INCLUDEDIR=$(INCLUDEDIR) MANDIR=$(MANDIR) RANLIB=$(RANLIB) "INSTALL=$(INSTALL)" "FMODE=$(FMODE)" install ; ) done X X Xclean: X @for i in $(LIBNAMES) ; do ( cd $(SRCDIR)/$$i ; make clean ; ) done X X Xuninstall: X @cd $(SRCDIR) ;\ X for i in $(LIBNAMES) ; do ( cd $$i ; make LIBDIR=$(LIBDIR) INCLUDEDIR=$(INCLUDEDIR) MANDIR=$(MANDIR) uninstall ) ; done X END_OF_FILE if test 4827 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'libs/src/misc/env.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libs/src/misc/env.c'\" else echo shar: Extracting \"'libs/src/misc/env.c'\" \(4772 characters\) sed "s/^X//" >'libs/src/misc/env.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: env.c,v 1.4 1992/11/03 00:07:50 panos Exp $" ; X X#include <memory.h> X#include <string.h> X X#include "misc.h" X#include "env.h" X Xtypedef struct __env env_s ; X X#define PRIVATE static X#define INITIAL_VARS 20 X#define INCREASE 10 X X#ifndef NULL X#define NULL 0 X#endif X Xchar *malloc() ; Xchar *realloc() ; X Xint env_errno ; X X X XPRIVATE env_s *alloc_env( max_vars ) X unsigned max_vars ; X{ X env_s *ep ; X unsigned size ; X char **pointers ; X X ep = (env_s *) malloc( sizeof( env_s ) ) ; X if ( ep == ENV_NULL ) X { X env_errno = ENV_ENOMEM ; X return( ENV_NULL ) ; X } X X size = ( max_vars + 1 ) * sizeof( char * ) ; X pointers = (char **) malloc( size ) ; X if ( pointers == NULL ) X { X free( (char *)ep ) ; X env_errno = ENV_ENOMEM ; X return( ENV_NULL ) ; X } X (void) memset( (char *)pointers, 0, (int) size ) ; X X ep->vars = pointers ; X ep->max_vars = max_vars ; X ep->n_vars = 0 ; X return( ep ) ; X} X X Xenv_h env_create( init_env ) X env_h init_env ; X{ X unsigned u ; X env_s *ep ; X unsigned max_vars ; X X if ( init_env == ENV_NULL ) X max_vars = INITIAL_VARS ; X else X max_vars = init_env->n_vars + 5 ; X X ep = alloc_env( max_vars ) ; X if ( ep == NULL ) X { X env_errno = ENV_ENOMEM ; X return( ENV_NULL ) ; X } X X if ( init_env == ENV_NULL ) X return( ep ) ; X X for ( u = 0, ep->n_vars = 0 ; u < init_env->n_vars ; u++, ep->n_vars++ ) X { X ep->vars[ ep->n_vars ] = make_string( 1, init_env->vars[ u ] ) ; X if ( ep->vars[ ep->n_vars ] == NULL ) X { X env_destroy( ep ) ; X env_errno = ENV_ENOMEM ; X return( ENV_NULL ) ; X } X } X return( ep ) ; X} X X Xvoid env_destroy( env ) X env_h env ; X{ X unsigned u ; X X for ( u = 0 ; u < env->n_vars ; u++ ) X free( env->vars[ u ] ) ; X free( (char *)env->vars ) ; X free( (char *)env ) ; X} X X Xenv_h env_make( env_strings ) X char **env_strings ; X{ X env_s *ep ; X char **pp ; X X for ( pp = env_strings ; *pp ; pp++ ) ; X X ep = alloc_env( (unsigned) (pp-env_strings) ) ; X if ( ep == NULL ) X { X env_errno = ENV_ENOMEM ; X return( ENV_NULL ) ; X } X X for ( pp = env_strings ; *pp ; pp++ ) X { X char *p = make_string( 1, *pp ) ; X X if ( p == NULL ) X { X env_destroy( ep ) ; X env_errno = ENV_ENOMEM ; X return( ENV_NULL ) ; X } X ep->vars[ ep->n_vars++ ] = p ; X } X return( ep ) ; X} X X Xchar *env_lookup( env, var ) X env_h env ; X char *var ; X{ X char **lookup() ; X char **pp = lookup( env, var, strlen( var ) ) ; X X return( ( pp == NULL ) ? NULL : *pp ) ; X} X X XPRIVATE char **lookup( env, var, len ) X env_h env ; X char *var ; X register int len ; X{ X register char **pp ; X X for ( pp = env->vars ; *pp ; pp++ ) X if ( strncmp( *pp, var, len ) == 0 && (*pp)[ len ] == '=' ) X return( pp ) ; X return( NULL ) ; X} X X XPRIVATE int grow( ep ) X env_s *ep ; X{ X char **new_vars ; X unsigned new_max_vars ; X unsigned new_size ; X X new_max_vars = ep->max_vars + INCREASE ; X new_size = ( new_max_vars+1 ) * sizeof( char * ) ; X new_vars = (char **) realloc( (char *)ep->vars, new_size ) ; X if ( new_vars == NULL ) X return( ENV_ERR ) ; X X ep->vars = new_vars ; X ep->max_vars = new_max_vars ; X return( ENV_OK ) ; X} X X X/* X * Add the variable string to the given environment. X */ XPRIVATE int addstring( ep, var_string, len ) X env_s *ep ; X char *var_string ; X int len ; X{ X char **pp ; X char *p ; X X p = make_string( 1, var_string ) ; X if ( p == NULL ) X return( ENV_ERR ) ; X X pp = lookup( ep, var_string, len ) ; X if ( pp == NULL ) X { X if ( ep->n_vars >= ep->max_vars && grow( ep ) == ENV_ERR ) X { X free( p ) ; X env_errno = ENV_ENOMEM ; X return( ENV_ERR ) ; X } X ep->vars[ ep->n_vars++ ] = p ; X } X else X { X free( *pp ) ; X *pp = p ; X } X return( ENV_OK ) ; X} X X Xint env_addvar( env, from_env, var_name ) X env_h env ; X env_h from_env ; X char *var_name ; X{ X char *var_string = env_lookup( from_env, var_name ) ; X X if ( var_string == NULL ) X { X env_errno = ENV_EBADVAR ; X return( ENV_ERR ) ; X } X X return( addstring( env, var_string, strlen( var_name ) ) ) ; X} X X Xint env_addstr( env, var_string ) X env_h env ; X char *var_string ; X{ X char *p = strchr( var_string, '=' ) ; X X if ( p == NULL ) X { X env_errno = ENV_EBADSTRING ; X return( ENV_ERR ) ; X } X X return( addstring( env, var_string, p-var_string ) ) ; X} X X Xint env_remvar( env, var ) X env_h env ; X char *var ; X{ X char **pp = lookup( env, var, strlen( var ) ) ; X X if ( pp == NULL ) X { X env_errno = ENV_EBADVAR ; X return( ENV_ERR ) ; X } X X free( *pp ) ; X *pp = env->vars[ --env->n_vars ] ; X return( ENV_OK ) ; X} X X X#ifdef notdef XPRIVATE int comparator( p1, p2 ) X char **p1, **p2 ; X{ X return( strcmp( *p1, *p2 ) ) ; X} X X Xvoid env_sort( env ) X env_h env ; X{ X qsort( (char *)env->vars, env->n_vars, sizeof( char * ), comparator ) ; X} X#endif END_OF_FILE if test 4772 -ne `wc -c <'libs/src/misc/env.c'`; then echo shar: \"'libs/src/misc/env.c'\" unpacked with wrong size! fi # end of 'libs/src/misc/env.c' fi if test -f 'libs/src/sio/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libs/src/sio/README'\" else echo shar: Extracting \"'libs/src/sio/README'\" \(4699 characters\) sed "s/^X//" >'libs/src/sio/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 SIO ? X XSIO is a library that provides _stream_ I/O which is what most Unix Xprograms do. As such it is a competitor to stdio. X X X2. Why would you care to use it ? X Xa. SIO is a little faster than stdio Xb. SIO provides an easier-to-use interface (IMHO) Xc. SIO is capable of using memory mapping for reading files if the operating X system supports it. Xd. If you have a program that uses read(2)/write(2) it is trivial X to convert it to use SIO (just replace read with Sread and X write with Swrite) Xe. You get source X X X X3. Setting up the Stream I/O (SIO) library X XThere are 3 steps to the process: X 1) compiling SIO for your system X 2) testing SIO X 3) installing the library and manpages X X X3.1. How to compile the Stream I/O (SIO) library X XAll the system-dependent stuff of SIO is placed in the sioconf.h file. XIf your system is not among those listed below, you will need to read Xthat file to see what flags you need to set to properly compile SIO. X X SunOS 4.x: X make "DEFS=-DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY" X X SunOS 5.x (aka Solaris 2.y): X make "DEFS=-DHAS_MMAP -DHAS_ATEXIT -DHAS_MEMOPS -DHAS_ISATTY" X (I don't have access to a system running Solaris 2.y so I have not X tested this) X X Ultrix 4.x: X make "DEFS=-DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY" X XIf your system is one of the above, then you can skip to the next subsection. XHowever, I should mention that the library compiles by default with Xdebugging enabled (i.e. uses the -g flag of cc). You can override this Xby appending to the above invocations of 'make' the argument "DEBUG=-O" X XIf your system is not among the above, then you will need to modify the Xsioconf.h file. You do this by uncommenting the inclusion of Xcustomconf.h. Then, you can override all constants/macros defined in Xsioconf.h by defining them first in customconf.h. Please read Xsioconf.h for more information on what constants/macros can be Xdefined. X XThe Makefile has a header that explains what the Makefile can do. XThe only flag that you may want to define is -DDEBUG which enables Xassertions in the SIO code (if an assertion fails, the program is Xterminated with an error message that lists the SIO file and line Xnumber where the error occured). X X X3.2. Testing SIO X XAfter you have successfully compiled SIO, you can use the programs in Xthe "suite" directory to test the SIO functions. It may make you feel Xbetter if you test the library before installing it. XThe script testlib does everything; just type: X X testlib all X XThe script sprint_test (invoked by testlib) tests Sprint by using a variety Xof formats and comparing its output with that of an ANSI-compatible printf. XAt least on Ultrix 4.1 and 4.2 this test fails because printf is not XANSI-compatible. XIn such a case, you can test the rest of the SIO functions by typing: X X testlib all Sprint X X(anything after the 'all' argument is interpreted as a function that Xshould not be tested). X XThe README file in the "suite" directory describes how to do a Xfew more tests that cannot be done automatically. X X X3.3. Installing the library and manpages X XThe default 'make' target will create libsio.a in the current directory. XThe Makefile includes an "install" target. Doing a 'make install' will Xcause the following: X Xa) libsio.a will be installed in LIBDIR Xb) the necessary SIO header files will be installed in INCLUDEDIR Xc) the SIO man pages will be installed in MANDIR X XLIBDIR, INCLUDEDIR, and MANDIR are Makefile variables that you can edit in Xthe Makefile or override when you invoke 'make'. XHere is a sample command to install SIO: X X make install LIBDIR=/usr/local/lib INCLUDEDIR=/usr/local/include MANDIR=/usr/local/man/man3 X X X4. Epilogue X XFeel free to modify SIO to suit your needs. Please let me know if you Xfind any bugs (my email address is panos@cs.colorado.edu). X XIf you want to distribute your modifications, 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 X X ** Panos Tsirigotis ** X END_OF_FILE if test 4699 -ne `wc -c <'libs/src/sio/README'`; then echo shar: \"'libs/src/sio/README'\" unpacked with wrong size! fi # end of 'libs/src/sio/README' fi if test -f 'libs/src/sio/sioconf.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libs/src/sio/sioconf.h'\" else echo shar: Extracting \"'libs/src/sio/sioconf.h'\" \(5101 characters\) sed "s/^X//" >'libs/src/sio/sioconf.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: sioconf.h,v 8.5 1993/03/17 02:54:47 panos Exp $ X */ X X/* X * This file has 2 sections: X * 1. a OS-specific section X * 2. a CPU/compiler-specific section X * X * You can override/redefing any of the constants/macros in this file. X * by uncommenting the inclusion of customconf.h and placing your own X * definitions in that file. X */ X X/* #include "customconf.h" */ X X X X/* X * OS-specific section. X * X * Features here use the flag HAS_<feature>. X * List of flags (check the following for macros that can be overriden): X * X * HAS_MMAP (overridable macros) X * X * HAS_ATEXIT X * HAS_ONEXIT X * HAS_OTHER_FINALIZER (must define macros) X * X * HAS_MEMOPS X * HAS_BCOPY (HAS_MEMOPS will be preferred if both are defined) X * X * At least one of the following flags must be defined. The 2nd and 3rd X * flags are incompatible. X * HAS_ISATTY X * HAS_SYSVTTY X * HAS_BSDTTY X */ X X/* X * Memory mapping. X * The library requires 3 macros: SIO_MMAP, SIO_MUNMAP, SIO_MNEED. X * You can selectively override any of them. X * Notice that the SIO_MNEED macro is not required. If your system X * does not have madvise, you can define the macro as: X * #define SIO_MNEED( addr, len ) X */ X#ifdef HAS_MMAP X X#if !defined( SIO_MMAP ) || !defined( SIO_MUNMAP ) || !defined( SIO_MNEED ) X#include <sys/types.h> X#include <sys/mman.h> X#endif X X#ifndef SIO_MMAP X#define SIO_MMAP( addr, len, fd, off ) \ X mmap( addr, len, PROT_READ, \ X ( addr == 0 ) ? MAP_PRIVATE : MAP_PRIVATE + MAP_FIXED, \ X fd, off ) X#endif X X#ifndef SIO_MUNMAP X#define SIO_MUNMAP( addr, len ) munmap( addr, len ) X#endif X X#ifndef SIO_MNEED X#define SIO_MNEED( addr, len ) (void) madvise( addr, len, MADV_WILLNEED ) X#endif X X#endif /* HAS_MMAP */ X X/* X * N_SIO_DESCRIPTORS is the maximum number of file descriptors X * supported by the OS X */ X#ifndef N_SIO_DESCRIPTORS X#include <sys/param.h> X#define N_SIO_DESCRIPTORS NOFILE X#endif X X X X/* X * Finalization function. X * X * The purpose of this function is to do work after your program has X * called exit(3). In the case of SIO, this means flushing the SIO X * output buffers. X * X * If your system does not support atexit or onexit but has some other X * way of installing a finalization function, you define the flag X * HAS_FINALIZER. Then you must define the macros X * SIO_FINALIZE and SIO_DEFINE_FIN X * X * SIO_FINALIZE attempts to install a finalization function and returns TRUE X * if successful, FALSE if unsuccessful. X * SIO_DEFINE_FIN defines the finalization function (the reason for this macro X * s that different systems pass different number/type of arguments to the X * finalization function; the SIO finalization function does not use any X * arguments). X */ X#if defined(HAS_ONEXIT) || defined(HAS_ATEXIT) || defined(HAS_FINALIZER) X X#define HAS_FINALIZATION_FUNCTION X X#if defined( HAS_ONEXIT ) && defined( HAS_ATEXIT ) X#undef HAS_ONEXIT X#endif X X#ifdef HAS_ONEXIT X#define SIO_FINALIZE( func ) ( on_exit( func, (caddr_t) 0 ) == 0 ) X#define SIO_DEFINE_FIN( func ) static void func ( exit_status, arg ) \ X int exit_status ; \ X caddr_t arg ; X#endif /* HAS_ONEXIT */ X X#ifdef HAS_ATEXIT X#define SIO_FINALIZE( func ) ( atexit( func ) == 0 ) X#define SIO_DEFINE_FIN( func ) static void func () X#endif /* HAS_ATEXIT */ X X#endif /* HAS_ONEXIT || HAS_ATEXIT || HAS_FINALIZER */ X X X/* X * HAS_MEMOPS should be defined if your OS supports the mem* functions X * (memcpy etc). If not, then you can define HAS_BCOPY if your OS supports X * bcopy. X */ X#if defined( HAS_MEMOPS ) && defined( HAS_BCOPY ) X#undef HAS_BCOPY X#endif X X X/* X * Support for the isatty(3) function. This function identifies if a X * desciptor refers to a terminal. X * X * Case 1: isatty(3) is in the C library X * --> define HAS_ISATTY X * Case 2: no isatty(3), BSD 4.3 tty handling X * --> define HAS_BSDTTY X * Case 3: no isatty(3), System V tty handling X * --> define HAS_SYSVTTY X * X * The following code checks: X * 1) that at least one of the flags is defined X * 2) only one of the BSD, SYS V flags is defined X */ X#if !defined(HAS_ISATTY) && !defined(HAS_BSDTTY) && !defined(HAS_SYSVTTY) XERROR function_isatty_not_available ; X#endif X X#ifdef HAS_ISATTY X#undef HAS_BSDTTY X#undef HAS_SYSVTTY X#endif X X#if defined(HAS_BSDTTY) && defined(HAS_SYSVTTY) XERROR HAS_BSDTTY_and_HAS_SYSVTTY_both_defined ; X#endif X X X X/* X * CPU/compiler-specific section. X * X * The following constant affects the behavior of Sprint. X * X * Sprint performs integer->string conversions by first converting X * the integer to the widest int type supported by the CPU/compiler. X * By default, this is the "long int" type. If your machine has X * a wider type, you can specify it by defining the WIDE_INT constant. X * For example: X * #define WIDE_INT long long X */ X END_OF_FILE if test 5101 -ne `wc -c <'libs/src/sio/sioconf.h'`; then echo shar: \"'libs/src/sio/sioconf.h'\" unpacked with wrong size! fi # end of 'libs/src/sio/sioconf.h' fi if test -f 'libs/src/xlog/xlog.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libs/src/xlog/xlog.c'\" else echo shar: Extracting \"'libs/src/xlog/xlog.c'\" \(5105 characters\) sed "s/^X//" >'libs/src/xlog/xlog.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: xlog.c,v 2.2 1993/10/28 01:38:48 panos Exp $" ; Xstatic char version[] = VERSION ; X X#include <varargs.h> X X#include "xlog.h" X#include "impl.h" X Xchar *malloc() ; X Xextern struct xlog_ops __xlog_filelog_ops ; X#ifndef NO_SYSLOG Xextern struct xlog_ops __xlog_syslog_ops ; X#endif X Xstruct lookup_table X{ X struct xlog_ops *ops ; X xlog_e type ; X} ; X Xstatic struct lookup_table ops_lookup_table[] = X { X { &__xlog_filelog_ops, XLOG_FILELOG }, X#ifndef NO_SYSLOG X { &__xlog_syslog_ops, XLOG_SYSLOG }, X#endif X { NULL } X } ; X X X#define CALLBACK( xp, status ) \ X if ( (xp)->xl_callback ) \ X (*(xp)->xl_callback)( (xlog_h)(xp), status, (xp)->xl_callback_arg ) X X XPRIVATE void xlog_link() ; XPRIVATE void xlog_unlink() ; X X XPRIVATE struct xlog_ops *xlog_ops_lookup( type ) X register xlog_e type ; X{ X register struct lookup_table *ltp ; X X for ( ltp = &ops_lookup_table[ 0 ] ; ltp->ops ; ltp++ ) X if ( ltp->type == type ) X break ; X return( ltp->ops ) ; X} X X X X/* VARARGS3 */ Xxlog_h xlog_create( type, id, flags, va_alist ) X xlog_e type ; X char *id ; X int flags ; X va_dcl X{ X xlog_s *xp ; X va_list ap ; X struct xlog_ops *xops ; X int status ; X X if ( ( xp = NEW( xlog_s ) ) == NULL ) X return( NULL ) ; X X if ( id == NULL || ( xp->xl_id = __xlog_new_string( id ) ) == NULL ) X { X FREE( xp ) ; X return( NULL ) ; X } X X xops = xlog_ops_lookup( type ) ; X X if ( xops != NULL ) X { X va_start( ap ) ; X xp->xl_ops = xops ; X status = XL_INIT( xp, ap ) ; X va_end( ap ) ; X X if ( status == XLOG_ENOERROR ) X { X xp->xl_flags = flags ; X xp->xl_type = type ; X xp->xl_clients = XLOG_NULL ; X xp->xl_use = XLOG_NULL ; X return( (xlog_h) xp ) ; X } X } X X free( xp->xl_id ) ; X FREE( xp ) ; X return( NULL ) ; X} X X X XPRIVATE void xlog_link( client, server ) X xlog_s *client, *server ; X{ X client->xl_use = server ; X if ( server == NULL ) X return ; X X if ( server->xl_clients == XLOG_NULL ) X { X INIT_LINKS( client, xl_other_users ) ; X server->xl_clients = client ; X } X else X LINK( server, client, xl_other_users ) ; X} X X XPRIVATE void xlog_unlink( xp ) X xlog_s *xp ; X{ X xlog_s *server = xp->xl_use ; X X /* X * Step 1: remove from server chain X */ X if ( server != XLOG_NULL ) X { X if ( server->xl_clients == xp ) X if ( NEXT( xp, xl_other_users ) == xp ) X server->xl_clients = XLOG_NULL ; X else X server->xl_clients = NEXT( xp, xl_other_users ) ; X else X UNLINK( xp, xl_other_users ) ; X } X X /* X * Step 2: If we have users, clear their link to us. X */ X if ( xp->xl_clients != NULL ) X { X xlog_s *xp2 = xp->xl_clients ; X X do X { X xp2->xl_use = XLOG_NULL ; X xp2 = NEXT( xp2, xl_other_users ) ; X } X while ( xp2 != xp->xl_clients ) ; X } X} X X XPRIVATE void xlog_flags( xp, cmd, ap ) X xlog_s *xp ; X xlog_cmd_e cmd ; X va_list ap ; X{ X int flag = va_arg( ap, int ) ; X int old_value = ( ( xp->xl_flags & flag ) != 0 ) ; X int *valp = va_arg( ap, int * ) ; X X if ( cmd == XLOG_SETFLAG ) X if ( *valp ) X xp->xl_flags |= flag ; X else X xp->xl_flags &= ~flag ; X *valp = old_value ; X} X X Xvoid xlog_destroy( xlog ) X xlog_h xlog ; X{ X xlog_s *xp = XP( xlog ) ; X X xlog_unlink( xp ) ; X XL_FINI( xp ) ; X free( xp->xl_id ) ; X FREE( xp ) ; X} X X X/* VARARGS4 */ Xvoid xlog_write( xlog, buf, len, flags, va_alist ) X xlog_h xlog ; X char buf[] ; X int len ; X int flags ; X va_dcl X{ X xlog_s *xp = XP( xlog ) ; X va_list ap ; X int status ; X X va_start( ap ) ; X status = XL_WRITE( xp, buf, len, flags, ap ) ; X va_end( ap ) ; X X if ( status != XLOG_ENOERROR ) X { X CALLBACK( xp, status ) ; X } X} X X X/* VARARGS2 */ Xint xlog_control( xlog, cmd, va_alist ) X xlog_h xlog ; X xlog_cmd_e cmd ; X va_dcl X{ X va_list ap ; X xlog_s *xp = XP( xlog ) ; X int status = XLOG_ENOERROR ; X X va_start( ap ) ; X X switch ( cmd ) X { X case XLOG_LINK: X xlog_unlink( xp ) ; X xlog_link( xp, va_arg( ap, xlog_s * ) ) ; X xp->xl_callback_arg = va_arg( ap, void * ) ; X break ; X X case XLOG_CALLBACK: X xp->xl_callback = va_arg( ap, voidfunc ) ; X break ; X X case XLOG_GETFLAG: X case XLOG_SETFLAG: X xlog_flags( xp, cmd, ap ) ; X break ; X X /* X * If the 'cmd' is not supported by the underlying logging object, X * XL_CONTROL should return XLOG_EBADOP, if the 'cmd' returns X * information to the caller (for example, XLOG_GETFD returns X * a file descriptor, so if this command is applied to a xlog X * that doesn't support it, it should return XLOG_EBADOP). X * XL_CONTROL should return XLOG_ENOERROR otherwise. X */ X default: X status = XL_CONTROL( xp, cmd, ap ) ; X } X X va_end( ap ) ; X X return( status ) ; X} X X Xint xlog_parms( type, va_alist ) X xlog_e type ; X va_dcl X{ X va_list ap ; X int status ; X X va_start( ap ) ; X switch ( type ) X { X#ifndef NO_SYSLOG X case XLOG_SYSLOG: X status = (*__xlog_syslog_ops.parms)( ap ) ; X break ; X#endif X case XLOG_FILELOG: X status = (*__xlog_filelog_ops.parms)( ap ) ; X break ; X X default: X status = XLOG_ENOERROR ; X } X va_end( ap ) ; X return( status ) ; X} X END_OF_FILE if test 5105 -ne `wc -c <'libs/src/xlog/xlog.c'`; then echo shar: \"'libs/src/xlog/xlog.c'\" unpacked with wrong size! fi # end of 'libs/src/xlog/xlog.c' fi echo shar: End of archive 10 \(of 20\). cp /dev/null ark10isdone 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