home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 164.lha / ARexx / WB_ARexx_v1.1 / main.c < prev    next >
C/C++ Source or Header  |  1988-04-28  |  1KB  |  61 lines

  1. /** main.c
  2. *
  3. *                     Copyright 1988, W.G.J. Langeveld
  4. *                           All Rights Reserved
  5. *                           Freely Distributable
  6. *
  7. *   This just sets up the libraries and calls wbrexx().
  8. *
  9. **/
  10. #include "exec/exec.h"
  11. #include "libraries/dos.h"
  12. #include "libraries/dosextens.h"
  13. #include "intuition/intuition.h"
  14. #include "stdio.h"
  15. #include "functions.h"
  16.  
  17. struct IntuitionBase *IntuitionBase = 0L;
  18. struct GfxBase *GfxBase = 0L;
  19. struct IconBase *IconBase = 0L;
  20.  
  21. main(argc, argv)
  22. int argc;
  23. char **argv;
  24. {
  25.    char **WB_msg;
  26.  
  27.    IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L);
  28.    if (IntuitionBase == NULL) cleanup("Can't open intuition library");
  29.  
  30.    GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0L);
  31.    if (GfxBase == NULL) cleanup("Can't open graphics library");
  32.  
  33.    IconBase = (struct IconBase *) OpenLibrary("icon.library", 0L);
  34.    if (IconBase == NULL) cleanup("Can't open icon library");
  35.  
  36.    if (argc == 0) 
  37.       WB_msg = argv;
  38.    else
  39.       cleanup("Use only from Workbench");
  40.  
  41.    WBRexx(WB_msg);
  42.  
  43.    cleanup(NULL);
  44. }
  45.  
  46. cleanup(error)
  47. char *error;
  48. {
  49.    struct Process *proc;
  50.  
  51.    if (IntuitionBase != NULL) CloseLibrary(IntuitionBase);
  52.    if (GfxBase != NULL) CloseLibrary(GfxBase);
  53.    if (IconBase != NULL) CloseLibrary(IconBase);
  54.  
  55.    proc = (struct Process *) FindTask(0L);
  56.    
  57.    if (error) AReqBool(proc->pr_WindowPtr, error, NULL, " Okay ");
  58.  
  59.    exit(0);
  60. }
  61.