/*
**	$Id: termdata.c,v 1.10 92/05/08 20:50:30 olsen Sta Locker: olsen $
**	$Revision: 1.10 $
**	$Date: 92/05/08 20:50:30 $
**
**	Global data structures
**
**	Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
**		All Rights Reserved
*/

#include "termGlobal.h"

	/* Libraries. */

struct ExecBase		*SysBase;
struct DosLibrary	*DOSBase;

struct IntuitionBase	*IntuitionBase;
struct GfxBase		*GfxBase;
struct Library		*GadToolsBase;
struct Library		*DiskfontBase;
struct Library		*UtilityBase;
struct Device		*TimerBase;
struct Library		*AslBase;
struct RxsLib		*RexxSysBase;
struct Library		*IFFParseBase;
struct Library		*CxBase;
struct Library		*LayersBase;
struct Library		*IconBase;
struct Library		*WorkbenchBase;
struct Library		*XEmulatorBase;
struct Library		*OwnDevUnitBase;

	/* Timer device. */

struct timerequest	*TimeRequest;
struct MsgPort		*TimePort;

	/* Console device. */

struct IOStdReq		*ConsoleRequest;
struct Device		*ConsoleDevice;
struct KeyMap		*KeyMap;
BPTR			 KeySegment;

	/* Screen & Windows. */

struct Screen		*Screen;
struct Window		*Window;
struct Window		*StatusWindow;
UWORD			 StatusOffset;
APTR			 OldWindowPtr;
struct BitMap		*InterleavedBitMap;
struct Requester	*RequesterList;

	/* Graphics rendering. */

struct ViewPort		*VPort;
struct RastPort		*RPort;
struct TextFont		*Topaz,
			*IBM,
			*GFX,
			*CurrentFont;
APTR			 VisualInfo;

UWORD ANSIPens[NUMDRIPENS + 1] =
{
	0,4,7,7,4,6,7,0,6,~0
};

UWORD EGAPens[NUMDRIPENS + 1] =
{
	0,8,15,15,8,7,15,0,7,~0
};

UWORD AtomicColours[16] =
{
	0x000,
	0xDDD,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000,
	0x000
};

UWORD EGAColours[16] =
{
	0x000,	/* Black. */
	0xA00,	/* Dark red. */
	0x0A0,	/* Dark green. */
	0xA60,	/* Dark yellow (orange). */
	0x00A,	/* Dark blue. */
	0xA0A,	/* Dark magenta.*/
	0x0AA,	/* Dark cyan. */
	0xBBB,	/* Light grey. */
	0x666,	/* Dark grey. */
	0xF00,	/* Red. */
	0x0F0,	/* Green. */
	0xFF0,	/* Yellow. */
	0x00F,	/* Blue. */
	0xF0F,	/* Magenta. */
	0x0FF,	/* Cyan. */
	0xFFF	/* White. */
};

UWORD ANSIColours[16] =
{
	0x000,	/* Black. */
	0xF00,	/* Red. */
	0x0F0,	/* Green. */
	0xFF0,	/* Yellow. */
	0x00F,	/* Blue. */
	0xF0F,	/* Magenta. */
	0x0FF,	/* Cyan. */
	0xFFF,	/* White. */

	0x000,	/* Black. */
	0xF00,	/* Red. */
	0x0F0,	/* Green. */
	0xFF0,	/* Yellow. */
	0x00F,	/* Blue. */
	0xF0F,	/* Magenta. */
	0x0FF,	/* Cyan. */
	0xFFF	/* White. */
};

UWORD			 DefaultColours[16],BlinkColours[16],StandardColours[16];

	/* DOS data. */

struct Process		*ThisProcess;
struct Process		*StatusProcess;
struct Process		*BufferProcess;
struct Process		*RexxProcess;
struct MsgPort		*TermRexxPort;
struct WBStartup	*WBenchMsg;
struct TermPort		*TermPort;

	/* Character conversion. */

struct InputEvent	*FakeInputEvent;

	/* Serial I/O. */

struct IOExtSer		*ReadRequest;
struct IOExtSer		*WriteRequest;
struct MsgPort		*ReadPort;
APTR			 ReadBuffer,
			 HostReadBuffer;
UBYTE			*SerialMessage;

	/* Hotkeys. */

struct Hotkeys		 Hotkeys;

struct NewBroker NewTermBroker =
{
	NB_VERSION,
	"term",
	"term © 1990-92 by MXM",
	"Terminal program",
	0,0,0,NULL,0
};

	/* Static default fonts. */

