1 // CPS.h --  generously provided by Bob Ippolito (bob@redivi.com)
2 
3 #pragma once
4 
5 #include <Carbon/Carbon.h>
6 
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #if PRAGMA_STRUCT_ALIGN
13     #pragma options align=mac68k
14 #elif PRAGMA_STRUCT_PACKPUSH
15     #pragma pack(push, 2)
16 #elif PRAGMA_STRUCT_PACK
17     #pragma pack(2)
18 #endif
19 
20 
21 struct CPSProcessSerNum
22 {
23 	UInt32		lo;
24 	UInt32		hi;
25 };
26 
27 typedef struct CPSProcessSerNum	CPSProcessSerNum;
28 
29 enum
30 {
31 	kCPSNoProcess		=	0,
32 	kCPSSystemProcess	=	1,
33 	kCPSCurrentProcess	=	2
34 };
35 
36 
37 enum
38 {
39 	bfCPSIntraProcessSwitch =	1,
40 	bfCPSDeathBySignal	=	2
41 };
42 
43 typedef UInt16	CPSEventFlags;
44 
45 enum
46 {
47 	kCPSBlueApp	=	0,
48 	kCPSBlueBox	=	1,
49 	kCPSCarbonApp	=	2,
50 	kCPSYellowApp	=	3,
51 	kCPSUnknownApp	=	4
52 };
53 
54 typedef UInt32	CPSAppFlavour;
55 
56 
57 enum
58 {
59 	kCPSBGOnlyAttr		=	1024,
60 	kCPSUIElementAttr	=	65536,
61 	kCPSHiddenAttr		=	131072,
62 	kCPSNoConnectAttr	=	262144,
63 	kCPSFullScreenAttr	=	524288,
64 	kCPSClassicReqAttr	=	1048576,
65 	kCPSNativeReqAttr	=	2097152
66 };
67 
68 typedef UInt32	CPSProcAttributes;
69 
70 struct CPSProcessInfoRec
71 {
72 	CPSProcessSerNum 	Parent;
73 	UInt64			LaunchDate;
74 	CPSAppFlavour		Flavour;
75 	CPSProcAttributes	Attributes;
76 	UInt32			ExecFileType;
77 	UInt32			ExecFileCreator;
78 	UInt32			UnixPID;
79 };
80 
81 typedef struct CPSProcessInfoRec	CPSProcessInfoRec;
82 
83 enum
84 {
85 	kCPSNotifyChildDeath	=	1,
86 	kCPSNotifyNewFront	=	2,
87 	kCPSNotifyAppBirth	=	4,
88 	kCPSNotifyAppDeath	=	8,
89 	kCPSNotifyLaunch	=	9,
90 	kCPSNotifyServiceReq	=	16,
91 	kCPSNotifyAppHidden	=	32,
92 	kCPSNotifyAppRevealed	=	64,
93 	kCPSNotifyFGEnabled	=	128,
94 	kCPSNotifyLaunchStart	=	256,
95 	kCPSNotifyAppReady	=	512,
96 	kCPSNotifyLaunchFail	=	1024,
97 	kCPSNotifyAppDeathExt	=	2048,
98 	kCPSNotifyLostKeyFocus	=	4096
99 };
100 
101 typedef UInt32	CPSNotificationCodes;
102 
103 enum
104 {
105 	bfCPSLaunchInhibitDaemon	=	128,
106 	bfCPSLaunchDontSwitch		=	512,
107 	bfCPSLaunchNoProcAttr		=	2048,
108 	bfCPSLaunchAsync		=	65536,
109 	bfCPSLaunchStartClassic		=	131072,
110 	bfCPSLaunchInClassic		=	262144,
111 	bfCPSLaunchInstance		=	524288,
112 	bfCPSLaunchAndHide		=	1048576,
113 	bfCPSLaunchAndHideOthers	=	2097152
114 };
115 
116 typedef UInt32	CPSLaunchOptions;
117 typedef	UInt8	*CPSLaunchRefcon;
118 typedef	UInt8	*CPSLaunchData;
119 
120 enum
121 {
122 	bfCPSExtLaunchWithData	=	2,
123 	bfCPSExtLaunchByParent	=	4,
124 	bfCPSExtLaunchAsUidGid	=	8
125 };
126 
127 typedef UInt32	CPSLaunchPBFields;
128 
129 struct CPSLaunchPB
130 {
131 	CPSLaunchPBFields	Contents;
132 	CPSLaunchData		pData;
133 	UInt32			DataLen;
134 	UInt32			DataTag;
135 	UInt32			RefCon;
136 	CPSProcessSerNum	Parent;
137 	UInt32			ChildUID;
138 	UInt32			ChildGID;
139 };
140 
141 typedef struct CPSLaunchPB	CPSLaunchPB;
142 
143 
144 enum
145 {
146 	bfCPSKillHard		=	1,
147 	bfCPSKillAllClassicApps	=	2
148 };
149 
150 typedef UInt32	CPSKillOptions;
151 
152 
153 enum
154 {
155 	kCPSLaunchService	=	0,
156 	kCPSKillService		=	1,
157 	kCPSHideService		=	2,
158 	kCPSShowService		=	3,
159 	kCPSPrivService		=	4,
160 	kCPSExtDeathNoteService	=	5
161 };
162 
163 typedef UInt32	CPSServiceReqType;
164 
165 
166 struct CPSLaunchRequest
167 {
168 	CPSProcessSerNum	TargetPSN;
169 	CPSLaunchOptions 	Options;
170 	CPSProcAttributes 	ProcAttributes;
171 	UInt8			*pUTF8TargetPath;
172 	UInt32			PathLen;
173 };
174 
175 typedef struct CPSLaunchRequest	CPSLaunchRequest;
176 
177 
178 struct CPSKillRequest
179 {
180 	CPSProcessSerNum	TargetPSN;
181 	CPSKillOptions		Options;
182 };
183 
184 typedef struct CPSKillRequest	CPSKillRequest;
185 
186 
187 struct CPSHideRequest
188 {
189 	CPSProcessSerNum 	TargetPSN;
190 };
191 
192 typedef struct CPSHideRequest	CPSHideRequest;
193 
194 
195 struct CPSShowRequest
196 {
197 	CPSProcessSerNum 	TargetPSN;
198 };
199 
200 typedef struct CPSShowRequest	CPSShowRequest;
201 
202 
203 struct CPSExtDeathNotice
204 {
205 	CPSProcessSerNum 	DeadPSN;
206 	UInt32			Flags;
207 	UInt8			*pUTF8AppPath;
208 	UInt32			PathLen;
209 };
210 
211 typedef struct CPSExtDeathNotice	CPSExtDeathNotice;
212 
213 
214 union CPSRequestDetails
215 {
216 	CPSLaunchRequest 	LaunchReq;
217 	CPSKillRequest 		KillReq;
218 	CPSHideRequest 		HideReq;
219 	CPSShowRequest 		ShowReq;
220 	CPSExtDeathNotice 	DeathNotice;
221 };
222 
223 typedef union CPSRequestDetails	CPSRequestDetails;
224 
225 
226 struct CPSServiceRequest
227 {
228 	CPSServiceReqType 	Type;
229 	SInt32			ID;
230 	CPSRequestDetails 	Details;
231 };
232 
233 typedef struct CPSServiceRequest	CPSServiceRequest;
234 
235 
236 enum
237 {
238 	kCPSProcessInterruptKey	=	0,
239 	kCPSAppSwitchFwdKey	=	1,
240 	kCPSAppSwitchBackKey	=	2,
241 	kCPSSessionInterruptKey	=	3,
242 	kCPSScreenSaverKey	=	4,
243 	kCPSDiskEjectKey	=	5,
244 	kCPSSpecialKeyCount	=	6
245 };
246 
247 typedef SInt32	CPSSpecialKeyID;
248 
249 extern Boolean	CPSEqualProcess( CPSProcessSerNum *psn1, CPSProcessSerNum *psn2);
250 extern OSErr	CPSGetCurrentProcess( CPSProcessSerNum *psn);
251 extern OSErr	CPSGetFrontProcess( CPSProcessSerNum *psn);
252 extern OSErr	CPSGetNextProcess( CPSProcessSerNum *psn);
253 extern OSErr	CPSGetNextToFrontProcess( CPSProcessSerNum *psn);
254 extern OSErr	CPSGetProcessInfo( CPSProcessSerNum *psn, CPSProcessInfoRec *info, char *path, int maxPathLen, int *len, char *name, int maxNameLen);
255 extern OSErr	CPSPostHideMostReq( CPSProcessSerNum *psn);
256 extern OSErr	CPSPostHideReq( CPSProcessSerNum *psn);
257 extern OSErr	CPSPostKillRequest( CPSProcessSerNum *psn, CPSKillOptions options);
258 extern OSErr	CPSPostShowAllReq( CPSProcessSerNum *psn);
259 extern OSErr	CPSPostShowReq( CPSProcessSerNum *psn);
260 extern OSErr	CPSSetFrontProcess( CPSProcessSerNum *psn);
261 extern OSErr	CPSReleaseKeyFocus( CPSProcessSerNum *psn);
262 extern OSErr	CPSStealKeyFocus( CPSProcessSerNum *psn);
263 extern OSErr 	CPSSetProcessName ( CPSProcessSerNum *psn, char *processname);
264 extern OSErr 	CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
265 
266 
267 #if PRAGMA_STRUCT_ALIGN
268     #pragma options align=reset
269 #elif PRAGMA_STRUCT_PACKPUSH
270     #pragma pack(pop)
271 #elif PRAGMA_STRUCT_PACK
272     #pragma pack()
273 #endif
274 
275 #ifdef __cplusplus
276 }
277 #endif
278