/*****************************************************************************
*                                                                            *
*      COMMON OCEANOGRAPHIC DATA ACCESS SYSTEM (CODAS)                       *
*                                                                            *
*      WRITTEN BY:  RAMON CABRERA, ERIC FIRING, and JULIE RANADA             *
*                   JOINT INSTITUTE FOR MARINE AND ATMOSPHERIC RESEARCH      *
*                   1000 POPE ROAD  MSB 404                                  *
*                   HONOLULU, HI 96822                                       *
*                                                                            *
*      VERSION:     3.00                                                     *
*                                                                            *
*      DATE:        APRIL 1989                                               *
*                                                                            *
*****************************************************************************/
/*
       FILE:  dbdcl.h

*/
#ifndef dbdcl_included
#define dbdcl_included

#ifndef dbhost_included
#include "dbhost.h" /* PROTOTYPE_ALLOWED */
#endif
#ifndef dbext_included
#include "dbext.h"  /* FLOAT, etc. */
#endif

#if PROTOTYPE_ALLOWED
/*---------------------------
    FUNCTIONS in dbcommon.c
*/
void DBCLOSE(int *ierr);
void report_db_error(char *fun);
int close_block_dir(void);
int close_block(void);
void release_database(void);
void release_block(void);
void update_block_dir(void);
void update_block(void);
void update_block_dir_entry(void);
int write_block_dir_hdr(void);
int write_block_dir(void);
int write_block_dir_entry(void);
int write_block_hdr(void);
int write_profile_dir(void);
void sort_block_dir(void);
void sort_profile_dir(void);
int load_block_dir(void);
int load_profile_dir(void);
int load_data_list(void);
int open_block_dir(void);
int open_block(void);
int allocate_memory_for_directories(void);
int alignment_check(void);
int identify_ms(char *ms);
int identify_ms_code(char *ms);
/*---------------------------
    FUNCTIONS in dbmove.c
*/
void DBMOVE(int *steps, int *ierr);
/*---------------------------
    FUNCTIONS in dbopsrch.c
*/
void DBOPEN(int *db_id, char *db_name, int *access_mode, int *memory_mode,
            int *ierr);
void DBSRCH(int *search_type, char *search_parameters, int *ierr);
int lock_on_block(void);
int lock_on_profile(void);
int set_block_access(void);
int set_profile_access(void);
int load_block_dir_entry(void);
int load_profile_dir_entry(void);
int lock_on_blkprf_index(int *d, int *ierr);
int lock_on_time(YMDHMS_TIME_TYPE *t, int *ierr);
int search_for_block_by_time(ULONG tpck, int *ierr);
int search_for_profile_by_time(LONG secs);
/*---------------------------
    FUNCTIONS in dbcreate.c
*/
void DBCREATE(int *db_id, char *db_name, char *prd_name, int *memory_mode,
              int *ierr);
void DBNEWBLK(int *ierr);
void DBNEWPRF(YMDHMS_TIME_TYPE *prf_time, int *ierr);
void DBADD   (int *type, char *data, unsigned int *nb, int *ierr);
void DBENDPRF(int *ierr);
void DBENDBLK(int *ierr);
int create_block_dir(void);
int create_block(void);
void create_block_dir_entry(void);
void create_profile_dir_entry(YMDHMS_TIME_TYPE *prf_time);
int add_profile_aux(int *type, char *data, unsigned int nb, int ind);
int add_profile_data(int *type, char *data, unsigned int *nb, int *ierr);
int dbadd_flags(void);
int set_position(DMSH_POSITION_TYPE *data);
int set_depth_range(DEPTH_RANGE_TYPE *data);
void set_access_param(int *type, unsigned int nb, int *ind, int *ierr);
int store_temp_data(char *data, unsigned int total_nb);
int flush_block_dir_file(void);
int write_data_list(void);
int write_block_strdef(void);
int add_block_dir_entry(void);
int load_producer_definition(void);
int define_data(int code);
/*---------------------------
    FUNCTIONS in defstruc.c
*/
int define_struct(FILE *fpin, STRUCT_DEF_HDR_TYPE **head_ptr, USHORT *nentries);
FORMAT_SPEC *define_format_spec(FILE *fpin);
int find_print_function(char *fn_name);
/*---------------------------
    FUNCTIONS in dbadd_f.c
*/
void DBADD_F(int *type, FLOAT data[], unsigned int *nv, unsigned int *nbad,
             int *ierr);
