/*
**	termARexxGlobal.h
**
**	Global data definitions for ARexx interface
**
**	Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
**		All Rights Reserved
*/

#include "termGlobal.h"

	/* Information table entry types. */

enum	{	INFO_STEM,INFO_TEXT,INFO_NUMERIC,INFO_BOOLEAN,INFO_MAPPED };

	/* Data types to save or open. */

enum	{	DATATYPE_TRANSLATIONS,DATATYPE_FUNCTIONKEYS,DATATYPE_CURSORKEYS,
		DATATYPE_FASTMACROS,DATATYPE_HOTKEYS,DATATYPE_SPEECH,DATATYPE_SOUND,DATATYPE_BUFFER,
		DATATYPE_CONFIGURATION,DATATYPE_PHONEBOOK,DATATYPE_SCREENTEXT,
		DATATYPE_SCREENIMAGE,DATATYPE_COUNT };

	/* Requester types. */

enum	{	REQUESTER_SERIAL,REQUESTER_MODEM,REQUESTER_SCREEN,
		REQUESTER_TERMINAL,REQUESTER_EMULATION,REQUESTER_CLIPBOARD,
		REQUESTER_CAPTURE,REQUESTER_COMMANDS,REQUESTER_MISC,
		REQUESTER_PATH,REQUESTER_TRANSFER,REQUESTER_TRANSLATIONS,
		REQUESTER_FUNCTIONKEYS,REQUESTER_CURSORKEYS,REQUESTER_FASTMACROS,
		REQUESTER_HOTKEYS,REQUESTER_SPEECH,REQUESTER_SOUND,REQUESTER_PHONE,
		REQUESTER_COUNT };

	/* Window types. */

enum	{	WINDOW_BUFFER,WINDOW_REVIEW,WINDOW_PACKET,WINDOW_FASTMACROS,
		WINDOW_STATUS,WINDOW_MAIN,WINDOW_COUNT };

	/* The maximum length of an ARexx result variable. */

#define MAX_RESULT_LEN	65536

	/* ARexx interface error codes. */

#define TERMERROR_NO_DATA_TO_PROCESS			1000
#define TERMERROR_INDEX_OUT_OF_RANGE			1001
#define TERMERROR_UNKNOWN_OBJECT			1002
#define TERMERROR_RESULT_VARIABLE_REQUIRED		1003
#define TERMERROR_UNIT_NOT_AVAILABLE			1004
#define TERMERROR_DEVICE_DRIVER_STILL_OPEN		1005
#define TERMERROR_CLIPBOARD_ERROR			1006
#define TERMERROR_INFORMATION_IS_READ_ONLY		1007
#define TERMERROR_DATA_TYPES_INCOMPATIBLE		1008
#define TERMERROR_LIST_IS_ALREADY_EMPTY			1009
#define TERMERROR_UNKNOWN_LIST				1010
#define TERMERROR_WRONG_LIST				1011
#define TERMERROR_UNKNOWN_COMMAND			1012

	/* An information table entry node. */

struct AttributeEntry
{
	WORD	 Level;		/* Node level */
	STRPTR	 Name;		/* Name or NULL for numeric value */
	UBYTE	 Type;		/* Node type (INFO_TEXT through INFO_MAPPED) */
	BYTE	 ReadOnly;	/* If information happens to be read-only */
	STRPTR	*Mappings;	/* Type mappings if applicable */
	WORD	 NodeID;	/* Node ID code */
};

	/* Argument mutual exclusion information. */

struct ExclusionInfo
{
	BYTE	A,B;
};

	/* A special message and argument packet. */

struct RexxPkt
{
	struct Message		 VanillaMessage;

	struct RexxMsg		*RexxMsg;
	STRPTR			*Array;
	struct RDArgs		*Args;
	struct CommandInfo	*CommandInfo;
	LONG			 Results[2];
};

	/* A special function key pointer. */

typedef STRPTR (* __regargs COMMAND)(struct RexxPkt *);

	/* Argument inclusion bits. */

#define INCLUDE_00 (1 <<  0)
#define INCLUDE_01 (1 <<  1)
#define INCLUDE_02 (1 <<  2)
#define INCLUDE_03 (1 <<  3)
#define INCLUDE_04 (1 <<  4)
#define INCLUDE_05 (1 <<  5)
#define INCLUDE_06 (1 <<  6)
#define INCLUDE_07 (1 <<  7)
#define INCLUDE_08 (1 <<  8)
#define INCLUDE_09 (1 <<  9)
#define INCLUDE_10 (1 << 10)
#define INCLUDE_11 (1 << 11)

	/* Rexx command information. */

struct CommandInfo
{
	WORD	Async;
	BYTE	Tool;
	BYTE	Console;
	COMMAND	Routine;
	STRPTR	Name,
		Arguments;
};

	/* termARexx.c */

