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

  1. Newsgroups: comp.sources.unix
  2. From: panos@anchor.cs.colorado.edu (Panos Tsirigotis)
  3. Subject: v27i110: clc - C Libraries Collection, Part04/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 110
  10. Archive-Name: clc/part04
  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 4 (of 20)."
  19. # Contents:  libs/src/dict/bst.3 libs/src/dict/bsttest.c
  20. #   libs/src/dict/dll.3 libs/src/dict/dlltest.c libs/src/fsma/fsma.h
  21. #   libs/src/misc/ftwx.3 libs/src/misc/misc.3 libs/src/pset/pset.c
  22. #   libs/src/sio/suite/Makefile libs/src/timer/ostimer.h
  23. #   libs/src/timer/timemacros.3 libs/src/timer/timer.h
  24. # Wrapped by panos@eclipse on Sun Nov 28 14:48:15 1993
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'libs/src/dict/bst.3' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'libs/src/dict/bst.3'\"
  28. else
  29. echo shar: Extracting \"'libs/src/dict/bst.3'\" \(2035 characters\)
  30. sed "s/^X//" >'libs/src/dict/bst.3' <<'END_OF_FILE'
  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.\" $Id: bst.3,v 3.3 93/11/23 20:07:28 panos Exp $
  36. X.TH BST 3X "23 April 1993"
  37. X.SH NAME
  38. Xbst_create, bst_destroy, bst_insert, bst_insert_uniq, bst_delete, bst_search, bst_minimum, bst_maximum, bst_successor, bst_predecessor, bst_iterate, bst_nextobj - binary search tree management functions
  39. X.SH SYNOPSIS
  40. X.LP
  41. X.nf
  42. X.ft B
  43. X#include "bst.h"
  44. X.LP
  45. X.ft B
  46. Xdict_h bst_create( oo_compare, ko_compare, flags, errnop )
  47. Xint (*oo_compare)( dict_obj, dict_obj ) ;
  48. Xint (*ko_compare)( dict_key, dict_obj ) ;
  49. Xint flags ;
  50. Xint *errnop ;
  51. X.LP
  52. X.ft B
  53. Xvoid bst_destroy( handle )
  54. Xdict_h handle ;
  55. X.LP
  56. X.ft B
  57. Xint bst_insert( handle, object )
  58. Xdict_h handle ;
  59. Xdict_obj object ;
  60. X.LP
  61. X.ft B
  62. Xint bst_insert_uniq( handle, object, objectp )
  63. Xdict_h handle ;
  64. Xdict_obj object ;
  65. Xdict_obj *objectp ;
  66. X.LP
  67. X.ft B
  68. Xint bst_delete( handle, object )
  69. Xdict_h handle ;
  70. Xdict_obj object ;
  71. X.LP
  72. X.ft B
  73. Xdict_obj bst_search( handle, key )
  74. Xdict_h handle ;
  75. Xdict_key key ;
  76. X.LP
  77. X.ft B
  78. Xdict_obj bst_minimum( handle )
  79. Xdict_h handle ;
  80. X.LP
  81. X.ft B
  82. Xdict_obj bst_maximum( handle )
  83. Xdict_h handle ;
  84. X.LP
  85. X.ft B
  86. Xdict_obj bst_successor( handle, object )
  87. Xdict_h handle ;
  88. Xdict_obj object ;
  89. X.LP
  90. X.ft B
  91. Xdict_obj bst_predecessor( handle, object )
  92. Xdict_h handle ;
  93. Xdict_obj object ;
  94. X.LP
  95. X.ft B
  96. Xvoid bst_iterate( handle, direction )
  97. Xdict_h handle ;
  98. Xenum dict_direction direction ;
  99. X.LP
  100. X.ft B
  101. Xdict_obj bst_nextobj( handle )
  102. Xdict_h handle ;
  103. X.SH DESCRIPTION
  104. X.LP
  105. XThis library supports dictionary functions using binary search trees.
  106. XIt follows the standard library interface which is described in
  107. X.I "dict(3)."
  108. XThe flags supported by
  109. X.B bst_create()
  110. Xinclude:
  111. X.RS
  112. X.TP
  113. X.SB DICT_RETURN_ERROR
  114. X.TP
  115. X.SB DICT_UNIQUE_KEYS
  116. X.TP
  117. X.SB DICT_ORDERED
  118. X.TP
  119. X.SB DICT_BALANCED_TREE
  120. Xthe tree will be kept balanced (the implementation uses red-black trees
  121. Xto enforce this property).
  122. X.RE
  123. X.SH "SEE ALSO"
  124. Xdict(3)
  125. X.SH "RETURN VALUES"
  126. XCheck 
  127. X.I "dict(3)"
  128. Xfor function return values and error codes.
  129. END_OF_FILE
  130. if test 2035 -ne `wc -c <'libs/src/dict/bst.3'`; then
  131.     echo shar: \"'libs/src/dict/bst.3'\" unpacked with wrong size!
  132. fi
  133. # end of 'libs/src/dict/bst.3'
  134. fi
  135. if test -f 'libs/src/dict/bsttest.c' -a "${1}" != "-c" ; then 
  136.   echo shar: Will not clobber existing file \"'libs/src/dict/bsttest.c'\"
  137. else
  138. echo shar: Extracting \"'libs/src/dict/bsttest.c'\" \(2082 characters\)
  139. sed "s/^X//" >'libs/src/dict/bsttest.c' <<'END_OF_FILE'
  140. X/*
  141. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  142. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  143. X * and conditions for redistribution.
  144. X */
  145. X
  146. Xstatic char RCSid[] = "$Id: bsttest.c,v 3.3 93/09/17 00:50:33 panos Exp $" ;
  147. X
  148. X#ifndef NULL
  149. X#define NULL 0
  150. X#endif
  151. X
  152. X#include "bst.h"
  153. X
  154. X
  155. Xint_comp( p1, p2 )
  156. X    char *p1, *p2 ;
  157. X{
  158. X    int i1 = *(int *)p1 ;
  159. X    int i2 = *(int *)p2 ;
  160. X
  161. X    return( i1 - i2 ) ;
  162. X}
  163. X
  164. Xvoid printval( ip )
  165. X    int *ip ;
  166. X{
  167. X    printf( "%d\n", *ip ) ;
  168. X}
  169. X
  170. X
  171. X#define N 100
  172. Xint nums[ N ] ;
  173. X
  174. Xint main( argc, argv )
  175. X    int argc ;
  176. X    char *argv[] ;
  177. X{
  178. X    dict_h bh ;
  179. X    int i ;
  180. X    int *ip ;
  181. X    int j ;
  182. X    int flags = DICT_NOFLAGS ;
  183. X    struct bst_depth d ;
  184. X
  185. X    if ( argc == 2 && argv[1][0] == 'b' )
  186. X        flags |= DICT_BALANCED_TREE ;
  187. X
  188. X    bh = bst_create( int_comp, int_comp, flags, (int *)0 ) ;
  189. X
  190. X    for ( i = 0 ; i < N ; i++ )
  191. X    {
  192. X#ifdef notdef
  193. X        nums[ i ] = random() % 100 ;
  194. X#else
  195. X        nums[ i ] = N-i ;
  196. X#endif
  197. X        if ( bst_insert( bh, &nums[ i ] ) != DICT_OK )
  198. X        {
  199. X            printf( "Failed at %d\n", i ) ;
  200. X            exit( 1 ) ;
  201. X        }
  202. X    }
  203. X
  204. X   /*
  205. X    * If the tree is balanced, this call will make sure that
  206. X    *    max_depth <= 2*min_depth
  207. X    */
  208. X   bst_getdepth( bh, &d ) ;
  209. X
  210. X    bst_traverse( bh, BST_INORDER, printval ) ;
  211. X    putchar( '\n' ) ;
  212. X
  213. X    printf( "Successor test\n" ) ;
  214. X    for ( ip=(int *)bst_minimum( bh ) ; ip ; ip=(int *)bst_successor( bh, ip ) ) 
  215. X        printf( "%d ", *ip ) ;
  216. X    putchar( '\n' ) ;
  217. X
  218. X    printf( "Predecessor test\n" ) ;
  219. X    for ( ip=(int *)bst_maximum( bh ) ;ip; ip=(int *)bst_predecessor( bh, ip ) ) 
  220. X        printf( "%d ", *ip ) ;
  221. X    putchar( '\n' ) ;
  222. X
  223. X    printf( "Search/delete test\n" ) ;
  224. X    i = 7 ;
  225. X    ip = (int *) bst_search( bh, &i ) ;
  226. X    if ( ip == NULL )
  227. X        printf( "Search failed\n" ) ;
  228. X    else
  229. X        if ( bst_delete( bh, ip ) != DICT_OK )
  230. X        {
  231. X            printf( "Delete failed\n" ) ;
  232. X            exit( 0 ) ;
  233. X        }
  234. X
  235. X    printf( "Successor test 2\n" ) ;
  236. X    for ( ip=(int *)bst_minimum( bh ) ; ip ; ip=(int *)bst_successor( bh, ip ) ) 
  237. X        printf( "%d ", *ip ) ;
  238. X    putchar( '\n' ) ;
  239. X
  240. X    printf( "Predecessor test 2\n" ) ;
  241. X    for ( ip=(int *)bst_maximum( bh ) ;ip; ip=(int *)bst_predecessor( bh, ip ) ) 
  242. X        printf( "%d ", *ip ) ;
  243. X    putchar( '\n' ) ;
  244. X    exit( 0 ) ;
  245. X}
  246. END_OF_FILE
  247. if test 2082 -ne `wc -c <'libs/src/dict/bsttest.c'`; then
  248.     echo shar: \"'libs/src/dict/bsttest.c'\" unpacked with wrong size!
  249. fi
  250. # end of 'libs/src/dict/bsttest.c'
  251. fi
  252. if test -f 'libs/src/dict/dll.3' -a "${1}" != "-c" ; then 
  253.   echo shar: Will not clobber existing file \"'libs/src/dict/dll.3'\"
  254. else
  255. echo shar: Extracting \"'libs/src/dict/dll.3'\" \(2523 characters\)
  256. sed "s/^X//" >'libs/src/dict/dll.3' <<'END_OF_FILE'
  257. X.\"(c) Copyright 1993 by Panagiotis Tsirigotis
  258. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  259. X.\"and conditions for redistribution.
  260. X.\"
  261. X.\" $Id: dll.3,v 3.5 93/11/23 20:07:28 panos Exp $
  262. X.TH DLL 3X "23 April 1993"
  263. X.SH NAME
  264. Xdll_create, dll_destroy, dll_insert, dll_insert_uniq, dll_delete, dll_search, dll_minimum, dll_maximum, dll_successor, dll_predecessor, dll_iterate, dll_nextobj - double linked list management functions
  265. X.SH SYNOPSIS
  266. X.LP
  267. X.nf
  268. X.ft B
  269. X#include "dll.h"
  270. X.LP
  271. X.ft B
  272. Xdict_h dll_create( oo_compare, ko_compare, flags, errnop )
  273. Xint (*oo_compare)( dict_obj, dict_obj ) ;
  274. Xint (*ko_compare)( dict_key, dict_obj ) ;
  275. Xint flags ;
  276. Xint *errnop ;
  277. X.LP
  278. X.ft B
  279. Xvoid dll_destroy( handle )
  280. Xdict_h handle ;
  281. X.LP
  282. X.ft B
  283. Xint dll_insert( handle, object )
  284. Xdict_h handle ;
  285. Xdict_obj object ;
  286. X.LP
  287. X.ft B
  288. Xint dll_insert_uniq( handle, object, objectp )
  289. Xdict_h handle ;
  290. Xdict_obj object ;
  291. Xdict_obj *objectp ;
  292. X.LP
  293. X.ft B
  294. Xint dll_delete( handle, object )
  295. Xdict_h handle ;
  296. Xdict_obj object ;
  297. X.LP
  298. X.ft B
  299. Xdict_obj dll_search( handle, key )
  300. Xdict_h handle ;
  301. Xdict_key key ;
  302. X.LP
  303. X.ft B
  304. Xdict_obj dll_minimum( handle )
  305. Xdict_h handle ;
  306. X.LP
  307. X.ft B
  308. Xdict_obj dll_maximum( handle )
  309. Xdict_h handle ;
  310. X.LP
  311. X.ft B
  312. Xdict_obj dll_successor( handle, object )
  313. Xdict_h handle ;
  314. Xdict_obj object ;
  315. X.LP
  316. X.ft B
  317. Xdict_obj dll_predecessor( handle, object )
  318. Xdict_h handle ;
  319. Xdict_obj object ;
  320. X.LP
  321. X.ft B
  322. Xvoid dll_iterate( handle, direction )
  323. Xdict_h handle ;
  324. Xenum dict_direction direction ;
  325. X.LP
  326. X.ft B
  327. Xdict_obj dll_nextobj( handle )
  328. Xdict_h handle ;
  329. X.SH DESCRIPTION
  330. X.LP
  331. XThis library supports dictionary functions using double linked lists.
  332. XIt follows the standard library interface which is explained in
  333. X.I "dict(3)."
  334. XThe flags supported by
  335. X.B dll_create()
  336. Xinclude:
  337. X.RS
  338. X.TP
  339. X.SB DICT_RETURN_ERROR
  340. X.TP
  341. X.SB DICT_UNIQUE_KEYS
  342. X.TP
  343. X.SB DICT_UNORDERED
  344. X.TP
  345. X.SB DICT_ORDERED
  346. X.RE
  347. X.LP
  348. XIf the flag
  349. X.B DICT_UNORDERED
  350. Xis used when a list is created, a 
  351. X.B dll_insert()
  352. Xoperation will always insert an object at the beginning of the list.
  353. XThis allows such a list to be used to enforce an LRU policy by
  354. Xdeleting the most recently found node and inserting it back.
  355. X.LP
  356. X.B dll_minimum()
  357. Xreturns the object with the minimum key value if the list is sorted, or
  358. Xthe object at the beginning of the list if the list is not sorted.
  359. X.LP
  360. X.B dll_maximum()
  361. Xreturns the object with the maximum key value if the list is sorted, or
  362. Xthe object at the end of the list if the list is not sorted.
  363. X.SH "SEE ALSO"
  364. Xdict(3)
  365. X.SH "RETURN VALUES"
  366. XCheck
  367. X.I "dict(3)"
  368. Xfor function return values and error codes.
  369. END_OF_FILE
  370. if test 2523 -ne `wc -c <'libs/src/dict/dll.3'`; then
  371.     echo shar: \"'libs/src/dict/dll.3'\" unpacked with wrong size!
  372. fi
  373. # end of 'libs/src/dict/dll.3'
  374. fi
  375. if test -f 'libs/src/dict/dlltest.c' -a "${1}" != "-c" ; then 
  376.   echo shar: Will not clobber existing file \"'libs/src/dict/dlltest.c'\"
  377. else
  378. echo shar: Extracting \"'libs/src/dict/dlltest.c'\" \(2100 characters\)
  379. sed "s/^X//" >'libs/src/dict/dlltest.c' <<'END_OF_FILE'
  380. X/*
  381. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  382. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  383. X * and conditions for redistribution.
  384. X */
  385. X
  386. Xstatic char RCSid[] = "$Id: dlltest.c,v 3.2 93/09/17 00:22:07 panos Exp $" ;
  387. X
  388. X
  389. X#ifndef NULL
  390. X#define NULL 0
  391. X#endif
  392. X
  393. X#include "dll.h"
  394. X
  395. X
  396. X#define COMPARE( i1, i2 )                                                \
  397. X                                        if ( i1 < i2 )                        \
  398. X                                            return( -1 ) ;                    \
  399. X                                        else if ( i1 == i2 )                \
  400. X                                            return( 0 ) ;                    \
  401. X                                        else                                    \
  402. X                                            return( 1 ) ;
  403. X
  404. X#define INTP( p )                    ((int *)(p))
  405. X
  406. Xstatic int int_comp( p1, p2 )
  407. X    char *p1, *p2 ;
  408. X{
  409. X    int i1 = *INTP( p1 ) ;
  410. X    int i2 = *INTP( p2 ) ;
  411. X
  412. X    COMPARE( i1, i2 ) ;
  413. X}
  414. X
  415. X
  416. Xstatic int int_kcomp( p1, p2 )
  417. X    char *p1, *p2 ;
  418. X{
  419. X    int k = *INTP( p1 ) ;
  420. X    int obj = *INTP( p2 ) ;
  421. X
  422. X    COMPARE( k, obj ) ;
  423. X}
  424. X
  425. X
  426. X#define N 10
  427. Xint nums[ N ] ;
  428. X
  429. Xmain()
  430. X{
  431. X    dict_h lh ;
  432. X    int i ;
  433. X    int *ip ;
  434. X
  435. X    lh = dll_create( int_comp, int_kcomp, 0, NULL ) ;
  436. X
  437. X    for ( i = 0 ; i < N ; i++ )
  438. X    {
  439. X        nums[ i ] = 10-i ;
  440. X        if ( dll_insert( lh, &nums[ i ] ) != DICT_OK )
  441. X        {
  442. X            printf( "Failed at %d\n", i ) ;
  443. X            exit( 1 ) ;
  444. X        }
  445. X    }
  446. X        
  447. X    printf( "Successor test\n" ) ;
  448. X    for ( ip=INTP(dll_minimum( lh )) ; ip ; ip=INTP(dll_successor( lh, ip )) ) 
  449. X        printf( "%d\n", *ip ) ;
  450. X    printf( "Predecessor test\n" ) ;
  451. X    for ( ip=INTP(dll_maximum( lh )) ; ip ; ip=INTP(dll_predecessor( lh, ip )) ) 
  452. X        printf( "%d\n", *ip ) ;
  453. X    
  454. X    printf( "Search/delete test\n" ) ;
  455. X    i = 7 ;
  456. X    ip = INTP( dll_search( lh, &i ) ) ;
  457. X    if ( ip == NULL )
  458. X        printf( "Search failed\n" ) ;
  459. X    else
  460. X        if ( dll_delete( lh, ip ) != DICT_OK )
  461. X        {
  462. X            printf( "Delete failed\n" ) ;
  463. X            exit( 0 ) ;
  464. X        }
  465. X
  466. X    printf( "Successor test 2\n" ) ;
  467. X    for ( ip=INTP(dll_minimum( lh )) ; ip ; ip=INTP(dll_successor( lh, ip )) ) 
  468. X        printf( "%d\n", *ip ) ;
  469. X    printf( "Predecessor test 2\n" ) ;
  470. X    for ( ip=INTP(dll_maximum( lh )) ; ip ; ip=INTP(dll_predecessor( lh, ip )) ) 
  471. X        printf( "%d\n", *ip ) ;
  472. X
  473. X    printf( "Iteration test\n" ) ;
  474. X    dll_iterate( lh, DICT_FROM_START ) ;
  475. X    while ( ip = INTP( dll_nextobj( lh ) ) )
  476. X        if ( *ip == 5 )
  477. X            (void) dll_delete( lh, ip ) ;
  478. X        else
  479. X            printf( "%d\n", *ip ) ;
  480. X        
  481. X    exit( 0 ) ;
  482. X}
  483. END_OF_FILE
  484. if test 2100 -ne `wc -c <'libs/src/dict/dlltest.c'`; then
  485.     echo shar: \"'libs/src/dict/dlltest.c'\" unpacked with wrong size!
  486. fi
  487. # end of 'libs/src/dict/dlltest.c'
  488. fi
  489. if test -f 'libs/src/fsma/fsma.h' -a "${1}" != "-c" ; then 
  490.   echo shar: Will not clobber existing file \"'libs/src/fsma/fsma.h'\"
  491. else
  492. echo shar: Extracting \"'libs/src/fsma/fsma.h'\" \(2026 characters\)
  493. sed "s/^X//" >'libs/src/fsma/fsma.h' <<'END_OF_FILE'
  494. X/*
  495. X * (c) Copyright 1992 by Panagiotis Tsirigotis
  496. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  497. X * and conditions for redistribution.
  498. X */
  499. X
  500. X#ifndef __FSMA_H
  501. X#define __FSMA_H
  502. X
  503. X/*
  504. X * $Id: fsma.h,v 5.4 1992/10/20 21:20:34 panos Exp $
  505. X */
  506. X
  507. X#define __FSMA_ALIGNMENT                    8
  508. X
  509. Xunion __fsma_chunk_header
  510. X{
  511. X    union __fsma_chunk_header *next_chunk ;
  512. X    char bytes[ __FSMA_ALIGNMENT ] ;
  513. X} ;
  514. X
  515. Xtypedef char *__fsma_pointer ;
  516. X
  517. Xstruct __fsma_header
  518. X{
  519. X    union __fsma_chunk_header *chunk_chain ;
  520. X    __fsma_pointer next_free ;
  521. X    __fsma_pointer temp ;
  522. X    unsigned slots_in_chunk ;
  523. X    unsigned slot_size ;
  524. X    unsigned chunk_size ;
  525. X    int flags ;
  526. X    int is_inlined ;                        /* header is inlined (boolean)    */
  527. X} ;
  528. X
  529. Xtypedef struct __fsma_header *fsma_h ;
  530. X
  531. X/*
  532. X * Flags
  533. X */
  534. X#define FSM_NOFLAGS                    0x0
  535. X#define FSM_RETURN_ERROR            0x1
  536. X#define FSM_ZERO_ALLOC                0x2
  537. X#define FSM_ZERO_FREE                0x4
  538. X#define FSM_ZERO_DESTROY            0x8
  539. X
  540. X
  541. X/*
  542. X * INTERFACE
  543. X */
  544. X
  545. X#ifdef __ARGS
  546. X#undef __ARGS
  547. X#endif
  548. X
  549. X#ifdef PROTOTYPES
  550. X#  define __ARGS( s )               s
  551. X#else
  552. X#  define __ARGS( s )               ()
  553. X#endif
  554. X
  555. Xfsma_h fsm_create __ARGS( ( unsigned size, unsigned slots, int flags ) ) ;
  556. Xvoid fsm_destroy __ARGS( ( fsma_h handle ) ) ;
  557. Xchar *_fsm_alloc __ARGS( ( fsma_h handle ) ) ;
  558. Xvoid _fsm_free __ARGS( ( fsma_h handle, char *ptr ) ) ;
  559. X
  560. X#define fsm_alloc( fsma )                                                                \
  561. X    (                                                                                            \
  562. X        ( ! (fsma)->next_free || (fsma)->flags & FSM_ZERO_ALLOC )         \
  563. X            ? _fsm_alloc( fsma )                                                            \
  564. X            : ((fsma)->temp = (fsma)->next_free,                           \
  565. X                (fsma)->next_free = *(__fsma_pointer *) (fsma)->next_free,  \
  566. X                (char *) (fsma)->temp)                                                    \
  567. X    )
  568. X
  569. X#define fsm_free( fsma, p )                                                            \
  570. X            if ( (fsma)->flags & FSM_ZERO_FREE )                                    \
  571. X                _fsm_free( fsma, p )    ;                                                    \
  572. X            else                                                                                \
  573. X                (fsma)->temp = (p),                                                        \
  574. X                *(__fsma_pointer *) (fsma)->temp = (fsma)->next_free,         \
  575. X                (fsma)->next_free = (fsma)->temp
  576. X
  577. X#define fsm_size( fsma )            (fsma)->slot_size
  578. X
  579. X#endif     /* __FSMA_H */
  580. X
  581. END_OF_FILE
  582. if test 2026 -ne `wc -c <'libs/src/fsma/fsma.h'`; then
  583.     echo shar: \"'libs/src/fsma/fsma.h'\" unpacked with wrong size!
  584. fi
  585. # end of 'libs/src/fsma/fsma.h'
  586. fi
  587. if test -f 'libs/src/misc/ftwx.3' -a "${1}" != "-c" ; then 
  588.   echo shar: Will not clobber existing file \"'libs/src/misc/ftwx.3'\"
  589. else
  590. echo shar: Extracting \"'libs/src/misc/ftwx.3'\" \(2552 characters\)
  591. sed "s/^X//" >'libs/src/misc/ftwx.3' <<'END_OF_FILE'
  592. X.\"(c) Copyright 1992 by Panagiotis Tsirigotis
  593. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  594. X.\"and conditions for redistribution.
  595. X.\"
  596. X.\" $Id: ftwx.3,v 2.2 1992/10/31 03:08:39 panos Exp $
  597. X.TH FTWX 3X "25 January 1992"
  598. X.SH NAME
  599. Xftwx -- file tree walk
  600. X.SH SYNOPSIS
  601. X.LP
  602. X.nf
  603. X.ft B
  604. X#include "ftwx.h"
  605. X.LP
  606. X.ft B
  607. X.ft B
  608. X.ft B
  609. Xint ftwx( path, func, depth, flags )
  610. Xchar *path ;
  611. Xint (*func)() ;
  612. Xint depth ;
  613. Xint flags ;
  614. X.SH DESCRIPTION
  615. X.LP
  616. X.B ftwx()
  617. Xis an extension to \fIftw(3)\fR that optionally follows symbolic
  618. Xlinks (the default is not to follow them). It recursively descends
  619. Xthe directory tree whose root is \fIpath\fR. For each object it finds
  620. X(an object is anything that is in the file system name space,
  621. Xlike a directory, a socket, a regular file, a device etc.)
  622. Xit invokes \fIfunc()\fR passing
  623. Xit a pointer to a string containing the object path name (the first
  624. Xcomponent of the path will be \fIpath\fR), a pointer to a \fIstat()\fR
  625. Xstructure that contains information about the object, and a flag (of
  626. Xtype \fIint\fR). The user function is never invoked for the directory 
  627. Xentries "." and "..".
  628. XPossible flag values are:
  629. X.TP 10
  630. X.SB FTW_D
  631. Xthe object is a directory
  632. X.TP
  633. X.SB FTW_DNR
  634. Xthe object is a directory that is not readable
  635. X.TP
  636. X.SB FTW_F
  637. Xthe object is not a directory
  638. X.TP
  639. X.SB FTW_NS
  640. Xthe \fIstat()\fR of the object failed. The value of the pointer passed
  641. Xto the user function is undefined. This flag value will be returned
  642. Xfor directory entries of a directory for which execute access is not
  643. Xpermitted.
  644. X.LP
  645. X\fBftwx\fR visits a directory before visiting any of the files in
  646. Xthe directory. The tree walk continues until the tree is exhausted,
  647. Xthe user function returns a negative value or some error occurs
  648. X(since -1 indicates an error in \fBftwx()\fR, the user function
  649. Xshould not return that value).
  650. XIf the user function returns a positive value for a directory, that
  651. Xdirectory is not traversed.
  652. XSymbolic links are followed if the \fIflag\fR is \fBFTWX_FOLLOW\fR.
  653. X.LP
  654. XThe \fBdepth\fR argument determines how deep in the tree to go. The
  655. Xoriginal \fIpath\fR is at depth 0. If \fIdepth\fR is \fBFTWX_ALL\fR,
  656. Xthere is no depth limit. However since \fBftwx()\fR uses a file
  657. Xdescriptor for each level of the tree, there is a limit to
  658. Xthe tree depth that it can process that depends on the number
  659. Xof available file descriptors.
  660. X.SH "RETURN VALUES"
  661. X.LP
  662. X\fBftwx()\fR
  663. Xreturns 0 if is successful, -1 if an error occurs (\fIerrno\fR is set)
  664. Xand the (negative) value returned by the user function if that occurs.
  665. X.SH "SEE ALSO"
  666. X.LP
  667. Xftw(3)
  668. END_OF_FILE
  669. if test 2552 -ne `wc -c <'libs/src/misc/ftwx.3'`; then
  670.     echo shar: \"'libs/src/misc/ftwx.3'\" unpacked with wrong size!
  671. fi
  672. # end of 'libs/src/misc/ftwx.3'
  673. fi
  674. if test -f 'libs/src/misc/misc.3' -a "${1}" != "-c" ; then 
  675.   echo shar: Will not clobber existing file \"'libs/src/misc/misc.3'\"
  676. else
  677. echo shar: Extracting \"'libs/src/misc/misc.3'\" \(2525 characters\)
  678. sed "s/^X//" >'libs/src/misc/misc.3' <<'END_OF_FILE'
  679. X.\"(c) Copyright 1992 by Panagiotis Tsirigotis
  680. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  681. X.\"and conditions for redistribution.
  682. X.\"
  683. X.\" $Id: misc.3,v 2.2 1992/10/31 03:08:54 panos Exp $
  684. X.TH MISC 3X "25 January 1992"
  685. X.SH NAME
  686. Xmake_string, make_pathname, argv_copy_and_clear, basename, dirname - miscellaneous functions
  687. X.SH SYNOPSIS
  688. X.LP
  689. X.nf
  690. X.ft B
  691. X#include "misc.h"
  692. X.LP
  693. X.ft B
  694. Xchar *make_string( count, ... )
  695. Xunsigned count ;
  696. X.LP
  697. X.ft B
  698. Xchar *make_pathname( count, ... )
  699. Xunsigned count ;
  700. X.LP
  701. X.ft B
  702. Xchar **argv_copy_and_clear( argv, start, count )
  703. Xchar **argv ;
  704. Xint start, count ;
  705. X.LP
  706. X.ft B
  707. Xchar *dirname( path )
  708. Xchar *path ;
  709. X.LP
  710. X.ft B
  711. Xchar *basename( path )
  712. Xchar *path ;
  713. X.SH DESCRIPTION
  714. X.LP
  715. XThis library contain miscellaneous functions, hence the name.
  716. X.LP
  717. X.B make_string()
  718. Xcreates a string by catenating the list of strings passed as arguments.
  719. X\fIcount\fR indicates how many strings there are.
  720. XStrings that are
  721. X.SM NULL
  722. Xpointers are ignored.
  723. X\fBmake_string()\fR returns malloc'ed memory.
  724. X.LP
  725. X.B make_pathname()
  726. Xcreates a pathname by catenating the list of pathname components passed
  727. Xas arguments and inserting slashes between them.
  728. X\fIcount\fR indicates how many components there are.
  729. X\fBmake_pathname()\fR returns malloc'ed memory.
  730. X.LP
  731. X.B argv_copy_and_clear()
  732. Xcreates a new argv array of size \fIcount\fR, and fills it with the
  733. Xcontents of \fIargv\fR from \fIstart\fR up to \fIstart+count-1\fR.
  734. XThe original \fIargv\fR entries in that range are cleared by filling
  735. Xthem with
  736. X.SM SPACEs.
  737. X.LP
  738. X.B dirname()
  739. Xreturns in a malloced string containing all but the last of 
  740. Xcomponent of \fIpath\fR. There are 2 special cases:
  741. Xfirst when the
  742. X\fIpath\fR is "/", \fBdirname()\fR will return "/", 
  743. Xand second, when the \fIpath\fR does not contain any '/',
  744. X\fBdirname()\fR will return ".".
  745. X.LP
  746. X.B basename()
  747. Xreturns a pointer to the last component of \fIpath\fR.
  748. X.SH "RETURN VALUES"
  749. X.LP
  750. X\fBmake_string()\fR returns a pointer to the new string.
  751. XIt returns
  752. X.SM NULL
  753. Xif \fIcount\fR is 0.
  754. X.LP
  755. X\fBmake_pathname()\fR returns a pointer to the new pathname.
  756. XIt returns
  757. X.SM NULL
  758. Xif \fIcount\fR is 0.
  759. X.LP
  760. X\fBargv_copy_and_clear()\fR returns the new argv array. It returns
  761. X.SM NULL
  762. Xif \fImalloc\fR fails to allocate more memory.
  763. X.LP
  764. X\fBdirname()\fR returns a new string or
  765. X.SM NULL
  766. Xif \fImalloc\fR fails to allocate more memory.
  767. X.LP
  768. X\fBbasename()\fR returns a pointer to the last component of \fIpath\fR.
  769. X.SH BUGS
  770. X.LP
  771. XThe behavior of \fBdirname()\fR and \fBbasename()\fR is undefined if
  772. Xthey are given a zero-length string.
  773. END_OF_FILE
  774. if test 2525 -ne `wc -c <'libs/src/misc/misc.3'`; then
  775.     echo shar: \"'libs/src/misc/misc.3'\" unpacked with wrong size!
  776. fi
  777. # end of 'libs/src/misc/misc.3'
  778. fi
  779. if test -f 'libs/src/pset/pset.c' -a "${1}" != "-c" ; then 
  780.   echo shar: Will not clobber existing file \"'libs/src/pset/pset.c'\"
  781. else
  782. echo shar: Extracting \"'libs/src/pset/pset.c'\" \(2242 characters\)
  783. sed "s/^X//" >'libs/src/pset/pset.c' <<'END_OF_FILE'
  784. X/*
  785. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  786. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  787. X * and conditions for redistribution.
  788. X */
  789. X
  790. Xstatic char RCSid[] = "$Id: pset.c,v 3.1 93/03/06 18:48:57 panos Exp $" ;
  791. Xstatic char version[] = VERSION ;
  792. X
  793. X#include "pset.h"
  794. X
  795. X#ifndef NULL
  796. X#define NULL                        0
  797. X#endif
  798. X
  799. X#define ALLOC_START                20
  800. X#define ALLOC_STEP                10
  801. X
  802. X#define POINTER                    __pset_pointer
  803. X
  804. Xchar *malloc(), *realloc() ;
  805. X
  806. X
  807. X/*
  808. X * Create a pointer set and return a handle to it.
  809. X * Some space is initially allocated for the set.
  810. X */
  811. Xpset_h pset_create( alloc_start, alloc_step )
  812. X    unsigned alloc_start, alloc_step ;
  813. X{
  814. X    pset_h pset ;
  815. X    unsigned start ;
  816. X
  817. X    pset = (pset_h) malloc( sizeof( struct __pset ) ) ;
  818. X    if ( pset == NULL )
  819. X        return( NULL ) ;
  820. X    
  821. X    start = ( alloc_start == 0 ) ? ALLOC_START : alloc_start ;
  822. X    pset->ptrs = (POINTER *) malloc( start * sizeof( POINTER ) ) ;
  823. X    if ( pset->ptrs == NULL )
  824. X    {
  825. X        free( (char *) pset ) ;
  826. X        return( NULL ) ;
  827. X    }
  828. X
  829. X    pset->max = start ;
  830. X    pset->count = 0 ;
  831. X    pset->alloc_step = ( alloc_step == 0 ) ? ALLOC_STEP : alloc_step ;
  832. X    return( pset ) ;
  833. X}
  834. X
  835. X
  836. X/*
  837. X * Destroy a pset
  838. X */
  839. Xvoid pset_destroy( pset )
  840. X    pset_h pset ;
  841. X{
  842. X    free( (char *) pset->ptrs ) ;
  843. X    free( (char *) pset ) ;
  844. X}
  845. X
  846. X
  847. X/*
  848. X * Insert a pointer to a pset
  849. X */
  850. XPOINTER pset_insert( pset, p )
  851. X    pset_h pset ;
  852. X    POINTER p ;
  853. X{
  854. X    if ( pset->count >= pset->max )
  855. X    {
  856. X        unsigned new_max = pset->max + pset->alloc_step ;
  857. X        POINTER *new_ptrs ;
  858. X
  859. X        new_ptrs = (POINTER *) realloc(
  860. X                                (char *)pset->ptrs, new_max * sizeof( POINTER ) ) ;
  861. X        if ( new_ptrs == NULL )
  862. X            return( NULL ) ;
  863. X        pset->max = new_max ;
  864. X        pset->ptrs = new_ptrs ;
  865. X    }
  866. X    return( pset->ptrs[ pset->count++ ] = p ) ;
  867. X}
  868. X
  869. X
  870. X/*
  871. X * Remove a pointer from a pset
  872. X */
  873. Xvoid pset_delete( pset, ptr )
  874. X    register pset_h pset ;
  875. X    register POINTER ptr ;
  876. X{
  877. X    register unsigned u = pset->count ;
  878. X
  879. X    if ( u == 0 )
  880. X        return ;
  881. X    
  882. X    do
  883. X    {
  884. X        u-- ;
  885. X        if ( pset->ptrs[ u ] == ptr )
  886. X        {
  887. X            pset->ptrs[ u ] = pset->ptrs[ --pset->count ] ;
  888. X            return ;
  889. X        }
  890. X    }
  891. X    while ( u ) ;
  892. X}
  893. X
  894. X
  895. X/*
  896. X * Create a pset iterator
  897. X */
  898. Xpsi_h psi_create( pset )
  899. X    pset_h pset ;
  900. X{
  901. X    psi_h iter = (psi_h) malloc( sizeof( struct __pset_iterator ) ) ;
  902. X
  903. X    if ( iter == NULL )
  904. X        return( NULL ) ;
  905. X    iter->pset = pset ;
  906. X    return( iter ) ;
  907. X}
  908. X
  909. X
  910. END_OF_FILE
  911. if test 2242 -ne `wc -c <'libs/src/pset/pset.c'`; then
  912.     echo shar: \"'libs/src/pset/pset.c'\" unpacked with wrong size!
  913. fi
  914. # end of 'libs/src/pset/pset.c'
  915. fi
  916. if test -f 'libs/src/sio/suite/Makefile' -a "${1}" != "-c" ; then 
  917.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/Makefile'\"
  918. else
  919. echo shar: Extracting \"'libs/src/sio/suite/Makefile'\" \(2571 characters\)
  920. sed "s/^X//" >'libs/src/sio/suite/Makefile' <<'END_OF_FILE'
  921. X# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  922. X# All rights reserved.  The file named COPYRIGHT specifies the terms 
  923. X# and conditions for redistribution.
  924. X
  925. X#
  926. X# $Id: Makefile,v 8.2 1993/09/08 06:00:25 panos Exp $
  927. X#
  928. X
  929. XCC                    = cc -I..
  930. X
  931. X#
  932. X# NOTE: When using the test scripts, DEFS is provided as an
  933. X#          argument to make, the setting of it here has no effect.
  934. X#
  935. XDEFS                =
  936. XCFLAGS            = -g $(DEFS) $(MORE_DEFS)
  937. XLIBOBJS            = ../libsio.a
  938. X
  939. XDISTRIBUTION_FILES=copytest.c example.c print.c tietest.c buftest.c fdtest.c tester sprint_test testlib README
  940. X
  941. XALL=Sread Swrite Sputchar Sgetchar Srdline \
  942. X     Sgetc Sputc Sfetch Sflush Sundo switch \
  943. X     Sprint buftest tietest switch2 example fdtest evtest
  944. X
  945. Xevtest: evtest.c $(LIBOBJS)
  946. X    $(CC) $(CFLAGS) -o $@ evtest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  947. X
  948. Xfdtest: fdtest.c $(LIBOBJS)
  949. X    $(CC) $(CFLAGS) -o $@ fdtest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  950. X
  951. Xbuftest: buftest.c $(LIBOBJS)
  952. X    $(CC) $(CFLAGS) -o $@ buftest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  953. X
  954. XSprint: print.c $(LIBOBJS)
  955. X    $(CC) $(CFLAGS) -o $@ print.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  956. X
  957. XSputchar: copytest.c $(LIBOBJS)
  958. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  959. X
  960. XSgetchar: copytest.c $(LIBOBJS)
  961. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  962. X
  963. XSrdline: copytest.c $(LIBOBJS)
  964. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) || rm -f $@
  965. X
  966. XSread: copytest.c $(LIBOBJS)
  967. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  968. X
  969. XSwrite: copytest.c $(LIBOBJS)
  970. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  971. X
  972. XSgetc: copytest.c $(LIBOBJS)
  973. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  974. X
  975. XSputc: copytest.c $(LIBOBJS)
  976. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  977. X
  978. XSfetch: copytest.c $(LIBOBJS)
  979. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  980. X
  981. XSflush: copytest.c $(LIBOBJS)
  982. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  983. X
  984. XSundo: copytest.c $(LIBOBJS)
  985. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  986. X
  987. Xswitch: copytest.c $(LIBOBJS)
  988. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  989. X
  990. Xswitch2: copytest.c $(LIBOBJS)
  991. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  992. X
  993. Xtietest: tietest.c $(LIBOBJS)
  994. X    $(CC) $(CFLAGS) -o $@ tietest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  995. X
  996. Xexample: example.c $(LIBOBJS)
  997. X    $(CC) $(CFLAGS) -o $@ example.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  998. X
  999. Xclean:
  1000. X    rm -f $(ALL) core
  1001. X
  1002. Xcheckout: $(DISTRIBUTION_FILES)
  1003. X
  1004. X$(DISTRIBUTION_FILES):
  1005. X    co $@
  1006. X
  1007. Xdist:
  1008. X    -co -q $(DISTRIBUTION_FILES)
  1009. END_OF_FILE
  1010. if test 2571 -ne `wc -c <'libs/src/sio/suite/Makefile'`; then
  1011.     echo shar: \"'libs/src/sio/suite/Makefile'\" unpacked with wrong size!
  1012. fi
  1013. # end of 'libs/src/sio/suite/Makefile'
  1014. fi
  1015. if test -f 'libs/src/timer/ostimer.h' -a "${1}" != "-c" ; then 
  1016.   echo shar: Will not clobber existing file \"'libs/src/timer/ostimer.h'\"
  1017. else
  1018. echo shar: Extracting \"'libs/src/timer/ostimer.h'\" \(1998 characters\)
  1019. sed "s/^X//" >'libs/src/timer/ostimer.h' <<'END_OF_FILE'
  1020. X/*
  1021. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  1022. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1023. X * and conditions for redistribution.
  1024. X */
  1025. X
  1026. X#ifndef OSTIMER_H
  1027. X#define OSTIMER_H
  1028. X
  1029. X/*
  1030. X * Include signal.h to get sigset_t
  1031. X */
  1032. X#ifndef NO_POSIX_SIGS
  1033. X#include <signal.h>
  1034. X#endif
  1035. X
  1036. X#include "pq.h"
  1037. X
  1038. X/*
  1039. X * Holds a list of timers ordered by expiration time (the one at the
  1040. X * head of the list is the one that will expire first).
  1041. X */
  1042. Xstruct timer_q
  1043. X{
  1044. X    pq_h    tq_handle ;
  1045. X    int    tq_errno ;
  1046. X} ;
  1047. X
  1048. X/*
  1049. X * Macros to handle the priority queue
  1050. X */
  1051. X#define timer_pq_insert( tpq, tp )     pq_insert( tpq, (char *) tp )
  1052. X#define timer_pq_head( tpq )           (struct timer *) pq_head( tpq )
  1053. X#define timer_pq_extract_head( tpq )   (struct timer *) pq_extract_head( tpq )
  1054. X#define timer_pq_delete( tpq, tp )     pq_delete( tpq, (char *) tp )
  1055. X
  1056. X
  1057. Xtypedef enum { AVAILABLE, UNAVAILABLE } availability_e ;
  1058. X
  1059. X/*
  1060. X * Description of a timer provided by the operating system
  1061. X */
  1062. Xstruct os_timer
  1063. X{
  1064. X    availability_e        ost_availability ;
  1065. X    int                    ost_systype ;            /* e.g. ITIMER_REAL                         */
  1066. X    int                    ost_signal ;            /* what signal is generated             */
  1067. X                                                        /* upon expiration                        */
  1068. X    enum timer_types    ost_timertype ;        /* e.g. TIMER_REAL                        */
  1069. X    void                    (*ost_handler)() ;    /* what function to invoke                */
  1070. X    void                    (*ost_get_current_time)() ;
  1071. X                                                    /* how to find the current time            */
  1072. X    struct timer_q        ost_timerq ;            /* list of timers of this type        */
  1073. X#ifndef NO_POSIX_SIGS
  1074. X    sigset_t                ost_block_mask ;        /* signal mask to blocks this timer */
  1075. X#else
  1076. X    int                     ost_block_mask ;
  1077. X#endif
  1078. X} ;
  1079. X
  1080. Xtypedef struct os_timer ostimer_s ;
  1081. X
  1082. X#define OSTIMER_NULL                    ((ostimer_s *)0)
  1083. X
  1084. X#define SIGSET_NULL                    ((sigset_t *)0)
  1085. X
  1086. X/*
  1087. X * Public functions
  1088. X */
  1089. Xostimer_s    *__ostimer_init() ;
  1090. Xint            __ostimer_newtimer() ;
  1091. Xint            __ostimer_add() ;
  1092. Xvoid            __ostimer_interrupt() ;
  1093. Xvoid            __ostimer_remove() ;
  1094. Xvoid            __ostimer_blockall() ;
  1095. Xvoid            __ostimer_unblockall() ;
  1096. Xvoid            __ostimer_unblockall_except() ;
  1097. X
  1098. X#endif    /* OSTIMER_H */
  1099. X
  1100. END_OF_FILE
  1101. if test 1998 -ne `wc -c <'libs/src/timer/ostimer.h'`; then
  1102.     echo shar: \"'libs/src/timer/ostimer.h'\" unpacked with wrong size!
  1103. fi
  1104. # end of 'libs/src/timer/ostimer.h'
  1105. fi
  1106. if test -f 'libs/src/timer/timemacros.3' -a "${1}" != "-c" ; then 
  1107.   echo shar: Will not clobber existing file \"'libs/src/timer/timemacros.3'\"
  1108. else
  1109. echo shar: Extracting \"'libs/src/timer/timemacros.3'\" \(2098 characters\)
  1110. sed "s/^X//" >'libs/src/timer/timemacros.3' <<'END_OF_FILE'
  1111. X.\"(c) Copyright 1993 by Panagiotis Tsirigotis
  1112. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  1113. X.\"and conditions for redistribution.
  1114. X.\"
  1115. X.\" $Id: timemacros.3,v 5.1 93/11/26 12:09:33 panos Exp $
  1116. X.TH TIMEMACROS 3X "20 April 1993"
  1117. X.SH NAME
  1118. XTV_ADD, TV_SUB, TV_LT, TV_LE, TV_GT. TV_GE, TV_EQ, TV_NE, TV_ISZERO, TV_ZERO, TVP_ADD, TVP_SUB, TVP_LT, TVP_LE, TVP_GT, TVP_GE, TVP_EQ, TVP_NE, TVP_ISZERO, TVP_ZERO - macros for manipulating timeval structures
  1119. X.SH SYNOPSIS
  1120. X.LP
  1121. X.nf
  1122. X.ft B
  1123. X#include "timemacros.h"
  1124. X.LP
  1125. X.ft B
  1126. Xvoid TV_ADD( tv_res, tv1, tv2 )
  1127. Xstruct timeval tv_res, tv1, tv2 ;
  1128. X.LP
  1129. X.ft B
  1130. Xvoid TV_SUB( tv_res, tv1, tv2 )
  1131. Xstruct timeval tv_res, tv1, tv2 ;
  1132. X.LP
  1133. X.ft B
  1134. Xvoid TV_ZERO( tv )
  1135. Xstruct timeval tv ;
  1136. X.LP
  1137. X.ft B
  1138. Xint TV_LT( tv1, tv2 )
  1139. Xstruct timeval tv1, tv2 ;
  1140. X.LP
  1141. X.ft B
  1142. Xint TV_LE( tv1, tv2 )
  1143. Xstruct timeval tv1, tv2 ;
  1144. X.LP
  1145. X.ft B
  1146. Xint TV_GT( tv1, tv2 )
  1147. Xstruct timeval tv1, tv2 ;
  1148. X.LP
  1149. X.ft B
  1150. Xint TV_GE( tv1, tv2 )
  1151. Xstruct timeval tv1, tv2 ;
  1152. X.LP
  1153. X.ft B
  1154. Xint TV_EQ( tv1, tv2 )
  1155. Xstruct timeval tv1, tv2 ;
  1156. X.LP
  1157. X.ft B
  1158. Xint TV_NE( tv1, tv2 )
  1159. Xstruct timeval tv1, tv2 ;
  1160. X.LP
  1161. X.ft B
  1162. Xint TV_ISZERO( tv )
  1163. Xstruct timeval tv ;
  1164. X.SH DESCRIPTION
  1165. XThere are 2 groups of macros: the
  1166. X.I "TV_*"
  1167. Xmacros expect arguments that are
  1168. X.I "struct timeval's"
  1169. Xwhile the
  1170. X.I "TVP_*"
  1171. Xmacros expect arguments that are pointers to
  1172. X.I "struct timeval."
  1173. XIn the following only the
  1174. X.I "TV_*"
  1175. Xmacros will be described.
  1176. X.LP
  1177. X.B "TV_ADD()"
  1178. Xadds
  1179. X.I tv1
  1180. Xand
  1181. X.I tv2
  1182. Xand puts the result in
  1183. X.I tv_res.
  1184. XThe result is "normalized" if the number of microseconds in
  1185. X.I tv_res
  1186. Xexceeds 1 million.
  1187. X.LP
  1188. X.B "TV_SUB()"
  1189. Xperforms the subtraction
  1190. X.I "tv1-tv2"
  1191. Xand places the result in
  1192. X.I tv_res.
  1193. XThe result is "normalized" if the number of microseconds in 
  1194. X.I tv_res
  1195. Xbecomes negative.
  1196. X.LP
  1197. X.B "TV_ZERO()"
  1198. Xsets
  1199. X.I tv
  1200. Xto zero seconds and zero microseconds.
  1201. X.LP
  1202. X.B "TV_LT(),"
  1203. X.B "TV_LE(),"
  1204. X.B "TV_GT(),"
  1205. X.B "TV_GE(),"
  1206. X.B "TV_EQ(),"
  1207. Xand
  1208. X.B "TV_NE()"
  1209. Xreturn
  1210. X.SM TRUE 
  1211. Xif
  1212. X.I tv1
  1213. Xis
  1214. Xless than,
  1215. Xless than or equal,
  1216. Xgreater than,
  1217. Xgreater than or equal,
  1218. Xequal,
  1219. Xor
  1220. Xnot equal
  1221. Xto
  1222. X.I tv2,
  1223. Xrespectively.
  1224. X.LP
  1225. X.B "TV_ISZERO()"
  1226. Xreturns
  1227. X.SM TRUE
  1228. Xif
  1229. X.I tv
  1230. Xis equal to zero.
  1231. END_OF_FILE
  1232. if test 2098 -ne `wc -c <'libs/src/timer/timemacros.3'`; then
  1233.     echo shar: \"'libs/src/timer/timemacros.3'\" unpacked with wrong size!
  1234. fi
  1235. # end of 'libs/src/timer/timemacros.3'
  1236. fi
  1237. if test -f 'libs/src/timer/timer.h' -a "${1}" != "-c" ; then 
  1238.   echo shar: Will not clobber existing file \"'libs/src/timer/timer.h'\"
  1239. else
  1240. echo shar: Extracting \"'libs/src/timer/timer.h'\" \(1993 characters\)
  1241. sed "s/^X//" >'libs/src/timer/timer.h' <<'END_OF_FILE'
  1242. X/*
  1243. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  1244. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1245. X * and conditions for redistribution.
  1246. X */
  1247. X
  1248. X#ifndef __TIMER_H
  1249. X#define __TIMER_H
  1250. X
  1251. X/*
  1252. X * $Id: timer.h,v 5.1 93/11/26 12:37:23 panos Exp $
  1253. X */
  1254. X
  1255. X#include <sys/time.h>
  1256. X#include <setjmp.h>
  1257. X
  1258. X/*
  1259. X * Return values
  1260. X */
  1261. X#define TIMER_OK            0
  1262. X#define TIMER_ERR            (-1)
  1263. X
  1264. X/*
  1265. X * errno values
  1266. X */
  1267. X#define TIMER_ENOMEM                1
  1268. X#define TIMER_EBADTYPE            2
  1269. X#define TIMER_EBADSTATE            3
  1270. X#define TIMER_EBADTIME            4
  1271. X#define TIMER_ESIGPROBLEM        5
  1272. X#define TIMER_ECANTINSERT        6
  1273. X#define TIMER_ENOTAVAILABLE    7
  1274. X
  1275. X/*
  1276. X * flags
  1277. X */
  1278. X#define TIMER_NOFLAGS                0x0
  1279. X#define TIMER_RETURN_ERROR            0x1
  1280. X#define TIMER_INC_VAR                0x2
  1281. X#define TIMER_BLOCK_SAME            0x4
  1282. X#define TIMER_BLOCK_ALL                0x8
  1283. X#define TIMER_LONGJMP                0x10
  1284. X
  1285. Xenum timer_types { TIMER_REAL = 0, TIMER_VIRTUAL = 1, TIMER_PROF = 2 } ;
  1286. Xenum timer_timetypes { TIMER_ABSOLUTE, TIMER_RELATIVE } ;
  1287. X
  1288. Xstruct timer_action
  1289. X{
  1290. X    int        ta_flags ;
  1291. X    void        (*ta_func)() ;
  1292. X    void        *ta_arg ;
  1293. X    jmp_buf    ta_env ;
  1294. X} ;
  1295. X
  1296. X#ifdef __ARGS
  1297. X#undef __ARGS
  1298. X#endif
  1299. X
  1300. X#ifdef PROTOTYPES
  1301. X#   define __ARGS( s )           s
  1302. X#else
  1303. X#   define __ARGS( s )           ()
  1304. X#endif
  1305. X
  1306. Xtypedef void *timer_h ;
  1307. X
  1308. Xtimer_h timer_create        __ARGS( ( 
  1309. X                                            enum timer_types type,
  1310. X                                            int flags,
  1311. X                                            int *errnop
  1312. X                                        ) ) ;
  1313. Xvoid timer_destroy         __ARGS( ( timer_h handle ) ) ;
  1314. X
  1315. Xint timer_start             __ARGS( (
  1316. X                                            timer_h handle,
  1317. X                                            struct itimerval *itvp,
  1318. X                                            enum timer_times time_type,
  1319. X                                            struct timer_action *ap 
  1320. X                                        ) ) ;
  1321. Xvoid timer_stop             __ARGS( ( timer_h handle ) ) ;
  1322. X
  1323. Xvoid timer_block             __ARGS( ( timer_h handle ) ) ;
  1324. Xvoid timer_unblock         __ARGS( ( timer_h handle ) ) ;
  1325. X
  1326. Xunsigned timer_expirations __ARGS( ( timer_h handle ) ) ;
  1327. X
  1328. Xvoid timer_block_all        __ARGS( ( enum timer_types type ) ) ;
  1329. Xvoid timer_unblock_all    __ARGS( ( enum timer_types type ) ) ;
  1330. X
  1331. Xchar *timer_strerr        __ARGS( ( timer_h handle ) ) ;
  1332. X
  1333. Xextern int timer_errno ;
  1334. X
  1335. X#endif    /* __TIMER_H */
  1336. X
  1337. END_OF_FILE
  1338. if test 1993 -ne `wc -c <'libs/src/timer/timer.h'`; then
  1339.     echo shar: \"'libs/src/timer/timer.h'\" unpacked with wrong size!
  1340. fi
  1341. # end of 'libs/src/timer/timer.h'
  1342. fi
  1343. echo shar: End of archive 4 \(of 20\).
  1344. cp /dev/null ark4isdone
  1345. MISSING=""
  1346. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  1347.     if test ! -f ark${I}isdone ; then
  1348.     MISSING="${MISSING} ${I}"
  1349.     fi
  1350. done
  1351. if test "${MISSING}" = "" ; then
  1352.     echo You have unpacked all 20 archives.
  1353.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1354. else
  1355.     echo You still need to unpack the following archives:
  1356.     echo "        " ${MISSING}
  1357. fi
  1358. ##  End of shell archive.
  1359. exit 0
  1360.