int addf_profile_data(int *type, FLOAT data[], unsigned int *nv,
                      unsigned int *nbad, int *ierr);
/*---------------------------
    FUNCTIONS in dbput_f.c
*/
void DBPUT_F(int *type, FLOAT data[], unsigned int *user_nv, unsigned int *nbad,
             int *ierr);
int putf_profile_data(int *type, FLOAT data[], unsigned int *user_nv,
                      unsigned int *nbad, int *ierr);
/*---------------------------
    FUNCTIONS in dbget.c
*/
void DBGET(int *type, char *data, unsigned int *nb, int *ierr);
int get_profile_data(int *type, char *data, unsigned int *user_nb);
int get_position(DMSH_POSITION_TYPE *data);
int get_depth_range(DEPTH_RANGE_TYPE *data);
/*---------------------------
    FUNCTIONS in dbget_f.c
*/
void DBGET_F(int *type, FLOAT data[], unsigned int *user_nv, int *ierr);
int getf_profile_data(int *type, FLOAT data[], unsigned int *user_nv);
/*---------------------------
    FUNCTIONS in dbgetput.c
*/
void get_access_param(int *type, unsigned int *nb, long *ofs);
int dbget_flags(void);
int load_block_strdef(void);
/*---------------------------
    FUNCTIONS in dbput.c
*/
void DBPUT(int *type, char *data, unsigned int *nb, int *ierr);
int put_profile_data(int *type, char *data, unsigned int *user_nb, int *ierr);
int put_profile_aux(char *data, unsigned int nb, long ofs);
int put_position(DMSH_POSITION_TYPE *data);
int put_depth_range(DEPTH_RANGE_TYPE *data);
int put_struct_def(STRUCT_DEF_HDR_TYPE *new_sd, unsigned int *nb);
int write_profile_dir_entry(void);
/*---------------------------
    FUNCTIONS in dbdelete.c
*/
void DBDELBLK(int *ierr);
void DBDELPRF(int *ierr);
/*---------------------------
    FUNCTIONS in dbloadsd.c
*/
void DBLOADSD(char *filename, int *ierr);
int load_structure_definition(char *filename, STRUCT_DEF_HDR_TYPE **hdr,
                              USHORT *nentries, FORMAT_HDR_TYPE **format_list);
int define_format(FILE *fpin, FORMAT_HDR_TYPE **format_list, USHORT *nentries);
void concat_strdef(STRUCT_DEF_HDR_TYPE **head, STRUCT_DEF_HDR_TYPE *new);
/*---------------------------
    FUNCTIONS in dbprtstr.c
*/
void DBPRTSTR(char *data, char *name, unsigned int *n);
int match_formats(STRUCT_DEF_HDR_TYPE *strdef_list,
                  FORMAT_HDR_TYPE *format_list);
