home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / programming / aztecarp_436 / src / source.lzh / wbparse.c < prev   
C/C++ Source or Header  |  1990-12-05  |  2KB  |  62 lines

  1. /* Copyright (C) 1986,1987 by Manx Software Systems, Inc. */
  2.  
  3. /*
  4.  *    This routine is called from the _main() routine and is used to
  5.  *    open a window for standard I/O to use. The window is actually
  6.  *    defined by setting the ToolType, "WINDOW", to the desired window
  7.  *    specification. If this is not required, this routine may be
  8.  *    replaced by a stub in the users main program. Note that even if
  9.  *    this code is called by _main(), if the WINDOW tool type is not
  10.  *    defined, there will be no window.
  11.  *
  12.  *    EXAMPLE:    WINDOW=CON:0/0/640/200/Test Window
  13.  */
  14.  
  15. /* tweeked to handle v1.4 wbench startup */
  16.  
  17. void *IconBase;
  18.  
  19. void *            OpenLibrary(char *,LONG);
  20. struct DiskObject *    GetDiskObject(char *);
  21. char *            FindToolType(char **,char *);
  22.  
  23. _wb_parse(struct Process *pp,struct WBStartup *wbm)
  24. {
  25.     if(IconBase = (void *)OpenLibrary("icon.library",0))
  26.     {
  27.         struct DiskObject *dop;
  28.  
  29.         if(dop = (struct DiskObject *)GetDiskObject(wbm -> sm_ArgList -> wa_Name))
  30.         {
  31.             char *cp;
  32.  
  33.             if(cp = (char *)FindToolType(dop -> do_ToolTypes,"WINDOW"))
  34.             {
  35.                 BPTR wind;
  36.  
  37.                 if(wind = (BPTR)Open(cp, MODE_OLDFILE))
  38.                 {
  39.                     struct FileHandle *fhp;
  40.  
  41.                     fhp = (struct FileHandle *)BADDR(wind);
  42.  
  43.                     pp -> pr_ConsoleTask    = (APTR)fhp -> fh_Type;
  44.                     pp -> pr_CIS        = (BPTR)wind;
  45.                     pp -> pr_COS        = (BPTR)Open("*", MODE_OLDFILE);
  46.  
  47.                     /* !!! 1.4 tweek */
  48.  
  49.                     _devtab[0] . mode &= ~O_STDIO;    /* setup for exit to close these if we succeeded */
  50.                     _devtab[1] . mode &= ~O_STDIO;
  51.                 }
  52.             }
  53.  
  54.             FreeDiskObject(dop);
  55.         }
  56.  
  57.         CloseLibrary(IconBase);
  58.  
  59.         IconBase = NULL;
  60.     }
  61. }
  62.