

  tmsAPI.h

  ^{Mods:  }
  

  Mon Jul 27 13:58:00 1992, Rev 10.0, aam
   Added support for changing the parent of a TMS child task.
   For use by Presentation Manager only.

  Fri Jul  8 11:37:00 1992, Rev 9.0, aam
   Comments to various TMS structures for ease of use.

  Fri May  8 14:16:00 1992, Rev 8.0, aam
   Added request code rcTMSSwitchToTask and TMSSwitchToTaskType.

  Mon May  4 17:45:17 1992, Rev 7.0, jay(0108)
   If a task is being invoked without a custom environment, it does not
   require EVS to be installed.
  
  Mon May  4 15:44:52 1992, Rev 6.0, jay(0108)
   Rollback TMSLockContext mechanism; changing to TMSCM implementation.
  
  Wed Apr 22 17:59:03 1992, Rev 5.0, jay(0108)
   Allow context lock only when the originator is in the forground  i.e.,
   owns the video.
  
  Mon Apr 13 15:27:30 1992, Rev 4.0, jay(0108)
   Implement TMSLockContext; merge new request codes; obsolete pipe mechanism
   used during the merge of TMPWBS; merge new error codes.
  
  Fri Mar  6 11:12:00 1992, Rev 3.0, jay(0108)
   Aligned TMSVersion with previous TMVersion request  swapped places
   with TMSInvokeTask  to facilitate runtime verification of proper
   system service support.
  
  Thu Feb 27 16:21:34 1992, Rev 2.0, jay(0108)
   Minor syntax tweaks.
  
  Mon Feb 24 17:47:27 1992, Rev 1.0, jay(0108)
   After porting from HC to MSC, implementing the pseudopipe support needed
   for the MSC 6.1 toolset, merging TM and PWBS to allow peaceful co
   existence of PM and MSC at common beta sites, the source baseline for
   Task Management Service (TMS) is finally being placed under source
   control.