FORMAT_HDR_TYPE *find_format(char *struct_name, FORMAT_HDR_TYPE *format_list);
/*---------------------------
    FUNCTIONS in dbshow.c
*/
void SHDB(void);
void shbdh(void);
void shbde(void);
void shbh(void);
void shpde(void);
void shdl(void);
void shdd(void);
void shstrdef(void);
void shbd(void);
void shpd(void);
void shst(void);
void shdata(int iansw);
void set_max_screen_lines(int n);
/*---------------------------
    FUNCTIONS in dbprint.c
*/
/* 1999/07/30 Pierre Jaccard
      File dbprint does not exist, neither is function DBPRINT_N() used
      somewhere

      void DBPRINT_N(FILE *fp, char *name, char *format, int *ierr);
*/
/*---------------------------
    FUNCTIONS in dbget_n.c
*/
void DBGET_N(char *var_name, char *data, unsigned int *user_nb, int *ierr);
int get_data_list_index(char *var_name);
int get_name_access_param(char *name, int *type, unsigned int *nb, long *rel_ofs);
/*---------------------------
    FUNCTIONS in dberror.c
*/
int DBERROR(int *ierr, char *msg);
/*---------------------------
    FUNCTIONS in dbset.c
*/
void DBSET(int *db_id, int *ierr);
#else
/*---------------------------
    FUNCTIONS in dberror.c
*/
int DBERROR();
/*---------------------------
    FUNCTIONS in dbset.c
*/
void DBSET();
/*---------------------------
    FUNCTIONS in dbcommon.c
*/
void DBCLOSE();
void report_db_error();
int close_block_dir();
int close_block();
void release_database();
void release_block();
void update_block_dir();
void update_block();
void update_block_dir_entry();
int write_block_dir_hdr();
int write_block_dir();
int write_block_dir_entry();
int write_block_hdr();
int write_profile_dir();
void sort_block_dir();
void sort_profile_dir();
int load_block_dir();
int load_profile_dir();
int load_data_list();
int open_block_dir();
int open_block();
int allocate_memory_for_directories();
int alignment_check();
int identify_ms();
int identify_ms_code();
/*---------------------------
    FUNCTIONS in dbopsrch.c
*/
void DBOPEN();
void DBSRCH();
int lock_on_block();
int lock_on_profile();
int set_block_access();
int set_profile_access();
int load_block_dir_entry();
int load_profile_dir_entry();
int lock_on_blkprf_index();
int lock_on_time();
int search_for_block_by_time();
int search_for_profile_by_time();
/*---------------------------
    FUNCTIONS in dbmove.c
*/
void DBMOVE();
/*---------------------------
    FUNCTIONS in dbcreate.c
*/
void DBCREATE();
void DBNEWBLK();
void DBNEWPRF();
void DBADD   ();
void DBENDPRF();
void DBENDBLK();
int create_block_dir();
int create_block();
void create_block_dir_entry();
void create_profile_dir_entry();
int add_profile_aux();
int add_profile_data();
int dbadd_flags();
int set_position();
int set_depth_range();
void set_access_param();
int store_temp_data();
int flush_block_dir_file();
int write_data_list();
int write_block_strdef();
int add_block_dir_entry();
int load_producer_definition();
int define_data();
/*---------------------------
    FUNCTIONS in defstruc.c
*/
int define_struct();
FORMAT_SPEC *define_format_spec();
int find_print_function();
/*---------------------------
    FUNCTIONS in dbadd_f.c
*/
void DBADD_F();
int addf_profile_data();
/*---------------------------
    FUNCTIONS in dbput_f.c
*/
void DBPUT_F();
int putf_profile_data();
/*---------------------------
    FUNCTIONS in dbget.c
*/
void DBGET();
int get_profile_data();
int get_position();
int get_depth_range();
/*---------------------------
    FUNCTIONS in dbget_f.c
*/
void DBGET_F();
int getf_profile_data();
/*---------------------------
    FUNCTIONS in dbgetput.c
*/
void get_access_param();
int dbget_flags();
int load_block_strdef();
/*---------------------------
    FUNCTIONS in dbput.c
*/
void DBPUT();
int put_profile_data();
int put_profile_aux();
int put_position();
int put_depth_range();
int put_struct_def();
int write_profile_dir_entry();
/*---------------------------
    FUNCTIONS in dbdelete.c
*/
void DBDELBLK();
void DBDELPRF();
/*---------------------------
    FUNCTIONS in dbloadsd.c
*/
void DBLOADSD();
int load_structure_definition();
int define_format();
void concat_strdef();
/*---------------------------
    FUNCTIONS in dbprtstr.c
*/
void DBPRTSTR();
int match_formats();
FORMAT_HDR_TYPE *find_format();
/*---------------------------
    FUNCTIONS in dbprint.c
*/
/* 1999/07/30 Pierre Jaccard
      File dbprint does not exist, neither is function DBPRINT_N() used
      somewhere

      void DBPRINT_N();
*/
/*---------------------------
    FUNCTIONS in dbshow.c:
*/
void SHDB();
void shbdh();
void shbde();
void shbh();
void shpde();
void shdl();
void shdd();
void shstrdef();
void shbd();
void shpd();
void shst();
void shdata();
void set_max_screen_lines();
#endif  /* PROTOTYPE_ALLOWED */
#include "mem_.h"
#include "unscale.h"
#include "time_.h"
#include "sort.h"
#include "scale.h"
#include "prtstruc.h"
#include "prtarray.h"
#include "prtspecl.h"
#include "posn.h"
#include "misc.h"
#include "io_nc.h"
#include "io_.h"
#include "find_def.h"

/* 1999/07/30 Pierre Jaccard
      Moving include directive for mc0 into the if block
*/
#include "mc0.h"

#endif  /* ifndef dbdcl_included */


