/**---------------------------------------------------------------------------
 ** 
 ** con2db.h -- 
 ** 
 ** Author          : Pierre Jaccard
 ** Created On      : 1999/08/02 16:22:21
 ** Last Modified By: Pierre Jaccard
 ** Last Modified On: 1999/08/02 17:06:04
 ** Update Count    : 9
 ** Directory       : /home/pego/pcd1/codas3c/gfi/src/apps/util/
 ** Version         : 0.0
 ** Status          : Unknown
 ** ---------------------------------------------------------------------- ** 
 ** DESCRIPTION: 
 ** 
 **    Undocumented.
 ** 
 ** ---------------------------------------------------------------------- ** 
 ** REVISIONS: 
 ** ---------------------------------------------------------------------- ** 
 ** CHANGES: 
 **------------------------------------------------------------------------**/

#include "geninc.h"
#include "data_lst.h"
#include "ioserv.h"
#include "dbsource.h"
#include "use_db.h"
#include "gfimisc.h"
#include "gfidb.h"

/* ------------------------------------------------------------------
	 -MACROS:
	 ------------------------------------------------------------------ */
#define MAXLEN    100
#define BLK_COM   1
#define BLK_VAR   2
#define PRF_VAR   3
#define IN_DATA   4
#define ACC_VAR   5
#define PRF_FLAGS 6

#define MAX_BINS  512

/* ------------------------------------------------------------------
	 -TYPES:
	 ------------------------------------------------------------------ */

typedef struct
{
  SHORT fgb;
	SHORT lgb;
	FLOAT Usa;
	FLOAT Vsa;
	SHORT uf1, uf2, uf3, uf4;
} CON2DB_ACC_VAR_TYPE;

typedef struct 
{
	int   n; /* Number of characters */
	char *c; /* Array for comment    */
} CON2DB_COM_TYPE;

typedef struct 
{
	int   n;                /* Number of elements       */
	int   col;              /* Column number in file    */
	int   id;               /* Variable identifier      */
	FLOAT *d;               /* Array for values of data */
} CON2DB_DATA_TYPE;

typedef struct
{
	int n;                     /* Number of variables         */
	CON2DB_DATA_TYPE *data;    /* Array for all variable data */
} CON2DB_VARS_TYPE;

typedef struct
{
	int              n;         /* Number of input data columns, 
									 							 equals length of <data> vector 
									 							 below                          */ 
	double           yd;        /* Decimal day                    */
	DOUBLE_LL_TYPE   pos;       /* Decimal position               */
	YMDHMS_TIME_TYPE time;      /* Time of input                  */
	DMSH_LL_TYPE     position;  /* Position of input              */
	FLOAT            *data;     /* Space for data                 */
} CON2DB_INPUT_TYPE;
	
typedef struct
{
	CON2DB_COM_TYPE   blk_com; /* Space for block comment             */
	CON2DB_VARS_TYPE  blk_var; /* Space for list of block variables   */
	CON2DB_VARS_TYPE  prf_var; /* Space for list of profile variables */
	CON2DB_INPUT_TYPE input;   /* Space for a contour input line      */
} CON2DB_TYPE;

/* ------------------------------------------------------------------
	 GLOBAL VARIABLES:
	 ------------------------------------------------------------------ */

int year_base;
FILE_NAME_TYPE dbname, prdfile, confile;
CON2DB_TYPE con2db;

/* ------------------------------------------------------------------
	 -PARAMETERS:
	 ------------------------------------------------------------------ */

PARAMETER_LIST_ENTRY_TYPE con2db_param[]=
{
	{" year_base:", "%d"  , (char *) &year_base, TYPE_INT   },
	{" dbname:"   , "%79s", (char *) dbname    , TYPE_STRING},
	{" prdfile:"  , "%79s", (char *) prdfile   , TYPE_STRING},
	{" confile:"  , "%79s", (char *) confile   , TYPE_STRING},
  {NULL, NULL, NULL, 0}
};

/* ------------------------------------------------------------------
	 -OPTIONS:
	 ------------------------------------------------------------------ */

#if PROTOTYPE_ALLOWED
int con2db_read_vars(FILE *fp, char *arg, int code);
#else
int ();
#endif

OPTION_TYPE con2db_options[]=
{
	{"end", 0, NULL, (char *) NULL},
	{"OPTIONS:", 0, NULL, (char *) NULL},
	{"profile_variables:", PRF_VAR, con2db_read_vars, 
	 (char *) &(con2db.prf_var) },
	{"block_variables:"  , BLK_VAR, con2db_read_vars, 
	 (char *) &(con2db.blk_var) },
	{"block_comments:"   , BLK_COM, con2db_read_vars, 
	 (char *) &(con2db.blk_com) },
	{NULL, 0, NULL, (char *) NULL}
};




