home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 552.lha / ParM_v3.0 / source.LZH / source / Startup.c < prev   
C/C++ Source or Header  |  1991-03-30  |  2KB  |  92 lines

  1. /*
  2.  *    Startup.c - Copyright © 1991 by S.R. & P.C.
  3.  *
  4.  *    Created:    18 Feb 1991  11:36:37
  5.  *    Modified:    30 Mar 1991  13:31:10
  6.  *
  7.  *    Make>> make
  8.  */
  9.  
  10. #include "ParMBase.h"
  11.  
  12.  
  13. extern struct ExecBase *SysBase;
  14. extern struct Library  *DOSBase;
  15.  
  16. struct ParMBase *ParMBase;
  17. struct ArpBase *ArpBase;
  18. struct ReqLib  *ReqBase;
  19. struct IconBase *IconBase;
  20. struct IntuitionBase *IntuitionBase;
  21. struct WBStartup *WBenchMsg;
  22. int _argc;
  23. char **_argv;
  24.  
  25.  
  26. long DosWrite(BPTR file, char *buffer, long length);
  27. #pragma amicall(DOSBase, 0x30, DosWrite(d1,d2,d3))
  28.  
  29. int main(int argc, char **argv);
  30.  
  31.  
  32. void exit(int code)
  33. {
  34.     if (WBenchMsg)
  35.     {
  36.         Forbid();
  37.         ReplyMsg((struct Message *)WBenchMsg);
  38.     }
  39.     CloseLibrary(ParMBase);
  40.     Exit(code);
  41. }
  42.  
  43.  
  44. void _main(long alen, char *aptr)
  45. {
  46.     struct Library *DOSBase;
  47.     struct Process *pp;
  48.  
  49.     pp = (struct Process *)SysBase->ThisTask;
  50.     if (!pp->pr_CLI) {
  51.         WaitPort(&pp->pr_MsgPort);
  52.         WBenchMsg = (struct WBStartup *)GetMsg(&pp->pr_MsgPort);
  53.     }
  54.     if (!(ParMBase = (struct ParMBase *)OpenLibrary("parm.library",1L))) {
  55.         if (pp->pr_CLI && (DOSBase = OpenLibrary("dos.library",0L))) {
  56.             DosWrite(pp->pr_COS, "You need parm.library V1+\n", 26L);
  57.             CloseLibrary(DOSBase);
  58.         }
  59.         if (WBenchMsg) {
  60.             Forbid();
  61.             ReplyMsg((struct Message *)WBenchMsg);
  62.         }
  63.         return;
  64.     }
  65.     ArpBase = ParMBase->ArpBase;
  66.     ReqBase = ParMBase->ReqBase;
  67.     IconBase = ParMBase->IconBase;
  68.     IntuitionBase = (struct IntuitionBase *)ArpBase->IntuiBase;
  69.  
  70.     if (WBenchMsg) {
  71.         CurrentDir(WBenchMsg->sm_ArgList->wa_Lock);
  72.         _argv = (char **)WBenchMsg;
  73.     }
  74.     else {
  75.         /*
  76.          *    WARNING: With that function, argv[] array will not start with the program
  77.          *    name but with it's first argument. If there's no args, argc will be zero.
  78.          */
  79.         _argc = (int)GADS(aptr, alen, NULL, (char **)&_argv, "args/...");
  80.         if (_argc < 0) {
  81.             Puts(_argv[0]);
  82.             exit(20);
  83.         }
  84.     }
  85.  
  86.     main(_argc, _argv);
  87.  
  88.     exit(0);
  89. }
  90.  
  91.  
  92.