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

  1. Newsgroups: comp.sources.unix
  2. From: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
  3. Subject: v27i111: clc - C Libraries Collection, Part05/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 111
  10. Archive-Name: clc/part05
  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 5 (of 20)."
  19. # Contents:  libs/src/dict/dllimpl.h libs/src/misc/env.3
  20. #   libs/src/pset/pset.h libs/src/str/ss_impl.h libs/src/str/ss_kmp.c
  21. #   libs/src/str/ss_rk.c libs/src/str/ss_so.c libs/src/str/strprint.3
  22. #   libs/src/xlog/impl.h
  23. # Wrapped by panos@eclipse on Sun Nov 28 14:48:15 1993
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'libs/src/dict/dllimpl.h' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'libs/src/dict/dllimpl.h'\"
  27. else
  28. echo shar: Extracting \"'libs/src/dict/dllimpl.h'\" \(3016 characters\)
  29. sed "s/^X//" >'libs/src/dict/dllimpl.h' <<'END_OF_FILE'
  30. X/*
  31. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  32. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  33. X * and conditions for redistribution.
  34. X */
  35. X
  36. X
  37. X/*
  38. X * $Id: dllimpl.h,v 3.1 93/04/23 17:50:15 panos Exp $
  39. X */
  40. X
  41. X#include "dictimpl.h"
  42. X#include "dll.h"
  43. X
  44. Xstruct list_node
  45. X{
  46. X    struct list_node    *next ;
  47. X    struct list_node    *prev ;
  48. X    dict_obj                obj ;
  49. X} ;
  50. X
  51. Xtypedef struct list_node node_s ;
  52. X
  53. X
  54. X/*
  55. X * Macros for list_node's
  56. X */
  57. X#define NEXT( n )                (n)->next
  58. X#define PREV( n )                (n)->prev
  59. X#define OBJ( n )                (n)->obj
  60. X
  61. X
  62. X/*
  63. X * The oo_compare function is used for insertions and deletions.
  64. X * The ko_compare function is used in searches.
  65. X * These functions are expected to return:
  66. X *                a negative value     if        key(o1) < key(o2)
  67. X *                0                        if     key(o1) = key(o2)
  68. X *                a positive value     if        key(o1) > key(o2)
  69. X *
  70. X *
  71. X * The list is sorted according to some key. The package does not
  72. X * care what the key is. The order is defined by the two comparison
  73. X * functions (which, of course, should be consistent).
  74. X *
  75. X * We assume that key values get larger when we follow the _next_ chain
  76. X * and they get smaller when we follow the _prev_ chain.
  77. X *
  78. X *
  79. X * ABOUT HINTS:
  80. X *     a. We keep hints to avoid linear searches of the linked list.
  81. X *     b. A hint is either correct or non-existent.
  82. X *     c. To avoid bad hints, dll_delete sets the DATA field of a 
  83. X *            list_node to NULL.
  84. X *     d. We do not allow insertions of NULL.
  85. X *        e. An operation that uses/consults a hint always clears it or resets it.
  86. X *
  87. X *   --------------------------------------------------------------------
  88. X *  | OPERATIONS |                        HINTS                          |
  89. X *  |------------|-------------------------------------------------------|
  90. X *  |                  |    SEARCH    |    SUCCESSOR          |        PREDECESSOR  |
  91. X *  |------------|--------------|--------------------|-------------------|
  92. X *  | insert     |       X      |        X           |         X         |
  93. X *  | delete     | USE & CLEAR  |      CLEAR         |       CLEAR       |
  94. X *  | search     |      SET     |        X           |         X         |
  95. X *  | minimum    |       X      |       SET          |         X         |
  96. X *  | maximum    |       X      |        X           |        SET        |
  97. X *  | successor  |       X      |    USE & SET       |         X         |
  98. X *  | predecessor|       X      |        X           |     USE & SET     |
  99. X *   --------------------------------------------------------------------
  100. X *
  101. X */
  102. X
  103. X
  104. Xstruct hints
  105. X{
  106. X    node_s *last_search ;
  107. X    node_s *last_successor ;
  108. X    node_s *last_predecessor ;
  109. X} ;
  110. X
  111. X#include "fsma.h"
  112. X
  113. Xstruct dll_iterator
  114. X{
  115. X    node_s                    *next ;
  116. X    enum dict_direction    direction ;
  117. X} ;
  118. X
  119. Xstruct dll_header
  120. X{
  121. X    struct dict_header     dh ;
  122. X    struct hints             hint ;
  123. X    fsma_h                     alloc ;                        /* FSM allocator */
  124. X    node_s                    *head ;
  125. X    struct dll_iterator    iter ;
  126. X} ;
  127. X
  128. Xtypedef struct dll_header header_s ;
  129. X
  130. X#define DHP( hp )                    (&(hp->dh))
  131. X#define LHP( p )                    ((struct dll_header *) (p))
  132. X
  133. X#define HINT_CLEAR( hp, hint_name )        hp->hint.hint_name = hp->head
  134. X
  135. X
  136. END_OF_FILE
  137. if test 3016 -ne `wc -c <'libs/src/dict/dllimpl.h'`; then
  138.     echo shar: \"'libs/src/dict/dllimpl.h'\" unpacked with wrong size!
  139. fi
  140. # end of 'libs/src/dict/dllimpl.h'
  141. fi
  142. if test -f 'libs/src/misc/env.3' -a "${1}" != "-c" ; then 
  143.   echo shar: Will not clobber existing file \"'libs/src/misc/env.3'\"
  144. else
  145. echo shar: Extracting \"'libs/src/misc/env.3'\" \(2942 characters\)
  146. sed "s/^X//" >'libs/src/misc/env.3' <<'END_OF_FILE'
  147. X.\"(c) Copyright 1992 by Panagiotis Tsirigotis
  148. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  149. X.\"and conditions for redistribution.
  150. X.\"
  151. X.\" $Id: env.3,v 1.1 1992/10/20 20:44:30 panos Exp $
  152. X.TH ENV 3L "20 October 1992"
  153. X.SH NAME
  154. Xenv_create, env_destroy, env_make, env_addvar, env_addstr, env_remvar, env_lookup, env_getvars -- environment manipulation functions
  155. X.SH SYNOPSIS
  156. X.LP
  157. X.nf
  158. X.ft B
  159. X#include "env.h"
  160. X.LP
  161. X.ft B
  162. Xenv_h env_create( env )
  163. Xenv_h env ;
  164. X.LP
  165. X.ft B
  166. Xvoid env_destroy( env )
  167. Xenv_h env ;
  168. X.LP
  169. X.ft B
  170. Xenv_h env_make( env_strings )
  171. Xchar **env_strings ;
  172. X.LP
  173. X.ft B
  174. Xint env_addvar( env, from_env, var )
  175. Xenv_h env ;
  176. Xenv_h from_env ;
  177. Xchar *var ;
  178. X.LP
  179. X.ft B
  180. Xint env_addstr( env, str )
  181. Xenv_h env ;
  182. Xchar *str ;
  183. X.LP
  184. X.ft B
  185. Xint env_remvar( env, var )
  186. Xenv_h env ;
  187. Xchar *var ;
  188. X.LP
  189. X.ft B
  190. Xchar **env_getvars( env )
  191. Xenv_h env ;
  192. X.SH DESCRIPTION
  193. XThis library handles environments. An environment is a set of strings
  194. Xof the form 
  195. X.I "name=value".
  196. XIn the following, we will use the term string as a synonym of
  197. XNUL-terminated array of 
  198. X.I char.
  199. X.LP
  200. X.B env_create()
  201. Xcreates a new environment. The new environment will be empty unless
  202. Xthe argument
  203. X.I env
  204. Xis not
  205. X.SB ENV_NULL.
  206. XIn that case, the new environment will be a duplicate of 
  207. X.I env
  208. X(i.e. they will contain the same strings).
  209. X.LP
  210. X.B env_destroy()
  211. Xdestroys the specified environment.
  212. X.LP
  213. X.B env_make()
  214. Xcreates a new environment which includes the
  215. X.I env_strings.
  216. X.I env_strings
  217. Xshould be a NULL-terminated array of strings.
  218. X.LP
  219. X.B env_addvar()
  220. Xadds the specified variable
  221. X.I var
  222. Xto
  223. X.I env.
  224. XThe variable value is obtained from the environment
  225. X.I from_env.
  226. XIf the variable exists already in 
  227. X.I env
  228. Xthe old value is replaced with the new value.
  229. X.LP
  230. X.B env_addstr()
  231. Xadds a string of the form
  232. X.I "name=value"
  233. Xto
  234. X.I env.
  235. X.LP
  236. X.B env_remvar()
  237. Xremoves the specified variable
  238. X.I var
  239. Xfrom the environment
  240. X.I env.
  241. X.LP
  242. X.B env_lookup()
  243. Xsearches
  244. X.I env
  245. Xfor variable
  246. X.I var.
  247. XIt returns a string of the form
  248. X.I "name=value"
  249. Xwhere
  250. X.I name
  251. Xis the name of the variable
  252. X(i.e. it is equal to
  253. X.I var).
  254. X.LP
  255. X.B env_getvars
  256. Xreturns a NULL-terminated array of strings of the form
  257. X.I "name=value".
  258. X.SH "RETURN VALUES"
  259. XIn case of error, all calls will place an error code in the global variable
  260. X.I env_errno.
  261. XPossible error codes:
  262. X.TP 15
  263. X.SB ENV_ENOMEM
  264. Xout of memory
  265. X.TP
  266. X.SB ENV_EBADVAR
  267. Xvariable is not in environment
  268. X.TP
  269. X.SB ENV_EBADSTRING
  270. Xstring is not well-formed (i.e. is not of the form \fIname=value\fR).
  271. X.LP
  272. X.B env_create()
  273. Xreturns a handle or 
  274. X.SM ENV_NULL
  275. Xif it fails.
  276. X.LP
  277. X.B env_make()
  278. Xreturns a handle or 
  279. X.SM ENV_NULL
  280. Xif it fails.
  281. X.LP
  282. X.B env_addvar()
  283. Xreturns
  284. X.SM ENV_OK
  285. Xon success or
  286. X.SM ENV_ERR
  287. Xon failure.
  288. X.LP
  289. X.B env_addstr()
  290. Xreturns
  291. X.SM ENV_OK
  292. Xon success or
  293. X.SM ENV_ERR
  294. Xon failure.
  295. X.LP
  296. X.B env_remvar()
  297. Xreturns
  298. X.SM ENV_OK
  299. Xon success or
  300. X.SM ENV_ERR
  301. Xif the variable is not part of the environment.
  302. X.LP
  303. X.B env_loopkup()
  304. Xreturns a string on success or
  305. X.SM NULL
  306. Xon failure.
  307. X.SH "SEE ALSO"
  308. Xenviron(5)
  309. END_OF_FILE
  310. if test 2942 -ne `wc -c <'libs/src/misc/env.3'`; then
  311.     echo shar: \"'libs/src/misc/env.3'\" unpacked with wrong size!
  312. fi
  313. # end of 'libs/src/misc/env.3'
  314. fi
  315. if test -f 'libs/src/pset/pset.h' -a "${1}" != "-c" ; then 
  316.   echo shar: Will not clobber existing file \"'libs/src/pset/pset.h'\"
  317. else
  318. echo shar: Extracting \"'libs/src/pset/pset.h'\" \(3129 characters\)
  319. sed "s/^X//" >'libs/src/pset/pset.h' <<'END_OF_FILE'
  320. X/*
  321. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  322. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  323. X * and conditions for redistribution.
  324. X */
  325. X
  326. X#ifndef __PSET_H
  327. X#define __PSET_H
  328. X
  329. X/*
  330. X * $Id: pset.h,v 3.2 93/11/23 19:46:33 panos Exp $
  331. X */
  332. X
  333. Xtypedef void *__pset_pointer ;
  334. X
  335. Xstruct __pset
  336. X{
  337. X    unsigned            alloc_step ;
  338. X    __pset_pointer *ptrs ;
  339. X    unsigned            max ;
  340. X    unsigned            count ;
  341. X} ;
  342. X
  343. X
  344. X/*
  345. X * INTERFACE
  346. X */
  347. X
  348. X#ifdef __ARGS
  349. X#undef __ARGS
  350. X#endif
  351. X
  352. X#ifdef PROTOTYPES
  353. X#  define __ARGS( s )               s
  354. X#else
  355. X#  define __ARGS( s )               ()
  356. X#endif
  357. X
  358. Xtypedef struct __pset *pset_h ;
  359. X
  360. Xpset_h pset_create            __ARGS( ( unsigned start, unsigned step ) ) ;
  361. Xvoid pset_destroy                __ARGS( ( pset_h ) ) ;
  362. X
  363. X__pset_pointer pset_insert __ARGS( ( pset_h, __pset_pointer ) ) ;
  364. Xvoid pset_delete                __ARGS( ( pset_h, __pset_pointer ) ) ;
  365. X
  366. Xvoid pset_compact             __ARGS( ( pset_h ) ) ;
  367. Xvoid pset_uniq                 __ARGS( ( pset_h, void (*func)(), void *arg ) ) ;
  368. Xvoid pset_apply                 __ARGS( ( pset_h, void (*func)(), void *arg ) ) ;
  369. X
  370. X/*
  371. X * Macros
  372. X */
  373. X#define pset_add( pset, ptr )                                               \
  374. X      (                                                                 \
  375. X         ( (pset)->count < (pset)->max )                                \
  376. X            ? (pset)->ptrs[ (pset)->count++ ] = (__pset_pointer) ptr    \
  377. X            : pset_insert( (pset), (__pset_pointer) ptr )                    \
  378. X      )
  379. X
  380. X#define pset_remove( pset, ptr )            pset_delete( pset, (__pset_pointer)ptr )
  381. X
  382. X#define pset_remove_index( pset, i )                                                \
  383. X        {                                                                                        \
  384. X            if ( (i) < (pset)->count )                                                    \
  385. X                 (pset)->ptrs[ i ] = (pset)->ptrs[ --(pset)->count ] ;        \
  386. X        }
  387. X
  388. X#define pset_clear( pset )                (pset)->count = 0
  389. X#define pset_count( pset )                (pset)->count
  390. X#define pset_pointer( pset, i )        (pset)->ptrs[ i ]
  391. X
  392. X#define pset_sort( pset, compfunc )                                                    \
  393. X        (void) qsort( (char *) &pset_pointer( pset, 0 ),                        \
  394. X                pset_count( pset ), sizeof( __pset_pointer ), compfunc )
  395. X
  396. X/*
  397. X * PSET iterators
  398. X * 
  399. X * Note that the iterators do NOT use any knowledge about the internals
  400. X * of pset's.
  401. X */
  402. Xstruct __pset_iterator
  403. X{
  404. X    pset_h pset ;
  405. X    unsigned current ;
  406. X    int step ;
  407. X} ;
  408. X
  409. Xtypedef struct __pset_iterator *psi_h ;
  410. X
  411. X
  412. X#define __psi_current( iter )                                                            \
  413. X                        ( (iter)->current < pset_count( (iter)->pset )            \
  414. X                            ? pset_pointer( (iter)->pset, (iter)->current )        \
  415. X                            : NULL )
  416. X
  417. X#define psi_start( iter )                                                            \
  418. X                    ( (iter)->current = 0, (iter)->step = 1,                        \
  419. X                    __psi_current( iter ) )
  420. X
  421. X#define psi_next( iter )                                                             \
  422. X                    ( (iter)->current += (iter)->step, (iter)->step = 1,        \
  423. X                    __psi_current( iter ) )
  424. X
  425. X#define psi_remove( iter )                                                            \
  426. X                {                                                                                \
  427. X                    if ( (iter)->current < pset_count( (iter)->pset ) )        \
  428. X                    {                                                                            \
  429. X                        pset_remove_index( (iter)->pset, (iter)->current ) ;    \
  430. X                        (iter)->step = 0 ;                                                \
  431. X                    }                                                                            \
  432. X                }
  433. X
  434. X#define psi_reset( iter, newpset )        (iter)->pset = (newpset)
  435. X
  436. X#define psi_destroy( iter )                free( (char *) iter )
  437. X
  438. Xpsi_h psi_create __ARGS( ( pset_h ) ) ;
  439. X
  440. X#endif    /* __PSET_H */
  441. X
  442. END_OF_FILE
  443. if test 3129 -ne `wc -c <'libs/src/pset/pset.h'`; then
  444.     echo shar: \"'libs/src/pset/pset.h'\" unpacked with wrong size!
  445. fi
  446. # end of 'libs/src/pset/pset.h'
  447. fi
  448. if test -f 'libs/src/str/ss_impl.h' -a "${1}" != "-c" ; then 
  449.   echo shar: Will not clobber existing file \"'libs/src/str/ss_impl.h'\"
  450. else
  451. echo shar: Extracting \"'libs/src/str/ss_impl.h'\" \(2969 characters\)
  452. sed "s/^X//" >'libs/src/str/ss_impl.h' <<'END_OF_FILE'
  453. X/*
  454. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  455. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  456. X * and conditions for redistribution.
  457. X */
  458. X
  459. X#ifndef SS_IMPL_H
  460. X#define SS_IMPL_H
  461. X
  462. X/*
  463. X * $Id: ss_impl.h,v 3.2 1993/06/16 00:06:34 panos Exp $
  464. X */
  465. X
  466. X/*
  467. X * NBIC is the Number-of-Bits-In-a-Char
  468. X */
  469. X#ifndef NBIC
  470. X#define NBIC                                8
  471. X#endif
  472. X
  473. X#define ALPHABET_SIZE                    ( 1 << NBIC )
  474. X
  475. X#ifndef WIDE_INT
  476. X#define WIDE_INT                 long
  477. X#define WIDE_INT_SIZE            32       /* bits */
  478. X#endif
  479. X
  480. Xtypedef WIDE_INT wide_int ;
  481. Xtypedef unsigned WIDE_INT u_wide_int ;
  482. X
  483. X
  484. X#include "ss_rk.h"
  485. X#include "ss_kmp.h"
  486. X#include "ss_sbm.h"
  487. X#include "ss_bmh.h"
  488. X#include "ss_so.h"
  489. X
  490. X#include "str.h"
  491. X
  492. Xstruct ss_ops
  493. X{
  494. X    int    (*so_setup)() ;
  495. X    char    *(*so_match)() ;
  496. X    void    (*so_done)() ;
  497. X} ;
  498. X
  499. X
  500. Xstruct ss_header
  501. X{
  502. X    char                 *ss_pattern ;
  503. X    int                ss_patlen ;
  504. X    int                ss_flags ;
  505. X    char                *ss_map ;                /* either identity or upper->lower */
  506. X    struct ss_ops    *ss_ops ;
  507. X    union ss_headers
  508. X    {
  509. X        struct rk_header    rkh ;
  510. X        struct kmp_header kmph ;
  511. X        struct sbm_header sbmh ;
  512. X        struct bmh_header bmhh ;
  513. X        struct so_header    soh ;
  514. X    } ss_h ;
  515. X} ;
  516. X
  517. Xtypedef struct ss_header header_s ;
  518. X
  519. X#define HP( p )                            ((header_s *)(p))
  520. X
  521. X/*
  522. X * Structure field access
  523. X */
  524. X#define SS_PATTERN( hp )                (hp)->ss_pattern
  525. X#define SS_PATLEN( hp )                    (hp)->ss_patlen
  526. X#define SS_FLAGS( hp )                    (hp)->ss_flags
  527. X#define SS_OPS( hp )                        (hp)->ss_ops
  528. X#define SS_SETMAP( hp, map )            (hp)->ss_map = map
  529. X#define SS_MAP( hp, c )                    (hp)->ss_map[ (unsigned char) (c) ]
  530. X
  531. X/*
  532. X * Predicates
  533. X */
  534. X#define SS_MALLOC( hp )                ( ! ( SS_FLAGS( hp ) & STRS_NOMALLOC ) )
  535. X#define SS_IGNCASE( hp )            ( SS_FLAGS( hp ) & STRS_IGNCASE )
  536. X#define SS_SWITCH( hp )                ( ! ( SS_FLAGS( hp ) & STRS_NOSWITCH ) )
  537. X#define SS_SETMALLOC( hp )            SS_FLAGS( hp ) &= ~ STRS_NOMALLOC
  538. X
  539. X/*
  540. X * Indirect op invocation
  541. X */
  542. X#define SS_SETUP( hp )                    (*SS_OPS( hp )->so_setup)( hp )
  543. X#define SS_MATCH( hp, str, len )        (*SS_OPS( hp )->so_match)( hp, str, len )
  544. X#define SS_DONE( hp )                    (*SS_OPS( hp )->so_done)( hp )
  545. X
  546. X/*
  547. X * Header extraction
  548. X */
  549. X#define RK_HEADER( hp )                    (&(hp)->ss_h.rkh)
  550. X#define KMP_HEADER( hp )                (&(hp)->ss_h.kmph)
  551. X#define SBM_HEADER( hp )                (&(hp)->ss_h.sbmh)
  552. X#define BMH_HEADER( hp )                (&(hp)->ss_h.bmhh)
  553. X#define SO_HEADER( hp )                    (&(hp)->ss_h.soh)
  554. X
  555. X/*
  556. X * Macros to extract method and flags from the 'flags' argument
  557. X */
  558. X#define METHOD_BITS                        5        /* flag bits devoted to methods */
  559. X#define METHOD_MASK                        ( ( 1 << METHOD_BITS ) - 1 )
  560. X#define SS_GETMETHOD( x )                ( (x) & METHOD_MASK )
  561. X#define SS_GETFLAGS( x )                ( (x) & ~METHOD_MASK )
  562. X
  563. X
  564. Xstruct ss_select
  565. X{
  566. X    int                sel_method ;
  567. X    struct ss_ops    *sel_ops ;
  568. X} ;
  569. X
  570. X
  571. X#ifndef NULL
  572. X#define NULL                                0
  573. X#endif
  574. X
  575. X#ifndef FALSE
  576. X#define FALSE                                0
  577. X#define TRUE                                1
  578. X#endif
  579. X
  580. X#define CHAR_NULL                            ((char *)0)
  581. X#define NULL_HANDLE                        ((strs_h)0)
  582. X
  583. X#define PRIVATE                            static
  584. X
  585. X
  586. X/*
  587. X * Return values
  588. X */
  589. X#define SS_OK                                0
  590. X#define SS_ERR                                (-1)
  591. X
  592. X#endif    /* SS_IMPL_H */
  593. X
  594. END_OF_FILE
  595. if test 2969 -ne `wc -c <'libs/src/str/ss_impl.h'`; then
  596.     echo shar: \"'libs/src/str/ss_impl.h'\" unpacked with wrong size!
  597. fi
  598. # end of 'libs/src/str/ss_impl.h'
  599. fi
  600. if test -f 'libs/src/str/ss_kmp.c' -a "${1}" != "-c" ; then 
  601.   echo shar: Will not clobber existing file \"'libs/src/str/ss_kmp.c'\"
  602. else
  603. echo shar: Extracting \"'libs/src/str/ss_kmp.c'\" \(2827 characters\)
  604. sed "s/^X//" >'libs/src/str/ss_kmp.c' <<'END_OF_FILE'
  605. X/*
  606. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  607. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  608. X * and conditions for redistribution.
  609. X */
  610. X
  611. Xstatic char RCSid[] = "$Id: ss_kmp.c,v 3.1 1993/06/13 02:44:39 panos Exp $" ;
  612. X
  613. Xchar *malloc() ;
  614. X
  615. X#include "ss_impl.h"
  616. X
  617. XPRIVATE int kmp_setup() ;
  618. XPRIVATE char *kmp_match() ;
  619. XPRIVATE void kmp_done() ;
  620. X
  621. Xstruct ss_ops __strs_kmpops = { kmp_setup, kmp_match, kmp_done } ;
  622. X
  623. X
  624. XPRIVATE void compute_next( hp )
  625. X    header_s *hp ;
  626. X{
  627. X    char            *pattern = SS_PATTERN( hp ) ;
  628. X    int            patlen    = SS_PATLEN( hp ) ;
  629. X    next_int        *next        = KMP_HEADER( hp )->next ;
  630. X    int            q ;
  631. X    next_int     k ;
  632. X
  633. X    k = next[ 0 ] = -1 ;
  634. X
  635. X    for ( q = 0 ; q < patlen-1 ; )
  636. X    {
  637. X        /*
  638. X         * The invariant of the following loop is:
  639. X         * if k>=0, then
  640. X         *        pattern[ 0..k-1 ] SUFFIX pattern[ 0..q-1 ]  ( <==> next[ q ] = k )
  641. X         * This condition is true on entry to the loop.
  642. X         */
  643. X        while ( k >= 0 && pattern[ k ] != pattern[ q ] )
  644. X            k = next[ k ] ;
  645. X
  646. X        /*
  647. X         * Case 1: k == -1
  648. X         *        Setting next[ q+1 ] = 0 is ok since it implies that the next
  649. X         *        position in the pattern to check is position 0 (i.e. start
  650. X         *        from the beginning).
  651. X         *    Case 2: k >= 0.
  652. X         *        Since we exited the loop, pattern[ k ] == pattern[ q ].
  653. X         *        Therefore,
  654. X         *            pattern[ 0..k ] SUFFIX pattern[ 0..q ] ==> next[ q+1 ] = k+1
  655. X         */
  656. X        k++, q++ ;
  657. X#ifdef PATH_COMPRESSION
  658. X        if ( pattern[ k ] == pattern[ q ] )
  659. X            next[ q ] = next[ k ] ;
  660. X#endif
  661. X        next[ q ] = k ;
  662. X    }
  663. X}
  664. X
  665. X
  666. XPRIVATE int kmp_setup( hp )
  667. X    register header_s *hp ;
  668. X{
  669. X    register next_int *next ;
  670. X
  671. X    next = (next_int *) malloc( (unsigned)SS_PATLEN( hp )*sizeof( next_int ) ) ;
  672. X    if ( next == (next_int *)0 )
  673. X        return( SS_ERR ) ;
  674. X    
  675. X    KMP_HEADER( hp )->next = next ;
  676. X
  677. X    compute_next( hp ) ;
  678. X
  679. X    return( SS_OK ) ;
  680. X}
  681. X
  682. X
  683. XPRIVATE char *kmp_match( hp, str, len )
  684. X    header_s        *hp ;
  685. X    char            *str ;
  686. X    int            len ;
  687. X{
  688. X    register int            i ;
  689. X    register next_int     q ;
  690. X    next_int                    *next        = KMP_HEADER( hp )->next ;
  691. X    char                        *pattern = SS_PATTERN( hp ) ;
  692. X    register int            patlen    = SS_PATLEN( hp ) ;
  693. X
  694. X    /*
  695. X     * As a special case, we consider pattern[ -1..0 ] to be the empty string.
  696. X     */
  697. X    for ( q = 0, i = 0 ; i < len ; i++ )
  698. X    {
  699. X        register char current_char = SS_MAP( hp, str[ i ] ) ;
  700. X
  701. Xagain:
  702. X        /*
  703. X         * At this point:
  704. X         *        pattern[ 0..q-1 ] is a suffix of str[ 0..i-1 ]
  705. X         */
  706. X        if ( pattern[ q ] == current_char )
  707. X        {
  708. X            q++ ;
  709. X            if ( q == patlen )
  710. X                return( &str[ i - patlen + 1 ] ) ;
  711. X        }
  712. X        else
  713. X        {
  714. X            /*
  715. X             * Let q' = next[ q ]. If q' >= 0, then
  716. X             *        pattern[ 0..q'-1 ] SUFFIX pattern[ 0..q-1 ]
  717. X             *    which implies that
  718. X             *        pattern[ 0..q'-1 ] SUFFIX str[ 0..i-1 ]
  719. X             * Therefore, it is ok to set q = q'.
  720. X             */
  721. X            q = next[ q ] ;
  722. X            if ( q >= 0 )
  723. X                goto again ;
  724. X            q++ ;
  725. X        }
  726. X    }
  727. X
  728. X    return( CHAR_NULL ) ;
  729. X}
  730. X
  731. X
  732. XPRIVATE void kmp_done( hp )
  733. X    header_s *hp ;
  734. X{
  735. X    (void) free( (char *)KMP_HEADER( hp )->next ) ;
  736. X}
  737. X
  738. END_OF_FILE
  739. if test 2827 -ne `wc -c <'libs/src/str/ss_kmp.c'`; then
  740.     echo shar: \"'libs/src/str/ss_kmp.c'\" unpacked with wrong size!
  741. fi
  742. # end of 'libs/src/str/ss_kmp.c'
  743. fi
  744. if test -f 'libs/src/str/ss_rk.c' -a "${1}" != "-c" ; then 
  745.   echo shar: Will not clobber existing file \"'libs/src/str/ss_rk.c'\"
  746. else
  747. echo shar: Extracting \"'libs/src/str/ss_rk.c'\" \(2625 characters\)
  748. sed "s/^X//" >'libs/src/str/ss_rk.c' <<'END_OF_FILE'
  749. X/*
  750. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  751. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  752. X * and conditions for redistribution.
  753. X */
  754. X
  755. Xstatic char RCSid[] = "$Id: ss_rk.c,v 3.1 1993/06/13 02:45:04 panos Exp $" ;
  756. X
  757. X#include "ss_impl.h"
  758. X
  759. X/*
  760. X * Multiply a number by the radix we are using
  761. X */
  762. X#define RADIX_MULT( n )                        ( (n) << NBIC )
  763. X
  764. X#define UCHAR( c )                            ((unsigned char)(c))
  765. X
  766. X
  767. XPRIVATE int rk_setup() ;
  768. XPRIVATE char *rk_match() ;
  769. XPRIVATE void rk_done() ;
  770. X
  771. Xstruct ss_ops __strs_rkops = { rk_setup, rk_match, rk_done } ;
  772. X
  773. X
  774. XPRIVATE int rk_setup( hp )
  775. X    register header_s *hp ;
  776. X{
  777. X    register int        i ;
  778. X    struct rk_header    *rkp        = RK_HEADER( hp ) ;
  779. X    u_wide_int            patval    = 0 ;
  780. X    u_wide_int            digit_1    = 1 ;
  781. X
  782. X    /*
  783. X     * Compute pattern value
  784. X     */
  785. X    for ( i = 0 ; i < SS_PATLEN( hp ) ; i++ )
  786. X        patval = ( RADIX_MULT( patval ) + UCHAR( SS_PATTERN( hp )[i] ) ) % PRIME ;
  787. X    
  788. X    for ( i = 0 ; i < SS_PATLEN( hp )-1 ; i++ )
  789. X        digit_1 = RADIX_MULT( digit_1 ) % PRIME ;
  790. X
  791. X    rkp->rk_patval = patval ;
  792. X    rkp->rk_digit1 = digit_1 ;
  793. X    return( SS_OK ) ;
  794. X}
  795. X
  796. X
  797. XPRIVATE void rk_done( hp ) 
  798. X    header_s *hp ;
  799. X{
  800. X#ifdef lint
  801. X    hp = hp ;
  802. X#endif
  803. X}
  804. X
  805. X
  806. XPRIVATE char *rk_match( hp, str, len )
  807. X    register header_s        *hp ;
  808. X    char                        *str ;
  809. X    int                        len ;
  810. X{
  811. X    register int                i ;
  812. X    register unsigned char    uc ;
  813. X    register u_wide_int        strval    = 0 ;
  814. X    register u_wide_int        patval    = RK_HEADER( hp )->rk_patval ;
  815. X    register u_wide_int        digit_1    = RK_HEADER( hp )->rk_digit1 ;
  816. X    int                            patlen    = SS_PATLEN( hp ) ;
  817. X    char                            *endpat    = &SS_PATTERN( hp )[ patlen ] ;
  818. X
  819. X    /*
  820. X     * Calculate initial value of 'str'
  821. X     * Note that we are guaranteed that len >= pattern length
  822. X     */
  823. X    for ( i = 0 ; i < patlen ; i++ )
  824. X    {
  825. X        uc = UCHAR( SS_MAP( hp, str[i] ) ) ;
  826. X        strval = ( RADIX_MULT( strval ) + uc ) % PRIME ;
  827. X    }
  828. X
  829. X    for ( i = 0 ;; i++ )
  830. X    {
  831. X        register u_wide_int t1 ;
  832. X
  833. X        if ( strval == patval )
  834. X        {
  835. X            char *pp, *sp ;
  836. X
  837. X            for ( pp = SS_PATTERN( hp ), sp = &str[i] ;; sp++, pp++ )
  838. X            {
  839. X                if ( pp == endpat )
  840. X                    return( &str[i] ) ;
  841. X                if ( *pp != SS_MAP( hp, *sp ) )
  842. X                    break ;
  843. X            }
  844. X        }
  845. X
  846. X        if ( i == len-patlen+1 )
  847. X            break ;
  848. X
  849. X        /*
  850. X         * The formula we evaluate is:
  851. X         *
  852. X         *    strval = ( RADIX_MULT( ( strval - UCHAR( str[i] )*digit_1 ) ) + 
  853. X         *                        UCHAR( str[i+patlen] ) ) % PRIME ;
  854. X         *
  855. X         * We have to make sure that the subtraction does not produce
  856. X         * a negative number since that causes strval to be wrong.
  857. X         */
  858. X        uc = UCHAR( SS_MAP( hp, str[i] ) ) ;
  859. X        t1 = ( uc * digit_1 ) % PRIME ;
  860. X        if ( t1 > strval )
  861. X            strval += PRIME ;
  862. X        uc = UCHAR( SS_MAP( hp, str[i+patlen] ) ) ;
  863. X        strval = ( RADIX_MULT( strval - t1 ) + uc ) % PRIME ;
  864. X    }
  865. X    return( NULL ) ;
  866. X}
  867. X
  868. X
  869. END_OF_FILE
  870. if test 2625 -ne `wc -c <'libs/src/str/ss_rk.c'`; then
  871.     echo shar: \"'libs/src/str/ss_rk.c'\" unpacked with wrong size!
  872. fi
  873. # end of 'libs/src/str/ss_rk.c'
  874. fi
  875. if test -f 'libs/src/str/ss_so.c' -a "${1}" != "-c" ; then 
  876.   echo shar: Will not clobber existing file \"'libs/src/str/ss_so.c'\"
  877. else
  878. echo shar: Extracting \"'libs/src/str/ss_so.c'\" \(2898 characters\)
  879. sed "s/^X//" >'libs/src/str/ss_so.c' <<'END_OF_FILE'
  880. X/*
  881. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  882. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  883. X * and conditions for redistribution.
  884. X */
  885. X
  886. Xstatic char RCSid[] = "$Id: ss_so.c,v 3.1 1993/06/13 02:46:12 panos Exp $" ;
  887. X
  888. Xchar *malloc() ;
  889. X
  890. X#include "ss_impl.h"
  891. X
  892. XPRIVATE int so_setup() ;
  893. XPRIVATE char *so_match() ;
  894. XPRIVATE void so_done() ;
  895. X
  896. Xstruct ss_ops __strs_soops = { so_setup, so_match, so_done } ;
  897. X
  898. X/*
  899. X * There is a single twist in this implementation of the shift-or algorithm:
  900. X * To make the check for complete match faster, we are using the sign-bit
  901. X * of the word. This means that everything is shifted to the left by
  902. X *             (word_size - pattern_length)
  903. X */
  904. X
  905. XPRIVATE int so_setup( hp )
  906. X    header_s *hp ;
  907. X{
  908. X    register wide_int        *maskbuf ;
  909. X    register wide_int        mask ;
  910. X    register wide_int        offset_mask ;
  911. X    register int            i ;
  912. X    int                        offset ;
  913. X    register int            patlen    = SS_PATLEN( hp ) ;
  914. X    register char            *pattern = SS_PATTERN( hp ) ;
  915. X
  916. X    if ( patlen > WIDE_INT_SIZE )
  917. X        return( SS_ERR ) ;
  918. X    
  919. X    maskbuf = (wide_int *) malloc( ALPHABET_SIZE * sizeof( wide_int ) ) ;
  920. X    if ( maskbuf == (wide_int *)NULL )
  921. X        return( SS_ERR ) ;
  922. X    
  923. X    offset = WIDE_INT_SIZE - patlen ;
  924. X    offset_mask = ( (~0) << offset ) ;
  925. X    
  926. X    /*
  927. X     * The bits of each word that won't be used must be set to 0
  928. X     */
  929. X    for ( i = 0 ; i < ALPHABET_SIZE ; i++ )
  930. X        maskbuf[ i ] = offset_mask ;
  931. X
  932. X    for ( i = 0, mask = 1 << offset ; i < patlen ; i++, mask <<= 1 )
  933. X        maskbuf[ (unsigned char) pattern[ i ] ] &= ~mask ;
  934. X
  935. X    SO_HEADER( hp )->mask = maskbuf ;
  936. X    SO_HEADER( hp )->offset_mask = offset_mask ;
  937. X    return( SS_OK ) ;
  938. X}
  939. X
  940. X
  941. XPRIVATE char *so_match( hp, str, len )
  942. X    register header_s        *hp ;
  943. X    char                        *str ;
  944. X    int                        len ;
  945. X{
  946. X    register char            *p ;
  947. X    register char            pfc                = SS_PATTERN( hp )[ 0 ] ;
  948. X    register wide_int        *mask                = SO_HEADER( hp )->mask ;
  949. X    register char            *endmatch        = &str[ len - SS_PATLEN( hp ) + 1 ] ;
  950. X    char                        *endstr            = &str[ len ] ;
  951. X    wide_int                    no_match_state = ~0 & SO_HEADER( hp )->offset_mask ;
  952. X
  953. X    /*
  954. X     * The shift-or algorithm can be described by the following for-loop:
  955. X     *
  956. X     *    for ( p = str ; p < endstr ; p++ )
  957. X     *    {
  958. X     *        state = ( state << 1 ) | mask[ (unsigned char) SS_MAP( hp, *p ) ] ;
  959. X     *        if ( state >= 0 )
  960. X     *            return( &p[ -SS_PATLEN( hp ) + 1 ] ) ;
  961. X     *    }
  962. X     *
  963. X     * For efficiency reasons, the algorithm is used only after the first 
  964. X     * character of the pattern is matched against a character of the string.
  965. X     */
  966. X
  967. X    for ( p = str ; p < endmatch ; p++ )
  968. X    {
  969. X        register wide_int state ;
  970. X
  971. X        if ( SS_MAP( hp, *p ) != pfc )
  972. X            continue ;
  973. X
  974. X        for ( state = no_match_state ; p < endstr ; p++ )
  975. X        {
  976. X            state = ( state << 1 ) | mask[ (unsigned char) SS_MAP( hp, *p ) ] ;
  977. X            if ( state >= 0 )
  978. X                return( &p[ -SS_PATLEN( hp ) + 1 ] ) ;
  979. X            if ( state == no_match_state )
  980. X                break ;
  981. X        }
  982. X    }
  983. X    return( CHAR_NULL ) ;
  984. X}
  985. X
  986. X
  987. XPRIVATE void so_done( hp )
  988. X    header_s *hp ;
  989. X{
  990. X    (void) free( (char *) SO_HEADER( hp )->mask ) ;
  991. X}
  992. X
  993. END_OF_FILE
  994. if test 2898 -ne `wc -c <'libs/src/str/ss_so.c'`; then
  995.     echo shar: \"'libs/src/str/ss_so.c'\" unpacked with wrong size!
  996. fi
  997. # end of 'libs/src/str/ss_so.c'
  998. fi
  999. if test -f 'libs/src/str/strprint.3' -a "${1}" != "-c" ; then 
  1000.   echo shar: Will not clobber existing file \"'libs/src/str/strprint.3'\"
  1001. else
  1002. echo shar: Extracting \"'libs/src/str/strprint.3'\" \(3148 characters\)
  1003. sed "s/^X//" >'libs/src/str/strprint.3' <<'END_OF_FILE'
  1004. X.\"(c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1005. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  1006. X.\"and conditions for redistribution.
  1007. X.\"
  1008. X.\" $Id: strprint.3,v 3.1 1993/06/13 02:48:55 panos Exp $
  1009. X.TH STRPRINT 3X "30 September 1992"
  1010. X.SH NAME
  1011. Xstr_sprint, tr_sprintv, str_nprint, str_nprintv, str_print, str_printv, strx_sprint, strx_sprintv, strx_nprint, strx_nprintv, strx_print, strx_printv -- formatted conversion to string
  1012. X.SH SYNOPSIS
  1013. X.LP
  1014. X.nf
  1015. X.ft B
  1016. X#include "str.h"
  1017. X.LP
  1018. X.ft B
  1019. Xchar *str_sprint( buf, format, ... )
  1020. Xchar *buf ;
  1021. Xchar *format ;
  1022. X.LP
  1023. X.ft B
  1024. Xchar *str_sprintv( buf, format, ap )
  1025. Xchar *buf ;
  1026. Xchar *format ;
  1027. Xva_list ap ;
  1028. X.LP
  1029. X.ft B
  1030. Xint str_nprint( buf, format, ... )
  1031. Xchar *buf ;
  1032. Xchar *format ;
  1033. X.LP
  1034. X.ft B
  1035. Xint str_nprintv( buf, format, ap )
  1036. Xchar *buf ;
  1037. Xchar *format ;
  1038. Xva_list ap ;
  1039. X.LP
  1040. X.ft B
  1041. Xvoid str_print( countp, buf, format, ... )
  1042. Xint *countp ;
  1043. Xchar *buf ;
  1044. Xchar *format ;
  1045. X.LP
  1046. X.ft B
  1047. Xvoid str_printv( countp, buf, format, ap )
  1048. Xint *countp ;
  1049. Xchar *buf ;
  1050. Xchar *format ;
  1051. Xva_list ap ;
  1052. X.LP
  1053. X.ft B
  1054. Xchar *strx_sprint( buf, len, format, ... )
  1055. Xchar *buf ;
  1056. Xint len ;
  1057. Xchar *format ;
  1058. X.LP
  1059. X.ft B
  1060. Xchar *strx_sprintv( buf, len, format, ap )
  1061. Xchar *buf ;
  1062. Xint len ;
  1063. Xchar *format ;
  1064. Xva_list ap ;
  1065. X.LP
  1066. X.ft B
  1067. Xint strx_nprint( buf, len, format, ... )
  1068. Xchar *buf ;
  1069. Xint len ;
  1070. Xchar *format ;
  1071. X.LP
  1072. X.ft B
  1073. Xint strx_nprintv( buf, len, format, ap )
  1074. Xchar *buf ;
  1075. Xint len ;
  1076. Xchar *format ;
  1077. Xva_list ap ;
  1078. X.LP
  1079. X.ft B
  1080. Xvoid strx_print( countp, buf, len, format, ... )
  1081. Xint *countp ;
  1082. Xchar *buf ;
  1083. Xint len ;
  1084. Xchar *format ;
  1085. X.LP
  1086. X.ft B
  1087. Xvoid strx_printv( countp, buf, len, format, ap )
  1088. Xint *countp ;
  1089. Xchar *buf ;
  1090. Xint len ;
  1091. Xchar *format ;
  1092. Xva_list ap ;
  1093. X.SH DESCRIPTION
  1094. X.LP
  1095. XAll functions are similar in functionality to \fIsprintf()\fR.
  1096. XTheir only difference is in their return values. For information about their
  1097. Xconversion capabilities, check \fISprint(3)\fR.
  1098. X.LP
  1099. XThe difference between the \fIstr_*\fR and the \fIstrx_*\fR functions
  1100. Xis that the latter take an extra argument, the size of the buffer, so
  1101. Xthat they will never write beyond the end of the buffer. Writing
  1102. Xbeyond the end of the buffer is possible with the \fIstr_*\fR functions.
  1103. XInvoking any of the \fIstrx_*\fR functions with the
  1104. X.I len
  1105. Xargument set to 0
  1106. Xis the same as calling the equivalent \fIstr_*\fR function.
  1107. X.LP
  1108. XAll functions will append a
  1109. X.SM NUL
  1110. Xat the end of
  1111. X.I buf
  1112. X(the \fIstrx_*\fR functions will not do this if it would cause 
  1113. Xa buffer overrun).
  1114. X.LP
  1115. X.B str_print(),
  1116. X.B str_printv(),
  1117. X.B strx_print(),
  1118. Xand
  1119. X.B strx_printv()
  1120. Xwill put in
  1121. X.I "*countp"
  1122. Xthe number of characters placed in 
  1123. X.I buf
  1124. Xexcluding the ending
  1125. X.SM NUL
  1126. X(this happens only if
  1127. X.I "*countp"
  1128. Xis not
  1129. X.SM NULL
  1130. X).
  1131. X.LP
  1132. XThe functions that have a name ending in 'v' are similar to those without
  1133. Xthe 'v' at the end of their name
  1134. Xexcept that instead of accepting a variable number of arguments, they
  1135. Xexpect a \fIvarargs(3)\fR argument list.
  1136. X.SH "RETURN VALUES"
  1137. X.LP
  1138. X.B str_sprint(),
  1139. X.B str_sprintv(),
  1140. X.B strx_sprint(),
  1141. Xand
  1142. X.B strx_sprintv()
  1143. Xreturn
  1144. X.I buf.
  1145. X.LP
  1146. X.B str_nprint(),
  1147. X.B str_nprintv(),
  1148. X.B strx_nprint(),
  1149. Xand
  1150. X.B strx_nprintv()
  1151. Xreturn the number of characters placed in 
  1152. X.I buf
  1153. Xexcluding the ending
  1154. X.SM NUL.
  1155. X.SH "SEE ALSO"
  1156. XSprint(3)
  1157. END_OF_FILE
  1158. if test 3148 -ne `wc -c <'libs/src/str/strprint.3'`; then
  1159.     echo shar: \"'libs/src/str/strprint.3'\" unpacked with wrong size!
  1160. fi
  1161. # end of 'libs/src/str/strprint.3'
  1162. fi
  1163. if test -f 'libs/src/xlog/impl.h' -a "${1}" != "-c" ; then 
  1164.   echo shar: Will not clobber existing file \"'libs/src/xlog/impl.h'\"
  1165. else
  1166. echo shar: Extracting \"'libs/src/xlog/impl.h'\" \(2862 characters\)
  1167. sed "s/^X//" >'libs/src/xlog/impl.h' <<'END_OF_FILE'
  1168. X/*
  1169. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1170. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1171. X * and conditions for redistribution.
  1172. X */
  1173. X
  1174. X
  1175. X/*
  1176. X * $Id: impl.h,v 2.1 1993/05/06 07:40:05 panos Exp $
  1177. X */
  1178. X
  1179. X
  1180. X#define DEFINE_LINK_TYPE( type, name )        struct { type *next, *prev ; } name
  1181. X
  1182. X
  1183. X#define NEXT( obj, field )                        (obj)->field.next
  1184. X#define PREV( obj, field )                        (obj)->field.prev
  1185. X
  1186. X#define INIT_LINKS( obj, field )                                                            \
  1187. X                    {                                                                                \
  1188. X                        NEXT( obj, field ) = obj ;                                            \
  1189. X                        PREV( obj, field ) = obj ;                                            \
  1190. X                    }
  1191. X
  1192. X/*
  1193. X * Link new object after object using the specified field
  1194. X */
  1195. X#define LINK( obj, new_obj, field )                                                        \
  1196. X            {                                                                                        \
  1197. X                NEXT( new_obj, field ) = NEXT( obj, field ) ;                        \
  1198. X                PREV( new_obj, field ) = obj ;                                            \
  1199. X                NEXT( obj, field ) = new_obj ;                                            \
  1200. X                PREV( NEXT( obj, field ), field ) = new_obj ;                        \
  1201. X            }
  1202. X
  1203. X#define UNLINK( obj, field )                                                                \
  1204. X                    {                                                                                \
  1205. X                        NEXT( PREV( obj, field ), field ) = NEXT( obj, field ) ;    \
  1206. X                        PREV( NEXT( obj, field ), field ) = PREV( obj, field ) ;    \
  1207. X                    }
  1208. X
  1209. X
  1210. X/*
  1211. X * xlog linking:
  1212. X *     When xlog1 is linked to xlog2 (i.e. errors on xlog1 are reported to 
  1213. X *        xlog2) we use the xl_clients field on xlog2 and the xl_other_users 
  1214. X *        field on xlog1
  1215. X */
  1216. Xstruct xlog
  1217. X{
  1218. X    xlog_e             xl_type ;
  1219. X    char                 *xl_id ;
  1220. X    int                 xl_flags ;
  1221. X    void                 (*xl_callback)() ;
  1222. X    void                 *xl_callback_arg ;
  1223. X    struct xlog     *xl_use ;                /* xlog we report errors to         */
  1224. X    struct xlog     *xl_clients ;            /* linked list of xlogs that use */
  1225. X                                                    /* this xlog to report errors     */
  1226. X    DEFINE_LINK_TYPE( struct xlog, xl_other_users ) ;
  1227. X    struct xlog_ops
  1228. X    {
  1229. X        int     (*init)        __ARGS( ( struct xlog *, va_list ) ) ;
  1230. X        void    (*fini)         __ARGS( ( struct xlog * ) ) ;
  1231. X        int    (*write)        __ARGS( ( struct xlog *, char *, int, int, va_list ) ) ;
  1232. X        int    (*control)    __ARGS( ( struct xlog *, xlog_cmd_e, va_list ) ) ;
  1233. X        int    (*parms)     __ARGS( ( va_list ) ) ;
  1234. X    }                     *xl_ops ;
  1235. X    void                 *xl_data ;
  1236. X} ;
  1237. X
  1238. X#define XL_INIT( xp, ap )                    (*(xp)->xl_ops->init)( (xp), (ap) )
  1239. X#define XL_FINI( xp )                        (*(xp)->xl_ops->fini)( xp )
  1240. X#define XL_WRITE( xp, buf, size, flags, ap ) \
  1241. X                    (*(xp)->xl_ops->write)( (xp), (buf), (size), (flags), (ap ) )
  1242. X#define XL_CONTROL( xp, cmd, ap ) \
  1243. X                    (*(xp)->xl_ops->control)( (xp), (cmd), (ap) )
  1244. X
  1245. Xtypedef struct xlog xlog_s ;
  1246. X
  1247. Xtypedef void (*voidfunc)() ;
  1248. Xtypedef int bool_int ;
  1249. X
  1250. X#define XP( p )                        ((struct xlog *)(p))
  1251. X
  1252. X#define XLOG_NULL                        XP( NULL )
  1253. X
  1254. X#ifndef FALSE
  1255. X#define FALSE        0
  1256. X#define TRUE        1
  1257. X#endif
  1258. X
  1259. X#ifndef NULL
  1260. X#define NULL        0
  1261. X#endif
  1262. X
  1263. X#define NEW( type )                    (type *) malloc( sizeof( type ) )
  1264. X#define FREE( p )                        (void) free( (char *)p )
  1265. X
  1266. X#define PRIVATE        static
  1267. X
  1268. Xchar *__xlog_add_errno() ;
  1269. Xchar *__xlog_explain_errno() ;
  1270. Xchar *__xlog_new_string() ;
  1271. X
  1272. Xchar *malloc() ;
  1273. X
  1274. END_OF_FILE
  1275. if test 2862 -ne `wc -c <'libs/src/xlog/impl.h'`; then
  1276.     echo shar: \"'libs/src/xlog/impl.h'\" unpacked with wrong size!
  1277. fi
  1278. # end of 'libs/src/xlog/impl.h'
  1279. fi
  1280. echo shar: End of archive 5 \(of 20\).
  1281. cp /dev/null ark5isdone
  1282. MISSING=""
  1283. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  1284.     if test ! -f ark${I}isdone ; then
  1285.     MISSING="${MISSING} ${I}"
  1286.     fi
  1287. done
  1288. if test "${MISSING}" = "" ; then
  1289.     echo You have unpacked all 20 archives.
  1290.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1291. else
  1292.     echo You still need to unpack the following archives:
  1293.     echo "        " ${MISSING}
  1294. fi
  1295. ##  End of shell archive.
  1296. exit 0
  1297.