/*************************************************************************
NIXMAIL Main Header File
--------------------------------------------------------------------------
General info and Copyrights
--------------------------------------------------------------------------
RCS Info

$Header: /home/smilie/emsi/RCS/nixmail.h,v 1.7 1992/12/06 09:40:04 smilie Exp $

$Log: nixmail.h,v $
 * Revision 1.7  1992/12/06  09:40:04  smilie
 * fixed up some things
 *
 * Revision 1.6  1992/10/18  11:34:17  smilie
 * added CONFIG.locaddress
 *
 * Revision 1.5  1992/10/18  07:59:41  smilie
 * *** empty log message ***
 *
 * Revision 1.1  1992/06/14  16:18:08  smilie
 * Initial revision
 *

$Id: nixmail.h,v 1.7 1992/12/06 09:40:04 smilie Exp $

*************************************************************************/
#ifndef _NIXMAIL_H
#define _NIXMAIL_H

#define NIXMAIL_VERSION "0.05a"

#define NIX_FILE_AREA	"/usr/spool/fnet"
#define NIX_CONFIG_AREA	"/usr/lib/nixmail"

#ifndef word
#define word unsigned short
#endif

typedef struct
	{
	word zone;
	word net;
	word node;
	word point;
	} address_str;

typedef struct
	{
	char dialpre[255];	/* Dialing Prefix */
	char dialsuf[255];	/* Dialing Suffix */
	char modeminit[255];	/* Modem initialisation string */
	int logging;		/* Logging flag */
	char logfile[255];	/* Logfile */
	char port[255];		/* Modem Port */
	FILE *modemfhin;	/* port IN stream */
	FILE *modemfhout;	/* port OUT stream */
	char number[255];	/* (remote) Number to Dial */
	address_str address;	/* (remote) System Address */
	char password[255];	/* Link Password */
	address_str locaddress;	/* (local) Local Address */
	char name[255];		/* (local) System Name */
	char location[255];	/* (local) location */
	char sysop[128];	/* (local) Sysop Name */
	char phone[128];	/* (local) phone number */
	int speed;		/* Modem Dialing Speed */
	int locked;		/* If the modem is locked at speed */
	int poll;		/* Dial out even if no outbound mail waiting */
	int maxdial;		/* Maximum number of Dialing Retrys */
	} nixmail_config;
	
extern nixmail_config CONFIG;

typedef struct
	{
	char node[255];			/* (remote) Node/s */
	char pass[255];			/* (remote) Password */
	char link_codes[100];		/* (remote) Link Codes */
	char capability_codes[100];	/* (remote) compatability codes */
	char mailer_prod_code[100];	/* (remote) Mailer Product Codes */
	char mailer_name[128];		/* (remote) Mailer Name */
	char mailer_version[20];	/* (remote) Mailer Version */
	char mailer_serial[255];	/* (remote) Mailer Serial Number */
	char prod_id[50];		/* (remote) Product ID */
	char prod_data[1024];		/* (remote) Product Data */
	} system_dat;

extern system_dat SYSTEM;

typedef struct
	{
	char system_name[256];		/* (remote) System Name */
	char city[256];			/* (remote) City */
	char operator_name[256];	/* (remote) Operator Name */
	char phone_number[256];		/* (remote) Phone Number */
	char baud_rate[256];		/* (remote) Baud Rate */
	char flags[256];		/* (remote) Flags */
	} bbs_dat; 

extern bbs_dat BBS_DAT;

typedef struct
	{
	unsigned char token;
	char *string;
	} outbound_struct;

#define MAX_OBD		20
extern outbound_struct OBD[MAX_OBD];

/* Outbound Tokens */
#define OBD_NULL	0
#define OBD_SEND	1
#define OBD_MOVE	2
#define OBD_REQ		3
	
/* Return Error Codes */
#define RET_ERR	0
#define RET_OK	1

/* make_address codes */
#define ADR_FILE	0
#define ADR_NORM	1

/* Modem Return codes */
#define MDM_UNKNOWN	0
#define MDM_NOCARRIER	1
#define MDM_NOANSWER	2
#define MDM_BUSY	3
#define MDM_VOICE	4
#define MDM_NODIALTONE	5
#define MDM_CONNECT	6
#define	MDM_COMMAND	7
#define	MDM_RINGING	8

/* Error Level Return Codes */
#define ERRET_OK	0
#define ERRET_FATAL	1
#define ERRET_NOMAIL	2
#define ERRET_BUSY	3
#define ERRET_NOANSWER	4
#define ERRET_RECV	5
#define ERRET_LOCKED	6

/* Macros for File Streams */
#define MFHI CONFIG.modemfhin
#define MFHO CONFIG.modemfhout

/* EMSI Return Strings */
#define EMSI_NUL	0	
#define EMSI_BADCRC	1
#define EMSI_REQ	2
#define EMSI_INQ	3
#define EMSI_CLI	4
#define EMSI_HBT	5
#define EMSI_DAT	6
#define EMSI_ACK	7
#define EMSI_NAK	8

/* The timeout in seconds for the Wake_up function*/
#define WAKE_UP_TIMEOUT	40

/* External defines */

/* strupr.c */
extern char *strupr(char *);

/* fgetstr.c */
extern char *fgetstr(char *, int, FILE *);

/* global.c */
extern char *make_address(address_str *, int);	/* Makes a Fido Address */
extern void flog(char *, ...);			/* General Logging */
extern int load_config(void);			/* Load Config files */
extern int load_outbound(void);			/* Load Outbound list */

/* modem.c */
extern int dial_system(void);
extern int open_modem(void);
extern void disconnect(void);

/* emsi.c */
extern int connect_emsi(void);

extern int fgetsraw(char *, int, FILE *, int);

#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif

#endif