struct TextAttr DefaultFont =
{
	(UBYTE *)"topaz.font",
	8,
	FS_NORMAL,
	FPF_ROMFONT | FPF_DESIGNED
};

struct TextAttr IBMFont =
{
	(UBYTE *)"IBM.font",
	8,
	FS_NORMAL,
	FPF_DISKFONT | FPF_DESIGNED
};

struct TextAttr GFXFont =
{
	(UBYTE *)"GFX.font",
	8,
	FS_NORMAL,
	FPF_DISKFONT | FPF_DESIGNED
};

	/* Audio data. */

UBYTE AnyChannel[4] =
{
	LEFT0F,
	LEFT1F,
	RIGHT0F,
	RIGHT1F,
};

UBYTE __chip SineWave[8] =
{
	90,
	127,
	90,
	0,
	-90,
	-127,
	-90,
	0
};

struct IOAudio	*AudioBlock;

	/* Character lookup tables. */

BYTE ValidTab[256] =
{
	0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,
	0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
};

	/* IBM <-> Amiga/DEC font conversion. */

UBYTE IBMConversion[256] =
{
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x00,0x00,
	0x00,0x11,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x00,0x00,0x00,0x00,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0xAD,0x9B,0x9C,0x00,0x9D,0x00,0x15,0x00,0x00,0xA6,0x00,0x00,0x00,0xAE,0x00,
	0xF8,0xF1,0xFD,0x00,0x00,0xE6,0x14,0xF9,0x00,0x00,0xA7,0xAF,0xAC,0xAB,0x00,0xA8,
	0x00,0x00,0x00,0x00,0x8E,0x8F,0x92,0x80,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0xA5,0x00,0x00,0x00,0x00,0x99,0x00,0x00,0x00,0x00,0x00,0x9A,0x00,0x00,0xE1,
	0x85,0xA0,0x83,0x00,0x84,0x86,0x91,0x87,0x8A,0x82,0x88,0x89,0x8D,0xA1,0x8C,0x00,
	0x00,0xA4,0x95,0xA2,0x93,0x00,0x94,0x00,0x00,0x97,0xA3,0x96,0x81,0x00,0x00,0x98
};

	/* Table of graphics characters. */

BYTE GfxTable[256] =
{
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

	/* Special character treatment. */

struct SpecialKey SpecialKeys[11] =
{
	BEL,	DoSomeBeep,	/* Ring the bell. */
	XON,	XOn,		/* Flow control - stop output. */
	BKS,	DoBackspace,	/* Erase a character. */
	ENT,	DoLF_FF_VT,	/* Enter key. */
	FFD,	DoFF,		/* Form feed. */
	VTB,	DoLF_FF_VT,	/* Vertical tab (huh?). */
	RET,	DoCR,		/* Return key. */
	TAB,	DoTab,		/* Move to next tab stop. */
	SI,	DoShiftIn,	/* ^N Change to graphics mode */
	SO,	DoShiftOut,	/* ^O Change out of graphics mode. */
	ENQ,	DoEnq		/* Transmit answerback message. */
};

UBYTE SpecialMap[256];

	/* Shared global string formatting buffer. */

UBYTE SharedBuffer[512];

	/* Screen pull-down-menu. */

struct NewMenu TermMenu[] =
{
	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_OPEN},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SAVE},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SAVEAS},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_PRINTSCREEN},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_ICONIFY},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_ABOUT},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_QUIT},

	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SETCONSOLE},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_DOSCOMMAND},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_REXXCOMMAND},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_PASTE},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_PACKET},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_FASTMACROPANEL},

	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_CLEARBUFFER},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_DISPLAYBUFFER},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_CLOSEBUFFER},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , CHECKIT|MENUTOGGLE, 0, (APTR)MEN_FREEZEBUFFER},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_LOADBUFFER},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SAVEBUFFER},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , CHECKIT|MENUTOGGLE, 0, (APTR)MEN_CAPTUREDISK},
	{  NM_ITEM, NULL,		 0 , CHECKIT|MENUTOGGLE, 0, (APTR)MEN_CAPTUREPRINTER},

	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_UPLOADTEXT},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_DOWNLOADTEXT},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SEND},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_RECEIVE},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_UPLOAD},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_DOWNLOAD},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_EDIT},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_XFERPROTOCOL},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SELECTXFER},

	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_PHONEBOOK},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_DIAL},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_REDIAL},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_PLAY},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SENDBREAK},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_FLUSHBUFFER},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_HANGUP},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_RELEASE},

	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_CLEARSCREEN},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_RESETSTYLES},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_RESETFONT},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_RESETTERMINAL},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SAVEILBM},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SAVEASCII},

	{ NM_TITLE, NULL,		 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SERIAL},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_MODEM},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SCREEN},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_TERMINAL},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_COMMANDS},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_MISC},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_PATH},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_MACROS},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_FASTMACROS},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_HOTKEYS},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_SPEECH},
	{  NM_ITEM, NM_BARLABEL,	 0 , 0, 0, (APTR)0},
	{  NM_ITEM, NULL,		 0 , 0, 0, (APTR)MEN_EMULATION},
	{   NM_END, 0,			 0 , 0, 0, (APTR)0},
};

