Mac OS 9
Processes.h
Go to the documentation of this file.
1 
19 #ifndef __PROCESSES__
20 #define __PROCESSES__
21 
22 #ifndef __MACTYPES__
23 #include <MacTypes.h>
24 #endif
25 
26 #ifndef __EVENTS__
27 #include <Events.h>
28 #endif
29 
30 #ifndef __FILES__
31 #include <Files.h>
32 #endif
33 
34 #ifndef __TEXTCOMMON__
35 #include <TextCommon.h>
36 #endif
37 
38 #ifndef __CFSTRING__
39 #include <CFString.h>
40 #endif
41 
42 #if PRAGMA_ONCE
43 #pragma once
44 #endif
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif
50 
51 #if PRAGMA_IMPORT
52 #pragma import on
53 #endif
54 
55 #if PRAGMA_STRUCT_ALIGN
56 #pragma options align = mac68k
57 #elif PRAGMA_STRUCT_PACKPUSH
58 #pragma pack(push, 2)
59 #elif PRAGMA_STRUCT_PACK
60 #pragma pack(2)
61 #endif
62 
63  /* type for unique process identifier */
65  {
66  unsigned long highLongOfPSN;
67  unsigned long lowLongOfPSN;
68  };
71  enum
72  {
73  /* Process identifier - Various reserved process serial numbers */
74  kNoProcess = 0,
75  kSystemProcess = 1,
76  kCurrentProcess = 2
77  };
78 
79  /* Definition of the parameter block passed to _Launch */
80  /* Typedef and flags for launchControlFlags field*/
81  typedef unsigned short LaunchFlags;
82  enum
83  {
84  launchContinue = 0x4000,
85  launchNoFileFlags = 0x0800,
86  launchUseMinimum = 0x0400,
87  launchDontSwitch = 0x0200,
88  launchAllow24Bit = 0x0100,
89  launchInhibitDaemon = 0x0080
90  };
91 
92  /* Format for first AppleEvent to pass to new process. The size of the overall
93  buffer variable: the message body immediately follows the messageLength */
95  {
96  EventRecord theMsgEvent;
97  unsigned long eventRefCon;
98  unsigned long messageLength;
99  };
100  typedef struct AppParameters AppParameters;
102  /* Parameter block to _Launch */
104  {
105  unsigned long reserved1;
106  unsigned short reserved2;
107  unsigned short launchBlockID;
108  unsigned long launchEPBLength;
109  unsigned short launchFileFlags;
110  LaunchFlags launchControlFlags;
111  FSSpecPtr launchAppSpec;
112  ProcessSerialNumber launchProcessSN;
113  unsigned long launchPreferredSize;
114  unsigned long launchMinimumSize;
115  unsigned long launchAvailableSize;
116  AppParametersPtr launchAppParameters;
117  };
120  /* Set launchBlockID to extendedBlock to specify that extensions exist.
121  Set launchEPBLength to extendedBlockLen for compatibility.*/
122  enum
123  {
124  extendedBlock = 0x4C43, /* 'LC' */
125  extendedBlockLen = sizeof(LaunchParamBlockRec) - 12
126  };
127 
128  enum
129  {
130  /* Definition of the information block returned by GetProcessInformation */
131  modeReserved = 0x01000000,
132  modeControlPanel = 0x00080000,
133  modeLaunchDontSwitch = 0x00040000,
134  modeDeskAccessory = 0x00020000,
135  modeMultiLaunch = 0x00010000,
136  modeNeedSuspendResume = 0x00004000,
137  modeCanBackground = 0x00001000,
138  modeDoesActivateOnFGSwitch = 0x00000800,
139  modeOnlyBackground = 0x00000400,
140  modeGetFrontClicks = 0x00000200,
141  modeGetAppDiedMsg = 0x00000100,
142  mode32BitCompatible = 0x00000080,
143  modeHighLevelEventAware = 0x00000040,
144  modeLocalAndRemoteHLEvents = 0x00000020,
145  modeStationeryAware = 0x00000010,
146  modeUseTextEditServices = 0x00000008,
147  modeDisplayManagerAware = 0x00000004
148  };
149 
161  {
162  unsigned long processInfoLength;
163  StringPtr processName;
164  ProcessSerialNumber processNumber;
165  unsigned long processType;
166  OSType processSignature;
167  unsigned long processMode;
168  Ptr processLocation;
169  unsigned long processSize;
170  unsigned long processFreeMem;
171  ProcessSerialNumber processLauncher;
172  unsigned long processLaunchDate;
173  unsigned long processActiveTime;
174  FSSpecPtr processAppSpec;
175  };
176  typedef struct ProcessInfoRec ProcessInfoRec;
189  {
190  unsigned long processInfoLength;
191  StringPtr processName;
192  ProcessSerialNumber processNumber;
193  unsigned long processType;
194  OSType processSignature;
195  unsigned long processMode;
196  Ptr processLocation;
197  unsigned long processSize;
198  unsigned long processFreeMem;
199  ProcessSerialNumber processLauncher;
200  unsigned long processLaunchDate;
201  unsigned long processActiveTime;
202  FSSpecPtr processAppSpec;
203  unsigned long processTempMemTotal;
204  unsigned long processPurgeableTempMemTotal;
205  };
208  /* Record corresponding to the SIZE resource definition */
210  {
211  unsigned short flags;
212  unsigned long preferredHeapSize;
213  unsigned long minimumHeapSize;
214  };
215  typedef struct SizeResourceRec SizeResourceRec;
224  enum
225  {
226  kQuitBeforeNormalTimeMask = 1,
227  kQuitAtNormalTimeMask = 2,
228  kQuitBeforeFBAsQuitMask = 4,
229  kQuitBeforeShellQuitsMask = 8,
230  kQuitBeforeTerminatorAppQuitsMask = 16,
231  kQuitNeverMask = 32,
232  kQuitOptionsMask = 0x7F,
233  kQuitNotQuitDuringInstallMask = 0x0100,
234  kQuitNotQuitDuringLogoutMask = 0x0200
235  };
236 
245 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
246 #pragma parameter __D0 LaunchApplication(__A0)
247 #endif
248  OSErr
250 
251 #if CALL_NOT_IN_CARBON
260  OSErr
261  LaunchDeskAccessory(const FSSpec *pFileSpec, ConstStr255Param pDAName);
262 
263 #endif /* CALL_NOT_IN_CARBON */
264 
273 #if TARGET_OS_MAC
274 #define MacGetCurrentProcess GetCurrentProcess
275 #endif
276  OSErr
278 
290  OSErr
292 
317  OSErr
319 
328  OSErr
330 
365  OSErr
367 
400  OSErr
402 
433  OSErr
435  Boolean *result);
436 
437  /* ExitToShell was previously in SegLoad.h*/
446  void
447  ExitToShell(void);
448 
454 #if CALL_NOT_IN_CARBON
463  OSErr
464  LaunchControlPanel(const FSSpec *pFileSpec);
465 
466 #endif /* CALL_NOT_IN_CARBON */
467 
486  TextEncoding
488 
504  ScriptCode
506 
533  OSStatus
535 
565  OSStatus
566  CopyProcessName(const ProcessSerialNumber *psn, CFStringRef *name);
567 
568  /*************************************************************************
569  * Process Visibility.
570  *************************************************************************/
591  Boolean
593 
619  OSErr
621 
622  /* Values of the 'message' parameter to a Control Panel 'cdev' */
623  enum
624  {
625  initDev = 0, /*Time for cdev to initialize itself*/
626  hitDev = 1, /*Hit on one of my items*/
627  closeDev = 2, /*Close yourself*/
628  nulDev = 3, /*Null event*/
629  updateDev = 4, /*Update event*/
630  activDev = 5, /*Activate event*/
631  deactivDev = 6, /*Deactivate event*/
632  keyEvtDev = 7, /*Key down/auto key*/
633  macDev = 8, /*Decide whether or not to show up*/
634  undoDev = 9,
635  cutDev = 10,
636  copyDev = 11,
637  pasteDev = 12,
638  clearDev = 13,
639  cursorDev = 14
640  };
641 
642  /* Special values a Control Panel 'cdev' can return */
643  enum
644  {
645  cdevGenErr = -1, /*General error; gray cdev w/o alert*/
646  cdevMemErr = 0, /*Memory shortfall; alert user please*/
647  cdevResErr = 1, /*Couldn't get a needed resource; alert*/
648  cdevUnset = 3 /* cdevValue is initialized to this*/
649  };
650 
651  /* Control Panel Default Proc */
652  typedef CALLBACK_API(long, ControlPanelDefProcPtr)(
653  short message, short item, short numItems, short cPanelID,
654  EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);
655  typedef STACK_UPP_TYPE(ControlPanelDefProcPtr) ControlPanelDefUPP;
656 #if CALL_NOT_IN_CARBON
665  ControlPanelDefUPP
666  NewControlPanelDefUPP(ControlPanelDefProcPtr userRoutine);
667 #if !OPAQUE_UPP_TYPES
668  enum
669  {
670  uppControlPanelDefProcInfo = 0x000FEAB0
671  }; /* pascal 4_bytes Func(2_bytes, 2_bytes, 2_bytes, 2_bytes, 4_bytes, 4_bytes,
672  4_bytes) */
673 #ifdef __cplusplus
674  inline ControlPanelDefUPP
675  NewControlPanelDefUPP(ControlPanelDefProcPtr userRoutine)
676  {
677  return (ControlPanelDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine),
678  uppControlPanelDefProcInfo,
679  GetCurrentArchitecture());
680  }
681 #else
682 #define NewControlPanelDefUPP(userRoutine) \
683  (ControlPanelDefUPP) \
684  NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, \
685  GetCurrentArchitecture())
686 #endif
687 #endif
688 
697  void
698  DisposeControlPanelDefUPP(ControlPanelDefUPP userUPP);
699 #if !OPAQUE_UPP_TYPES
700 #ifdef __cplusplus
701  inline void DisposeControlPanelDefUPP(ControlPanelDefUPP userUPP)
702  {
703  DisposeRoutineDescriptor((UniversalProcPtr)userUPP);
704  }
705 #else
706 #define DisposeControlPanelDefUPP(userUPP) DisposeRoutineDescriptor(userUPP)
707 #endif
708 #endif
709 
718  long
719  InvokeControlPanelDefUPP(short message, short item, short numItems,
720  short cPanelID, EventRecord *theEvent, long cdevValue,
721  DialogPtr cpDialog, ControlPanelDefUPP userUPP);
722 #if !OPAQUE_UPP_TYPES
723 #ifdef __cplusplus
724  inline long InvokeControlPanelDefUPP(short message, short item, short numItems,
725  short cPanelID, EventRecord *theEvent,
726  long cdevValue, DialogPtr cpDialog,
727  ControlPanelDefUPP userUPP)
728  {
729  return (long)CALL_SEVEN_PARAMETER_UPP(userUPP, uppControlPanelDefProcInfo,
730  message, item, numItems, cPanelID,
731  theEvent, cdevValue, cpDialog);
732  }
733 #else
734 #define InvokeControlPanelDefUPP(message, item, numItems, cPanelID, theEvent, \
735  cdevValue, cpDialog, userUPP) \
736  (long)CALL_SEVEN_PARAMETER_UPP((userUPP), uppControlPanelDefProcInfo, \
737  (message), (item), (numItems), (cPanelID), \
738  (theEvent), (cdevValue), (cpDialog))
739 #endif
740 #endif
741 
742 #endif /* CALL_NOT_IN_CARBON */
743 
744 #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
745 /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
746 #define NewControlPanelDefProc(userRoutine) NewControlPanelDefUPP(userRoutine)
747 #define CallControlPanelDefProc(userRoutine, message, item, numItems, \
748  cPanelID, theEvent, cdevValue, cpDialog) \
749  InvokeControlPanelDefUPP(message, item, numItems, cPanelID, theEvent, \
750  cdevValue, cpDialog, userRoutine)
751 #endif /* CALL_NOT_IN_CARBON */
752 
753 #if PRAGMA_STRUCT_ALIGN
754 #pragma options align = reset
755 #elif PRAGMA_STRUCT_PACKPUSH
756 #pragma pack(pop)
757 #elif PRAGMA_STRUCT_PACK
758 #pragma pack()
759 #endif
760 
761 #ifdef PRAGMA_IMPORT_OFF
762 #pragma import off
763 #elif PRAGMA_IMPORT
764 #pragma import reset
765 #endif
766 
767 #ifdef __cplusplus
768 }
769 #endif
770 
771 #endif /* __PROCESSES__ */
772 * /*/*/ */*/
Event Manager Interfaces.
File Manager (MFS, HFS, and HFS+) Interfaces.
Basic Macintosh data types.
unsigned char * StringPtr
Definition: MacTypes.h:477
unsigned char Boolean
Definition: MacTypes.h:318
void DisposeRoutineDescriptor(UniversalProcPtr theUPP)
#define STACK_UPP_TYPE(name)
Definition: MixedMode.h:734
UniversalProcPtr NewRoutineDescriptor(ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA)
OSErr SameProcess(const ProcessSerialNumber *PSN1, const ProcessSerialNumber *PSN2, Boolean *result)
Compare two process serial numbers.
OSErr GetProcessInformation(const ProcessSerialNumber *PSN, ProcessInfoRec *info)
OSErr GetFrontProcess(ProcessSerialNumber *PSN)
Get serial number of foreground process.
Boolean IsProcessVisible(const ProcessSerialNumber *psn)
OSStatus GetProcessBundleLocation(const ProcessSerialNumber *psn, FSRef *location)
OSErr LaunchApplication(LaunchPBPtr LaunchParams)
OSErr MacGetCurrentProcess(ProcessSerialNumber *PSN)
OSErr ShowHideProcess(const ProcessSerialNumber *psn, Boolean visible)
void DisposeControlPanelDefUPP(ControlPanelDefUPP userUPP)
ControlPanelDefUPP NewControlPanelDefUPP(ControlPanelDefProcPtr userRoutine)
long InvokeControlPanelDefUPP(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog, ControlPanelDefUPP userUPP)
OSStatus CopyProcessName(const ProcessSerialNumber *psn, CFStringRef *name)
void ExitToShell(void)
OSErr GetNextProcess(ProcessSerialNumber *PSN)
Get the process serial number of the next process.
OSErr LaunchDeskAccessory(const FSSpec *pFileSpec, ConstStr255Param pDAName)
ScriptCode GetApplicationScript(void)
OSErr WakeUpProcess(const ProcessSerialNumber *PSN)
Make a process eligible to receive CPU time.
TextEncoding GetApplicationTextEncoding(void)
OSErr LaunchControlPanel(const FSSpec *pFileSpec)
OSErr SetFrontProcess(const ProcessSerialNumber *PSN)
Make a process the foreground process.
TextEncoding-related types and constants, and prototypes for related functions.
Definition: Processes.h:95
Definition: Events.h:224
Definition: Files.h:6527
Definition: Quickdraw.h:1648
Definition: Processes.h:104
Definition: Processes.h:189
Definition: Processes.h:161
Definition: Processes.h:65
Definition: Processes.h:210