home *** CD-ROM | disk | FTP | other *** search
/ Executor 2.0 / executorv2.0.iso / pc / dos / extra / source / browser / browser.hqx / Browser / launch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-06  |  3.6 KB  |  144 lines

  1. #include "go.h"
  2. #include "xfer.h"
  3.  
  4. #ifndef THINK_C
  5. #include <Assembler.h>
  6. #include <Traps.h>
  7. #include <stdlib.h>
  8. #endif /* THINK_C */
  9. #include "launch.proto.h"
  10. #include "misc.proto.h"
  11.  
  12. static void adjust_sfpvars(const WDPBRec *wdpbrp, int vrefnum);
  13.  
  14. static void
  15. adjust_sfpvars (const WDPBRec * wdpbrp, int vrefnum)
  16. {
  17.   SFSaveDisk = -vrefnum;
  18.   CurDirStore = wdpbrp->ioWDDirID;
  19. }
  20.  
  21. void
  22. mylaunch (short vrefnum, long parid, Str255 s, int adjustflag)
  23. {
  24.   WDPBRec wdpb;
  25.   OSErr e1, e2;
  26.  
  27.   wdpb.ioNamePtr = (StringPtr) 0;
  28.   wdpb.ioVRefNum = vrefnum;
  29.   wdpb.ioWDDirID = parid;
  30.   wdpb.ioWDProcID = CREATOR;
  31.   e1 = PBOpenWD (&wdpb, false);
  32.   savestate ();
  33.   e2 = SetVol ((StringPtr) 0, wdpb.ioVRefNum);
  34.   if (e1 == noErr && e2 == noErr)
  35.     {
  36.       if (adjustflag)
  37.       adjust_sfpvars (&wdpb, vrefnum);
  38.       asm
  39.       {
  40.       move.l s, (a0)
  41.         clr.w 4 (a0)
  42.         _Launch
  43.       }
  44.     }
  45.   ParamText (s, (StringPtr) "\p could not be launched.", (StringPtr) "\p", (StringPtr) "\p");
  46.   StopAlert (FOUR_PARAM_ALERT, 0);
  47.   ExitToShell ();
  48. }
  49.  
  50. void
  51. launchapp (ControlHandle c)
  52. {
  53.   unsigned char state;
  54.   
  55.   state = HGetState((Handle) c);
  56.   HLock ((Handle) c);
  57.   mylaunch ((*(item **) (*c)->contrlData)->vrefnum,
  58.         (*(item **) (*c)->contrlData)->ioparid, (*c)->contrlTitle, true);
  59.   HSetState ((Handle) c, state);
  60. }
  61.  
  62. void
  63. launchcreator (ControlHandle c, short message)
  64. {
  65.   short hashval;
  66.   OSType csig;
  67.   applist **ah;
  68.   item **ih;
  69.   char *p;
  70.   OSErr e;
  71.   unsigned char state;
  72.   WDPBRec wdpb;
  73.   HParamBlockRec pb;
  74.   int adjust_flag;
  75.  
  76.   csig = (*(item **) (*c)->contrlData)->sig;
  77.   hashval = (unsigned long) csig % SIGARRAYSIZE;
  78.   for (ah = sigowners[hashval]; ah != 0 && (*ah)->sig != csig; ah = (*ah)->next)
  79.     ;
  80.   pb.fileParam.ioVRefNum = (*(item **) (*c)->contrlData)->vrefnum;
  81.   pb.fileParam.ioFDirIndex = 0;
  82.   pb.fileParam.ioDirID = (*(item **) (*c)->contrlData)->ioparid;
  83.   pb.fileParam.ioNamePtr = (*c)->contrlTitle;
  84.   e = PBHGetFInfo (&pb, false);
  85.   if (ah == 0)
  86.     {
  87.       if (e == noErr && (pb.fileParam.ioFlFndrInfo.fdType == 'TEXT'
  88.                          || pb.fileParam.ioFlFndrInfo.fdType == 'ttro'
  89.                          || pb.fileParam.ioFlFndrInfo.fdType == 'PICT'))
  90.     ah = sigowners[TEXTEDITORPOS];
  91.     }
  92.   if (ah != 0)
  93.     {
  94. #if 0
  95.       SetHandleSize (AppParmHandle, 14 + (*c)->contrlTitle[0]);
  96. #else /* 0 */
  97. #ifdef THINK_C
  98.       TheZone = SysZone;
  99.       AppParmHandle = NewHandle (14 + (*c)->contrlTitle[0]);
  100.       TheZone = ApplZone;
  101. #else
  102.       LMSetTheZone (LMGetSysZone ());
  103.       LMSetAppParmHandle (NewHandle (14 + (*c)->contrlTitle[0]));
  104.       LMSetTheZone (LMGetApplZone ());
  105. #endif
  106. #endif /* 0 */
  107.       if (MemError () == noErr)
  108.     {
  109.       ih = (item **) (*c)->contrlData;
  110.       state = HGetState (AppParmHandle);
  111.       HLock (AppParmHandle);
  112. #ifdef THINK_C
  113.       p = *AppParmHandle;
  114. #else
  115.       p = *LMGetAppParmHandle ();
  116. #endif
  117.       *(short *) p = message;
  118.       *(short *) (p + 2) = 1;
  119.       wdpb.ioNamePtr = (StringPtr) 0;
  120.       wdpb.ioVRefNum = (*(item **) (*c)->contrlData)->vrefnum;
  121.       wdpb.ioWDDirID = (*(item **) (*c)->contrlData)->ioparid;
  122.       wdpb.ioWDProcID = CREATOR;
  123.       e = PBOpenWD (&wdpb, false);
  124.       ((AppFile *) (p + 4))->vRefNum = wdpb.ioVRefNum;
  125.       ((AppFile *) (p + 4))->fType = pb.fileParam.ioFlFndrInfo.fdType;
  126.       ((AppFile *) (p + 4))->versNum = 0;
  127.       mystr255copy (((AppFile *) (p + 4))->fName, (*c)->contrlTitle);
  128.       adjust_sfpvars (&wdpb, (*(item **) (*c)->contrlData)->vrefnum);
  129.       adjust_flag = false;
  130.       HSetState (AppParmHandle, state);
  131.     }
  132.       else
  133.     adjust_flag = true;
  134.       mylaunch ((*ah)->vrefnum, (*ah)->parid, (*ah)->name, adjust_flag);
  135.     }
  136. }
  137.  
  138. void
  139. launchda (ControlHandle c)
  140. {
  141.   c = c;
  142. /* TODO */
  143. }
  144.