home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / Processes.pm < prev    next >
Text File  |  1998-04-17  |  5KB  |  241 lines

  1.  
  2. =head1 NAME
  3.  
  4. Mac::Processes - Macintosh Toolbox Interface to Process Manager
  5.  
  6. =head1 SYNOPSIS
  7.  
  8.     use Mac::Processes;
  9.     
  10.     while ( ($psn, $psi) = each(%Process) ) {
  11.         print "$psn\t", $psi->processName, 
  12.         " ", $psi->processNumber,
  13.         " ", $psi->processType,
  14.         " ", $psi->processSignature,
  15.         " ", $psi->processSize,
  16.         " ", $psi->processMode,
  17.         " ", $psi->processLocation,
  18.         " ", $psi->processLauncher,
  19.         " ", $psi->processLaunchDate,
  20.         " ", $psi->processActiveTime,
  21.         " ", $psi->processAppSpec, "\n";
  22.     }
  23.  
  24. =head1 DESCRIPTION
  25.  
  26. Access to Inside Macintosh is essential for proper use of these functions.
  27. Explanations of terms, processes and procedures are provided there.
  28. Any attempt to use these functions without guidance can cause severe errors in 
  29. your machine, including corruption of data. B<You have been warned.>
  30.  
  31. =cut
  32.  
  33. use strict;
  34.  
  35. package Mac::Processes::_ProcessInfoMap;
  36.     
  37. package Mac::Processes;
  38.  
  39. BEGIN {
  40.     use Exporter   ();
  41.     use DynaLoader ();
  42.     
  43.     use vars qw(@ISA @EXPORT %Process);
  44.     
  45.     @ISA = qw(Exporter DynaLoader);
  46.     @EXPORT = qw(
  47.         LaunchApplication
  48.         LaunchDeskAccessory
  49.         GetCurrentProcess
  50.         GetFrontProcess
  51.         GetNextProcess
  52.         GetProcessInformation
  53.         SetFrontProcess
  54.         WakeUpProcess
  55.         SameProcess
  56.         ExitToShell
  57.         
  58.         %Process
  59.         
  60.         kNoProcess
  61.         kSystemProcess
  62.         kCurrentProcess
  63.         launchContinue
  64.         launchNoFileFlags
  65.         launchUseMinimum
  66.         launchDontSwitch
  67.         launchAllow24Bit
  68.         launchInhibitDaemon
  69.         modeDeskAccessory
  70.         modeMultiLaunch
  71.         modeNeedSuspendResume
  72.         modeCanBackground
  73.         modeDoesActivateOnFGSwitch
  74.         modeOnlyBackground
  75.         modeGetFrontClicks
  76.         modeGetAppDiedMsg
  77.         mode32BitCompatible
  78.         modeHighLevelEventAware
  79.         modeLocalAndRemoteHLEvents
  80.         modeStationeryAware
  81.         modeUseTextEditServices
  82.         modeDisplayManagerAware
  83.     );
  84. }
  85.  
  86. bootstrap Mac::Processes;
  87.  
  88. tie %Process, q(Mac::Processes::_ProcessInfoMap);
  89.  
  90. =head2 Constants
  91.  
  92. =over 4
  93.  
  94. =item kNoProcess
  95.  
  96. =item kSystemProcess
  97.  
  98. =item kCurrentProcess
  99.  
  100. Special process IDs.
  101.  
  102. =cut
  103. sub kNoProcess ()                    {          0; }
  104. sub kSystemProcess ()                {          1; }
  105. sub kCurrentProcess ()               {          2; }
  106.  
  107.  
  108. =item launchContinue
  109.  
  110. =item launchNoFileFlags
  111.  
  112. =item launchUseMinimum
  113.  
  114. =item launchDontSwitch
  115.  
  116. =item launchAllow24Bit
  117.  
  118. =item launchInhibitDaemon
  119.  
  120. Launch flags.
  121.  
  122. =cut
  123. sub launchContinue ()                {     0x4000; }
  124. sub launchNoFileFlags ()             {     0x0800; }
  125. sub launchUseMinimum ()              {     0x0400; }
  126. sub launchDontSwitch ()              {     0x0200; }
  127. sub launchAllow24Bit ()              {     0x0100; }
  128. sub launchInhibitDaemon ()           {     0x0080; }
  129.  
  130.  
  131. =item modeDeskAccessory
  132.  
  133. =item modeMultiLaunch
  134.  
  135. =item modeNeedSuspendResume
  136.  
  137. =item modeCanBackground
  138.  
  139. =item modeDoesActivateOnFGSwitch
  140.  
  141. =item modeOnlyBackground
  142.  
  143. =item modeGetFrontClicks
  144.  
  145. =item modeGetAppDiedMsg
  146.  
  147. =item mode32BitCompatible
  148.  
  149. =item modeHighLevelEventAware
  150.  
  151. =item modeLocalAndRemoteHLEvents
  152.  
  153. =item modeStationeryAware
  154.  
  155. =item modeUseTextEditServices
  156.  
  157. =item modeDisplayManagerAware
  158.  
  159. Mode flags in SIZE resource.
  160.  
  161. =cut
  162. sub modeDeskAccessory ()             { 0x00020000; }
  163. sub modeMultiLaunch ()               { 0x00010000; }
  164. sub modeNeedSuspendResume ()         { 0x00004000; }
  165. sub modeCanBackground ()             { 0x00001000; }
  166. sub modeDoesActivateOnFGSwitch ()    { 0x00000800; }
  167. sub modeOnlyBackground ()            { 0x00000400; }
  168. sub modeGetFrontClicks ()            { 0x00000200; }
  169. sub modeGetAppDiedMsg ()             { 0x00000100; }
  170. sub mode32BitCompatible ()           { 0x00000080; }
  171. sub modeHighLevelEventAware ()       { 0x00000040; }
  172. sub modeLocalAndRemoteHLEvents ()    { 0x00000020; }
  173. sub modeStationeryAware ()           { 0x00000010; }
  174. sub modeUseTextEditServices ()       { 0x00000008; }
  175. sub modeDisplayManagerAware ()       { 0x00000004; }
  176.  
  177. =back
  178.  
  179. =cut
  180.  
  181. package Mac::Processes::_ProcessInfoMap;
  182.  
  183. use Carp;
  184.  
  185. sub TIEHASH {
  186.     my($pack) = @_;
  187.     
  188.     bless \{}, $pack;
  189. }
  190.  
  191. sub FETCH {
  192.     my($self,$psn) = @_;
  193.     
  194.     Mac::Processes::GetProcessInformation($psn);
  195. }
  196.  
  197. sub FIRSTKEY {
  198.     Mac::Processes::GetNextProcess(0);
  199. }
  200.  
  201. sub NEXTKEY {
  202.     my($self,$psn) = @_;
  203.     
  204.     Mac::Processes::GetNextProcess($psn);
  205. }
  206.  
  207. sub DESTROY {
  208. }
  209.  
  210. sub STORE { croak "Can't change process info"; }
  211. sub DELETE { croak "Can't DELETE processes yet"; }
  212.  
  213. package LaunchParam;
  214.  
  215. sub new {
  216.     my $package = shift @_;
  217.     my $my = _new();
  218.     my ($arg,$value);
  219.     
  220.     while (($arg, $value) = splice(@_, 0, 2)) {
  221.         $my->$arg($value);
  222.     }
  223.     $my;
  224. }
  225.  
  226. =include Processes.xs
  227.  
  228. =head1 BUGS/LIMITATIONS
  229.  
  230. =head1 FILES
  231.  
  232. =head1 AUTHOR(S)
  233.  
  234. Matthias Ulrich Neeracher <neeri@iis.ee.ethz.ch> Author
  235.  
  236. Bob Dalgleish <bob.dalgleish@sasknet.sk.ca> Documenter
  237.  
  238. =cut
  239.  
  240. __END__
  241.