home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d995 / whatis.lha / WhatIs / c / WBInfo.c < prev    next >
C/C++ Source or Header  |  1994-04-05  |  2KB  |  82 lines

  1. /*
  2.  *    WBInfo.c - Copyright © 1991 by Devil's child.
  3.  *
  4.  *    Created:    24 Jun 1993  21:38:57
  5.  *    Modified:    24 Jun 1993  21:43:27
  6.  *
  7.  *    Make>> sc <file>.c
  8.  *    Make>> slink <file>.o SC SD ND BATCH NOICONS TO <file>
  9.  */
  10.  
  11. #define VERSION "1.0"
  12.  
  13. static const char version[] = "\0$VER: wbinfo " VERSION " (24.06.93)";
  14.  
  15. #define TEMPLATE    "NAME/A,PUBSCREEN/K"
  16.  
  17. #define ARG_NAME    0
  18. #define ARG_SCREEN    1
  19.  
  20.  
  21. long wbinfo(void)
  22. {
  23.     long rc = RETURN_OK;
  24.     struct ExecBase *SysBase = *((struct ExecBase **) 4L);
  25.     struct Library *DOSBase;
  26.     struct Library *WorkbenchBase;
  27.     struct Library *IntuitionBase;
  28.     char *options[2] = {0, 0};
  29.     struct RDArgs *args;
  30.  
  31.     if (!(DOSBase = OpenLibrary("dos.library", 39)))
  32.         return RETURN_FAIL;
  33.  
  34.     WorkbenchBase = OpenLibrary("workbench.library", 39);
  35.     IntuitionBase = OpenLibrary("intuition.library", 39);
  36.     if (!WorkbenchBase || !IntuitionBase)
  37.         return RETURN_FAIL;
  38.  
  39.     if (args = ReadArgs(TEMPLATE, (long *)options, NULL)) {
  40.         struct Screen *screen = LockPubScreen(options[ARG_SCREEN]);
  41.  
  42.         if (screen) {
  43.             BPTR lock = Lock(options[ARG_NAME], ACCESS_READ);
  44.  
  45.             if (lock) {
  46.                 BPTR par;
  47.  
  48.                 par = ParentDir(lock);
  49.                 if (!par)
  50.                     par = DupLock(lock);    /* for Devices */
  51.                 WBInfo(par, options[ARG_NAME], screen);
  52.                 if (par)
  53.                     UnLock(par);
  54.                 UnLock(lock);
  55.             }
  56.             else {
  57.                 PrintFault(IoErr(), options[ARG_NAME]);
  58.                 rc = RETURN_ERROR;
  59.             }
  60.  
  61.             UnlockPubScreen(NULL, screen);
  62.         }
  63.         else {
  64.             /* error message for 'pubscreen not found' */
  65.             if (options[ARG_SCREEN])
  66.                 PrintFault(ERROR_OBJECT_NOT_FOUND, options[ARG_SCREEN]);
  67.             rc = RETURN_FAIL;
  68.         }
  69.         FreeArgs(args);
  70.     }
  71.     else {
  72.         PrintFault(IoErr(), NULL);
  73.         rc = RETURN_ERROR;
  74.     }
  75.  
  76.     CloseLibrary(WorkbenchBase);
  77.     CloseLibrary(IntuitionBase);
  78.     CloseLibrary(DOSBase);
  79.  
  80.     return rc;
  81. }
  82.