home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / library / ix_get_vars2.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  3KB  |  125 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  ix_get_vars2.c,v 1.1.1.1 1994/04/04 04:30:55 amiga Exp
  20.  *
  21.  *  ix_get_vars2.c,v
  22.  * Revision 1.1.1.1  1994/04/04  04:30:55  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.4  1992/08/09  20:49:16  amiga
  26.  *  add cast
  27.  *
  28.  *  Revision 1.3  1992/07/04  19:14:44  mwild
  29.  *  add new variable, environ-in, primarly support for fork-emulation in ksh
  30.  *
  31.  * Revision 1.2  1992/05/20  01:32:00  mwild
  32.  * do atexit(_cleanup) here, ix_open is the wrong place
  33.  *
  34.  * Revision 1.1  1992/05/14  19:55:40  mwild
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39. #define _KERNEL
  40. #include "ixemul.h"
  41. #include "kprintf.h"
  42.  
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45.  
  46. extern char _ctype_[];
  47. extern int sys_nerr;
  48. extern void _cleanup();
  49.  
  50. /* too bad this is necessary, but the old function didn't know how to tell
  51.  * how many values to fill out, making later extensions impossible without
  52.  * breaking old executables. This one uses an explicit counter for this.
  53.  */
  54.  
  55. void
  56. ix_get_vars2 (int argc, char **ctype, int *_sys_nerr, 
  57.           struct Library **sysbase, struct Library **dosbase,
  58.           FILE ***fpp, char ***environ_out, char ***environ_in,
  59.           int *real_errno, int *real_h_errno, struct __res_state *_res,
  60.           int *_res_socket)
  61. {
  62.   switch (argc)
  63.     {
  64.     default:
  65.     case 11:
  66.       if (_res_socket)
  67.         u.u_res_socket = _res_socket;
  68.  
  69.     case 10:
  70.       if (_res)
  71.         u.u_res = _res;
  72.  
  73.     case 9:
  74.       if (real_h_errno)
  75.         {
  76.           u.u_h_errno = real_h_errno;
  77.         }
  78.         
  79.     case 8:
  80.       /* Needed in pdksh: after the ix_resident call the child needs to
  81.          tell ixemul.library what the new address of the errno variable is. */
  82.       if (real_errno)
  83.     {
  84.       u.u_errno = real_errno;
  85.       /* assume when h_errno is set, errno is set also */
  86.           if (u.u_ixnetbase)
  87.         netcall(NET_set_errno, real_errno, u.u_h_errno);
  88.     }
  89.  
  90.     case 7:
  91.       /* a `bit' kludgy.. */
  92.       if (environ_in) *environ_in = *u.u_environ;
  93.  
  94.     case 6:
  95.       if (environ_out) u.u_environ = environ_out;
  96.  
  97.     case 5:
  98.       if (fpp)
  99.         {
  100.       __init_stdinouterr ();
  101.           *fpp = (FILE **) &u.u_sF[0];
  102.       /* make sure all stdio buffers are flushed on exit() */
  103.       atexit (_cleanup);
  104.         }
  105.  
  106.     case 4:
  107.       if (dosbase) *dosbase = (struct Library *)DOSBase;
  108.       
  109.     case 3:
  110.       if (sysbase) *sysbase =  (struct Library *)SysBase;
  111.       
  112.     case 2:
  113.       if (_sys_nerr) *_sys_nerr = sys_nerr;
  114.       
  115.     case 1:
  116.       if (ctype) *ctype = _ctype_;
  117.  
  118.     case 0:
  119.       break;
  120.     }
  121.    
  122.   /* now that system start is over, free the tracer */
  123.   u.u_trace_flags = 0;
  124. }
  125.