/*
 *
 * DIRMES.SYS
 * ----------
 *
 * This binary file holds the informations on all active messages. This file is
 * very important and must not be edited or changed otherwise the list of the
 * messages could be lost. This file can only be opened for reading.
 *
 * It is organized with records, each record containing information on a
 * message. The first record of the file only contains the number of the last
 * message. Never modify this file while the BBS is running.
 *
 * A null type of message (00 hex) invalidates the record.
 *
 * Dates are given as the number of seconds since january 1st, 1970 00:00.
 *
 * Masks are bit fields, number of bit corresponds to the number of the BBS in
 * the BBS.SYS file.
 *
 */

#define NBBBS 80
#define NBMASK NBBBS/8

#pragma pack(1)

typedef struct {
	char type;					/* 1   Type of message (A,B,P,T)       */
	char status;				/* 1   Status of message ($,A,F,K,N,Y) */
	long numero;				/* 4   Number of the message           */
	long taille;				/* 4   Size of message in characters   */
	long date;					/* 4   Date of message                 */
	char bbsf[7];				/* 7   Adjacent BBS giving the message */
	char bbsv[41];				/* 41  Route                           */
	char exped[7];				/* 7   Destination of the message      */
	char desti[7];				/* 7   To field                        */
	char bid[13];				/* 13  BID or MID                      */
	char titre[61];				/* 61  Title of message                */
	char free[16];				/* 16  Reserved bytes                  */
	long datesd;				/* 4   Date of the message creation    */
	long datech;				/* 4   Date of last status change      */
	char fbbs[NBMASK];			/* 10  Mask of BBSes to forward to     */
	char forw[NBMASK];			/* 10  Mask of BBSes already forwarded */
} bullist;						/* 194 bytes = length of one record    */

/*
 * STATIS.DAT
 * ----------
 *
 * This binary file holds the informations on all connections. This file is
 * very important and must not be edited or changed otherwise the list of the
 * connections could be lost. This file can only be opened for reading.
 *
 * It is organized with records, each record containing information on a
 * connection. Never modify this file while the BBS is running.
 *
 * Date is given as the number of seconds since january 1st, 1970 00:00.
 *
 */

typedef struct {
	char indcnx[7];				/* 7   Callsign                        */
	char port;					/* 1   (Port x 32) + channel           */
	long datcnx;				/* 4   Date of the connection          */
	short tpscnx;					/* 2   duration of the connection      */
} statis;						/* 14  bytes = length of one record    */

/*
 * WFBID.SYS
 * ---------
 *
 * This binary file holds the last received BIDs. The number of records of this
 * file is defined in the INIT.SRV file. This file is very important and must
 * not be edited or changed otherwise the list of the messages could be lost.
 * This file can only be opened for reading.
 *
 * It is organized with records, each record containing information on a BID.
 * This is a circular file and the first record of the file contains the pointer
 * of the last overwritten record in the msg_number field. Never modify this
 * file while the BBS is running.
 *
 */

typedef struct {
	char mode;					/* 1   Type of message (A,B,P,T)       */
	char fbid[13];				/* 13  BID of the message              */
	long msg_number;			/* 4   Number of the message           */
} bidfwd;						/* 18  bytes = length of one record    */

/*
 * INF.SYS
 * -------
 *
 * This binary file holds the informations on all users of the BBS. This file
 * is very important and must not be edited or changed otherwise the list of the
 * users could be lost. This file can only be opened for reading.
 *
 * It is organized with records, each record containing information on a user.
 * Never modify this file while the BBS is running.
 *
 */

#define uchar unsigned char

typedef struct {				/* Callsign structure used in info  */
	char callsign[7];
	char ssid;
} indicat;

