home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 165_01 / headers.d < prev    next >
Text File  |  1988-02-18  |  18KB  |  524 lines

  1. ###bin_io.h
  2. /* bin_io.h - header for binary file I/O functions 
  3.  * SYSTEM DEPENDENT - MUST BE CONFIGURED FOR EACH TARGET SYSTEM
  4.  */
  5. #ifndef BIN_IO_H
  6. #define BIN_IO_H
  7. #include "local.h"
  8.  
  9. #include "fcntl.h"        /* provide your own if not standard on system */
  10.  
  11. typedef int bin_fd;        /* "binary file descriptor" {0:BIN_NFILE-1} */
  12.  
  13. #define BIN_NFILE 20    /* adjust to local system */
  14.  
  15. #define O_RWMODE (O_RDONLY|O_WRONLY|O_RDWR)    /* uses symbols from fcntl.h */
  16.  
  17. #ifndef IDRIS
  18. #define bin_open(s, m)        open(s, m)
  19. #endif
  20. #define bin_close(f)        close(f)
  21. #define bin_lseek(f, o, w)    lseek(f, o, w)
  22. #define bin_read(f, b, n)    read(f, b, n)
  23. #define bin_write(f, b, n)    write(f, b, n)
  24.  
  25. #endif
  26. ###fcntl.h
  27. /* fcntl.h - definitions for binary  open
  28.  * Compatible with UNIX Sys V, ...
  29.  */
  30. #ifndef FCNTL_H
  31. #define FCNTL_H
  32. #define O_RDONLY 0        /* delete or change to conform to local */
  33. #define O_WRONLY 1        /* delete or change to conform to local */
  34. #define O_RDWR   2        /* delete or change to conform to local */
  35. #define O_NDELAY 4        /* NOT USED BY bin_io FUNCTIONS */
  36. #define O_APPEND 8        /* delete or change to conform to local */
  37. #define O_CREAT  0x100    /* delete or change to conform to local */
  38. #define O_TRUNC  0x200    /* delete or change to conform to local */
  39. #define O_EXCL   0x400    /* delete or change to conform to local */
  40. #endif
  41. ###local.h
  42. /* local.h - Definitions for use with Reliable Data Structures in C */
  43. #ifndef LOCAL_H
  44. #define LOCAL_H
  45. #include <stdio.h>
  46. #include <ctype.h>
  47. #include <math.h>
  48. #define FALSE            0            /* Boolean value */
  49. #define FOREVER            for(;;)        /* endless loop */
  50. #define NO                0            /* Boolean value */
  51. #define TRUE            1            /* Boolean value */
  52. #define YES                1            /* Boolean value */
  53. #define getln(s, n)        ((fgets(s, n, stdin)==NULL) ? EOF : strlen(s))
  54. #define ABS(x)            (((x) < 0) ? -(x) : (x))
  55. #define MAX(x, y)        (((x) < (y)) ? (y) : (x))
  56. #define MIN(x, y)        (((x) < (y)) ? (x) : (y))
  57. #define DIM(a)            (sizeof(a) / sizeof(a[0]))
  58. #define IN_RANGE(n, lo, hi) ((lo) <= (n) && (n) <= (hi))
  59. #ifndef NDEBUG
  60. #define asserts(cond, str) \
  61.     {if (!(cond)) fprintf(stderr, "Assertion '%s' failed\n", str);}
  62. #else
  63. #define asserts(cond, str)
  64. #endif
  65. #define SWAP(a, b, t)     ((t) = (a), (a) = (b), (b) = (t))
  66. #define LOOPDN(r, n)    for ((r) = (n)+1; --(r) > 0; )
  67. #define STREQ(s, t)        (strcmp(s, t) == 0)
  68. #define STRLT(s, t)        (strcmp(s, t) < 0)
  69. #define STRGT(s, t)        (strcmp(s, t) > 0)
  70. #include "portdefs.h"    /* portability definitions */
  71. #include "stddef.h"        /* (ANSI) standard definitions */
  72. #include "limits.h"        /* (ANSI) machine parameters */
  73. #include "string.h"        /* (ANSI) string functions */
  74. #include "stdlib.h"        /* (ANSI) miscellaneous standard functions */
  75. #include "rdslib.h"        /* functions from Reliable Data Structures in C */
  76. #endif
  77. ###menu.h
  78. /* menu.h - header for menu pgm */
  79. #ifndef MENU_H
  80. #define MENU_H
  81. #include "local.h"
  82. #include "screen.h"
  83. typedef struct string_val
  84.     {
  85.     char edit_type;        /* 'n' = numeric, 'd' = short int, 'a' = anything */
  86.     char *string;        /* ptr to the string value */
  87.     short maxsize;        /* maximum size of string: {2:SHORT_MAX} */
  88.     short *pnum;        /* if non-NULL, ptr to numeric storage */
  89.     } STRING_VAL;
  90. typedef struct choice_val
  91.     {
  92.     short nchoices;        /* number of possible choices: {2:10} */
  93.     char **choices;        /* ptr to start of array of choice strings */
  94.     char *pc;            /* ptr to the one-char coded choice value */
  95.     } CHOICE_VAL;
  96. /* (more)
  97. .PE
  98. .PS 33
  99.  */
  100. typedef struct field
  101.     {
  102.     short line, col;    /* co-ordinates of screen display position */
  103.     char *desc;            /* description (title) of this field: string */
  104.     char val_type;        /* what type of field is this?  */
  105.     STRING_VAL *psv;    /* non-NULL iff val_type == 's' or 'S' */
  106.     CHOICE_VAL *pcv;    /* non-NULL iff val_type == 'c' */
  107.     struct menu *pmenu;    /* non-NULL iff val_type == 'm' */
  108.     bool (*pfn)();        /* function to do after str or choice field */
  109.     } FIELD;
  110. typedef struct menu
  111.     {
  112.     char *title;        /* alphabetic title for menu: string */
  113.     FIELD *fields;        /* ptr to beginning of array of FIELDs */
  114.     short nfields;        /* how many fields in this menu */
  115.     short cur_field;    /* index of the current field */
  116.     } MENU;
  117. FIELD *mu_ask();        /* PARMS(MENU *pm) */
  118. SCR_CMDCHAR mu_chv();    /* PARMS(FIELD *pf) */
  119. void mu_do();            /* PARMS(MENU *pm) */
  120. void mu_pr();            /* PARMS(MENU *pm) */
  121. int mu_reply();            /* PARMS(char *prompt, char *reply, int size) */
  122. SCR_CMDCHAR mu_str();    /* PARMS(FIELD *pf) */
  123. SCR_CMDCHAR mu_sval();    /* PARMS(STRING_VAL *psv) */
  124. #endif
  125. ###part.h
  126. /* part.h - header for parts structure
  127.  */
  128. #ifndef PART_H
  129. #define PART_H
  130. typedef struct part
  131.     {
  132.     char part_no[14];    /* part number; string */
  133.     char lead_time[3];    /* lead time (in weeks); num string {0:99} */
  134.     char unit_meas[2];    /* unit of measure; coded string */
  135.                         /* {"0"=each, "1"=lb, "2"=box, other=each} */
  136.     char unit_cost[8];    /* cost; num string {0.00:9999.99} */
  137.     char cost_qty[5];    /* qty required for price */
  138.                         /* num string {0:9999} */
  139.     } PART;
  140. extern PART part1;
  141. #endif
  142. ###part.h1
  143. /* part.h - header for PART structure */
  144. #ifndef PART_H
  145. #define PART_H
  146. typedef struct part
  147.     {
  148.     char part_no[14];    /* part number: string */
  149.     short lead_time;    /* lead time (in weeks): {0:99} */
  150.     char unit_meas[6];    /* unit of measure: string {"each", "lb", "box"}  */
  151.     float unit_cost;    /* cost for one unit_meas: {0.00:9999.99} */
  152.     short cost_qty;        /* quantity required for price: {0:9999} */
  153.     } PART;
  154. #endif
  155. ###part.h2
  156. /* part.h - header for parts structure
  157.  */
  158. #ifndef PART_H
  159. #define PART_H
  160. typedef struct part
  161.     {
  162.     char part_no[14];    /* part number: string */
  163.     char lead_time[3];    /* lead time (in weeks): num string {0:99} */
  164.     char unit_meas[2];    /* unit of measure: coded string */
  165.                         /* {"0"=each, "1"=lb, "2"=box, other=each} */
  166.     char unit_cost[8];    /* cost: num string {0.00 : 9999.99} */
  167.     char cost_qty[5];    /* qty required for price: num string {0:9999} */
  168.     } PART;
  169. extern PART part1;
  170. #endif
  171. ###pointer.h
  172. /* pointer.h - concise macros for pointer checking and casting */
  173. /* PNN(p)         - test that p is not NULL, return p */
  174. /* PNNC(p, t)     - test that p is not NULL, return p cast to type t */
  175. #ifndef POINTER_H
  176. #define POINTER_H
  177. #ifndef NDEBUG
  178. #define PNN(p)            ((p) != NULL ? (p) : PNN_BAD(p))
  179. #define PNNC(p, t)        ((p) != NULL ? (t)(p) : (t)PNN_BAD(p))
  180. #define PNN_BAD(p)        (fprintf(stderr, "NULL\n"), p)
  181. #else
  182. #define PNN(p)            (p)
  183. #define PNNC(p,t)        ((t)(p))
  184. #endif
  185. #endif
  186. ###queue.h
  187. /* queue.h - header for queue package */
  188. #ifndef QUEUE_H
  189. #define QUEUE_H
  190. #include "local.h"
  191. #include "pointer.h"
  192. #define Q_NODE struct q_node
  193. Q_NODE
  194.     {
  195.     Q_NODE *next;
  196.     /* ... */
  197.     };
  198.  
  199. void q_append();    /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p) */
  200. void q_close();        /* PARMS(Q_NODE **frontp, Q_NODE **rearp) */
  201. void q_insert();
  202.     /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p, int (*cmpfn)()) */
  203. Q_NODE **q_lfind();
  204.     /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p, int (*cmpfn)()) */
  205. Q_NODE *q_pop();    /* PARMS(Q_NODE **frontp, Q_NODE **rearp) */
  206. void q_push();        /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p) */
  207. Q_NODE *q_r_detach();
  208.     /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE **pp) */
  209. void q_r_insert();
  210.     /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p, Q_NODE **pp) */
  211.  
  212. /* (more)
  213. .PE
  214. .PS 20
  215.  */
  216.  
  217. #define Q_PP(p)        PNNC(p, Q_NODE **)
  218. #define Q_P(p)        PNNC(p, Q_NODE *)
  219.  
  220. #define Q_APPEND(fp, rp, p)        q_append(Q_PP(fp), Q_PP(rp), Q_P(p))
  221. #define Q_CLOSE(fp, rp)            q_close(Q_PP(fp), Q_PP(rp))
  222. #define Q_INSERT(fp, rp, p, fn)    q_insert(Q_PP(fp), Q_PP(rp), Q_P(p), fn)
  223. #define Q_LFIND(fp, rp, p, fn)    q_lfind(Q_PP(fp), Q_PP(rp), Q_P(p), fn)
  224. #define Q_POP(fp, rp)            q_pop(Q_PP(fp), Q_PP(rp))
  225. #define Q_PUSH(fp, rp, p)        q_push(Q_PP(fp), Q_PP(rp), Q_P(p))
  226. #define Q_R_DETACH(fp, rp, pp)    q_r_detach(Q_PP(fp), Q_PP(rp), Q_PP(pp))
  227. #define Q_R_INSERT(fp, rp, p, pp) q_r_insert(Q_PP(fp), Q_PP(rp), Q_P(p), Q_PP(pp))
  228.  
  229. #define Q_IS_EMPTY(front)       ((front) == NULL)
  230. #define Q_OPEN(frontp, rearp)   (*(frontp) = *(rearp) = NULL)
  231. #define Q_NEXT(p)               ((p)->next)
  232. #define EACH_Q(front, p)        for ((p) = front; (p) != NULL; p = (p)->next)
  233. #endif
  234. ###rdslib.h
  235. #ifndef RDSLIB_H
  236. #define RDSLIB_H
  237. bool itoa();        /* PARMS(int n, char *str, int ndigits) */
  238. int fgetsnn();        /* PARMS(char *str, int size, FILE *fp) */
  239. int getsnn();        /* PARMS(char *str, int size) */
  240. int getreply();        /* PARMS(char *prompt, char *reply, int size) */
  241. bool getpstr();        /* PARMS(char *p, char *s, size_t n) */
  242. bool getplin();        /* PARMS(char *p, char *s, size_t n) */
  243. void plot_trk();    /* PARMS(int n, char c) */
  244. void reverse();        /* PARMS(char *s) */
  245. bool strfit();        /* PARMS(char *s1, char *s2, size_t n) */
  246. #endif
  247. ###rec_io.h
  248. /* rec_io.h - header for record file I/O functions */
  249. #ifndef REC_IO_H
  250. #define REC_IO_H
  251. #include "local.h"
  252. #include "bin_io.h"
  253.  
  254. #define REC_NFILE         BIN_NFILE    /* adjust to local system */
  255. #define REC_NEXT        (-1L)
  256. #define REC_W_END        (-2L)
  257. #define REC_NOT_FOUND    (-3L)    /* codes for hashed file access */
  258. #define REC_FULL        (-4L)    /* codes for hashed file access */
  259. #define REC_ERROR        (-5L)    /* codes for hashed file access */
  260. #define REC_AVAIL        'a'        /* codes for hashed file access */
  261. #define REC_OCCUP        'o'        /* codes for hashed file access */
  262. #define REC_DELET        'd'        /* codes for hashed file access */
  263. #define REC_FILE struct rec_file
  264. REC_FILE
  265.     {
  266.     short _byte0;                /* offset of the first data byte in file */
  267.     short _recsize;                /* size (in bytes) of each record */
  268.     long _nrecs;                /* size (in records) of current file */
  269.     bits _status;                /* open-modes of file */
  270.     };
  271. #define REC_BYTE0 BUFSIZ
  272. #define rec_nrecs(fd)    (rec_files[fd]._nrecs + 0)
  273. #define rec_recsize(fd) (rec_files[fd]._recsize + 0)
  274.  
  275. typedef int rec_fd;
  276.  
  277. extern int errno;
  278. extern REC_FILE rec_files[REC_NFILE];
  279.  
  280. int rec_close();    /* PARMS(rec_fd fd) */
  281. rec_fd rec_open();    /* PARMS(char fname[], int type, int recsize) */
  282. bool rec_get();        /* PARMS(rec_fd fd, data_ptr buf, long i) */
  283. bool rec_put();        /* PARMS(rec_fd fd, data_ptr buf, long i) */
  284. long rec_hfind();
  285. /* PARMS(rec_fd fd, data_ptr keybuf, data_ptr buf, int (*cmp)(), long (*hash)()) */
  286. long rec_havail();
  287. /* PARMS(rec_fd fd, data_ptr keybuf, data_ptr buf, long (*hash)()) */
  288. #endif
  289. ###screen.h
  290. /* screen.h - header for terminal package
  291.  * Assumes ANSI terminal
  292.  */
  293. #ifndef SCREEN_H
  294. #define SCREEN_H
  295.  
  296. typedef short SCR_CMDCHAR;
  297. #define SCR_RETURN '\r'
  298. #define SCR_EXIT   0x101
  299. #define SCR_UP     0x102
  300. #define SCR_DOWN   0x103
  301. #define SCR_LEFT   0x104
  302. #define SCR_RIGHT  0x105
  303. #define SCR_HOME   0x106
  304. #define SCR_CLEAR  "\33[2J"        /* clear entire screen, go HOME */
  305. #define SCR_CEL    "\33[K"        /* clear to end of line */
  306. #define SCR_TTY 1    /* screen is in ordinary (non-direct) mode */
  307. #define SCR_RAW 2    /* screen is in "total-control" mode */
  308.  
  309. #define SCR_CMD(c) \
  310.     (c == SCR_RETURN || c >= 0x101 && c <= 0x106)
  311.  
  312. extern short scr_mode;        /* {SCR_TTY, SCR_RAW} */
  313. extern short scr_lins;        /* number of lines on screen */
  314. extern short scr_cols;        /* number of columns on screen */
  315.  
  316. void scr_close();            /* PARMS(void) */
  317. SCR_CMDCHAR scr_getkey();    /* PARMS(void) */
  318. void scr_open();            /* PARMS(void) */
  319.  
  320. #define scr_beep()        putchar('\7')
  321. #define scr_clear()        printf(SCR_CLEAR)
  322. #define scr_cel()        printf(SCR_CEL)
  323. #define scr_curs(r, c)    printf("\33[%d;%dH", (r)+1, (c)+1)
  324. #define scr_print        printf
  325. #define scr_putc(c)        putchar(c)
  326. #define scr_refresh()    fflush(stdout)
  327. #endif
  328. ###setjmp.h
  329. int setjmp PARMS((jmp_buf env));
  330. void longjmp PARMS((jmp_buf env, int val));
  331. ###stack.h
  332. /* stack.h - header for stack package */
  333. #ifndef STACK_H
  334. #define STACK_H
  335. #include "local.h"
  336. #include "pointer.h"
  337. #define ST_NODE struct st_node
  338. ST_NODE
  339.     {
  340.     ST_NODE *next;
  341.     /* ... */
  342.     };
  343.  
  344. void st_close();            /* PARMS(ST_NODE **headp) */
  345. ST_NODE *st_pop();            /* PARMS(ST_NODE **headp) */
  346. void st_push();                /* PARMS(ST_NODE **headp, ST_NODE *p) */
  347.  
  348. #define ST_P(p)                PNNC(p, ST_NODE *)
  349. #define ST_PP(p)            PNNC(p, ST_NODE **)
  350.  
  351. #define ST_CLOSE(h)            (st_close(ST_PP(h)))
  352. #define ST_POP(h)            (st_pop(ST_PP(h)))
  353. #define ST_PUSH(h, p)        (st_push(ST_PP(h), ST_P(p)))
  354.  
  355. #define EACH_ST(head, p)    for ((p) = (head); (p) != NULL; (p) = (p)->next)
  356. #define ST_FIRST(head)        (head)
  357. #define ST_IS_EMPTY(head)    ((head) == NULL)
  358. #define ST_OPEN(headp)        (*(headp) = NULL)
  359. #define ST_NEXT(p)            ((p)->next)
  360. #endif
  361. ###stdlib.h
  362. /* stdlib.h - miscellaneous library functions (partial listing) */
  363. #ifndef STDLIB_H
  364. #define STDLIB_H
  365. #include "stddef.h"
  366. double atof();        /* PARMS(char *s) */
  367. int atoi();            /* PARMS(char *s) */
  368. long atol();        /* PARMS(char *s) */
  369. data_ptr calloc();    /* PARMS(unsigned int n, size_t size) */
  370. void exit();        /* PARMS(int status) */
  371. void free();        /* PARMS(data_ptr ptr) */
  372. data_ptr malloc();    /* PARMS(size_t size) */
  373. int rand();            /* PARMS(void) */
  374. void srand();        /* PARMS(unsigned int seed) */
  375. #endif
  376. ###task.h
  377. /* task.h - header for task package */
  378. #ifndef TASK_H
  379. #define TASK_H
  380. #include "local.h"
  381. #include "queue.h"
  382. typedef short TIME;
  383. #define TASK struct task
  384. TASK
  385.     {
  386.     TASK *next;
  387.     TIME start;
  388.     char desc[40];
  389.     };
  390. #endif
  391. ###time.h
  392. struct tm {
  393.     int tm_sec;        /* seconds {0:59} */
  394.     int tm_min;        /* minutes {0:59} */
  395.     int tm_hour;    /* hours {0:23} */
  396.     int tm_mday;    /* day of the month {1:31} */
  397.     int tm_mon;        /* month of the year {0:11} */
  398.     int tm_year;    /* years since 1900 A.D. */
  399.     int tm_wday;    /* days since previous Sunday {0:6} */
  400.     int tm_yday;    /* day of the year {0:365} */
  401.     int tm_isdst;    /* nonzero for daylight savings time */
  402.     /* ... other members are allowed ... */
  403.     };
  404.  
  405. typedef long time_t
  406. typedef long clock_t;
  407. #define CLK_TCK (1e6/60.)    /* 60 cycle clock */
  408.  
  409. char *asctime PARMS((const struct tm *timeptr));
  410. clock_t clock PARMS((void));
  411. char *ctime PARMS((time_t *timer));
  412. double difftime PARMS((time_t timer1, time_t timer2));
  413. struct tm *gmtime PARMS((const time_t *timer));               
  414. struct tm *localtime PARMS((const time_t *timer));
  415. time_t time PARMS((time_t *timer));
  416.  
  417. ###time_day.h1
  418. /* time_day.h - bit-field structure for  hh:mm:ss.fff */
  419. #ifndef TIME_DAY_H
  420. #define TIME_DAY_H
  421. typedef struct time_day
  422.     {
  423.     unsigned h1 : 2;    /* tens digit of hours        {0:2} */
  424.     unsigned h2 : 4;    /* units digit of hours        {0:9} */
  425.     unsigned m1 : 3;    /* tens digit of minutes    {0:5} */
  426.     unsigned m2 : 4;    /* units digit of minutes    {0:9} */
  427.     unsigned s1 : 3;    /* tens digit of seconds    {0:5} */
  428.     unsigned s2 : 4;    /* units digit of seconds    {0:9} */
  429.     unsigned f1 : 4;    /* first digit of fraction    {0:9} */
  430.     unsigned f2 : 4;    /* second digit of fraction    {0:9} */
  431.     unsigned f3 : 4;    /* third digit of fraction    {0:9} */
  432.     } TIME_DAY;        /* 32 bits total */
  433. #endif
  434. ###time_day.h2
  435. /* time_day.h - bit-field structure for  hh:mm:ss.fff */
  436. #ifndef TIME_DAY_H
  437. #define TIME_DAY_H
  438. typedef struct _time_day
  439.     {
  440.     unsigned _h1 : 2;    /* tens digit of hours        {0:2} */
  441.     unsigned _h2 : 4;    /* units digit of hours        {0:9} */
  442.     unsigned _m1 : 3;    /* tens digit of minutes    {0:5} */
  443.     unsigned _m2 : 4;    /* units digit of minutes    {0:9} */
  444.     unsigned _s1 : 3;    /* tens digit of seconds    {0:5} */
  445.     unsigned _s2 : 4;    /* units digit of seconds    {0:9} */
  446.     unsigned _f1 : 4;    /* first digit of fraction    {0:9} */
  447.     unsigned _f2 : 4;    /* second digit of fraction    {0:9} */
  448.     unsigned _f3 : 4;    /* third digit of fraction    {0:9} */
  449.     } TIME_DAY;        /* 32 bits total */
  450. #endif
  451. ###tree.h
  452. /* tree.h - header for tree functions
  453.  */
  454. #ifndef TREE_H
  455. #define TREE_H
  456. #include "local.h"
  457. #include "pointer.h"
  458. #define TR_NODE struct tr_node
  459. TR_NODE
  460.     {
  461.     TR_NODE *right;
  462.     TR_NODE *left;
  463.     /* ... */
  464.     };
  465. void tr_close();        /* PARMS(TR_NODE **plt) */
  466. void tr_delete();        /* PARMS(TR_NODE **plt, TR_NODE **pln, int (*cmpfn)()) */
  467. TR_NODE *tr_detach();    /* PARMS(TR_NODE **pln) */
  468. void tr_insert();        /* PARMS(TR_NODE **plt, TR_NODE *pn, int (*cmpfn)()) */
  469. TR_NODE **tr_lfind();    /* PARMS(TR_NODE **plt, TR_NODE *pn, int (*cmpfn)()) */
  470. TR_NODE **tr_lfirst();    /* PARMS(TR_NODE **plt) */
  471. TR_NODE **tr_lpfind();    /* PARMS(TR_NODE **plt, TR_NODE *pn, int (*cmpfn)()) */
  472. TR_NODE **tr_lnext();    /* PARMS(TR_NODE **plt, TR_NODE *pn, int (*cmpfn)()) */
  473.  
  474. #define TR_RIGHT(p)        ((p)->right)
  475. #define TR_LEFT(p)        ((p)->left)
  476.  
  477. #define TR_P(p)            PNNC(p, TR_NODE *)
  478. #define TR_PP(p)        PNNC(p, TR_NODE **)
  479.  
  480. #define TR_CLOSE(plt)            tr_close(TR_PP(plt))
  481. #define TR_DELETE(plt, pln, fn)    tr_delete(TR_PP(plt), TR_PP(pln), fn)
  482. #define TR_DETACH(pln)            tr_detach(TR_PP(pln))
  483. #define TR_INSERT(plt, pn, fn)    tr_insert(TR_PP(plt), TR_P(pn), fn)
  484. #define TR_LFIND(plt, pn, fn)    tr_lfind(TR_PP(plt), TR_P(pn), fn)
  485. #define TR_LFIRST(plt)            tr_lfirst(TR_PP(plt))
  486. #define TR_LPFIND(plt, pn, fn)    tr_lpfind(TR_PP(plt), TR_P(pn), fn)
  487. #define TR_LNEXT(plt, pn, fn)    tr_lnext(TR_PP(plt), TR_P(pn), fn)
  488.  
  489. /* true macros */
  490. #define TR_OPEN(plt)            (*(plt) = NULL)
  491. #define TR_FIRST(plt)            (*TR_LFIRST(plt))
  492. #define TR_FIND(plt, pn, fn)    (*TR_LFIND(plt, pn, fn))
  493. #define TR_NEXT(plt, pn, fn)    (*TR_LNEXT(plt, pn, fn))
  494. #define EACH_TR(plt, p, t, fn) \
  495.     for (p = (t *)*TR_LFIRST(plt); (p) != NULL; p = (t *)*TR_LNEXT(plt, p, fn))
  496. #endif
  497. ###wsl_bin_io.h
  498. /* bin_io.h - header for binary file I/O functions */
  499. #ifndef BIN_IO_H
  500. #define BIN_IO_H
  501. #include "local.h"
  502.  
  503. #define BIN_FILE FILE
  504.  
  505. int bin_fclose();        /* PARMS(BIN_FILE *bf) */
  506. long bin_fseek();        /* PARMS(BIN_FILE *bf, long offset, int whence) */
  507. BIN_FILE *bin_fopen();    /* PARMS(char fname[], char type[]) */
  508. int bin_fread();
  509.             /* PARMS(data_ptr buf, size_t size, int n, BIN_FILE *bf) */
  510. int bin_fread();
  511.             /* PARMS(data_ptr buf, size_t size, int n, BIN_FILE *bf) */
  512.  
  513. /* {{ CHANGE THE FOLLOWING TO ANSI STYLE BEFORE PRINTING }} */
  514.  
  515. #define bin_b4r_seek(bf)    /* nothing, no action needed */
  516. #define bin_b4w_seek(bf)    /* nothing, no action needed */
  517.  
  518. #define bin_fclose(bf)        close(bf)
  519. #define bin_fseek(bf, o, w)    (long)lseek(bf, o, w)    /* WSL - no "tell" */
  520. #define bin_fwrite(b, sz, n, bf)    write(bf, b, (sz)*(n))
  521.  
  522. #endif
  523. ###EOF
  524.