/*
** Macro header: macro.h
**
** Copyright (C) 1993 Brian L. Smith
** Copyright (C) 1993 RimStar Technology, Inc.
** All rights reserved internationally.
**	Last revision: Oct. 22, 1993
*/

/*
** NOTE: The 'C' Macro compiler uses the following sizes for built-in types
**		char  -  8 bit signed
**		int	- 16 bit signed
**		long	- 32 bit signed
**	 	short - 16 bit signed
**		float & double - unsupported
**	bit field declarations in a structure are treated as ints ( ie. they are not really supported.)
**
**	C runtime functions however do support 32 bit args where applicable, eg. malloc, strncpy.
*/

#ifndef MACRO_H_INCLUDED
	#define MACRO_H_INCLUDED

	typedef unsigned long	size_t;
	typedef signed short		SHORT, *PSHORT;
	typedef unsigned short	USHORT, BOOL, *PUSHORT;
	typedef signed long		LONG, *PLONG;
	typedef unsigned long	ULONG, *PULONG;
	typedef char				*PSZ;
	typedef void				*PVOID;

	typedef ULONG  HANDLE;
	typedef HANDLE HBUFFER;
	typedef HANDLE HEVENT;
	typedef HANDLE HFILE;
	typedef HANDLE HINI;
	typedef HANDLE HKEYBOARD;
	typedef HANDLE HMARK;
	typedef HANDLE HWINDOW;
	typedef HANDLE HWND;

	#ifndef NULL
	 #define NULL	0
	#endif
	#ifndef TRUE
	 #define TRUE (1)
	#endif
	#ifndef FALSE
	 #define FALSE (0)
	#endif

	/* PopupMsgBox settings */
	/* button types */
	#define MB_OK						0x0000
	#define MB_OKCANCEL				0x0001
	#define MB_RETRYCANCEL			0x0002
	#define MB_ABORTRETRYIGNORE 	0x0003
	#define MB_YESNO					0x0004
	#define MB_YESNOCANCEL			0x0005
	#define MB_CANCEL					0x0006
	#define MB_ENTER					0x0007
	#define MB_ENTERCANCEL			0x0008

	 /* icon type */
	#define MB_NOICON				0x0000
	#define MB_ICONQUESTION		0x0010
	#define MB_ICONEXCLAMATION	0x0020
	#define MB_ICONASTERISK		0x0030
	#define MB_ICONHAND			0x0040
	#define MB_ICONWORKING		0x0050
	#define MB_QUERY				MB_ICONQUESTION
	#define MB_WARNING			MB_ICONEXCLAMATION
	#define MB_INFORMATION		MB_ICONASTERISK
	#define MB_CRITICAL			MB_ICONHAND
	#define MB_ERROR				MB_ICONHAND

	 /* default button */
	#define MB_DEFBUTTON1		0x0000
	#define MB_DEFBUTTON2		0x0100
	#define MB_DEFBUTTON3		0x0200

	 /* modal flags */
	#define MB_APPLMODAL			0x0000
	#define MB_SYSTEMMODAL		0x1000
	#define MB_NONMODAL			0x5000	/* not in OS/2 version */
	#define MB_PRIMARYMODAL		0x6000	/* not in OS/2 version */
	#define MB_HELP				0x2000
	#define MB_MOVEABLE			0x4000

	#define MBID_OK			1
	#define MBID_CANCEL		2
	#define MBID_ABORT		3
	#define MBID_RETRY		4
	#define MBID_IGNORE		5
	#define MBID_YES			6
	#define MBID_NO			7
	#define MBID_ENTER		9
	#define MBID_ERROR		-1

	/* System flags (SysQueryFlags / SysSetFlags) */
	#define	SYSTEM_SW_OPENFILE	0x00000001L
	#define	SYSTEM_SW_ERROR		0x00000002L
	#define	SYSTEM_SW_BROWSE		0x00000004L
	#define	SYSTEM_USE_TABS		0x00000008L
	#define	SYSTEM_KEEP_DIR		0x00000010L
	#define	SYSTEM_BACKUP			0x00000020L
	#define	SYSTEM_AUTOSAVE		0x00000040L
	#define	SYSTEM_SAVESTATE		0x00000080L
	#define	SYSTEM_CTRLZ			0x00000100L
	#define	SYSTEM_ONE_EXE			0x00000200L
	#define	SYSTEM_INSERT			0x00000400L
	#define	SYSTEM_KEEP_UNDO		0x00000800L
	#define	SYSTEM_TOOLBAR			0x00001000L
	#define	SYSTEM_TOOLBAR_H		0x00002000L
	#define	SYSTEM_KEEP_TILED		0x00004000L
	#define	SYSTEM_KEEP_CASCADED 0x00008000L
	#define	SYSTEM_TILE_TALL		0x00010000L
	#define	SYSTEM_READ_ONLY		0x00020000L
	#define	SYSTEM_RAW				0x00040000L
	#define	SYSTEM_SOUNDS			0x00080000L
	#define	SYSTEM_FILE_DETECT	0x00100000L

	/* Buffer flags (BufQueryFlags / BufSetFlags) */
	#define  BUFFER_TYPE				0x0000000FL	/* mask to get BUFTYPE */
	#define  BUFFER_SCRAPTYPE		0x000000F8L /* mask to get scrap type */
	#define  BUFFER_LOCKED			0x00004000L
	#define  BUFFER_PRINT_IP		0x00008000L
	#define  BUFFER_READ_ONLY  	0x00020000L
	#define  BUFFER_RAW				0x00040000L
	#define  BUFFER_MODIFIED		0x00080000L

	/* Buffer types (BufCreateBuffer, BufEditFile) */
	#define BUFTYPE_NORMAL 			0x00000001L
	#define BUFTYPE_TEMP				0x00000002L
	#define BUFTYPE_SYSTEM 			0x00000004L
	#define BUFTYPE_SCRAP  			0x00000008L

	/* Srap buffer types */
	#define SCRAPTYPE_NORMAL 		0x00000018L
	#define SCRAPTYPE_COLUMN		0x00000028L
	#define SCRAPTYPE_LINE 			0x00000038L
	#define SCRAPTYPE_EXCLUSIVE	0x00000048L

	/* Selection types */
	#define SELECT_NORMAL		(1)
	#define SELECT_COLUMN		(2)
	#define SELECT_LINE			(3)
	#define SELECT_EXCLUSIVE	(4)

	typedef struct _pselection_t SELECTION, *PSELECTION;
	struct _pselection_t {
		SHORT		type;
		HBUFFER	hb;
		LONG		s_line;
		LONG		s_column;
		LONG		e_line;
		LONG		e_column;
	};


	typedef struct _rawkey RAWKEY, *PRAWKEY;
	#pragma pack(1)
	struct _rawkey {
		unsigned	short	key;		/* high byte has shift key modifiers - low byte has scan code	*/
		unsigned char 	ascii;	/* ascii representation if any											*/
		unsigned	char	repeat;	/* repeat count - 1 unless editor falls behind in processing	*/
	};

	typedef struct _binding BINDING, *PBINDING;
	struct _binding {
		ULONG		reserved1;		/* leave strictly alone */
		USHORT	reserved2;		/* leave strictly alone */
		USHORT	cKeys;			/* number of keystrokes in following array */
		PSZ		pszFunction;	/* function string used in KbdBind */
		USHORT	key[1];			/* array of keystrokes ( key portion of RAWKEY ) */
	};
	#pragma pack()


	/* Shift key modifiers - high byte of key */
	#define KC_SHIFT	0x0800
	#define KC_CTRL	0x1000
	#define KC_ALT		0x2000


	typedef struct _sys_font_attrs	FONTATTRIB, *PFONTATTRIB;
	struct _sys_font_attrs {
	SHORT	cxChar,
			cyChar,
			cyDesc;
	};

	/*
	** PROGINFO is used to pass the required information to ExecAssoc
	** If NULL is passed to ExecAssoc the editor uses the associations
	** contained in the configuration file (maintained using the File
	** Extensions Association dialog box) based on the file extension
	** of the current buffer. The ulFlags member currently supports:
	** 0 = create window for program output buffer
	** 1 = do not create window for program buffer
	*/
	typedef struct progInfo_ PROGINFO, *PPROGINFO;
	struct progInfo_ {
		ULONG	reserved;		/* reserved for internal use										  	*/
		PSZ  	pszTitle;		/* title of program - used to create output buffer's name	*/
		PSZ  	pszPath;			/* path & filename of executable to run							*/
		PSZ  	pszDir;			/* working directory defaults to current buffer's directory */
		PSZ  	pszArgs;			/* arguments to pass to program									  	*/
		PSZ	pszRegExp;		/* Regular expression used for default error msg processing */
		ULONG	ulFlags;			/* flags which control output window creation					*/
	};

	typedef struct _UserStringDlg USERSTRINGDLG, *PUSERSTRINGDLG;
	struct _UserStringDlg {
		ULONG		cbStruct;	/* sizeof this structure */
		PSZ		pszTitle;	/* Title of dialog box   */
		PSZ		pszPrompt;	/* Prompt text				 */
		USHORT	cbText;		/* len of pszText buffer */
		PSZ		pszText;		/* Buffer to place input */
	};

	/* Functions which are built into the editor */

	extern void 	BufBackspace( void );
	extern SHORT 	BufCopyToScrap( SHORT append );
	extern HBUFFER BufCreateBuffer( char *buf_name, char *pathname, ULONG ulCreateFlags );
	extern SHORT 	BufCutToScrap( SHORT append );
	extern USHORT 	BufCopyWordToString(char *, USHORT cBytes );
	extern SHORT 	BufDeleteBuffer( HBUFFER );
	extern SHORT 	BufDeleteBufferWithConfirm( HBUFFER );
	extern SHORT 	BufDeleteChar( ULONG count );
	extern SHORT 	BufDeleteCharOrSelection( void );
	extern SHORT 	BufDeleteCurrentBuffer( void );
	extern SHORT 	BufDeleteLeft( ULONG count );
	extern SHORT 	BufDeleteLine( ULONG count);
	extern SHORT 	BufDeletePrevChar( ULONG count );
	extern SHORT 	BufDeleteSel( void );
	extern SHORT 	BufDeleteToEOL( void );
	extern SHORT 	BufDeleteToSOL( void );
	extern void 	BufDeleteWhitespace( void );
	extern SHORT	BufEditFile( char *pathname, ULONG ulCreateFlags );
	extern HBUFFER BufFindBuffer( char *pathname, SHORT inclSysBufs );
	extern SHORT 	BufIndentColumn( LONG start, LONG end );
	extern SHORT 	BufInsertChar( int ch );
	extern SHORT 	BufInsertFile( char *pathname );
	extern SHORT 	BufInsertNewline( void );
	extern void 	BufInsertString( char * );
	extern SHORT	BufLoadFile(HBUFFER hb, char *pathname, ULONG ulFlags);
	extern void 	BufNewFile( void );
	extern SHORT 	BufNewlineIndent( void );
	extern void 	BufNextBuffer( void );
	extern SHORT 	BufPasteScrap( HBUFFER hbScrap );
	extern SHORT 	BufPrevBuffer( void );
	extern LONG 	BufQueryBufferSize( void );
	extern int 		BufQueryChar( LONG offset );
	extern LONG 	BufQueryColumn( void );
	extern HBUFFER BufQueryCurrentBuffer( void );
	extern LONG		BufQueryDistanceToTab( void );
	extern char *	BufQueryFilename( void );
	extern LONG		BufQueryFilesize( void );
	extern ULONG	BufQueryFlags( /* HBUFFER hb (optional) */ );
	extern BOOL		BufQueryIsTabstop( LONG column );
	extern LONG 	BufQueryLine( void );
	extern LONG 	BufQueryLineLength( void );
	extern SHORT 	BufQueryModified( HBUFFER );
	extern HBUFFER BufQueryNextBuffer( HBUFFER, SHORT inclSys );
	extern LONG		BufQueryNextTab( LONG column );
	extern LONG 	BufQueryOffset( void );
	extern LONG 	BufQueryPastEOL( void );
	extern void 	BufQueryPosition( LONG *line, LONG *column );
	extern HBUFFER BufQueryPrevBuffer( HBUFFER, SHORT inclSys );
	extern LONG		BufQueryPrevTab( LONG column );
	extern char *  BufRead( LONG cBytes );
	extern void		BufRefreshWindows(HBUFFER);
	extern SHORT 	BufSetCurrentBuffer( HBUFFER );
	extern char *	BufSetFlags( ULONG mask, ULONG newFlags );
	extern void 	BufSetMaxTabColumn( LONG );
	extern SHORT 	BufSetModified( SHORT );
	extern void 	BufSetTabs( char *pszTabStops );
	extern HBUFFER BufSwitchBuffer( HBUFFER );
	extern SHORT 	BufToggleModified( void );
	extern SHORT	BufTransfer(HBUFFER src, LONG s_line, LONG s_column, LONG e_line, LONG e_column );
	extern SHORT	BufTransferBytes(HBUFFER src, LONG offset, LONG cBytes );
	extern SHORT 	BufWrite( HBUFFER );
	extern SHORT 	BufWriteSel( void );
	extern SHORT 	BufZapBuffer( HBUFFER );

	extern SHORT ChgDir(char *dir );
	extern SHORT ChgDirOfFile( char *pathname );

	extern void DlgBufferList( void );
	extern void DlgConfigAssoc( void );
	extern void DlgConfigColors( void );
	extern void DlgConfigCursors( void );
	extern void DlgConfigFonts( void );
	extern void DlgConfigGlobals( void );
	extern void DlgGotoLine( void );
	extern void DlgOpenFile( void );
	extern void DlgRenameBuffer( void );
	extern SHORT DlgUserString( PUSERSTRINGDLG );
	extern void DlgVersion( void );


	extern void ErrJumpToError( void );
	extern void ErrNextError( void );
	extern void ErrPrevError( void );

	extern SHORT  EventDeregisterEvent( HEVENT );
	extern SHORT  EventDisableEvent( HEVENT );
	extern SHORT  EventEnableEvent( HEVENT );
	extern HEVENT EventRegisterEvent( USHORT usID, USHORT fsFlags, char *function, PVOID pUserData);
	extern SHORT  EventTriggerEvent( USHORT usID, PVOID data );
	/*
	** Event handlers should have this prototype:
	**		SHORT event_handler ( USHORT usEventID, PVOID pData, PVOID pUserData );
	**
	** pData is what is passed by EventTriggerEvent (see manual for what predefined events pass)
	** pUserData is data which has been registered to be passed to a specific event handler
	**	pUserData is set using the last arg to EventRegisterEvent()
	** Each event handler registered for a particular event will be passed the same pData when
	** an event is triggered; pUserData will be non-null only if that specific event handler
	** was registered with a non-null pUserData argument to EventRegisterEvent.
	*/

	extern SHORT ExecAssoc( PROGINFO *pInfo );
	extern void  ExecKillProcess( void );
	extern void  ExecFunction( char *funcStr );
	extern ULONG ExecProgram( PSZ pszProgpath, PSZ pszArgs, PSZ pszFunction,
									  PVOID pData, LONG hfStdin, LONG hfStdout, LONG hfStderr );

	extern SHORT ExecSession(PSZ 		pszTitle,	 /* Program title - for title bar 							*/
									 PSZ 		pszProgpath, /* path & filename of executable 							*/
									 PSZ 		pszArgs,		 /* command line to pass to pgm								*/
									 PSZ 		pszEnv,		 /* environment string											*/
									 USHORT 	fgbg,			 /* start in foreground/background							*/
									 USHORT	sessionType, /* type of session windowed, full-screen, PM, etc.	*/
									 USHORT	pgmCtrl,		 /* start visible/minimized/maximized etc. 				*/
									 USHORT	xPos,			 /* if pgmCtrl high bit set x pos of window				*/
									 USHORT	yPos,			 /* y pos of window 												*/
									 USHORT	cx,			 /* width of window 												*/
									 USHORT	cy,			 /* height of window												*/
									 PSZ		pszErrBuf,	 /* if exec fails - buffer to place possible reason	*/
									 ULONG	errBufLen);	 /* length of error buffer										*/

	extern void ExitEditor( void );
	extern void ExportClipboard( void );

	extern char *GetCurrentDir( PSZ buffer, USHORT cBytes );

	extern void HelpExtended( void );
	extern void HelpForHelp( void );
	extern void HelpIndex( void );
	extern void HelpKeys( void );
	extern void HelpQueryInfHelp( void );
	extern void HelpQueryQuickHelp( void );

	extern void ImportClipboard( void );

	extern SHORT 		KbdBind( char *keyStr, char *fname );
	extern void			KbdBufferFlush( void );
	extern PRAWKEY		KbdBufferQueryKey( void );
	extern PRAWKEY		KbdBufferGetKey( void );
	extern SHORT		KbdBufferPush( PRAWKEY );
	extern SHORT		KbdBufferInsert( PRAWKEY );
	extern void			KbdBufferUngetKey( USHORT nKeys );
	extern HKEYBOARD 	KbdCreateKeyboard( void );
	extern void 		KbdDestroyKeyboard( HKEYBOARD );
	extern SHORT 		KbdIsKeyboard( HKEYBOARD);
	extern char *		KbdKeysToString( PUSHORT ausKeys, SHORT nItems );
	extern SHORT 		KbdMacroLoad( char *pathname );
	extern SHORT 		KbdMacroPause( void );
	extern SHORT 		KbdMacroPlay( void );
	extern SHORT 		KbdMacroRecord( void );
	extern SHORT 		KbdMacroSave( char *pathname );
	extern HKEYBOARD 	KbdPop( void );
	extern SHORT 		KbdPush( HKEYBOARD );
	extern PBINDING	KbdQueryBinding( char *function, PBINDING pBind );
	extern char *		KbdQueryFunction( PUSHORT ausKeys, SHORT nItems );
	extern char *		KbdQueryLastFunction( void );
	extern HKEYBOARD 	KbdQueryBufferKeyboard( );
	extern HKEYBOARD 	KbdQueryCurrentKeyboard( );
	extern HKEYBOARD 	KbdQueryWindowKeyboard( );
	extern HKEYBOARD 	KbdSetBufferKeyboard( HKEYBOARD );
	extern HKEYBOARD 	KbdSetCurrentKeyboard( HKEYBOARD );
	extern HKEYBOARD 	KbdSetWindowKeyboard( HKEYBOARD );
	extern PUSHORT		KbdStringToKeys( char *s );

	extern void 		LibAutoload(char *filename, char *, ... );
	extern void 		LibAutoloadData(char *filename, char *, ... );
	extern void 		LibExecFunction( char *function );
	extern SHORT 		LibQueryFunction( char *function );
	extern SHORT		LibLoadMacro(char *pathname);

	extern SHORT MarkAdjustSel( void );
	extern HMARK MarkAllocGlobal(USHORT usID);
	extern HMARK MarkAllocLocal(USHORT usID);
	extern SHORT MarkBeginSel( SHORT type );
	extern SHORT MarkColumn( void );
	extern void  MarkCreateSel( PSELECTION );
	extern SHORT MarkEndSel( void );
	extern SHORT MarkExclusive( void );
	extern SHORT MarkFree(HMARK);
	extern USHORT MarkFreeAllGlobals(void);
	extern USHORT MarkFreeAllLocals(void);
	extern SHORT MarkGoto(HMARK);
	extern BOOL  MarkIsMark(HMARK);
	extern SHORT MarkLine( void );
	extern SHORT MarkNormal( void );
	extern void	 MarkPopPos(SHORT move, USHORT count);
	extern HMARK MarkPushPos(void);
	extern HMARK MarkQueryGlobalFromID(USHORT id);
	extern BOOL  MarkQueryIsSelOpen(void);
	extern HMARK MarkQueryLocalFromID(USHORT id);
	extern HMARK MarkQueryPosFromID(USHORT id);
	extern SHORT MarkQuerySel(PSELECTION pSel, SHORT adjust);
	extern SHORT MarkQuerySelType(void);
	extern SHORT MarkQuerySelWouldAdjust(void);
	extern void	 MarkRemoveAllSel(void);
	extern SHORT MarkRemoveSel(void);
	extern HMARK MarkResetMark(HMARK);
	extern SHORT MarkResumeSel(void);
	extern SHORT MarkSetID(HMARK hMark, USHORT id);
	extern SHORT MarkSetMark(HMARK hMark, LONG new_line, LONG new_col);
	extern SHORT MarkSetSelType(SHORT type);
	extern SHORT MarkSwapSel( void );

	extern SHORT MnuInsertItem(HWND hwndParentMenu,
										USHORT subMenuID,
										SHORT pos,
										USHORT afAttrib,
										USHORT id,
										PSZ pszText,
										PSZ pszHelp);
	extern HWND  MnuInsertSubMenu(HWND hwndParentMenu,
											HWND hwndSubMenu,
											SHORT pos,
											USHORT id,
											PSZ pszText,
											PSZ pszHelp);
	extern BOOL	 MnuSetItemAttr(HWND hwndMenu,
										 USHORT idItem,
										 BOOL fIncludeSubMenus,
										 USHORT usMask,
										 USHORT usData);
	extern void	 MnuSetItemText(USHORT idItem, PSZ text, PSZ accel);

	extern SHORT MovAbs( LONG line, LONG column );
	extern SHORT MovBottomWin( void );
	extern SHORT MovDown( LONG count );
	extern SHORT MovEOF( void );
	extern SHORT MovEOL( void );
	extern SHORT MovEndBrief( void );
	extern SHORT MovLeft( LONG count );
	extern SHORT MovNextChar( LONG count );
	extern SHORT MovUp( LONG count );
	extern SHORT MovPageDown( void );
	extern SHORT MovPageUp( void );
	extern SHORT MovPrevChar( LONG count );
	extern SHORT MovPrevTabPos( void );
	extern SHORT MovRel( LONG line_offset, LONG col_offset );
	extern SHORT MovRight( LONG count );
	extern SHORT MovSOF( void );
	extern SHORT MovSOL( void );
	extern LONG  MovSOT( void );	/* returns column moved to */
	extern SHORT MovStartBrief( void );
	extern SHORT MovToLine( LONG line );
	extern void  MovToMouse( void );
	extern SHORT MovTopWin( void );
	extern void  MovWordLeft( void );
	extern void  MovWordRight( void );

	extern Nothing( void );

	extern SHORT PopupMsg( char *msg, char *title);
	extern SHORT PopupMsgBox( char *msg, char *title, ULONG ulFlags );

	/*
	** These 'Pos' function do not retain undo information.
	** they just move you to the desired location.
	** They are faster than their 'Mov' versions, so if you don't want to retain undo
	** information while you are moving around, these are better choice.
	*/
	extern LONG	 PosAbs(LONG new_line, LONG new_col);
	extern LONG	 PosEOF(void);
	extern LONG	 PosEOL(void);
	extern LONG	 PosSOF(void);
	extern LONG	 PosSOL(void);
	extern LONG	 PosSOT(void);
	extern SHORT PosNextChar(LONG count);
	extern SHORT PosPrevChar(LONG count);
	extern LONG	 PosRel(LONG line_offset, LONG col_offset);
	extern LONG	 PosToOffset( LONG offset );

	extern SHORT Print( void );

	extern SHORT Redo( void );
	extern SHORT RedoAll( void );
	extern SHORT RedoModification( void );

	extern SHORT ReplaceForward( void );
	extern SHORT ReplaceBackward( void );
	extern SHORT ReplaceAgain( void );

	extern SHORT SearchForward( void );
	extern SHORT SearchBackward( void );
	extern SHORT SearchAgain( void );

	extern void	 SbBrowseDefs( void );
	extern void	 SbBrowseRefs( void );
	extern void	 SbBrowseSymbolsDefinedInModule( void );
	extern void	 SbBrowseSymbolAtCursor( void );
	extern SHORT SbFindNext( void );
	extern SHORT SbFindPrev( void );
	extern SHORT SbGotoDef( void );
	extern SHORT SbGotoThisDef( PSZ pszSymbol );
	extern void  SbJumpBack( void );
	extern SHORT SbLoadDatabase( /* PSZ dbPathname (optional), SHORT replace (optional)*/);
	extern SHORT SbUnloadDatabase(void);

	extern SHORT SelfInsert( void );


	#define RE_SYNTAX_UNIX  0
	#define RE_SYNTAX_BRIEF 1
	/* if syntax is not specified UNIX syntax is used */
	extern SHORT SrchFwd(char *pattern, SHORT re, SHORT case_s, SHORT block, LONG *total_length, SHORT syntax);
	extern SHORT SrchBack(char *pattern, SHORT re, SHORT case_s, SHORT block, LONG *total_length, SHORT syntax);
	extern LONG  SrchString(char *pattern, char *str, LONG *length, SHORT re, SHORT case_s, SHORT sytax);
	extern LONG  Translate(char *pattern, char *replacement, SHORT global, SHORT re, SHORT case_s, SHORT block, SHORT dir, SHORT syntax);

	extern void 			SysBeep( ULONG frequency, ULONG duration );
	extern char 		  *SysQueryCaller( void );
	extern ULONG			SysQueryFlags(void);
	extern PFONTATTRIB	SysQueryFontSize(void);
	extern void 			SysSaveAll( void );
	extern SHORT 			SysSaveAndExit( void );
	extern SHORT			SysSetFlags(ULONG ulMask, ULONG ulNewSettings);
	extern SHORT 			SysSetHourglass( SHORT on_off);

	extern void  ToggleBackups( void );
	extern void  ToggleInsert( void );
	extern void  ToggleKeepTiled( void );
	extern void  ToggleKeepCascaded( void );
	extern void  ToggleTabs( void );

	extern SHORT	Undo( void );
	extern SHORT	UndoAll( void );
	extern SHORT	UndoModification( void );

	extern SHORT	WinAttachBuffer( HBUFFER );
	extern SHORT	WinAttachBufferToWindow( HBUFFER, HWINDOW );
	extern void		WinCascade( void );
	extern SHORT 	WinDeleteCurrentWindow( void);
	extern SHORT 	WinDeleteWindow( HWINDOW );
	extern void  	WinDeleteWindowAndBuffer( void );
	extern HWINDOW WinLoadFileInWindow( char *pathname, HWINDOW window);
	extern HWINDOW	WinNewWindow( void );
	extern void		WinNextWindow( void );
	extern HWINDOW	WinQueryCurrentWindow( void );
	extern void		WinQueryCursor( SHORT *x, SHORT *y );
	extern HWINDOW	WinQueryNextWindow( void );
	extern HWINDOW	WinQueryPrevWindow( void );
	extern void		WinPrevWindow( void );
	extern SHORT	WinScrollBottom( void );
	extern SHORT	WinScrollCenter( void );
	extern SHORT	WinScrollDown( LONG count );
	extern SHORT	WinScrollH( LONG count );
	extern SHORT	WinScrollLeft( LONG count);
	extern SHORT	WinScrollRight( LONG count );
	extern SHORT	WinScrollTop( void );
	extern SHORT	WinScrollUp( LONG count );
	extern SHORT	WinScrollV( LONG count );
	extern ULONG	WinSendMsg( HWND, USHORT, ULONG, ULONG );
	extern SHORT	WinSetWindow( HWINDOW );
	extern LONG		WinSetY( LONG new_y );
	/* PM CUA */
	extern void		WinMaximize(void);
	extern void		WinMinimize(void);
	extern void		WinMove(void);
	extern void		WinRestore(void);
	extern void		WinSize( void );
	extern void		WinSysMenu( void );
	extern void		WinMainHide( void );
	extern void		WinMainMaximize( void );
	extern void		WinMainMinimize( void );
	extern void		WinMainMove( void );
	extern void		WinMainRestore( void );
	extern void		WinMainSize( void );
	extern void		WinMainSysMenu( void );

	#define TILE_ACROSS	0
	#define TILE_DOWN		1
	extern void WinTile( SHORT orientation );
	extern void WinTileAcross( void );
	extern void WinTileDown( void );
	extern void WinTileWindows( void );
	extern void WinUpdateWindow( void );

	extern char * ltrim( char * );
	extern char * rtrim( char * );

	/* 'C' Runtime library interface */
	extern void abort(void);	/* Aborts macro execution & returns to top level of editor */
	extern int  atoi(char *);
	extern long atol(char *);
	extern char *itoa(int value, char *buffer, int radix);
	extern char *ltoa(long value, char *buffer, int radix);
	extern void *calloc( size_t, size_t );
	extern char *complete_path(char *pathname);
	extern void free( void * );
	extern char *getenv( char * );
	extern void *malloc( size_t );
	extern void *realloc( void *, size_t );
	extern void *memcpy( void *, void *, size_t );
	extern void *memset( void *, short, size_t );

	#define _MAX_DRIVE	3
	#define _MAX_DIR		256
	#define _MAX_FNAME	256
	#define _MAX_EXT		256
	#define _MAX_PATH		260
	extern void splitpath( char *pathname, char *drive, char *dir, char *fname, char *ext );

	extern long sprintf(char *buf, char *fmt, ...); /* up to ten more args allowed */
	extern char * strcat( char *, char * );
	extern char * strchr( char *, int );
	extern short  strcmp( char *, char * );
	extern short  stricmp( char *, char * );
	extern char * strcpy( char *, char * );
	extern size_t strcspn( char *, char * );
	extern char * strdup( char * );
	extern size_t strlen( char * );
	extern char * strlwr( char * );
	extern char * strncat( char *, char*, size_t );
	extern short  strncmp( char *, char *, size_t );
	extern short  strnicmp( char *, char *, size_t );
	extern char * strncpy( char *, char *, size_t );
	extern char * strpbrk( char *, char * );
	extern char * strrchr( char *, int);
	extern size_t strspn( char *, char * );
	extern char * strstr( char *, char * );
	extern long	strtol( char *, int );
	extern unsigned long strtoul( char *, int );
	extern char * strupr( char * );

	#ifdef INCL_IO

		#define O_WRONLY		0x0001L
		#define O_RDWR			0x0002L
		#define O_RDONLY		0x0004L
		#define O_APPEND		0x0008L
		#define O_NOINHERIT	0x0080L
		#define O_CREAT		0x0100L
		#define O_TRUNC		0x0200L
		#define O_EXCL			0x0400L
		#define O_TEXT			0x4000L
		#define O_BINARY		0x8000L

		#define SH_DENYRW		0x0010L	/* deny read or write access to others */
		#define SH_DENYWR		0x0020L	/* deny write access to others */
		#define SH_DENYRD		0x0030L	/* deny read access to others */
		#define SH_DENYNO		0x0040L	/* allow others to read or write */

		#define SEEK_SET		0x0000L	/* seek relative to start of file */
		#define SEEK_CUR		0x0001L	/* seek relative to current position */
		#define SEEK_END		0x0002L	/* seek relative to EOF */

		extern long errno;

		#define EACCES			0x0018L	/* access denied */
		#define EBADF			0x002BL	/* bad file handle */
		#define EEXIST			0x0010L	/* file already exists */
		#define EMFILE			0x0019L	/* out of file handles */
		#define EINVAL			0x0024L	/* invalid argument(s) passed */
		#define ENOCMD			0x001AL	/* could not find command processor */
		#define ENOENT			0x0017L	/* file not found */
		#define ENOMEM			0x000DL	/* insufficient memory */
		#define ENOSPC			0x002DL	/* disk is full */
		#define ERANGE			0x0002L	/* path is longer than length of buffer passed */
		#define EOSERR			0x003CL	/* operating system error occurred */

		#pragma pack(2)
		struct stat {
			short				st_dev;		/* Drive number */
			unsigned short	st_ino;
			unsigned short	st_mode;		/* see below */
			short				st_nlink;
			short				st_uid;
			short				st_gid;
			short				st_rdev;
			unsigned short	__pad;
			long				st_size;		/* size of file */
			long				st_atime;	/* last access time */
			long				st_mtime;	/* last modification time */
			long				st_ctime;	/* create time */
		};
		#pragma pack()
		/* values for st_mode */
		#define S_IEXEC	0x0040	/* has execute/search permission */
		#define S_IWRITE	0x0080	/* has write permission */
		#define S_IREAD	0x0100	/* has read permission */
		#define S_IFCHR	0x2000	/* a character device */
		#define S_IFDIR	0x4000	/* a directory */
		#define S_IFREG	0x8000	/* a regular file */

		extern long access(char *pathname, int mode);
		extern long chdir(char *pathname);
		extern long chdrive(int drive);
		extern long chmod(char *pathname, long pmode);
		extern long chsize(long hf, long size);
		extern long close(long hf);
		extern long creat(char *pathname, long pmode);
		extern long eof(long hf);
		extern long filelength(long hf);
		extern long fstat(long hf, struct stat *buffer);
		extern char *getcwd(char *pathname);
		extern int  getdrive(void);
		extern long lseek(long hf, long offset, long origin);
		extern long mkdir(char *pathname);
		extern long open(char *pathname, long oflags, long pmode);
		extern long read(long hf, void *pBuffer, size_t cBytes);
		extern long remove(char *pathname);
		extern long rmdir(char *pathname);
		extern long searchenv(char *name, char *env_var, char *pathbuf);
		extern long sopen(char *pathname, long oflags, long sflags, long pmode);
		extern long stat(char *pathname, struct stat *buffer);
		extern long tell(long hf);
		extern long write(long hf, void *pBuffer, size_t cBytes);
	#endif

	#define __HEX			0x0001U		/* hexadecimal */
	#define __DIGIT		0x0002U		/* decimal	  */
	#define __SPACE		0x0004U		/* space		 */
	#define __WHITESPACE 0x0008U		/* whitespace  */
	#define __PUNCT 		0x0010U		/* punctuation */
	#define __CTRL			0x0020U		/* control	  */
	#define __LOWER		0x0040U		/* lowercase	*/
	#define __UPPER		0x0080U		/* uppercase	*/
	#define __ALPHA		0x0100U		/* alphabetic  */

	#define __UPR_NDX	257
	#define __LWR_NDX	514
	extern unsigned short _ctype[];
	#define isalnum(c)	( _ctype[(c)] & (__ALPHA | __DIGIT) )
	#define isalpha(c)	( _ctype[(c)] & __ALPHA )
	#define iscntrl(c)	( _ctype[(c)] & __CTRL )
	#define isdigit(c)	( _ctype[(c)] & __DIGIT )
	#define isgraph(c)	( _ctype[(c)] & (__PUNCT | __ALPHA | __DIGIT) )
	#define islower(c)	( _ctype[(c)] & __LOWER )
	#define isprint(c)	( _ctype[(c)] & (__PUNCT | __ALPHA | __DIGIT | __SPACE) )
	#define ispunct(c)	( _ctype[(c)] & __PUNCT )
	#define isspace(c)	( _ctype[(c)] & __WHITESPACE )
	#define isupper(c)	( _ctype[(c)] & __UPPER )
	#define isxdigit(c)	( _ctype[(c)] & __HEX )
	#define tolower(c)	(short)( _ctype[(c) + __LWR_NDX] )
	#define toupper(c)	(short)( _ctype[(c) + __UPR_NDX] )
	#define _tolower(c)	( (c) + 'a' - 'A' )
	#define _toupper(c)	( (c) + 'A' - 'a' )
	#define isascii(c)	( (unsigned short)(c) < 0x80 )
	#define iscsymf(c)	( isalpha( c ) || (c) == '_' )
	#define iscsym(c)		( isalnum( c ) || (c) == '_' )
	#define toascii(c)	( (c) & 0x7f )

 #ifdef INCL_MENU
  #include "menu.h"
 #endif
 #ifdef INCL_EVENT
  #include "event.h"
 #endif
 #ifdef INCL_MOUSE
  #include "mouse.h"
 #endif

 #ifdef WINDOWS
  extern int printf( char *fmt, ... );
  extern PSZ PromptGetString( PSZ prompt, PSZ buffer, USHORT count );
  extern void PromptSetText( PSZ prompt );
  extern void PromptSetEditText( PSZ text );
  extern PSZ PromptGetText( PSZ buf, LONG buflen );
  extern PSZ PromptGetEditText( PSZ buf, LONG buflen );
 #endif /* WINDOWS */
#endif /* MACRO_H_INCLUDED */



/*
** End macro header: macro.h
*/
