// CNT3.H - FiveNine-Datenformat ab FiveNine v2.00
// Written by Stefan Pfeiffer, DL1ELY, 960527
// Last modification: 960528
// (C) 1995 by Stefan Pfeiffer, DL1ELY@DB0PKE

#ifndef CNT3_H

#define CNT3_H


typedef unsigned char BYTE;
typedef unsigned int  WORD;
typedef unsigned long ULONG;


#define BAND_50MHZ     0x00000001L
#define BAND_70MHZ     0x00000002L
#define BAND_144MHZ    0x00000004L
#define BAND_432MHZ    0x00000008L
#define BAND_1_3GHZ    0x00000010L
#define BAND_2_3GHZ    0x00000020L
#define BAND_3_4GHZ    0x00000040L
#define BAND_5_7GHZ    0x00000080L
#define BAND_10GHZ     0x00000100L
#define BAND_24GHZ     0x00000200L
#define BAND_47GHZ     0x00000400L
#define BAND_76GHZ     0x00000800L
#define BAND_120GHZ    0x00001000L
#define BAND_144GHZ    0x00002000L
#define BAND_248GHZ    0x00004000L


#define CNT_IARU       0x0001
#define CNT_NORDIC     0x0002
#define CNT_AGCW       0x0003
#define CNT_BBT        0x0004
#define CNT_AUB        0x0005
#define CNT_HOLZHAMMER 0x0006
#define CNT_DIG        0x0007
#define CNT_EDR_QUART  0x0008
#define CNT_PA0_REGIO  0x0009


struct square_record
{
   BYTE  name[5];
   WORD  qsos;
   ULONG points;

   struct square_record *next;
   struct square_record *prev;
};


struct multi_record
{
   BYTE  multi[7];
   WORD  qsos;
   ULONG points;
   
   struct multi_record *next;
   struct multi_record *prev;
};


struct dxcc_record
{
   BYTE  name_dl[40];
   BYTE  name_g[40];
   BYTE  pref[10];
   WORD  qsos;
   ULONG points;

   struct dxcc_record *next;
   struct dxcc_record *prev;
};

struct dxcc_list
{
   BYTE   name_dl[40];
   BYTE   name_g[40];
   BYTE   pref[10];
   BYTE   *all_pref;
   BYTE   *locators;
   BYTE   capital[40];
   double east;
   double north;

   struct dxcc_list *next;
   struct dxcc_list *prev;
};


#define CNT3_HEADER_SIZE  1536

struct cnt3_header
{
   BYTE  cnt3_mark[6];
   BYTE  annotation[128];
   BYTE  eof_mark;
   ULONG header_crc;
   WORD  header_len;
   BYTE  contest_title[40];
   WORD  contest_type;
   BYTE  start_day;
   BYTE  start_month;
   WORD  start_year;
   BYTE  start_hour;
   BYTE  start_minute;
   BYTE  end_day;
   BYTE  end_month;
   WORD  end_year;
   BYTE  end_hour;
   BYTE  end_minute;
   BYTE  own_call[14];
   BYTE  own_locator[7];
   BYTE  own_multi[7];
   BYTE  qth_address1[40];
   BYTE  qth_address2[40];
   ULONG bands;
   BYTE  club_participation[20];
   BYTE  responsible_name[40];
   BYTE  responsible_call[10];
   BYTE  responsible_address1[40];
   BYTE  responsible_address2[40];
   BYTE  responsible_qth_zip[10];
   BYTE  responsible_qth[40];
   BYTE  responsible_country[40];
   BYTE  responsible_phone[40];
   BYTE  responsible_email[40];
   BYTE  remarks[924];
   WORD  all_qso_count;
   ULONG qso_crc;
};


#define BAND_SIZE_FILE  313
#define BAND_SIZE       sizeof(struct band_header)

struct band_header
{ 
   ULONG band_code;
   BYTE  section[10];
   BYTE  tx_equipment[80];
   BYTE  tx_power[10];
   BYTE  rx_equipment[80];
   BYTE  antenna[80];
   WORD  ant_over_ground;
   WORD  ant_over_sea;
   WORD  all_qsos;
   WORD  valid_qsos;
   BYTE  band_multi;
   ULONG qso_points;
   WORD  squares;
   WORD  square_bonus;
   WORD  square_multi;
   ULONG square_points;
   WORD  multis;
   WORD  multi_bonus;
   WORD  multi_multi;
   ULONG multi_points;
   WORD  dxccs;
   WORD  dxcc_bonus;
   WORD  dxcc_multi;
   ULONG dxcc_points;
   ULONG claimed_score;
   WORD  odx_handle;
   BYTE  operators;

   //------------------//

   struct operator_header *first_op;
   struct operator_header *last_op;

   struct square_record *first_square;
   struct square_record *last_square;

   struct multi_record *first_multi;
   struct multi_record *last_multi;

   struct dxcc_record *first_dxcc;
   struct dxcc_record *last_dxcc;
};


#define OPERATOR_SIZE_FILE  34
#define OPERATOR_SIZE       sizeof(struct operator_header)

struct operator_header
{
   BYTE  handle[10];
   WORD  odx_handle;
   WORD  all_qsos;
   WORD  valid_qsos;
   WORD  squares_op;
   WORD  squares_station;
   WORD  multis_op;
   WORD  multis_station;
   BYTE  dxccs_op;
   BYTE  dxccs_station;
   ULONG claimed_score_op;
   ULONG claimed_score_station;

   //-----------------------//

   struct operator_header *next;
   struct operator_header *prev;

   struct square_record *first_square;
   struct square_record *last_square;

   struct multi_record *first_multi;
   struct multi_record *last_multi;

   struct dxcc_record *first_dxcc;
   struct dxcc_record *last_dxcc;
};


#define QSO_SIZE_FILE  60
#define QSO_SIZE       sizeof(struct qso_record)

#define QSO_INVALID    0x01
#define QSO_DUPE       0x02
#define QSO_SELECTED   0x80
#define QSO_ODX        0x04
#define QSO_NEWMULTI   0x08
#define QSO_NEWDXCC    0x10

struct qso_record
{
   WORD  handle;
   BYTE  day;
   BYTE  month;
   WORD  year;
   BYTE  hour;
   BYTE  minute;
   BYTE  call[14];
   BYTE  mode;
   BYTE  tx_report[4];
   WORD  tx_number;
   BYTE  rx_report[4];
   WORD  rx_number;
   BYTE  multi[7];
   BYTE  locator[7];
   WORD  points;
   WORD  multi_points
   ULONG band;
   BYTE  flags;


   //--------------------//

   struct qso_record *next;   // N„chstes QSO
   struct qso_record *prev;
};


#endif