typedef struct {
	indicat indic;				/* 8   Callsign                     */
	indicat relai[8];			/* 64  Digis path                   */
	long lastmes;				/* 4   Last L number                */
	long nbcon;					/* 4   Number of connexions         */
	long hcon;					/* 4   Last connexion date          */
	long lastyap;				/* 4   Last YN date                 */
	unsigned short flags;		/* 2   Flags                        */
	unsigned short on_base;		/* 2   ON Base number               */
	uchar nbl;					/* 1   Lines paging                 */
	uchar lang;					/* 1   Language                     */
	char free[27];				/* 27  Reserved                     */
	char nom[18];				/* 18  1st Name                     */
	char prenom[13];			/* 13  Christian name               */
	char adres[61];				/* 61  Address                      */
	char ville[31];				/* 31  City                         */
	char teld[13];				/* 13  home phone                   */
	char telp[13];				/* 13  job phone                    */
	char home[41];				/* 41  home BBS                     */
	char qra[7];				/* 7   Qth Locator                  */
	char priv[13];				/* 13  PRIV directory               */
	char filtre[7];				/* 7   LC choice filter             */
	char pass[13];				/* 13  Password                     */
	char zip[9];				/* 9   Zipcode                      */
} info;							/* 360 bytes = lenght of one record */

/*
 * YAPLBL.SYS
 * ----------
 *
 * This binary file holds the descriptions of the FbbDos files.
 *
 * It is organized with records, each record containing the filename in upcase
 * characters (with the full path including disk name) and the description of
 * this file.
 *
 * Date is given as the number of seconds since january 1st, 1970 00:00.
 *
 */

#if defined (__MSDOS__)
typedef struct {
	char filename[80];			/* Complete path of the filename */
	char label[40];				/* Description of the file       */
	long creation;				/* Date of creation of the file  */
	long unused;				/* Not used should be 0          */
} YapLbl;
#elif defined (__linux__)
typedef struct {
	char filename[80];			/* Complete path of the filename */
	char label[40];				/* Description of the file       */
	char owner[7];				/* Owner of the file             */
	char unknown;
	long unknown2;
	long creation;				/* Date of creation of the file  */
	char unknown3[24];
} YapLbl;
#endif

/*
 * SATEL.DAT
 * ---------
 *
 * This binary file holds the informations on the satellite data base of the
 * BBS. This file is very important and must not be edited or changed otherwise
 * the list of the satellites could be lost. This file can only be opened for
 * reading.
 *
 * It is organized with records, each record containing information on a
 * satellite. Never modify this file while the BBS is running.
 *
 */

typedef struct {
	char sat_name[18];			/* 18  Name of the satellite           */
	short year;					/* 2   Year of reference               */
	double day;					/* 8   Day of reference                */
	short month;				/* 2   Month of reference              */
	short hour;					/* 2   Hour of reference               */
	short minute;				/* 2   Minute of reference             */
	short second;				/* 2   Second of reference             */
	double inclination;			/* 8   Inclination                     */
	double raan;				/* 8   R.A.A.N.                        */
	double excentricity;		/* 8   Excentricity                    */
	double a_perigee;			/* 8   Argument of perigee             */
	double mean_anomaly;		/* 8   Mean anomaly                    */
	double a;					/* 8   must be 0.0                     */
	double mean_motion;			/* 8   mean motion                     */
	double dec_rate;			/* 8   Decay rate                      */
	long revolution;			/* 4   Epoch revolution                */
	double frequency;			/* 8   Frequency for doppler computing */
	double v;					/* 8   must be 0.0                     */
	short step;					/* 2   Step of processing (minutes)    */
	long last_upd;				/* 4   Date of last update             */
	long catalog;				/* 4   NASA Catalog Number             */
	short free[4];				/* 8   Unused                          */
} satel;						/* 138 bytes : lenght of one record    */

/*
 * WP.SYS
 * ------
 * The WP.SYS file is composed of records. Each record is 194 bytes long.
 *
 * This file should NOT be modified while the BBS software is running !
 *
 */

typedef struct {
	char callsign[7];			/* Callsign of the record              */
	char name[13];				/* Name of the user                    */
	char free;					/* Unused                              */
	char changed;				/* Flag(U, G, I) of modification       */
	unsigned seen;				/* Number of updates                   */
	long activ_date;			/* Date of active part                 */
	long temp_date;				/* Date of temp part                   */
	char activ_homebbs[41];		/* Home BBS in active part             */
	char temp_homebbs[41];		/* Home BBS in temp part               */
	char activ_zip[9];			/* Zip code in active part             */
	char temp_zip[9];			/* Zip code in temp part               */
	char activ_qth[31];			/* Qth in active part                  */
	char temp_qth[31];			/* Qth in temp part                    */
} Wps;

#pragma pack()