typedef struct
{
	Uchar sbPartitionName[13];	 partition name.  if the size byte is zero,
								 defaults to TaskNN (where NN is 00 to
								 nPartitionsMax.
	Ulong qParagraphs;			 partition size in paragraphs.
	Ushort wPartitionType;		 CTOSbased partition type.
	Uchar sbFileSpec[79];		 The run file specification.
	Uchar sbPassword[13];		 The run file password.
	Ushort wPriority;			 priority at which the task is to be started.
}
TaskInfoType;		 used when a TMS task is started using TMSInvoke() call.

typedef struct
{
	Uchar	sbPartitionName[13];	 partition name.  if the size byte is 0,
									 defaults to TaskNN (where NN is 00 to
									 nPartitionsMax.
	Ulong	qParagraphs;			 partition size in paragraphs.
	Ushort	wPartitionType;			 CTOSbased partition type.
	Uchar	sbFileSpec[79];			 The run file specification.
	Uchar	sbPassword[13];			 The run file password.
	Ushort	wPriority;				 priority at which the task is to be
									 started.
	Uchar	sbVolume[13];			 the default volume of the new task.
	Uchar	sbDirectory[13];		 the default directory of the new task.
	Uchar	sbPrefix[13];			 the default file prefix of the new task.
	Uchar	sbNode[13];				 the default node of the new task.
	Ushort	contextAttrs;			 attributes of the context.
	Uchar	fDirty;					 set to TRUE, if the application should
									 only run when it is in foreground.
	Uchar	fNeedsExecScreen;		 set to TRUE if the application requires
									 the video to be initialized with frames
									 as though it had been invoked from the
									 Executive.
	Ushort	defaultColor;			 default color for the CM task.
}
cmTaskInfoType;		 used when a CM task is started using TMSInvoke() call.
					 This allows users to start CM contexts from TMS, if
					 context manager is installed.  The fields defined in
					 cmTaskInfoType are similar to the CMBlock structure
					 used in starting a CM context using the 
					 CMStartApplByBlock() call.  Refer to the context manager
					 reference manual for more details.  This feature is
					 supported only with Context Manager 4.1 and above.

typedef struct
{
	Ushort ercTermination;	 child task termination erc.
	Ushort wStatus;			 child task status, set in ASCB by some 
							 applications.
}
StatusInfoType;

typedef struct
{
	Ushort thParent;
	Ushort thChild;
}
PCInfoType;



 Values for 'typeInvoke'.
define runSync				0	 The parent is suspended until the child
								 task terminates.  Upon termination of the
								 child, the parent will receive termination
								 status of the child task.  If the parent
								 task terminates, the child task is also
								 terminated.

define runAsync			1	 The child task executes asynchronously to
								 the parent task.  The child's task handle is
								 returned to the parent.  If the child task
								 is successfully loaded no termination status
								 is returned to the parent, although the
								 parent may later query information about the
								 child while the child is active.  No
								 termination information is available to the 
								 parent after the child terminates.  If the
								 parent task terminates, the child task is
								 also terminated.

define runAsyncResults		2	 The child task executes asynchronously to
								 the parent task.  The child's task handle is
								 returned to the parent.  If the child task
								 is successfully loaded no termination status
								 is returned to the parent.  After the child
								 terminates, the parent may query TMS to
								 obtain the termination information (via the
								 TMSQueryTask() call).  Once the information
								 is queried, the task handle is invalidated.
								 If the parent task terminates, the child 
								 task is also terminated.

define runDebug			3	 The CTOS debugger is entered so that the 
								 child task may be debugged.  If the parent
								 task terminates, the child task is also
								 terminated.

define runBackground		4	 The child task executes asynchronously to
								 the parent.  If the parent task terminates
								 or is terminated, the child task continues
								 to run.

define runLoad				5	 The child task is loaded and suspended.
								 If the parent task terminates, the child
								 is also terminated.

define runDebugTree		6	 reserved.

 Masks for 'typeInvoke'.
define mRunTypeIO	(mRunTypeKBD|mRunTypeVID|mRunTypeEXEC|mRunTypeCODEVIEW|mRunTypeCM)
define mRunTypeKBD			0x8000	 reserved.  used by Microsoft C
define mRunTypeVID			0x4000	 reserved.  used by Microsoft C
define mRunTypeEXEC		0x2000	 reserved.  used by Microsoft C
define mRunTypeCODEVIEW	0x1000	 reserved.  used by Microsoft C
define mRunTypeCM			0x800	 for starting CM contexts using the
									 TMSInvokeTask() call.  The valid values
									 of typeInvoke, if this mask is set are
									 runAsync and runAsyncResults

 Masks for 'IOStatus'.
define mIOPending			(mIOPendingInput|mIOPendingOutput)
define mIOPendingInput		0x0001
define mIOPendingOutput	0x0002

 Values for 'typeQuery'.
define typeTerminationCheck	0
define typeTerminationWait		1

 Values for 'typeControl'.
define typeResumeTask			0
define typeSuspendTask			1



define ercNoRoomAvailable		850U
define ercParentVacated		851U
define ercInvalidTaskHandle	852U
define ercTaskNotFound			853U
define ercChildIsDead			854U
define ercChildIsNotDead		855U
define ercInvalidType			856U

define ercEVSNotAvailable		35161U
define ercStatusUnavailable	35162U
define ercInvalidTMSTask		35163U
define ercCannotSetParentTh	35164U
define ercTMS_35165_TBD		35165U
define ercTMS_35166_TBD		35166U
define ercTMS_35167_TBD		35167U
define ercTMS_35168_TBD		35168U
define ercTMS_35169_TBD		35169U
define ercTMS_35170_TBD		35170U



define rcTMSSwap				0x9047
define rcTMSAbortTerm			0x9048
define rcTMS_x9049_TBD			0x9049

define rcTypeWsAbort			8200

define rcTMSInvokeTask			0x81D8
define rcTMSVersion			0x81D9
define rcTMSQueryTask			0x81DA
define rcTMSControlTask		0x81DB
define rcTMSTerminateTask		0x81DC
define rcTMSMapThToUserNum		0x81DD
define rcTMSMapUserNumToTh		0x81DE
define rcTMSQueryRelations		0x81DF
define rcTMSRegisterTask		0x81E0

define rcTMSQueryIOStatus		0x6647
define rcTMSReadOutput			0x6648
define rcTMSWriteInput			0x6649
define rcTMSSwitchToTask		0x664A
define rcTMSSetParent			0x664B
define rcTMS_x664C_TBD			0x664C
define rcTMS_x664D_TBD			0x664D
define rcTMS_x664E_TBD			0x664E
define rcTMS_x664F_TBD			0x664F
define rcTMS_x6650_TBD			0x6650
define rcTMS_x6651_TBD			0x6651
define rcTMS_x6652_TBD			0x6652
define rcTMS_x6653_TBD			0x6653



extern Ushort _CTOSENTRY_
TMSInvokeTask(Ushort _far* pThRet, TaskInfoType _far* pTaskInfo,
	Ushort sTaskInfo, void _far* pVLPB, Ushort typeInvoke,
	Uchar _far* pbEnviron, Ushort cbEnviron,
	StatusInfoType _far* pStatusInfoRet, Ushort sStatusInfoRetMax);

extern Ushort _CTOSENTRY_
TMSVersion(Ushort _far* pwVersionRet, Ushort _far* pwRevisionRet);

extern Ushort _CTOSENTRY_
TMSQueryTask(Ushort th, Ushort typeQuery, StatusInfoType _far* pStatusInfoRet,
	Ushort sStatusInfoRetMax);

extern Ushort _CTOSENTRY_
TMSControlTask(Ushort th, Ushort typeControl);

extern Ushort _CTOSENTRY_
TMSTerminateTask(Ushort th, Uchar fTerminateChildren);

extern Ushort _CTOSENTRY_
TMSMapThToUserNum(Ushort thToMap, Ushort _far* pUserNumRet);

extern Ushort _CTOSENTRY_
TMSMapUserNumToTh(Ushort userNumToMap, Ushort _far* pThRet);

extern Ushort _CTOSENTRY_
TMSQueryRelations(Ushort th, PCInfoType _far* pPCInfoRet);

extern Ushort _CTOSENTRY_
TMSRegisterTask(Ushort userNum, Ushort _far* pThRet);

extern Ushort _CTOSENTRY_
TMSSetParent(Ushort thChild, Ushort thNewParent);

extern Ushort _CTOSENTRY_
TMSQueryIOStatus(Ushort th, Ushort _far* pIOStatusRet);

extern Ushort _CTOSENTRY_
TMSReadOutput(Ushort th, Uchar fWait, Uchar _far* pBufferRet,
	Ushort sBufferRetMax, Ushort _far* pcbTransferRet);

extern Ushort _CTOSENTRY_
TMSWriteInput(Ushort th, Uchar fWait, Uchar _far* pBuffer, Ushort sBuffer,
	Ushort _far* pcbTransferRet);



	WsAbort, Termination, and Swapping.
typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort type;
}
TMSSystemType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort typeInvoke;
	Uchar rgbUnused[4];
	TaskInfoType _far* pTaskInfo;
	Ushort sTaskInfo;
	void _far* pVLPB;
	Ushort sVLPB;
	Uchar _far* pbEnviron;
	Ushort cbEnviron;
	StatusInfoType _far* pStatusInfoRet;
	Ushort sStatusInfoRetMax;
	Ushort _far* pThRet;
	Ushort sThRet;
}
TMSInvokeTaskType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Uchar rgbUnused[6];
	Ushort _far* pwVersionRet;
	Ushort swVersionRet;
	Ushort _far* pwRevisionRet;
	Ushort swRevisionRet;
}
TMSVersionType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Ushort typeQuery;
	Uchar rgbUnused[2];
	StatusInfoType _far* pStatusInfoRet;
	Ushort sStatusInfoRetMax;
}
TMSQueryTaskType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Ushort typeControl;
	Uchar rgbUnused[2];
}
TMSControlTaskType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Uchar fTerminateChildren;
	Uchar rgbUnused[3];
}
TMSTerminateTaskType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort thToMap;
	Uchar rgbUnused[4];
	Ushort _far* pUserNumRet;
	Ushort sUserNumRet;
}
TMSMapThToUserNumType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort userNumToMap;
	Uchar rgbUnused[4];
	Ushort _far* pThRet;
	Ushort sThRet;
}
TMSMapUserNumToThType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Uchar rgbUnused[4];
	PCInfoType _far* pPCInfoRet;
	Ushort sPCInfoRet;
}
TMSQueryRelationsType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort userNumToRegister;
	Uchar rgbUnused[4];
	Ushort _far* pThRet;
	Ushort sThRet;
}
TMSRegisterTaskType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Uchar rgbUnused[4];
	Ushort _far* pIOStatusRet;
	Ushort sIOStatusRet;
}
TMSQueryIOStatusType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Uchar fWait;
	Uchar rgbUnused[3];
	Uchar _far* pBufferRet;
	Ushort sBufferRetMax;
	Ushort _far* pcbTransferRet;
	Ushort scbTransferRet;
}
TMSReadOutputType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort th;
	Uchar fWait;
	Uchar rgbUnused[3];
	Uchar _far* pBuffer;
	Ushort sBuffer;
	Ushort _far* pcbTransferRet;
	Ushort scbTransferRet;
}
TMSWriteInputType;

typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort thFrom;
	Ushort thTo;
	Ushort reserved;
	Uchar _far *prgpRealScreenLine;
	Ushort cbrgpRealScreenLine;
}
TMSSwitchToTaskType;


typedef struct
{
	Uchar sCntInfo;
	Uchar rtCode;
	Uchar nReqPbCb;
	Uchar nRespPbCb;
	Ushort userNum;
	Ushort exchResp;
	Ushort ercRet;
	Ushort rqCode;
	Ushort thChild;
	Ushort thNewParent;
}
TMSSetParentType;
sk(Ushort th, Ushort typeControl);

extern Ushort _CTOSENTRY_
TMSTerminateTask(Ushort th, Uchar fTerminateChildren);

extern Ushort _CTOSENTRY_
TMSMapThToUserNum(Ushort thToMap, Ushort _