#ifndef PROTOTYPE_ALLOWED
#include "dbhost.h" /* PROTOTYPE_ALLOWED */
#endif

#ifdef FIRST_DEC
#define CLASS
#undef FIRST_DEC
#else
#define CLASS extern
#endif

#ifndef dbext_included
#include "dbext.h"  /* YMDHMS_TIME_TYPE, UBYTE, SHORT */
#endif

#ifndef adcp_included
#include "adcp.h"   /* CONFIGURATION_1_TYPE, ANCILLARY_1_TYPE, ... */
#endif

CLASS YMDHMS_TIME_TYPE      h_time, prof_time;
CLASS CONFIGURATION_1_TYPE  conf1;
CLASS ANCILLARY_1_TYPE      ancil1;
CLASS ANCILLARY_2_TYPE      ancil2;
CLASS BOTTOM_TRACK_TYPE     bottom_track;
CLASS NAVIGATION_TYPE       navigation;

CLASS UBYTE  record_nbyte[128];
CLASS FILE_NAME_TYPE bname, logname;
CLASS FILE   *fpb, *fplog;

CLASS SHORT  u[128], v[128], w[128], e[128],
             u_std_dev[128], v_std_dev[128], w_std_dev[128],
             ev_std_dev[128], raw_doppler[512], ub_value_type;

CLASS UBYTE  amp[128], pg[128], *user_buffer_block,
             ave_spw_width[128], raw_amplitude[512],
             raw_spectral_width[512],
             percent_3_beam[128], beam_stats[4], profile_flags[128];

CLASS STRUCT_DEF_HDR_TYPE *ub_strdef;

CLASS USHORT note_length, user_buffer_count, old_buf_count;
CLASS LONG   CTDstrip[16];

CLASS int    log_file_flag, file_status,
             nprof_in_hdr, byte_count, nrec_in_data,
             rec_error, bad_data_flag, start_blk, nblk_in_prf,
             bottom_flag;

/* ----------------------- flags ---------------------------- */

CLASS int    hdr_flag, data_flag, file_note_flag,
             bottom_track_para_flag, user_buffer_flag,
             CTD_data_flag, spw_data_flag, ABER_para_flag,
             record_RPHT_stat_flag, velocity_flag,
             amplitude_flag, perc_good_flag, bottom_track_flag,
             raw_doppler_flag, raw_amplitude_flag, raw_spw_data_flag,
             three_beam_flag, beam_stats_flag, standard_dev_flag;

/* ------------ variables in header data block -------------- */

CLASS USHORT IBM_software_version, ADCP_software_version,
             disk_transducer_serial_No,
             disk_config1,disk_config2,disk_sys_serial;
             CLASS UBYTE  disk_up_down, disk_cave_vex,block_length,
             false_target, sig_to_noise, hundredths;
CLASS char   cruise_id [60], *file_notes;
CLASS UBYTE  zero_velocity, serial_parallel,
             record_return_header_block, record_return_data_block,
             transformed_data, n_bin_RSD,
             record_velx, record_vely, record_velz, record_error,
             roll_compensate, pitch_compensate, heading_compensate;
CLASS double roll_range, pitch_range, reject_error_set,
             temp_scale,temp_offset,
             salinity, Xducer_angles;
CLASS double sum_roll_squar, sum_pitch_squar,
             sum_heading_squar, sum_temp_squar;

CLASS USHORT nhdr_block, hdr_rec_num, ensemble_num,
             spare, num_samp_for_ave;

CLASS UBYTE  gyro_ok;

/* ----------------------- functions ------------------------ */

#if PROTOTYPE_ALLOWED
void   initial(void);
void   turn_off_flag(void);
USHORT get_uint(void);
UBYTE  get_ubyte(void);
double get_double(void);
void   get_cruise_id(void);
void   get_file_notes(void);
int    get_data_block(void);
void   read_record_prefix(void);
void   read_RPHT_stat(void);
void   read_velocity(void);
void   read_amplitude(void);
void   read_perc_good(void);
void   read_bottom_data(void);
void   read_user_buffer(void);
void   read_CTD_data(void);
void   read_ave_spw_data(void);
void   read_raw_doppler_data(void);
void   read_raw_amplitude_data(void);
void   read_raw_spw_data(void);
void   read_percent_3_beam_sol(void);
void   read_beam_statistic(void);
void   read_standard_dev(void);
int    collect_flag(void);
int    read_record(FILE *fp);
int    zero_double(UBYTE *b);
int    bad_double(UBYTE *b);
int    header_check(void);
int    get_hdr_block(void);
LONG   get_reverse_long(void);

#else
void   initial();
void   turn_off_flag();
USHORT get_uint();
UBYTE  get_ubyte();
double get_double();
void   get_cruise_id();
void   get_file_notes();
int    get_data_block();
void   read_record_prefix();
void   read_RPHT_stat();
void   read_velocity();
void   read_amplitude();
void   read_perc_good();
void   read_bottom_data();
void   read_user_buffer();
void   read_CTD_data();
void   read_ave_spw_data();
void   read_raw_doppler_data();
void   read_raw_amplitude_data();
void   read_raw_spw_data();
void   read_percent_3_beam_sol();
void   read_beam_statistic();
void   read_standard_dev();
int    collect_flag();
int    read_record();
int    zero_double();
int    bad_double();
int    header_check();
int    get_hdr_block();
LONG   get_reverse_long();

#endif
