home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
165_01
/
headers.d
< prev
next >
Wrap
Text File
|
1988-02-19
|
18KB
|
524 lines
###bin_io.h
/* bin_io.h - header for binary file I/O functions
* SYSTEM DEPENDENT - MUST BE CONFIGURED FOR EACH TARGET SYSTEM
*/
#ifndef BIN_IO_H
#define BIN_IO_H
#include "local.h"
#include "fcntl.h" /* provide your own if not standard on system */
typedef int bin_fd; /* "binary file descriptor" {0:BIN_NFILE-1} */
#define BIN_NFILE 20 /* adjust to local system */
#define O_RWMODE (O_RDONLY|O_WRONLY|O_RDWR) /* uses symbols from fcntl.h */
#ifndef IDRIS
#define bin_open(s, m) open(s, m)
#endif
#define bin_close(f) close(f)
#define bin_lseek(f, o, w) lseek(f, o, w)
#define bin_read(f, b, n) read(f, b, n)
#define bin_write(f, b, n) write(f, b, n)
#endif
###fcntl.h
/* fcntl.h - definitions for binary open
* Compatible with UNIX Sys V, ...
*/
#ifndef FCNTL_H
#define FCNTL_H
#define O_RDONLY 0 /* delete or change to conform to local */
#define O_WRONLY 1 /* delete or change to conform to local */
#define O_RDWR 2 /* delete or change to conform to local */
#define O_NDELAY 4 /* NOT USED BY bin_io FUNCTIONS */
#define O_APPEND 8 /* delete or change to conform to local */
#define O_CREAT 0x100 /* delete or change to conform to local */
#define O_TRUNC 0x200 /* delete or change to conform to local */
#define O_EXCL 0x400 /* delete or change to conform to local */
#endif
###local.h
/* local.h - Definitions for use with Reliable Data Structures in C */
#ifndef LOCAL_H
#define LOCAL_H
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#define FALSE 0 /* Boolean value */
#define FOREVER for(;;) /* endless loop */
#define NO 0 /* Boolean value */
#define TRUE 1 /* Boolean value */
#define YES 1 /* Boolean value */
#define getln(s, n) ((fgets(s, n, stdin)==NULL) ? EOF : strlen(s))
#define ABS(x) (((x) < 0) ? -(x) : (x))
#define MAX(x, y) (((x) < (y)) ? (y) : (x))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define DIM(a) (sizeof(a) / sizeof(a[0]))
#define IN_RANGE(n, lo, hi) ((lo) <= (n) && (n) <= (hi))
#ifndef NDEBUG
#define asserts(cond, str) \
{if (!(cond)) fprintf(stderr, "Assertion '%s' failed\n", str);}
#else
#define asserts(cond, str)
#endif
#define SWAP(a, b, t) ((t) = (a), (a) = (b), (b) = (t))
#define LOOPDN(r, n) for ((r) = (n)+1; --(r) > 0; )
#define STREQ(s, t) (strcmp(s, t) == 0)
#define STRLT(s, t) (strcmp(s, t) < 0)
#define STRGT(s, t) (strcmp(s, t) > 0)
#include "portdefs.h" /* portability definitions */
#include "stddef.h" /* (ANSI) standard definitions */
#include "limits.h" /* (ANSI) machine parameters */
#include "string.h" /* (ANSI) string functions */
#include "stdlib.h" /* (ANSI) miscellaneous standard functions */
#include "rdslib.h" /* functions from Reliable Data Structures in C */
#endif
###menu.h
/* menu.h - header for menu pgm */
#ifndef MENU_H
#define MENU_H
#include "local.h"
#include "screen.h"
typedef struct string_val
{
char edit_type; /* 'n' = numeric, 'd' = short int, 'a' = anything */
char *string; /* ptr to the string value */
short maxsize; /* maximum size of string: {2:SHORT_MAX} */
short *pnum; /* if non-NULL, ptr to numeric storage */
} STRING_VAL;
typedef struct choice_val
{
short nchoices; /* number of possible choices: {2:10} */
char **choices; /* ptr to start of array of choice strings */
char *pc; /* ptr to the one-char coded choice value */
} CHOICE_VAL;
/* (more)
.PE
.PS 33
*/
typedef struct field
{
short line, col; /* co-ordinates of screen display position */
char *desc; /* description (title) of this field: string */
char val_type; /* what type of field is this? */
STRING_VAL *psv; /* non-NULL iff val_type == 's' or 'S' */
CHOICE_VAL *pcv; /* non-NULL iff val_type == 'c' */
struct menu *pmenu; /* non-NULL iff val_type == 'm' */
bool (*pfn)(); /* function to do after str or choice field */
} FIELD;
typedef struct menu
{
char *title; /* alphabetic title for menu: string */
FIELD *fields; /* ptr to beginning of array of FIELDs */
short nfields; /* how many fields in this menu */
short cur_field; /* index of the current field */
} MENU;
FIELD *mu_ask(); /* PARMS(MENU *pm) */
SCR_CMDCHAR mu_chv(); /* PARMS(FIELD *pf) */
void mu_do(); /* PARMS(MENU *pm) */
void mu_pr(); /* PARMS(MENU *pm) */
int mu_reply(); /* PARMS(char *prompt, char *reply, int size) */
SCR_CMDCHAR mu_str(); /* PARMS(FIELD *pf) */
SCR_CMDCHAR mu_sval(); /* PARMS(STRING_VAL *psv) */
#endif
###part.h
/* part.h - header for parts structure
*/
#ifndef PART_H
#define PART_H
typedef struct part
{
char part_no[14]; /* part number; string */
char lead_time[3]; /* lead time (in weeks); num string {0:99} */
char unit_meas[2]; /* unit of measure; coded string */
/* {"0"=each, "1"=lb, "2"=box, other=each} */
char unit_cost[8]; /* cost; num string {0.00:9999.99} */
char cost_qty[5]; /* qty required for price */
/* num string {0:9999} */
} PART;
extern PART part1;
#endif
###part.h1
/* part.h - header for PART structure */
#ifndef PART_H
#define PART_H
typedef struct part
{
char part_no[14]; /* part number: string */
short lead_time; /* lead time (in weeks): {0:99} */
char unit_meas[6]; /* unit of measure: string {"each", "lb", "box"} */
float unit_cost; /* cost for one unit_meas: {0.00:9999.99} */
short cost_qty; /* quantity required for price: {0:9999} */
} PART;
#endif
###part.h2
/* part.h - header for parts structure
*/
#ifndef PART_H
#define PART_H
typedef struct part
{
char part_no[14]; /* part number: string */
char lead_time[3]; /* lead time (in weeks): num string {0:99} */
char unit_meas[2]; /* unit of measure: coded string */
/* {"0"=each, "1"=lb, "2"=box, other=each} */
char unit_cost[8]; /* cost: num string {0.00 : 9999.99} */
char cost_qty[5]; /* qty required for price: num string {0:9999} */
} PART;
extern PART part1;
#endif
###pointer.h
/* pointer.h - concise macros for pointer checking and casting */
/* PNN(p) - test that p is not NULL, return p */
/* PNNC(p, t) - test that p is not NULL, return p cast to type t */
#ifndef POINTER_H
#define POINTER_H
#ifndef NDEBUG
#define PNN(p) ((p) != NULL ? (p) : PNN_BAD(p))
#define PNNC(p, t) ((p) != NULL ? (t)(p) : (t)PNN_BAD(p))
#define PNN_BAD(p) (fprintf(stderr, "NULL\n"), p)
#else
#define PNN(p) (p)
#define PNNC(p,t) ((t)(p))
#endif
#endif
###queue.h
/* queue.h - header for queue package */
#ifndef QUEUE_H
#define QUEUE_H
#include "local.h"
#include "pointer.h"
#define Q_NODE struct q_node
Q_NODE
{
Q_NODE *next;
/* ... */
};
void q_append(); /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p) */
void q_close(); /* PARMS(Q_NODE **frontp, Q_NODE **rearp) */
void q_insert();
/* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p, int (*cmpfn)()) */
Q_NODE **q_lfind();
/* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p, int (*cmpfn)()) */
Q_NODE *q_pop(); /* PARMS(Q_NODE **frontp, Q_NODE **rearp) */
void q_push(); /* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p) */
Q_NODE *q_r_detach();
/* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE **pp) */
void q_r_insert();
/* PARMS(Q_NODE **frontp, Q_NODE **rearp, Q_NODE *p, Q_NODE **pp) */
/* (more)
.PE
.PS 20
*/
#define Q_PP(p) PNNC(p, Q_NODE **)
#define Q_P(p) PNNC(p, Q_NODE *)
#define Q_APPEND(fp, rp, p) q_append(Q_PP(fp), Q_PP(rp), Q_P(p))
#define Q_CLOSE(fp, rp) q_close(Q_PP(fp), Q_PP(rp))
#define Q_INSERT(fp, rp, p, fn) q_insert(Q_PP(fp), Q_PP(rp), Q_P(p), fn)
#define Q_LFIND(fp, rp, p, fn) q_lfind(Q_PP(fp), Q_PP(rp), Q_P(p), fn)
#define Q_POP(fp, rp) q_pop(Q_PP(fp), Q_PP(rp))
#define Q_PUSH(fp, rp, p) q_push(Q_PP(fp), Q_PP(rp), Q_P(p))
#define Q_R_DETACH(fp, rp, pp) q_r_detach(Q_PP(fp), Q_PP(rp), Q_PP(pp))
#define Q_R_INSERT(fp, rp, p, pp) q_r_insert(Q_PP(fp), Q_PP(rp), Q_P(p), Q_PP(pp))
#define Q_IS_EMPTY(front) ((front) == NULL)
#define Q_OPEN(frontp, rearp) (*(frontp) = *(rearp) = NULL)
#define Q_NEXT(p) ((p)->next)
#define EACH_Q(front, p) for ((p) = front; (p) != NULL; p = (p)->next)
#endif
#