home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume27 / clc / part10 < prev    next >
Encoding:
Text File  |  1993-11-28  |  28.4 KB  |  1,136 lines

  1. Newsgroups: comp.sources.unix
  2. From: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
  3. Subject: v27i116: clc - C Libraries Collection, Part10/20
  4. References: <1.754527080.23891@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
  9. Posting-Number: Volume 27, Issue 116
  10. Archive-Name: clc/part10
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 10 (of 20)."
  19. # Contents:  Makefile libs/src/misc/env.c libs/src/sio/README
  20. #   libs/src/sio/sioconf.h libs/src/xlog/xlog.c
  21. # Wrapped by panos@eclipse on Sun Nov 28 14:48:16 1993
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'Makefile'\"
  25. else
  26. echo shar: Extracting \"'Makefile'\" \(4827 characters\)
  27. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  28. X
  29. X#
  30. X# $Id: Makefile,v 1.5 93/11/27 15:42:10 panos Exp $
  31. X#
  32. X
  33. X#
  34. X# Makefile targets:
  35. X#        install:            install the libraries
  36. X#        uninstall:        uninstall the libraries
  37. X#        clean:            clean up
  38. X#
  39. X
  40. X#
  41. X# LIBNAMES is the list of library names that will be compiled.
  42. X# It may include any of the following:
  43. X#        sio, str, xlog, misc, pset, fsma, dict, pq, timer
  44. X#
  45. X# Note that the order is important, so if you choose not to compile some
  46. X# of the libraries, the relative order of the ones you do compile should
  47. X# not change.
  48. X#
  49. XLIBNAMES        = sio str xlog misc pset fsma dict pq timer
  50. X
  51. X#
  52. X# LIBDIR            : directory where the ".a" libraries will be installed
  53. X# INCLUDEDIR    : directory where the library include files will be installed
  54. X# MANDIR            : directory where the library man pages will be installed
  55. X#
  56. XLIBDIR        = ../../lib
  57. XINCLUDEDIR    = ../../include
  58. XMANDIR        = ../../man
  59. X
  60. XDEBUG            = -O        # either -g or -O
  61. X
  62. X#
  63. X# On System V systems, you should set RANLIB to "true" since "ar" does
  64. X# its job.
  65. X# On SVR4 systems (like Solaris 2.x), you should set INSTALL to
  66. X# "/usr/ucb/install -c"
  67. X# If your system does not have an 'install' command, set INSTALL to "cp"
  68. X#
  69. XRANLIB        = ranlib
  70. XINSTALL        = install -c
  71. XFMODE            = -m 644
  72. X
  73. X#
  74. X# SYSINC specified the absolute pathname for a directory that has shadow system 
  75. X# include files (for example, -I/homes/user/clone).
  76. X# Check the INSTALL file for more info about this.
  77. X#
  78. XSYSINC        =
  79. X
  80. X#######################################################################
  81. X#
  82. X# This section of the Makefile has instructions on what preprocessor
  83. X# flags need to be set for compiling the libraries. Specifically,
  84. X# there are instructions on how to set the following variables:
  85. X#
  86. X#        SIO_DEFS            : preprocessor flags for the SIO library
  87. X#        TIMER_DEFS        : preprocessor flags for the TIMER library
  88. X#        XLOG_DEFS        : preprocessor flags for the XLOG library
  89. X#        MISC_DEFS        : preprocessor flags for the MISC library
  90. X#
  91. X# The proper flag settings are provided for the following operating systems:
  92. X#
  93. X#        SunOS 4.x, SunOS 5.x (aka Solaris 2.x), Ultrix 4.x 
  94. X#
  95. X#######################################################################
  96. X
  97. X#
  98. X# The SIO library is the most OS-dependent part of the distribution, so
  99. X# unless your system is not among those listed below, you should read the 
  100. X# README file in the SIO source directory before proceeding.
  101. X# For SunOS 4.x, use:
  102. X#        -DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY
  103. X# For SunOS 5.x (aka, Solaris 2.x), use
  104. X#        -DHAS_MMAP -DHAS_ATEXIT -DHAS_MEMOPS -DHAS_ISATTY
  105. X# For Ultrix 4.x, use:
  106. X#        -DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY
  107. X# If your system is POSIX-compatible, use
  108. X#        -DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY
  109. X#
  110. XSIO_DEFS        =
  111. X
  112. X#
  113. X# Possible flags for the TIMER library:
  114. X#
  115. X#    NO_POSIX_SIGS        :     the system does not support POSIX signals (but it does
  116. X#                                support the sigvec(2) interface).
  117. X#    NO_ITIMER_REAL        :    do not use the ITIMER_REAL timer
  118. X#    NO_ITIMER_VIRTUAL    :    do not use the ITIMER_VIRTUAL timer
  119. X#    NO_ITIMER_PROF        :    do not use the ITIMER_PROF timer
  120. X#
  121. X# The last two flags are useful for systems that do not support the getrusage
  122. X# system call.
  123. X# For SunOS 4.x, use
  124. X#        -DNO_POSIX_SIGS
  125. X# For SunOS 5.x (aka, Solaris 2.x), use
  126. X#        -DNO_ITIMER_VIRTUAL -DNO_ITIMER_PROF
  127. X# For Ultrix 4.x, use
  128. X#        -DNO_POSIX_SIGS
  129. X#
  130. XTIMER_DEFS    =
  131. X
  132. X#
  133. X# Possible flags for the MISC library:
  134. X#
  135. X#    OLD_DIR                :    system supports the old BSD 4.2 directory(3)
  136. X#                                interface (i.e. <sys/dir.h> must be included 
  137. X#                                instead of <dirent.h>)
  138. X#    __FTWX_NO_FTW        :    <ftw.h> is not available
  139. X#
  140. X# For SunOS 4.x, SunOS 5.x, Ultrix 4.x do not set any of these flags.
  141. X# For POSIX-compatible systems, you don't need to set the OLD_DIR flag.
  142. X#    
  143. XMISC_DEFS    =
  144. X
  145. X#
  146. X# Possible flags for the XLOG library:
  147. X#
  148. X#    NO_SYSLOG            :    do not use syslog(3)
  149. X#    SYSLOG_IN_SYS        :    the proper syslog.h file is in /usr/include/sys
  150. X#
  151. X# For SunOS 4.x, SunOS 5.x do not set any of these flags.
  152. X# For Ultrix 4.x, use
  153. X#        -DSYSLOG_IN_SYS
  154. X#
  155. XXLOG_DEFS    =
  156. X
  157. X
  158. X#
  159. X# SRCDIR is where the source code for the libraries can be found (for
  160. X# example the source for STR should be in $SRCDIR/str).
  161. X# You shouldn't need to change this variable.
  162. X#
  163. XSRCDIR        = libs/src
  164. X
  165. X#----------------------------------------------------------------------
  166. X#
  167. X# Do not change anything in this section of the makefile
  168. X#
  169. X#----------------------------------------------------------------------
  170. X
  171. XLIB_DEFS        = $(SIO_DEFS) $(XLOG_DEFS) $(MISC_DEFS) $(TIMER_DEFS) $(SYSINC)
  172. X
  173. Xinstall:
  174. X    @cd $(SRCDIR) ;\
  175. 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
  176. X
  177. X
  178. Xclean:
  179. X    @for i in $(LIBNAMES) ; do ( cd $(SRCDIR)/$$i ; make clean ; ) done
  180. X
  181. X
  182. Xuninstall:
  183. X    @cd $(SRCDIR) ;\
  184. X    for i in $(LIBNAMES) ; do ( cd $$i ; make LIBDIR=$(LIBDIR) INCLUDEDIR=$(INCLUDEDIR) MANDIR=$(MANDIR) uninstall ) ; done
  185. X
  186. END_OF_FILE
  187. if test 4827 -ne `wc -c <'Makefile'`; then
  188.     echo shar: \"'Makefile'\" unpacked with wrong size!
  189. fi
  190. # end of 'Makefile'
  191. fi
  192. if test -f 'libs/src/misc/env.c' -a "${1}" != "-c" ; then 
  193.   echo shar: Will not clobber existing file \"'libs/src/misc/env.c'\"
  194. else
  195. echo shar: Extracting \"'libs/src/misc/env.c'\" \(4772 characters\)
  196. sed "s/^X//" >'libs/src/misc/env.c' <<'END_OF_FILE'
  197. X/*
  198. X * (c) Copyright 1992 by Panagiotis Tsirigotis
  199. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  200. X * and conditions for redistribution.
  201. X */
  202. X
  203. Xstatic char RCSid[] = "$Id: env.c,v 1.4 1992/11/03 00:07:50 panos Exp $" ;
  204. X
  205. X#include <memory.h>
  206. X#include <string.h>
  207. X
  208. X#include "misc.h"
  209. X#include "env.h"
  210. X
  211. Xtypedef struct __env env_s ;
  212. X
  213. X#define PRIVATE                    static
  214. X#define INITIAL_VARS                20
  215. X#define INCREASE                    10
  216. X
  217. X#ifndef NULL
  218. X#define NULL                        0
  219. X#endif
  220. X
  221. Xchar *malloc() ;
  222. Xchar *realloc() ;
  223. X
  224. Xint env_errno ;
  225. X
  226. X
  227. X
  228. XPRIVATE env_s *alloc_env( max_vars )
  229. X    unsigned max_vars ;
  230. X{
  231. X    env_s *ep ;
  232. X    unsigned size ;
  233. X    char **pointers ;
  234. X
  235. X    ep = (env_s *) malloc( sizeof( env_s ) ) ;
  236. X    if ( ep == ENV_NULL )
  237. X    {
  238. X        env_errno = ENV_ENOMEM ;
  239. X        return( ENV_NULL ) ;
  240. X    }
  241. X
  242. X    size = ( max_vars + 1 ) * sizeof( char * ) ;
  243. X    pointers = (char **) malloc( size ) ;
  244. X    if ( pointers == NULL )
  245. X    {
  246. X        free( (char *)ep ) ;
  247. X        env_errno = ENV_ENOMEM ;
  248. X        return( ENV_NULL ) ;
  249. X    }
  250. X    (void) memset( (char *)pointers, 0, (int) size ) ;
  251. X
  252. X    ep->vars = pointers ;
  253. X    ep->max_vars = max_vars ;
  254. X    ep->n_vars = 0 ;
  255. X    return( ep ) ;
  256. X}
  257. X
  258. X
  259. Xenv_h env_create( init_env )
  260. X    env_h init_env ;
  261. X{
  262. X    unsigned u ;
  263. X    env_s *ep ;
  264. X    unsigned max_vars ;
  265. X
  266. X    if ( init_env == ENV_NULL )
  267. X        max_vars = INITIAL_VARS ;
  268. X    else
  269. X        max_vars = init_env->n_vars + 5 ;
  270. X    
  271. X    ep = alloc_env( max_vars ) ;
  272. X    if ( ep == NULL )
  273. X    {
  274. X        env_errno = ENV_ENOMEM ;
  275. X        return( ENV_NULL ) ;
  276. X    }
  277. X
  278. X    if ( init_env == ENV_NULL )
  279. X        return( ep ) ;
  280. X
  281. X    for ( u = 0, ep->n_vars = 0 ; u < init_env->n_vars ; u++, ep->n_vars++ )
  282. X    {
  283. X        ep->vars[ ep->n_vars ] = make_string( 1, init_env->vars[ u ] ) ;
  284. X        if ( ep->vars[ ep->n_vars ] == NULL )
  285. X        {
  286. X            env_destroy( ep ) ;
  287. X            env_errno = ENV_ENOMEM ;
  288. X            return( ENV_NULL ) ;
  289. X        }
  290. X    }
  291. X    return( ep ) ;
  292. X}
  293. X
  294. X
  295. Xvoid env_destroy( env )
  296. X    env_h env ;
  297. X{
  298. X    unsigned u ;
  299. X
  300. X    for ( u = 0 ; u < env->n_vars ; u++ )
  301. X        free( env->vars[ u ] ) ;
  302. X    free( (char *)env->vars ) ;
  303. X    free( (char *)env ) ;
  304. X}
  305. X
  306. X
  307. Xenv_h env_make( env_strings )
  308. X    char **env_strings ;
  309. X{
  310. X    env_s *ep ;
  311. X    char **pp ;
  312. X
  313. X    for ( pp = env_strings ; *pp ; pp++ ) ;
  314. X
  315. X    ep = alloc_env( (unsigned) (pp-env_strings) ) ;
  316. X    if ( ep == NULL )
  317. X    {
  318. X        env_errno = ENV_ENOMEM ;
  319. X        return( ENV_NULL ) ;
  320. X    }
  321. X
  322. X    for ( pp = env_strings ; *pp ; pp++ )
  323. X    {
  324. X        char *p = make_string( 1, *pp ) ;
  325. X
  326. X        if ( p == NULL )
  327. X        {
  328. X            env_destroy( ep ) ;
  329. X            env_errno = ENV_ENOMEM ;
  330. X            return( ENV_NULL ) ;
  331. X        }
  332. X        ep->vars[ ep->n_vars++ ] = p ;
  333. X    }
  334. X    return( ep ) ;
  335. X}
  336. X
  337. X
  338. Xchar *env_lookup( env, var )
  339. X    env_h env ;
  340. X    char *var ;
  341. X{
  342. X    char **lookup() ;
  343. X    char **pp = lookup( env, var, strlen( var ) ) ;
  344. X
  345. X    return( ( pp == NULL ) ? NULL : *pp ) ;
  346. X}
  347. X
  348. X
  349. XPRIVATE char **lookup( env, var, len )
  350. X    env_h env ;
  351. X    char *var ;
  352. X    register int len ;
  353. X{
  354. X    register char **pp ;
  355. X
  356. X    for ( pp = env->vars ; *pp ; pp++ )
  357. X        if ( strncmp( *pp, var, len ) == 0 && (*pp)[ len ] == '=' )
  358. X            return( pp ) ;
  359. X    return( NULL ) ;
  360. X}
  361. X
  362. X
  363. XPRIVATE int grow( ep )
  364. X    env_s *ep ;
  365. X{
  366. X    char **new_vars ;
  367. X    unsigned new_max_vars ;
  368. X    unsigned new_size ;
  369. X
  370. X    new_max_vars = ep->max_vars + INCREASE ;
  371. X    new_size = ( new_max_vars+1 ) * sizeof( char * ) ;
  372. X    new_vars = (char **) realloc( (char *)ep->vars, new_size ) ;
  373. X    if ( new_vars == NULL )
  374. X        return( ENV_ERR ) ;
  375. X    
  376. X    ep->vars = new_vars ;
  377. X    ep->max_vars = new_max_vars ;
  378. X    return( ENV_OK ) ;
  379. X}
  380. X
  381. X
  382. X/*
  383. X * Add the variable string to the given environment.
  384. X */
  385. XPRIVATE int addstring( ep, var_string, len )
  386. X    env_s *ep ;
  387. X    char *var_string ;
  388. X    int len ;
  389. X{
  390. X    char **pp ;
  391. X    char *p ;
  392. X
  393. X    p = make_string( 1, var_string ) ;
  394. X    if ( p == NULL )
  395. X        return( ENV_ERR ) ;
  396. X        
  397. X    pp = lookup( ep, var_string, len ) ;
  398. X    if ( pp == NULL )
  399. X    {
  400. X        if ( ep->n_vars >= ep->max_vars && grow( ep ) == ENV_ERR )
  401. X        {
  402. X            free( p ) ;
  403. X            env_errno = ENV_ENOMEM ;
  404. X            return( ENV_ERR ) ;
  405. X        }
  406. X        ep->vars[ ep->n_vars++ ] = p ;
  407. X    }
  408. X    else
  409. X    {
  410. X        free( *pp ) ;
  411. X        *pp = p ;
  412. X    }
  413. X    return( ENV_OK ) ;
  414. X}
  415. X
  416. X
  417. Xint env_addvar( env, from_env, var_name )
  418. X    env_h env ;
  419. X    env_h from_env ;
  420. X    char *var_name ;
  421. X{
  422. X    char *var_string = env_lookup( from_env, var_name ) ;
  423. X
  424. X    if ( var_string == NULL )
  425. X    {
  426. X        env_errno = ENV_EBADVAR ;
  427. X        return( ENV_ERR ) ;
  428. X    }
  429. X
  430. X    return( addstring( env, var_string, strlen( var_name ) ) ) ;
  431. X}
  432. X
  433. X
  434. Xint env_addstr( env, var_string )
  435. X    env_h env ;
  436. X    char *var_string ;
  437. X{
  438. X    char *p = strchr( var_string, '=' ) ;
  439. X
  440. X    if ( p == NULL )
  441. X    {
  442. X        env_errno = ENV_EBADSTRING ;
  443. X        return( ENV_ERR ) ;
  444. X    }
  445. X    
  446. X    return( addstring( env, var_string, p-var_string ) ) ;
  447. X}
  448. X
  449. X
  450. Xint env_remvar( env, var )
  451. X    env_h env ;
  452. X    char *var ;
  453. X{
  454. X    char **pp = lookup( env, var, strlen( var ) ) ;
  455. X
  456. X    if ( pp == NULL )
  457. X    {
  458. X        env_errno = ENV_EBADVAR ;
  459. X        return( ENV_ERR ) ;
  460. X    }
  461. X    
  462. X    free( *pp ) ;
  463. X    *pp = env->vars[ --env->n_vars ] ;
  464. X    return( ENV_OK ) ;
  465. X}
  466. X
  467. X
  468. X#ifdef notdef
  469. XPRIVATE int comparator( p1, p2 )
  470. X    char **p1, **p2 ;
  471. X{
  472. X    return( strcmp( *p1, *p2 ) ) ;
  473. X}
  474. X
  475. X
  476. Xvoid env_sort( env )
  477. X    env_h env ;
  478. X{
  479. X    qsort( (char *)env->vars, env->n_vars, sizeof( char * ), comparator ) ;
  480. X}
  481. X#endif
  482. END_OF_FILE
  483. if test 4772 -ne `wc -c <'libs/src/misc/env.c'`; then
  484.     echo shar: \"'libs/src/misc/env.c'\" unpacked with wrong size!
  485. fi
  486. # end of 'libs/src/misc/env.c'
  487. fi
  488. if test -f 'libs/src/sio/README' -a "${1}" != "-c" ; then 
  489.   echo shar: Will not clobber existing file \"'libs/src/sio/README'\"
  490. else
  491. echo shar: Extracting \"'libs/src/sio/README'\" \(4699 characters\)
  492. sed "s/^X//" >'libs/src/sio/README' <<'END_OF_FILE'
  493. X======================================================================
  494. XNOTE: I use vi with a tabstop value of 3. Using the same tabstop
  495. X        value will make the text/code look properly indented.
  496. X======================================================================
  497. X
  498. X
  499. X1. What is SIO ?
  500. X
  501. XSIO is a library that provides _stream_ I/O which is what most Unix
  502. Xprograms do. As such it is a competitor to stdio.
  503. X
  504. X
  505. X2. Why would you care to use it ?
  506. X
  507. Xa. SIO is a little faster than stdio
  508. Xb. SIO provides an easier-to-use interface (IMHO)
  509. Xc. SIO is capable of using memory mapping for reading files if the operating
  510. X    system supports it.
  511. Xd. If you have a program that uses read(2)/write(2) it is trivial
  512. X   to convert it to use SIO (just replace read with Sread and 
  513. X   write with Swrite)
  514. Xe. You get source
  515. X
  516. X
  517. X
  518. X3. Setting up the Stream I/O (SIO) library
  519. X
  520. XThere are 3 steps to the process:
  521. X    1) compiling SIO for your system
  522. X    2) testing SIO
  523. X    3) installing the library and manpages
  524. X
  525. X
  526. X3.1. How to compile the Stream I/O (SIO) library
  527. X
  528. XAll the system-dependent stuff of SIO is placed in the sioconf.h file.
  529. XIf your system is not among those listed below, you will need to read
  530. Xthat file to see what flags you need to set to properly compile SIO.
  531. X
  532. X    SunOS 4.x:
  533. X        make "DEFS=-DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY"
  534. X
  535. X    SunOS 5.x (aka Solaris 2.y):
  536. X        make "DEFS=-DHAS_MMAP -DHAS_ATEXIT -DHAS_MEMOPS -DHAS_ISATTY"
  537. X    (I don't have access to a system running Solaris 2.y so I have not
  538. X    tested this)
  539. X
  540. X    Ultrix 4.x:
  541. X        make "DEFS=-DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY"
  542. X
  543. XIf your system is one of the above, then you can skip to the next subsection.
  544. XHowever, I should mention that the library compiles by default with
  545. Xdebugging enabled (i.e. uses the -g flag of cc). You can override this
  546. Xby appending to the above invocations of 'make' the argument "DEBUG=-O"
  547. X
  548. XIf your system is not among the above, then you will need to modify the
  549. Xsioconf.h file. You do this by uncommenting the inclusion of
  550. Xcustomconf.h. Then, you can override all constants/macros defined in
  551. Xsioconf.h by defining them first in customconf.h.  Please read
  552. Xsioconf.h for more information on what constants/macros can be
  553. Xdefined.
  554. X
  555. XThe Makefile has a header that explains what the Makefile can do.
  556. XThe only flag that you may want to define is -DDEBUG which enables 
  557. Xassertions in the SIO code (if an assertion fails, the program is 
  558. Xterminated with an error message that lists the SIO file and line 
  559. Xnumber where the error occured).
  560. X
  561. X
  562. X3.2. Testing SIO
  563. X
  564. XAfter you have successfully compiled SIO, you can use the programs in
  565. Xthe "suite" directory to test the SIO functions. It may make you feel
  566. Xbetter if you test the library before installing it.
  567. XThe script testlib does everything; just type:
  568. X
  569. X    testlib all
  570. X
  571. XThe script sprint_test (invoked by testlib) tests Sprint by using a variety 
  572. Xof formats and comparing its output with that of an ANSI-compatible printf.
  573. XAt least on Ultrix 4.1 and 4.2 this test fails because printf is not 
  574. XANSI-compatible.
  575. XIn such a case, you can test the rest of the SIO functions by typing:
  576. X
  577. X    testlib all Sprint
  578. X
  579. X(anything after the 'all' argument is interpreted as a function that
  580. Xshould not be tested).
  581. X
  582. XThe README file in the "suite" directory describes how to do a
  583. Xfew more tests that cannot be done automatically.
  584. X
  585. X
  586. X3.3. Installing the library and manpages
  587. X
  588. XThe default 'make' target will create libsio.a in the current directory.
  589. XThe Makefile includes an "install" target. Doing a 'make install' will 
  590. Xcause the following:
  591. X
  592. Xa) libsio.a will be installed in LIBDIR
  593. Xb) the necessary SIO header files will be installed in INCLUDEDIR
  594. Xc) the SIO man pages will be installed in MANDIR
  595. X
  596. XLIBDIR, INCLUDEDIR, and MANDIR are Makefile variables that you can edit in
  597. Xthe Makefile or override when you invoke 'make'.
  598. XHere is a sample command to install SIO:
  599. X
  600. X    make install LIBDIR=/usr/local/lib INCLUDEDIR=/usr/local/include MANDIR=/usr/local/man/man3
  601. X
  602. X
  603. X4. Epilogue
  604. X
  605. XFeel free to modify SIO to suit your needs. Please let me know if you
  606. Xfind any bugs (my email address is panos@cs.colorado.edu).
  607. X
  608. XIf you want to distribute your modifications, please read the COPYRIGHT
  609. Xfile.  It basically says that you are free to redistribute as long as
  610. Xyou retain the original copyright notice and you make sure that your
  611. Xmodifications are identifiable. In order to achieve this I have
  612. Xreserved the first 3 components of the version number (for example,
  613. X1.4.2) and you can identify your mods by appending another component to
  614. Xthat version number (for example, 1.4.2.A2). Also, if you distribute a
  615. Xmodified version of the library, you take full responsibility for any
  616. Xbugs in the code (not just your code; the whole thing).
  617. X
  618. X
  619. X    ** Panos Tsirigotis **
  620. X
  621. END_OF_FILE
  622. if test 4699 -ne `wc -c <'libs/src/sio/README'`; then
  623.     echo shar: \"'libs/src/sio/README'\" unpacked with wrong size!
  624. fi
  625. # end of 'libs/src/sio/README'
  626. fi
  627. if test -f 'libs/src/sio/sioconf.h' -a "${1}" != "-c" ; then 
  628.   echo shar: Will not clobber existing file \"'libs/src/sio/sioconf.h'\"
  629. else
  630. echo shar: Extracting \"'libs/src/sio/sioconf.h'\" \(5101 characters\)
  631. sed "s/^X//" >'libs/src/sio/sioconf.h' <<'END_OF_FILE'
  632. X/*
  633. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  634. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  635. X * and conditions for redistribution.
  636. X */
  637. X
  638. X
  639. X/*
  640. X * $Id: sioconf.h,v 8.5 1993/03/17 02:54:47 panos Exp $
  641. X */
  642. X
  643. X/*
  644. X * This file has 2 sections:
  645. X *        1. a OS-specific section
  646. X *        2. a CPU/compiler-specific section
  647. X *
  648. X * You can override/redefing any of the constants/macros in this file.
  649. X * by uncommenting the inclusion of customconf.h and placing your own
  650. X * definitions in that file.
  651. X */
  652. X
  653. X/* #include "customconf.h" */
  654. X
  655. X
  656. X
  657. X/*
  658. X * OS-specific section.
  659. X *
  660. X * Features here use the flag HAS_<feature>.
  661. X * List of flags (check the following for macros that can be overriden):
  662. X *
  663. X *            HAS_MMAP (overridable macros)
  664. X *
  665. X *            HAS_ATEXIT
  666. X *            HAS_ONEXIT
  667. X *            HAS_OTHER_FINALIZER    (must define macros)
  668. X *
  669. X *            HAS_MEMOPS
  670. X *            HAS_BCOPY             (HAS_MEMOPS will be preferred if both are defined)
  671. X *
  672. X *    At least one of the following flags must be defined. The 2nd and 3rd
  673. X * flags are incompatible.
  674. X *            HAS_ISATTY
  675. X *            HAS_SYSVTTY
  676. X *            HAS_BSDTTY
  677. X */
  678. X
  679. X/*
  680. X * Memory mapping.
  681. X *        The library requires 3 macros: SIO_MMAP, SIO_MUNMAP, SIO_MNEED.
  682. X *        You can selectively override any of them.
  683. X *        Notice that the SIO_MNEED macro is not required. If your system
  684. X *        does not have madvise, you can define the macro as:
  685. X *            #define SIO_MNEED( addr, len )
  686. X */
  687. X#ifdef HAS_MMAP
  688. X
  689. X#if !defined( SIO_MMAP ) || !defined( SIO_MUNMAP ) || !defined( SIO_MNEED )
  690. X#include <sys/types.h>
  691. X#include <sys/mman.h>
  692. X#endif
  693. X
  694. X#ifndef SIO_MMAP
  695. X#define SIO_MMAP( addr, len, fd, off )                                  \
  696. X         mmap( addr, len, PROT_READ,                                    \
  697. X            ( addr == 0 ) ? MAP_PRIVATE : MAP_PRIVATE + MAP_FIXED,      \
  698. X               fd, off )
  699. X#endif
  700. X
  701. X#ifndef SIO_MUNMAP
  702. X#define SIO_MUNMAP( addr, len )  munmap( addr, len )
  703. X#endif
  704. X
  705. X#ifndef SIO_MNEED
  706. X#define SIO_MNEED( addr, len )      (void) madvise( addr, len, MADV_WILLNEED )
  707. X#endif
  708. X
  709. X#endif    /* HAS_MMAP */
  710. X
  711. X/*
  712. X * N_SIO_DESCRIPTORS is the maximum number of file descriptors
  713. X * supported by the OS
  714. X */
  715. X#ifndef N_SIO_DESCRIPTORS
  716. X#include <sys/param.h>
  717. X#define N_SIO_DESCRIPTORS        NOFILE
  718. X#endif
  719. X
  720. X
  721. X
  722. X/*
  723. X * Finalization function. 
  724. X *
  725. X * The purpose of this function is to do work after your program has
  726. X * called exit(3). In the case of SIO, this means flushing the SIO
  727. X * output buffers.
  728. X *
  729. X * If your system does not support atexit or onexit but has some other
  730. X * way of installing a finalization function, you define the flag 
  731. X * HAS_FINALIZER. Then you must define the macros 
  732. X *            SIO_FINALIZE and SIO_DEFINE_FIN
  733. X *
  734. X * SIO_FINALIZE attempts to install a finalization function and returns TRUE 
  735. X * if successful, FALSE if unsuccessful.
  736. X * SIO_DEFINE_FIN defines the finalization function (the reason for this macro
  737. X * s that different systems pass different number/type of arguments to the
  738. X * finalization function; the SIO finalization function does not use any
  739. X * arguments).
  740. X */
  741. X#if defined(HAS_ONEXIT) || defined(HAS_ATEXIT) || defined(HAS_FINALIZER)
  742. X
  743. X#define HAS_FINALIZATION_FUNCTION
  744. X
  745. X#if defined( HAS_ONEXIT ) && defined( HAS_ATEXIT )
  746. X#undef HAS_ONEXIT
  747. X#endif
  748. X
  749. X#ifdef HAS_ONEXIT
  750. X#define SIO_FINALIZE( func )        ( on_exit( func, (caddr_t) 0 ) == 0 )
  751. X#define SIO_DEFINE_FIN( func )      static void func ( exit_status, arg )  \
  752. X                                          int exit_status ;                \
  753. X                                          caddr_t arg ;
  754. X#endif    /* HAS_ONEXIT */
  755. X
  756. X#ifdef HAS_ATEXIT
  757. X#define SIO_FINALIZE( func )        ( atexit( func ) == 0 )
  758. X#define SIO_DEFINE_FIN( func )      static void func ()
  759. X#endif    /* HAS_ATEXIT */
  760. X
  761. X#endif    /* HAS_ONEXIT || HAS_ATEXIT || HAS_FINALIZER */
  762. X
  763. X
  764. X/*
  765. X * HAS_MEMOPS should be defined if your OS supports the mem* functions
  766. X * (memcpy etc). If not, then you can define HAS_BCOPY if your OS supports 
  767. X * bcopy.
  768. X */
  769. X#if defined( HAS_MEMOPS ) && defined( HAS_BCOPY )
  770. X#undef HAS_BCOPY
  771. X#endif
  772. X
  773. X
  774. X/*
  775. X * Support for the isatty(3) function. This function identifies if a 
  776. X * desciptor refers to a terminal.
  777. X *
  778. X * Case 1: isatty(3) is in the C library
  779. X *        --> define HAS_ISATTY
  780. X *    Case 2: no isatty(3), BSD 4.3 tty handling
  781. X *        --> define HAS_BSDTTY
  782. X * Case 3: no isatty(3), System V tty handling
  783. X *        --> define HAS_SYSVTTY
  784. X *
  785. X * The following code checks:
  786. X *        1) that at least one of the flags is defined
  787. X *        2) only one of the BSD, SYS V flags is defined
  788. X */
  789. X#if !defined(HAS_ISATTY) && !defined(HAS_BSDTTY) && !defined(HAS_SYSVTTY)
  790. XERROR function_isatty_not_available ;
  791. X#endif
  792. X
  793. X#ifdef HAS_ISATTY
  794. X#undef HAS_BSDTTY
  795. X#undef HAS_SYSVTTY
  796. X#endif
  797. X
  798. X#if defined(HAS_BSDTTY) && defined(HAS_SYSVTTY)
  799. XERROR HAS_BSDTTY_and_HAS_SYSVTTY_both_defined ;
  800. X#endif
  801. X
  802. X
  803. X
  804. X/*
  805. X * CPU/compiler-specific section.
  806. X *
  807. X * The following constant affects the behavior of Sprint.
  808. X *
  809. X * Sprint performs integer->string conversions by first converting
  810. X * the integer to the widest int type supported by the CPU/compiler.
  811. X * By default, this is the "long int" type. If your machine has
  812. X * a wider type, you can specify it by defining the WIDE_INT constant.
  813. X * For example:
  814. X *        #define WIDE_INT                    long long
  815. X */
  816. X
  817. END_OF_FILE
  818. if test 5101 -ne `wc -c <'libs/src/sio/sioconf.h'`; then
  819.     echo shar: \"'libs/src/sio/sioconf.h'\" unpacked with wrong size!
  820. fi
  821. # end of 'libs/src/sio/sioconf.h'
  822. fi
  823. if test -f 'libs/src/xlog/xlog.c' -a "${1}" != "-c" ; then 
  824.   echo shar: Will not clobber existing file \"'libs/src/xlog/xlog.c'\"
  825. else
  826. echo shar: Extracting \"'libs/src/xlog/xlog.c'\" \(5105 characters\)
  827. sed "s/^X//" >'libs/src/xlog/xlog.c' <<'END_OF_FILE'
  828. X/*
  829. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  830. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  831. X * and conditions for redistribution.
  832. X */
  833. X
  834. Xstatic char RCSid[] = "$Id: xlog.c,v 2.2 1993/10/28 01:38:48 panos Exp $" ;
  835. Xstatic char version[] = VERSION ;
  836. X
  837. X#include <varargs.h>
  838. X
  839. X#include "xlog.h"
  840. X#include "impl.h"
  841. X
  842. Xchar *malloc() ;
  843. X
  844. Xextern struct xlog_ops __xlog_filelog_ops ;
  845. X#ifndef NO_SYSLOG
  846. Xextern struct xlog_ops __xlog_syslog_ops ;
  847. X#endif
  848. X
  849. Xstruct lookup_table
  850. X{
  851. X    struct xlog_ops    *ops ;
  852. X    xlog_e                type ;
  853. X} ;
  854. X
  855. Xstatic struct lookup_table ops_lookup_table[] =
  856. X    {
  857. X        { &__xlog_filelog_ops,                XLOG_FILELOG    },
  858. X#ifndef NO_SYSLOG
  859. X        { &__xlog_syslog_ops,                XLOG_SYSLOG        },
  860. X#endif
  861. X        { NULL }
  862. X    } ;
  863. X
  864. X
  865. X#define CALLBACK( xp, status )                                                                 \
  866. X        if ( (xp)->xl_callback )                                                                 \
  867. X            (*(xp)->xl_callback)( (xlog_h)(xp), status, (xp)->xl_callback_arg )
  868. X
  869. X
  870. XPRIVATE void xlog_link() ;
  871. XPRIVATE void xlog_unlink() ;
  872. X
  873. X
  874. XPRIVATE struct xlog_ops *xlog_ops_lookup( type )
  875. X    register xlog_e type ;
  876. X{
  877. X    register struct lookup_table *ltp ;
  878. X
  879. X    for ( ltp = &ops_lookup_table[ 0 ] ; ltp->ops ; ltp++ )
  880. X        if ( ltp->type == type )
  881. X            break ;
  882. X    return( ltp->ops ) ;
  883. X}
  884. X
  885. X
  886. X
  887. X/* VARARGS3 */
  888. Xxlog_h xlog_create( type, id, flags, va_alist )
  889. X    xlog_e    type ;
  890. X    char        *id ;
  891. X    int        flags ;
  892. X    va_dcl
  893. X{
  894. X    xlog_s                *xp ;
  895. X    va_list                ap ;
  896. X    struct xlog_ops    *xops ;
  897. X    int                    status ;
  898. X
  899. X    if ( ( xp = NEW( xlog_s ) ) == NULL )
  900. X        return( NULL ) ;
  901. X    
  902. X    if ( id == NULL || ( xp->xl_id = __xlog_new_string( id ) ) == NULL )
  903. X    {
  904. X        FREE( xp ) ;
  905. X        return( NULL ) ;
  906. X    }
  907. X
  908. X    xops = xlog_ops_lookup( type ) ;
  909. X    
  910. X    if ( xops != NULL )
  911. X    {
  912. X        va_start( ap ) ;
  913. X        xp->xl_ops = xops ;
  914. X        status = XL_INIT( xp, ap ) ;
  915. X        va_end( ap ) ;
  916. X
  917. X        if ( status == XLOG_ENOERROR )
  918. X        {
  919. X            xp->xl_flags = flags ;
  920. X            xp->xl_type = type ;
  921. X            xp->xl_clients = XLOG_NULL ;
  922. X            xp->xl_use = XLOG_NULL ;
  923. X            return( (xlog_h) xp ) ;
  924. X        }
  925. X    }
  926. X
  927. X    free( xp->xl_id ) ;
  928. X    FREE( xp ) ;
  929. X    return( NULL ) ;
  930. X}
  931. X
  932. X
  933. X
  934. XPRIVATE void xlog_link( client, server )
  935. X    xlog_s *client, *server ;
  936. X{
  937. X    client->xl_use = server ;
  938. X    if ( server == NULL )
  939. X        return ;
  940. X
  941. X    if ( server->xl_clients == XLOG_NULL )
  942. X    {
  943. X        INIT_LINKS( client, xl_other_users ) ;
  944. X        server->xl_clients = client ;
  945. X    }
  946. X    else
  947. X        LINK( server, client, xl_other_users ) ;
  948. X}
  949. X
  950. X
  951. XPRIVATE void xlog_unlink( xp )
  952. X    xlog_s *xp ;
  953. X{
  954. X    xlog_s *server = xp->xl_use ;
  955. X
  956. X    /*
  957. X     * Step 1: remove from server chain
  958. X     */
  959. X    if ( server != XLOG_NULL )
  960. X    {
  961. X        if ( server->xl_clients == xp )
  962. X            if ( NEXT( xp, xl_other_users ) == xp )
  963. X                server->xl_clients = XLOG_NULL ;
  964. X            else
  965. X                server->xl_clients = NEXT( xp, xl_other_users ) ;
  966. X        else
  967. X            UNLINK( xp, xl_other_users ) ;
  968. X    }
  969. X
  970. X    /*
  971. X     * Step 2: If we have users, clear their link to us.
  972. X     */
  973. X    if ( xp->xl_clients != NULL )
  974. X    {
  975. X        xlog_s *xp2 = xp->xl_clients ;
  976. X
  977. X        do
  978. X        {
  979. X            xp2->xl_use = XLOG_NULL ;
  980. X            xp2 = NEXT( xp2, xl_other_users ) ;
  981. X        }
  982. X        while ( xp2 != xp->xl_clients ) ;
  983. X    }
  984. X}
  985. X
  986. X
  987. XPRIVATE void xlog_flags( xp, cmd, ap )
  988. X    xlog_s        *xp ;
  989. X    xlog_cmd_e    cmd ;
  990. X    va_list        ap ;
  991. X{
  992. X    int    flag            = va_arg( ap, int ) ;
  993. X    int    old_value    = ( ( xp->xl_flags & flag ) != 0 ) ;
  994. X    int    *valp            = va_arg( ap, int * ) ;
  995. X
  996. X    if ( cmd == XLOG_SETFLAG )
  997. X        if ( *valp )
  998. X            xp->xl_flags |= flag ;
  999. X        else
  1000. X            xp->xl_flags &= ~flag ;
  1001. X    *valp = old_value ;
  1002. X}
  1003. X
  1004. X
  1005. Xvoid xlog_destroy( xlog )
  1006. X    xlog_h xlog ;
  1007. X{
  1008. X    xlog_s *xp = XP( xlog ) ;
  1009. X
  1010. X    xlog_unlink( xp ) ;
  1011. X    XL_FINI( xp ) ;
  1012. X    free( xp->xl_id ) ;
  1013. X    FREE( xp ) ;
  1014. X}
  1015. X
  1016. X
  1017. X/* VARARGS4 */
  1018. Xvoid xlog_write( xlog, buf, len, flags, va_alist )
  1019. X    xlog_h    xlog ;
  1020. X    char        buf[] ;
  1021. X    int        len ;
  1022. X    int        flags ;
  1023. X    va_dcl
  1024. X{
  1025. X    xlog_s    *xp = XP( xlog ) ;
  1026. X    va_list    ap ;
  1027. X    int        status ;
  1028. X
  1029. X    va_start( ap ) ;
  1030. X    status = XL_WRITE( xp, buf, len, flags, ap ) ;
  1031. X    va_end( ap ) ;
  1032. X
  1033. X    if ( status != XLOG_ENOERROR )
  1034. X    {
  1035. X        CALLBACK( xp, status ) ;
  1036. X    }
  1037. X}
  1038. X
  1039. X
  1040. X/* VARARGS2 */
  1041. Xint xlog_control( xlog, cmd, va_alist )
  1042. X    xlog_h        xlog ;
  1043. X    xlog_cmd_e    cmd ;
  1044. X    va_dcl
  1045. X{
  1046. X    va_list    ap ;
  1047. X    xlog_s    *xp        = XP( xlog ) ;
  1048. X    int        status    = XLOG_ENOERROR ;
  1049. X
  1050. X    va_start( ap ) ;
  1051. X
  1052. X    switch ( cmd )
  1053. X    {
  1054. X        case XLOG_LINK:
  1055. X            xlog_unlink( xp ) ;
  1056. X            xlog_link( xp, va_arg( ap, xlog_s * ) ) ;
  1057. X            xp->xl_callback_arg = va_arg( ap, void * ) ;
  1058. X            break ;
  1059. X        
  1060. X        case XLOG_CALLBACK:
  1061. X            xp->xl_callback = va_arg( ap, voidfunc ) ;
  1062. X            break ;
  1063. X            
  1064. X        case XLOG_GETFLAG:
  1065. X        case XLOG_SETFLAG:
  1066. X            xlog_flags( xp, cmd, ap ) ;
  1067. X            break ;
  1068. X
  1069. X        /*
  1070. X         * If the 'cmd' is not supported by the underlying logging object,
  1071. X         * XL_CONTROL should return XLOG_EBADOP, if the 'cmd' returns
  1072. X         * information to the caller (for example, XLOG_GETFD returns
  1073. X         * a file descriptor, so if this command is applied to a xlog
  1074. X         * that doesn't support it, it should return XLOG_EBADOP).
  1075. X         * XL_CONTROL should return XLOG_ENOERROR otherwise.
  1076. X         */
  1077. X        default:
  1078. X            status = XL_CONTROL( xp, cmd, ap ) ;
  1079. X    }
  1080. X
  1081. X    va_end( ap ) ;
  1082. X
  1083. X    return( status ) ;
  1084. X}
  1085. X
  1086. X
  1087. Xint xlog_parms( type, va_alist )
  1088. X    xlog_e type ;
  1089. X    va_dcl
  1090. X{
  1091. X    va_list    ap ;
  1092. X    int        status ;
  1093. X
  1094. X    va_start( ap ) ;
  1095. X    switch ( type )
  1096. X    {
  1097. X#ifndef NO_SYSLOG
  1098. X        case XLOG_SYSLOG:
  1099. X            status = (*__xlog_syslog_ops.parms)( ap ) ;
  1100. X            break ;
  1101. X#endif
  1102. X        case XLOG_FILELOG:
  1103. X            status = (*__xlog_filelog_ops.parms)( ap ) ;
  1104. X            break ;
  1105. X        
  1106. X        default:
  1107. X            status = XLOG_ENOERROR ;
  1108. X    }
  1109. X    va_end( ap ) ;
  1110. X    return( status ) ;
  1111. X}
  1112. X
  1113. END_OF_FILE
  1114. if test 5105 -ne `wc -c <'libs/src/xlog/xlog.c'`; then
  1115.     echo shar: \"'libs/src/xlog/xlog.c'\" unpacked with wrong size!
  1116. fi
  1117. # end of 'libs/src/xlog/xlog.c'
  1118. fi
  1119. echo shar: End of archive 10 \(of 20\).
  1120. cp /dev/null ark10isdone
  1121. MISSING=""
  1122. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  1123.     if test ! -f ark${I}isdone ; then
  1124.     MISSING="${MISSING} ${I}"
  1125.     fi
  1126. done
  1127. if test "${MISSING}" = "" ; then
  1128.     echo You have unpacked all 20 archives.
  1129.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1130. else
  1131.     echo You still need to unpack the following archives:
  1132.     echo "        " ${MISSING}
  1133. fi
  1134. ##  End of shell archive.
  1135. exit 0
  1136.