/*
	File:		Devices.h

	Copyright:	© 1984-1993 by Apple Computer, Inc., all rights reserved.

	WARNING
	This file was auto generated by the interfacer tool. Modifications
	must be made to the master file.

*/

#ifndef __DEVICES__
#define __DEVICES__

#ifndef __OSUTILS__
#include <OSUtils.H>
#endif

#ifndef __FILES__
#include <Files.H>
#endif

#ifndef __QUICKDRAW__
#if LONG_FILENAMES
#include <Quickdraw.H>
#else
#include <Quickdra.H>
#endif
#endif

#ifndef __EVENTS__
#include <Events.H>
#endif

#ifndef __DIALOGS__
#include <Dialogs.H>
#endif

#if PRAGMA_IMPORT
#pragma import on
#endif

#if PRAGMA_STRUCT_ALIGN
	#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
	#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
	#pragma pack(2)
#endif
enum  {
	newSelMsg			= 12,
	fillListMsg			= 13,
	getSelMsg			= 14,
	selectMsg			= 15,
	deselectMsg			= 16,
	terminateMsg			= 17,
	buttonMsg			= 19,
	chooserID			= 1,
	initDev			= 0,			/*Time for cdev to initialize itself*/
	hitDev			= 1,			/*Hit on one of my items*/
	closeDev			= 2,			/*Close yourself*/
	nulDev			= 3,			/*Null event*/
	updateDev			= 4,			/*Update event*/
	activDev			= 5,			/*Activate event*/
	deactivDev			= 6,			/*Deactivate event*/
	keyEvtDev			= 7,			/*Key down/auto key*/
	macDev			= 8,			/*Decide whether or not to show up*/
	undoDev			= 9,
	cutDev			= 10,
	copyDev			= 11
};

enum  {
	pasteDev			= 12,
	clearDev			= 13,
	cursorDev			= 14,
	cdevGenErr			= -1,			/*General error; gray cdev w/o alert*/
	cdevMemErr			= 0,			/*Memory shortfall; alert user please*/
	cdevResErr			= 1,			/*Couldn't get a needed resource; alert*/
	cdevUnset			= 3,			/* cdevValue is initialized to this*/
/* Monitors control panel messages */
	initMsg			= 1,			/*initialization*/
	okMsg			= 2,			/*user clicked OK button*/
	cancelMsg			= 3,			/*user clicked Cancel button*/
	hitMsg			= 4,			/*user clicked control in Options dialog*/
	nulMsg			= 5,			/*periodic event*/
	updateMsg			= 6,			/*update event*/
	activateMsg			= 7,			/*not used*/
	deactivateMsg			= 8,			/*not used*/
	keyEvtMsg			= 9,			/*keyboard event*/
	superMsg			= 10,			/*show superuser controls*/
	normalMsg			= 11,			/*show only normal controls*/
	startupMsg			= 12			/*code has been loaded*/
};

struct DCtlEntry {
	Ptr			dCtlDriver;
	short			dCtlFlags;
	QHdr			dCtlQHdr;
	long			dCtlPosition;
	Handle			dCtlStorage;
	short			dCtlRefNum;
	long			dCtlCurTicks;
	WindowPtr			dCtlWindow;
	short			dCtlDelay;
	short			dCtlEMask;
	short			dCtlMenu;
};
typedef struct DCtlEntry DCtlEntry;

typedef DCtlEntry *DCtlPtr, **DCtlHandle;

struct AuxDCE {
	Ptr			dCtlDriver;
	short			dCtlFlags;
	QHdr			dCtlQHdr;
	long			dCtlPosition;
	Handle			dCtlStorage;
	short			dCtlRefNum;
	long			dCtlCurTicks;
	GrafPtr			dCtlWindow;
	short			dCtlDelay;
	short			dCtlEMask;
	short			dCtlMenu;
	char			dCtlSlot;
	char			dCtlSlotId;
	long			dCtlDevBase;
	Ptr			dCtlOwner;
	char			dCtlExtDev;
	char			fillByte;
};
typedef struct AuxDCE AuxDCE;

typedef AuxDCE *AuxDCEPtr, **AuxDCEHandle;

typedef long (pascal *ControlPanelDefProcPtr)(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);

#define	uppControlPanelDefProcInfo	\
		( kPascalStackBased \
		| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
		| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))) \
		| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
		| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short))) \
		| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))) \
		| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(EventRecord*))) \
		| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long))) \
		| STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DialogPtr))) )

#if USESROUTINEDESCRIPTORS
typedef UniversalProcPtr ControlPanelDefUPP;

#define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)		\
		CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlPanelDefProcInfo, (message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
#define NewControlPanelDefProc(userRoutine)		\
		(ControlPanelDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, GetCurrentISA())
#else
typedef ControlPanelDefProcPtr ControlPanelDefUPP;

#define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)		\
		(*(userRoutine))((message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
#define NewControlPanelDefProc(userRoutine)		\
		(ControlPanelDefUPP)(userRoutine)
#endif

#ifdef __cplusplus
extern "C" {
#endif

extern DCtlHandle pascal GetDCtlEntry(short refNum);

/*
	SetChooserAlert used to simply set a bit in a low-mem global
	to tell the Chooser not to display its warning message when
	the printer is changed. However, under MultiFinder and System 7,
	this low-mem is swapped out when a layer change occurs, and the
	Chooser never sees the change. It is obsolete, and completely
	unsupported on the PowerPC. 68K apps can still call it if they
	wish.
*/

#if defined(OBSOLETE) && !defined(powerc) && !defined(__powerc)
extern Boolean pascal SetChooserAlert(Boolean f);
#endif

extern OSErr pascal DrvrInstall(Handle drvrHandle, short refNum);
extern OSErr pascal DrvrRemove(short refNum);
extern OSErr pascal OpenDrive(ConstStr255Param name, short *drvrRefNum);
extern OSErr opendriver(char *driverName, short *refNum);
extern OSErr pascal CloseDrive(short refNum);
extern OSErr pascal Control(short refNum, short csCode, const void *csParamPtr);
extern OSErr pascal Status(short refNum, short csCode, void *csParamPtr);
extern OSErr pascal KillIO(short refNum);

extern OSErr pascal PBControlSync(ParmBlkPtr paramBlock);

extern OSErr pascal PBControlAsync(ParmBlkPtr paramBlock);

extern OSErr pascal PBControlImmed(ParmBlkPtr paramBlock);

extern OSErr pascal PBStatusSync(ParmBlkPtr paramBlock);

extern OSErr pascal PBStatusAsync(ParmBlkPtr paramBlock);

extern OSErr pascal PBStatusImmed(ParmBlkPtr paramBlock);

extern OSErr pascal PBKillIOSync(ParmBlkPtr paramBlock);

extern OSErr pascal PBKillIOAsync(ParmBlkPtr paramBlock);

extern OSErr pascal PBKillIOImmed(ParmBlkPtr paramBlock);

#if WINVER
F_PASCAL( OSErr ) PBControl(ParmBlkPtr paramBlock,Boolean async); 
F_PASCAL( OSErr ) PBStatus(ParmBlkPtr paramBlock,Boolean async); 
F_PASCAL( OSErr ) PBKillIO(ParmBlkPtr paramBlock,Boolean async); 
#else
#define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
#define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
#define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
#endif

#if PRAGMA_STRUCT_ALIGN
	#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
	#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
	#pragma pack()
#endif

#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif

#endif