struct Menu *Menu;

	/* Pointer. */

UWORD __chip Stopwatch[(2 + 16) * 2] =
{
	0x0000,0x0000,

	0x0400,0x07C0,
	0x0000,0x07C0,
	0x0100,0x0380,
	0x0000,0x07E0,
	0x07C0,0x1FF8,
	0x1FF0,0x3FEC,
	0x3FF8,0x7FDE,
	0x3FF8,0x7FBE,
	0x7FFC,0xFF7F,
	0x7EFC,0xFFFF,
	0x7FFC,0xFFFF,
	0x3FF8,0x7FFE,
	0x3FF8,0x7FFE,
	0x1FF0,0x3FFC,
	0x07C0,0x1FF8,
	0x0000,0x07E0,

	0x0000,0x0000
};

	/* Configuration. */

struct Configuration	 Config;
struct Configuration	 PrivateConfig;
struct SpeechConfig	 SpeechConfig;
BYTE			 English = TRUE;
BYTE			 Status;
BYTE			 Online;
struct Configuration	*BackupConfig;
UWORD			 PublicModes;

UBYTE			 LastConfig[256];
UBYTE			 DefaultPubScreen[MAXPUBSCREENNAME];

	/* These are the sixteen more or less different display modes the
	 * term main and buffer display screens will be opened in.
	 */

ULONG ModeID[16] =
{
	DEFAULT_MONITOR_ID|HIRES_KEY,
	DEFAULT_MONITOR_ID|HIRESLACE_KEY,
	DEFAULT_MONITOR_ID|SUPER_KEY,
	DEFAULT_MONITOR_ID|SUPERLACE_KEY,
	DEFAULT_MONITOR_ID|VGAPRODUCT_KEY,
	DEFAULT_MONITOR_ID|VGAPRODUCTLACE_KEY,

	PAL_MONITOR_ID|HIRES_KEY,
	PAL_MONITOR_ID|HIRESLACE_KEY,
	PAL_MONITOR_ID|SUPER_KEY,
	PAL_MONITOR_ID|SUPERLACE_KEY,

	NTSC_MONITOR_ID|HIRES_KEY,
	NTSC_MONITOR_ID|HIRESLACE_KEY,
	NTSC_MONITOR_ID|SUPER_KEY,
	NTSC_MONITOR_ID|SUPERLACE_KEY,

	A2024TENHERTZ_KEY,
	A2024FIFTEENHERTZ_KEY
};

	/* Capture file. */

struct Buffer		*FileCapture;
BPTR			 PrinterCapture;
UBYTE			 CaptureName[256];
BYTE			 StandardPrinterCapture,
			 ControllerActive;

	/* Buffer. */

UBYTE			**BufferLines;
LONG			 Lines;
struct SignalSemaphore	*BufferSemaphore;
LONG			 MaxLines = 100;
LONG			 BufferSpace;
BYTE			 BufferClosed;
BYTE			 BufferFrozen;

	/* Phonebook. */

struct PhoneEntry	**Phonebook;
LONG			 PhoneSize;
LONG			 NumPhoneEntries;
UBYTE			 PhonePassword[256];
BYTE			 PhonePasswordUsed;

UBYTE			 LastPhone[256];
UBYTE			 LastKeys[256];
UBYTE			 LastMacros[256];
UBYTE			 LastSpeech[256];

struct MacroKeys	*MacroKeys;

	/* Console stuff. */

UBYTE			*StripBuffer;
UWORD			 LastLine,LastColumn,LastPixel;
BYTE			 Charset,Attributes,FgPen,BgPen;
WORD			 CursorX,CursorY,Top,Bottom;
BYTE			 UseRegion,RegionSet,InSequence,Quiet,Blocking;
BYTE			 TabStops[1024];
BYTE			 CharMode[2];

BYTE			 ResetDisplay = FALSE,Escape = FALSE;

	/* Flow filter. */

UBYTE			*AttentionBuffers[8],AttentionCount[8],FlowCount;
BYTE			 BaudPending,FullCheck;
UBYTE			 BaudBuffer[20],BaudCount;

