home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
INCLUDE
/
JADECL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1990-09-24
|
3KB
|
108 lines
/*
jadecl.h 4/14/89
% jarray (jeneric arrays)
originally written by stephen ng and Joe DeSantis.
OWL 1.2
Copyright (c) 1986-1989, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
9/01/87 jmd added NO_PROTO option
6/01/88 jmd added iarray, changed char *'s to VOID *'s
6/01/88 jmd changed growth strategy
6/01/88 jmd changed some names
6/24/88 jmd moved to oaklib
10/17/88 jmd added _arg()
4/14/89 jmd combined into one new super thingy
3/28/90 jmd ansi-fied
9/24/90 jmd added ja_Ok
*/
#define JA_GROW 1024
/* The jarray structure. */
typedef struct jarray_struct {
VOID *array;
unsigned size;
SIZE_T eltsize;
} *jarray;
/* Jarray macros. */
/* ja_Get copies the data from the array into your slot */
/* ja_GetPtr returns a pointer to the data */
#define ja_GetPtr(ja, eltno) \
(VOID *) ((char *) (ja)->array + (eltno * (ja)->eltsize))
#define ja_size(ja) ((ja)->size)
#define ja_Ok(ja) ((ja)->array != NULL)
/* Jarray declarations. */
/* JARRAY.C */
extern jarray ja_Open(unsigned size, SIZE_T eltsize);
extern void ja_Close(jarray ja);
extern int ja_Put(jarray ja, unsigned eltno, VOID *elt);
extern boolean ja_Resize(jarray ja, unsigned newsize);
extern VOID *ja_Get(jarray ja, unsigned eltno, VOID *out);
/* JAINS.C */
extern boolean ja_Ins(jarray ja, unsigned eltno, unsigned count, unsigned isize);
extern void ja_Del(jarray ja, unsigned eltno, unsigned count);
/* Xarray macros. (for pointers) */
typedef jarray xarray;
#define xa_Open(start) ja_Open(start, 0)
#define xa_Close(xa) ja_Close(xa)
#define xa_Get(xa, eltno) (((eltno) >= (xa)->size) ? \
(NULL) : ((VOID **)(xa)->array)[(eltno)])
#define xa_Put(xa, eltno, elt) (((eltno) >= (xa)->size) ? \
ja_Put(xa, eltno, (VOID *) elt) : (((VOID **)(xa)->array)[(eltno)] = (elt), TRUE))
#define xa_size(xa) ja_size(xa)
/* Larray macros. (for longs) */
typedef jarray larray;
#define la_Open(start) ja_Open(start, sizeof(long))
#define la_Close(la) ja_Close(la)
#define la_Get(la, eltno) (((eltno) >= (la)->size) ? \
(0L) : ((long *)(la)->array)[(eltno)])
#define la_Put(la, eltno, elt) (((eltno) >= (la)->size) ? \
ja_Put(la, eltno, (VOID *) &elt) : (((long *)(la)->array)[(eltno)] = (elt), TRUE))
#define la_size(la) ja_size(la)
/* Iarray macros. (for ints) */
typedef jarray iarray;
#define ia_Open(start) ja_Open(start, sizeof(int))
#define ia_Close(ia) ja_Close(ia)
#define ia_Get(ia, eltno) (((eltno) >= (ia)->size) ? \
(0) : ((int *)(ia)->array)[(eltno)])
#define ia_Put(ia, eltno, elt) (((eltno) >= (ia)->size) ? \
ja_Put(ia, eltno, (VOID *) &elt) : (((int *)(ia)->array)[(eltno)] = (elt), TRUE))
#define ia_size(ia) ja_size(ia)