BYTE __regargs		IsNumeric(STRPTR String);
STRPTR __regargs	CreateResult(STRPTR,LONG *);
BYTE __stdargs		CreateVarArgs(STRPTR,struct RexxPkt *,STRPTR,...);
STRPTR __regargs	CreateVar(STRPTR,struct RexxPkt *,STRPTR);
STRPTR __regargs	CreateMatchBuffer(STRPTR);
BYTE __regargs		MatchBuffer(STRPTR,STRPTR);
VOID __regargs		DeleteMatchBuffer(STRPTR);
VOID __regargs		RexxPktCleanup(struct RexxPkt *,STRPTR);
WORD __regargs		ToMode(STRPTR);
WORD __regargs		ToList(STRPTR);
WORD __regargs		ToConfig(STRPTR);
WORD __regargs		ToRequester(STRPTR);
WORD __regargs		ToWindow(STRPTR);

	/* termARexxCommands.c */

STRPTR __regargs	RexxActivate(struct RexxPkt *);
STRPTR __regargs	RexxAdd(struct RexxPkt *);
STRPTR __regargs	RexxBaud(struct RexxPkt *);
STRPTR __regargs	RexxBeepScreen(struct RexxPkt *);
STRPTR __regargs	RexxCallMenu(struct RexxPkt *);
STRPTR __regargs	RexxCapture(struct RexxPkt *);
STRPTR __regargs	RexxClear(struct RexxPkt *);
STRPTR __regargs	RexxClearScreen(struct RexxPkt *);
STRPTR __regargs	RexxClose(struct RexxPkt *);
STRPTR __regargs	RexxCloseDevice(struct RexxPkt *);
STRPTR __regargs	RexxCloseRequester(struct RexxPkt *);
STRPTR __regargs	RexxDeactivate(struct RexxPkt *);
STRPTR __regargs	RexxDelay(struct RexxPkt *);
STRPTR __regargs	RexxDial(struct RexxPkt *);
STRPTR __regargs	RexxDuplex(struct RexxPkt *);
STRPTR __regargs	RexxFault(struct RexxPkt *);
STRPTR __regargs	RexxGetClip(struct RexxPkt *);
STRPTR __regargs	RexxHangup(struct RexxPkt *);
STRPTR __regargs	RexxHelp(struct RexxPkt *);
STRPTR __regargs	RexxOpen(struct RexxPkt *);
STRPTR __regargs	RexxOpenDevice(struct RexxPkt *);
STRPTR __regargs	RexxOpenRequester(struct RexxPkt *);
STRPTR __regargs	RexxParity(struct RexxPkt *);
STRPTR __regargs	RexxPasteClip(struct RexxPkt *);
STRPTR __regargs	RexxPrint(struct RexxPkt *);
STRPTR __regargs	RexxProtocol(struct RexxPkt *);
STRPTR __regargs	RexxPutClip(struct RexxPkt *);
STRPTR __regargs	RexxQuit(struct RexxPkt *);
STRPTR __regargs	RexxRead(struct RexxPkt *);
STRPTR __regargs	RexxReceiveFile(struct RexxPkt *);
STRPTR __regargs	RexxRedial(struct RexxPkt *);
STRPTR __regargs	RexxRemove(struct RexxPkt *);
STRPTR __regargs	RexxRequestFile(struct RexxPkt *);
STRPTR __regargs	RexxRequestNotify(struct RexxPkt *);
STRPTR __regargs	RexxRequestNumber(struct RexxPkt *);
STRPTR __regargs	RexxRequestResponse(struct RexxPkt *);
STRPTR __regargs	RexxRequestString(struct RexxPkt *);
STRPTR __regargs	RexxResetScreen(struct RexxPkt *);
STRPTR __regargs	RexxResetStyles(struct RexxPkt *);
STRPTR __regargs	RexxResetText(struct RexxPkt *);
STRPTR __regargs	RexxSave(struct RexxPkt *);
STRPTR __regargs	RexxSaveAs(struct RexxPkt *);
STRPTR __regargs	RexxSelect(struct RexxPkt *);
STRPTR __regargs	RexxSend(struct RexxPkt *);
STRPTR __regargs	RexxSendBreak(struct RexxPkt *);
STRPTR __regargs	RexxSendFile(struct RexxPkt *);
STRPTR __regargs	RexxSpeak(struct RexxPkt *);
STRPTR __regargs	RexxStopBits(struct RexxPkt *);
STRPTR __regargs	RexxTextBuffer(struct RexxPkt *);
STRPTR __regargs	RexxTimeout(struct RexxPkt *);
STRPTR __regargs	RexxWait(struct RexxPkt *);
STRPTR __regargs	RexxWindow(struct RexxPkt *);
STRPTR __regargs	RexxRX(struct RexxPkt *);
STRPTR __regargs	RexxExecTool(struct RexxPkt *);

	/* termARexxAttributes.c */

STRPTR __regargs	RexxGetAttr(struct RexxPkt *);
STRPTR __regargs	RexxSetAttr(struct RexxPkt *);

	/* termARexxData.c */

extern struct AttributeEntry	 AttributeTable[];
extern LONG			 AttributeTableSize;

extern UWORD			 InclusionTable[];
extern struct ExclusionInfo	*ExclusionTable[];

extern struct CommandInfo	 CommandTable[];
extern LONG			 CommandTableSize;

extern struct MsgPort		*RexxPort;
extern LONG			 LastRexxError;
extern LONG			 RexxTimeoutVal;
extern BYTE			 UpdateRequired,
				 TransferUpdateRequired;
extern LONG			 RexxLaunchCount;
extern struct SignalSemaphore	 RexxLaunchSemaphore;