struct FlowInfo		 FlowInfo;

	/* Transfer data. */

LONG			 FileCount,FileCountMax;
struct WBArg		*FileArg;
BYTE			 MultipleFiles,FileMatch,BinaryTransfer;
struct AnchorPath	*FileAnchor;
LONG			 TransferBits;

UBYTE			*DownloadPath;
BYTE			 Uploading;
BYTE			 DidTransfer;

struct Window		*TransferWindow;
struct Menu		*TransferMenu;
struct Gadget		*TransferGadgetArray[8];
struct List		 TransferInfoList;

struct Library		*XProtocolBase;
struct XPR_IO		*XprIO;

UBYTE			 ProtocolOptsBuffer[256];
BYTE			 NewLibrary,NewOptions;
UBYTE			 LastXprLibrary[256];
UBYTE			 ConvNumber[30],ConvNumber10[30];
BYTE			 UsesZModem,SendAbort,TransferAborted;

	/* The standard ZModem cancel sequence
	 * (ten CAN chars followed by ten
	 * BS chars).
	 */

UBYTE ZModemCancel[] =
{
	24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8
};

	/* Pay per minute. */

LONG			 CurrentPay;
LONG			 PayPerUnit[2];
LONG			 SecPerUnit[2];
LONG			 TimeOfDay[2];
WORD			 PreferredTime;
UBYTE			 Password[20];
UBYTE			 UserName[20];
struct PhoneEntry	*ChosenEntry;
BYTE			 ChosenInUse;

	/* Execute a command/script. */

UBYTE			 WindowName[256];

	/* Rexx server info. */

BYTE			 WeAreBlocking;

	/* Dial list. */

struct List		*DialList;

BYTE			 SendStartup;

	/* TermMain data. */

BYTE			 ReleaseSerial;
BYTE			 ResetSerial;
BYTE			 BatchMode;
BYTE			 SerialSet;

	/* Upload/Download paths. */

UBYTE			 LastDownload[256];
UBYTE			 LastUpload[256];

	/* String gadgets hooks. */

struct Hook		 CommandHook;
BYTE			 DontActivate;

struct Window		*CommandWindow;
struct Gadget		*CommandGadget;
struct Gadget		*ActiveGadget;

struct Process		*ClipProcess;
struct MsgPort		*ClipPort;

	/* Packet window. */

struct Window		*PacketWindow;
struct Gadget		*PacketGadgetArray[2];
struct Menu		*PacketMenu;
struct Gadget		*PacketGadgetList;
struct List		 PacketHistoryList;

	/* Some more colour control flags. */

BYTE			 Initializing,LoadColours;

	/* The character raster. */

UBYTE			*Raster,*RasterAttr;
WORD			 RasterWidth,RasterHeight;

	/* File download tracking. */

struct SignalSemaphore	*DownloadSemaphore;
struct List		 DownloadList;
LONG			 DownloadLineCount;
struct Node		*DownloadNode;

	/* Rexx scanning sequences. */

struct List		 SequenceList;
LONG			 SequenceCount;

	/* File version test. */

ULONG VersionProps[2] =
{
	'TERM',
	'VERS'
};

	/* Cause a rexx command to terminate without waiting. */

BYTE			 ExitQuietly;

	/* The ARexx output window. */

struct Window		*RexxWindow;

	/* Window stack. */

struct Window		*TopWindow;

struct Window		*WindowStack[5];
WORD			 WindowStackPtr;

	/* Global term ID. */

LONG			 TermID;
UBYTE			 TermIDString[MAXPUBSCREENNAME + 1];

	/* Fast! macros. */

struct List		 FastMacroList;
LONG			 FastMacroCount;
UBYTE			 LastFastMacros[256];
struct Window		*FastWindow;
struct Gadget		*FastGadget;

	/* Double-buffered file locking. */

struct List		 DoubleBufferList;
struct SignalSemaphore	 DoubleBufferSemaphore;

	/* XEM interface. */

struct XEM_IO		*XEM_IO;
ULONG			 XEM_Signal;
struct XEmulatorHostData XEM_HostData;
UBYTE			*OptionTitle;
struct List		 XEM_MacroList;
struct XEmulatorMacroKey *XEM_MacroKeys;
UBYTE			 EmulationName[40];

struct List		 EmptyList;

	/* Screen scrolling support. */

UBYTE			 ScrollLineFirst,ScrollLineLast,
			 ScrollLineCount;
struct ScrollLineInfo	*ScrollLines;

	/* term review buffer. */

struct MsgPort		*ReviewPort;
struct Window		*ReviewWindow;
