/************************************************************************
*    Comm -- The Communicator for the AMIGA
*
*  A terminal program with ascii send and capture.
*  XMODEM send and receive using checksum and CRC capability
*  Windowed XMODEM receive ability
*
************************************************************************/

/*  compiler directives to fetch the necessary header files */

#include <libraries/dosextens.h>

#if   (COMM | MENUS | UTIL | CLOCK)
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include <exec/exec.h>
#include <graphics/gfxbase.h>
#include <graphics/regions.h>
#include <graphics/copper.h>
#include <graphics/gels.h>
#include <devices/keymap.h>
#include <hardware/blit.h>
#endif

#if   (COMM | TIMER | PHONE | SERIALIO | CLOCK)
#include <exec/devices.h>
#include <exec/memory.h>
#include <devices/timer.h>
#endif

#if   (SERIALIO | UTIL)
#include <intuition/intuition.h>
#include <devices/serial.h>
#endif

#include <stdio.h>
#include <ctype.h>
#include "defines.h"

extern struct setup {
   UBYTE  version[41];
   UBYTE  date[12];
   UBYTE  def_dir[41];
   UBYTE  DefDir[41];
   USHORT new_colors[4];
   UBYTE  cap_name[41];
   ULONG  priority;
   UBYTE  prefbaud;
   ULONG  titlebar;
   ULONG  interlace;
   int    numbuffs;
   int    period;
   int    volume;
   int    cycles;
   int    length;
   int    keyload;
} install;



#if   (COMM | PHONE | MENUS)
/*
   defines required for phone library
     library entry looks like this:
name              number           baud    comment
plink             652-0800         1200    accessed through tymnet
>                 555-1212,,,12345         MCI gateway and account number

*/

extern struct dir_entry {               /* phone directory entry */
                    char name[ NAMESIZE+1 ];
                    char number[ NBRSIZE+1 ];
                    char baud[ BAUDSIZE+1 ];
                    char comment[ COMTSIZE+1 ];
                 } pdir[ MAXPHONE ] ;

extern UBYTE version[], date[];
extern UBYTE alt_serv[ NBRSIZE+1 ];/* alternate long distance service # */
extern UBYTE phl_empty[];
extern UBYTE phonedir[];
extern int   altservflg;
#endif

extern UBYTE sbuff[],           /* sprintf work buffer */
             buffer[],          /* ASCII capture buffer */
             xbuffer[],         /* XMODEM buffer */
             def_dir[],         /* default directory for file xfers */
             *diskbuff;         /* XMODEM receive buffer */
extern int   numbufs;           /* number of sectors allocated */
extern unsigned
    fd,                  /* XMODEM file being sent/received */
    prt,                 /* printer device */
    sector,              /* sector being sent/received */
    baud,                /* current baud rate */
    cancel,              /* TRUE if CAN received and abort_flag is TRUE */
    abort,               /* TRUE if user aborts XMODEM xfer with ESC */
    timeout,             /* TRUE if timeout during character receive */
    chopflg,             /* TRUE if we CHOP files */
    xonflg,              /* TRUE if driver does XON/XOFF */
    echoflg;             /* TRUE to echo chars to sender */

extern USHORT printon;   /* TRUE if printer is ON */
extern USHORT capton;    /* TRUE if capture buffer is open */
extern USHORT crcflag;   /* TRUE if crc mode, FALSE for checksum */
                         /* can be changed in send mode by remote receiver */
extern USHORT xfrmode;   /* same as crcflag, except only under user control */
extern USHORT crc;       /* 16 bit crc value */
extern UBYTE  checksum;
extern int viewflg;      /* TRUE if XMODEM transfers are viewed on screen */
extern int close_window; /* TRUE if we have to close the split window */
extern int debug;        /* general debug flag */
extern int asciiflg;     /* TRUE to add CR/LF pairs to XMODEM send */
extern short dcd;          /* state of modem Carrier Detect */
extern short wxflag;
extern short halfduplex;
extern short dos_version;

extern UBYTE *keymacro[];
extern UBYTE commkeys[];
extern UBYTE *capt_status;

extern int    split_screen;         /* TRUE if 2 screens, FALSE if 1 */
#if   (COMM | MENUS | UTIL | SERIALIO)
extern struct Window       *tx_window;
#endif

#if   (COMM | MENUS | UTIL | CLOCK)
/*   Intuition always wants to see these declarations */
extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;

extern struct Screen       *commscreen;
extern struct NewScreen    CommScreen;
extern struct Window       *rx_window;     /* ptr to applications window */
extern struct Window       *req_window;
extern struct Window       *vw_window;
extern struct Window       *stat_window;
extern struct Window       *st_window;

extern struct Gadget  rx_window_close, rx_window_front, rx_window_back;
extern struct Gadget  tx_window_close, tx_window_front, tx_window_back;

extern struct IntuiMessage *NewMessage;    /* msg structure for GetMsg() */

/* my window structure */
extern struct NewWindow TXWindow, RXWindow, VWindow, STWindow, RQWindow;
#endif

#if   (COMM | SERIALIO | UTIL | GFILE)
/* declarations for the serial stuff */
extern struct IOExtSer *Read_Request, *Write_Request, *Echo_Request;

extern UBYTE  rs_in[];
extern UBYTE  rs_out[];
extern UBYTE  rs_echo[];

/* declarations for console device */

extern struct MsgPort  *CreatePort();
extern struct IOStdReq *CreateStdIO();

extern struct IOStdReq *tx_con,    *rx_con,    *st_con,    *vw_con;
extern struct MsgPort  *tx_con_mp, *rx_con_mp, *st_con_mp, *vw_con_mp;

#endif

#if   (COMM | PHONE | SERIALIO | TIMER)
/* Timer device allocation */
extern struct timerequest TimerIO;
extern struct MsgPort     TimerMsgPort;
#endif


#if (COMM | UTIL)
extern struct IntuiText  Reqtext, Entertxt, oktext;
extern struct StringInfo string, Dirstr;
extern struct Gadget     Strgadget, OKgadget, Dirgadget, Cancelgadget;
extern struct Requester  Req;
extern struct MenuItem   PhoneItem[MAXPHONE+2];
extern struct IntuiText  PhoneText[MAXPHONE+2];

extern struct MenuItem  FileItems[], SysItems[], ModeItems[], SerialIems[],
                        PhoneItems[], DebugItems[], PlibItems[];
extern struct IntuiText FileText[], SysText[], ModeText[], SerialText[],
                        PhoneText[], DebugText[], EolText[], BaudText[],
                        ParityText[], LengthText[], StopText[],
                        DuplexText[], AltFileText[];

extern struct Menu menu[];

extern struct Image knob;
extern struct PropInfo propinfo;
extern struct Gadget  delay_prop;
extern struct Process *this_process;

extern struct NewWindow STwindow;
#endif


