/*
 *  Copyright 1992 Science Applications International Corporation.
 */

/*
 * NAME    
 *	gdi_ArrayStructs.h
 *
 * SYNOPSIS
 *      Contains defines and structures used by css style arrays
 *	for the Generic Database Interface Library.
 *
 * DESCRIPTION
 *
 *
 * DIAGNOSTICS
 *
 *
 * FILES
 *
 *
 * SEE ALSO
 *
 *
 * AUTHOR
 *	Jeff Given 1993
 *
 *
 * MODIFICATIONS
 *
 */

/*
 *	SccsId:  @(#)gdi_ArrayStructs.h	16.1 8/3/93 SAIC
 */

/*
 *    offsetof is a macro that is supposedly supported by
 *    ANSI C.  The following gives the right results on the SUN,
 *    but there will be compiler warnings.
 */

#ifndef _GDI_ARRAYSTRUCTS_
#define _GDI_ARRAYSTRUCTS_

#define offsetof(str, elem)   (unsigned long) & ((str *)0)->elem

#define sizeof_(str, elem)    sizeof(((str *)0)->elem)

/*
 *    The supported structure element types
 */

typedef enum {carray_t, cptr_t, double_t, float_t, int_t, long_t} Elem_t;

/*
 *    The following defines a stucture that holds pertinent information
 *    about each element in a structure.
 */

typedef struct
{
     char     *name;
     int      offset;
     int      size;
     Elem_t   type;
} ElemAttr;

/*
 *    The following structure bundles up all the necessary
 *    information for an array container.
 */
typedef struct
{
     int                size;
     int                nrows;
     int                *col_nums;
     void               *blank_tuple;
     void               *null_tuple;
     ElemAttr           *elem_attr;
} ArrayStructsArgs;

/*
 * prototypes for ArrayStructs constructor function
 * which returns a pointer to an array of structures.
 * (emulates libdb30)
 */

Proto (int, gdi_get_ArrayStructs, (
	dbConn           *dbconn,      /* (i) database connector                  */
	char             *query,       /* (i) database query                      */
	void             **array,      /* (o) pointer to hold array of structures */
	int              maxrec,       /* (i) max number of rows to return        */
	ArrayStructsArgs *type         /* (i) struct describing data container    */
	));


Proto (int, gdi_add_ArrayStructs, (
	dbConn           *dbconn,      /* (i) database connector                  */
	char             *table_name,  /* (i) database table name                 */
	void             *array,       /* (i) pointer to array of structures      */
	int              ntuple,       /* (i) number of rows in array             */
	ArrayStructsArgs *type         /* (i) struct describing data container    */
	));


#endif  /* _GDI_ARRAYSTRUCTS_ */
