home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / _wb_parse.c,v < prev    next >
Encoding:
Text File  |  1992-08-09  |  4.4 KB  |  196 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.2
  10. date    92.08.09.20.42.46;    author amiga;    state Exp;
  11. branches;
  12. next    1.1;
  13.  
  14. 1.1
  15. date    92.05.14.19.55.40;    author mwild;    state Exp;
  16. branches;
  17. next    ;
  18.  
  19.  
  20. desc
  21. @provide WB specific startup to ixemul programs
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @get rid of some warnings
  28. @
  29. text
  30. @/*
  31.  *  This file is part of ixemul.library for the Amiga.
  32.  *  Copyright (C) 1991, 1992  Markus M. Wild
  33.  *
  34.  *  This library is free software; you can redistribute it and/or
  35.  *  modify it under the terms of the GNU Library General Public
  36.  *  License as published by the Free Software Foundation; either
  37.  *  version 2 of the License, or (at your option) any later version.
  38.  *
  39.  *  This library is distributed in the hope that it will be useful,
  40.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  41.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  42.  *  Library General Public License for more details.
  43.  *
  44.  *  You should have received a copy of the GNU Library General Public
  45.  *  License along with this library; if not, write to the Free
  46.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  47.  *
  48.  *  $Id: _wb_parse.c,v 1.1 1992/05/14 19:55:40 mwild Exp $
  49.  *
  50.  *  $Log: _wb_parse.c,v $
  51.  *  Revision 1.1  1992/05/14  19:55:40  mwild
  52.  *  Initial revision
  53.  *
  54.  */
  55.  
  56. /*
  57.  * Originally written by Olaf "Olsen" Barthel. Thanks Olsen!
  58.  * I left his indentation style...
  59.  */
  60.  
  61. #define KERNEL
  62. #include "ixemul.h"
  63.  
  64. #include <workbench/workbench.h>
  65. #include <workbench/startup.h>
  66.  
  67. #define BASE_EXT_DECL
  68. #define BASE_PAR_DECL  void *iconbase, 
  69. #define BASE_PAR_DECL0 void *iconbase
  70. #define BASE_NAME      iconbase
  71. #include <inline/icon.h>
  72.  
  73.     /* wb_parse():
  74.      *
  75.      *    A more or less decent rewrite of Manx' original
  76.      *    wb_parse() routine which will do the following:
  77.      *
  78.      *    - if open_wb_window is zero no console window
  79.      *      will be opened.
  80.      *
  81.      *    - if default_wb_window points to a valid string
  82.      *      it will be used to open the window.
  83.      *
  84.      *    - if everything fails, read the icon file,
  85.      *      scan it for a "WINDOW" tool type and take
  86.      *      the corresponding tool type entry string
  87.      *      (somewhat primitive if compared to the Macintosh
  88.      *      way of doing it...).
  89.      *
  90.      *    This routine will return TRUE if it was able to
  91.      *    open an output file, FALSE otherwise.
  92.      */
  93.  
  94. int
  95. _wb_parse(struct Process *ThisProcess,struct WBStartup *WBenchMsg,
  96.       char *default_wb_window)
  97. {
  98.   void  *iconbase;
  99.   char    *WindowName    = NULL;
  100.   int    fd = -1;
  101.  
  102.         /* Are we to open a console window? */
  103.  
  104.     if(default_wb_window != (char *)-1)
  105.     {
  106.  
  107.             /* Any special name preference? */
  108.  
  109.         if(default_wb_window)
  110.             WindowName = default_wb_window;
  111.         else
  112.         {
  113.                 /* Do we have a valid tool window? */
  114.  
  115.             if(WBenchMsg -> sm_ToolWindow)
  116.                 WindowName = WBenchMsg -> sm_ToolWindow;
  117.             else
  118.             {
  119.                     /* Open icon.library. */
  120.  
  121.                 if(iconbase = OpenLibrary("icon.library",0))
  122.                 {
  123.                     struct DiskObject *Icon;
  124.  
  125.                         /* Try to load the icon file. */
  126.  
  127.                     if(Icon = GetDiskObject(iconbase, WBenchMsg -> sm_ArgList[0] . wa_Name))
  128.                     {
  129.                             /* Look for a "WINDOW" tool type. */
  130.  
  131.                         WindowName = (u_char *) FindToolType(iconbase, (u_char **) Icon -> do_ToolTypes, "WINDOW");
  132.                         if (WindowName)
  133.                             WindowName = strdup (WindowName);
  134.  
  135.                         FreeDiskObject(iconbase, Icon);
  136.                     }
  137.  
  138.                     CloseLibrary(iconbase);
  139.                 }
  140.             }
  141.         }
  142.  
  143.             /* Are we to open a file? */
  144.  
  145.         if (WindowName)
  146.           fd = syscall (SYS_open, WindowName, 2);
  147.         if (fd != -1)
  148.           {
  149.             /* this fd "should" be 0, since we didn't open any files
  150.              * till now when running under workbench */
  151.             if (fd != 0)
  152.                 ix_panic ("_wb_parse: first opened fd != 0!");
  153.  
  154.             ThisProcess -> pr_ConsoleTask    = u.u_ofile[fd]->f_fh->fh_Type;
  155.             syscall (SYS_dup2, fd, 2); 
  156.             /* now dup() the descriptor to cover an additional descriptor, 
  157.              * so that by closing 0-2 pr_ConsoleTask doesn't vanish yet */
  158.             syscall (SYS_dup2, fd, NOFILE-1);
  159.                 syscall (SYS_close, fd);
  160.  
  161.             
  162.             fd = syscall (SYS_open, "*", 0);
  163.             if (fd != -1)
  164.               ThisProcess -> pr_CIS        = CTOBPTR (u.u_ofile[fd]->f_fh);
  165.  
  166.             fd = syscall (SYS_open, "*", 1);
  167.               ThisProcess -> pr_COS        = CTOBPTR (u.u_ofile[fd]->f_fh);
  168.  
  169.             return 1;
  170.           }
  171.     }
  172.  
  173.     return(FALSE);
  174. }
  175. @
  176.  
  177.  
  178. 1.1
  179. log
  180. @Initial revision
  181. @
  182. text
  183. @d19 1
  184. a19 1
  185.  *  $Id$
  186. d21 4
  187. a24 1
  188.  *  $Log$
  189. d28 1
  190. a28 1
  191.  * Originally written by Olaf Barthel. Thanks Olaf!
  192. d102 1
  193. a102 1
  194.                         WindowName = FindToolType(iconbase, Icon -> do_ToolTypes,"WINDOW");
  195. @
  196.