head	1.4;
access;
symbols
	version39-41:1.3;
locks;
comment	@ *  @;


1.4
date	92.08.09.20.49.16;	author amiga;	state Exp;
branches;
next	1.3;

1.3
date	92.07.04.19.14.44;	author mwild;	state Exp;
branches;
next	1.2;

1.2
date	92.05.20.01.32.00;	author mwild;	state Exp;
branches;
next	1.1;

1.1
date	92.05.14.19.55.40;	author mwild;	state Exp;
branches;
next	;


desc
@general initializer for program static variables (like stdio)
@


1.4
log
@add cast
@
text
@/*
 *  This file is part of ixemul.library for the Amiga.
 *  Copyright (C) 1991, 1992  Markus M. Wild
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  $Id: ix_get_vars2.c,v 1.3 1992/07/04 19:14:44 mwild Exp $
 *
 *  $Log: ix_get_vars2.c,v $
 *  Revision 1.3  1992/07/04  19:14:44  mwild
 *  add new variable, environ-in, primarly support for fork-emulation in ksh
 *
 * Revision 1.2  1992/05/20  01:32:00  mwild
 * do atexit(_cleanup) here, ix_open is the wrong place
 *
 * Revision 1.1  1992/05/14  19:55:40  mwild
 * Initial revision
 *
 */

#define KERNEL
#include "ixemul.h"

#include <stdio.h>

extern char _ctype_[];
extern int sys_nerr;
extern void _cleanup();

/* too bad this is necessary, but the old function didn't know how to tell
 * how many values to fill out, making later extensions impossible without
 * breaking old executables. This one uses an explicit counter for this.
 */

void
ix_get_vars2 (int argc, char **ctype, int *_sys_nerr, 
	      struct Library **SysBase, struct Library **DOSBase,
	      FILE ***fpp, char ***environ_out, char ***environ_in)
{
  switch (argc)
    {
    case 7:
      /* a `bit' kludgy.. */
      if (environ_in) *environ_in = *u.u_environ;

    case 6:
      if (environ_out) u.u_environ = environ_out;

    case 5:
      if (fpp)
        {
	  __init_stdinouterr ();
          *fpp = (FILE **) &u.u_sF[0];
	  /* make sure all stdio buffers are flushed on exit() */
	  atexit (_cleanup);
        }

    case 4:
      if (DOSBase) *DOSBase = (struct Library *) ix.ix_dos_base;
      
    case 3:
      if (SysBase) *SysBase =  (struct Library *) *(struct ExecBase **)4;
      
    case 2:
      if (_sys_nerr) *_sys_nerr = sys_nerr;
      
    case 1:
      if (ctype) *ctype = _ctype_;

    default:
      break;
    }
   
  /* now that system start is over, free the tracer */
  u.u_trace_flags = 0;
}
@


1.3
log
@add new variable, environ-in, primarly support for fork-emulation in ksh
@
text
@d19 1
a19 1
 *  $Id: ix_get_vars2.c,v 1.2 1992/05/20 01:32:00 mwild Exp $
d22 3
d65 1
a65 1
          *fpp = &u.u_sF[0];
@


1.2
log
@do atexit(_cleanup) here, ix_open is the wrong place
@
text
@d19 1
a19 1
 *  $Id: ix_get_vars2.c,v 1.1 1992/05/14 19:55:40 mwild Exp $
d22 3
d47 1
a47 1
	      FILE ***fpp, char ***environ)
d51 4
d56 1
a56 1
      if (environ) u.u_environ = environ;
@


1.1
log
@Initial revision
@
text
@d19 1
a19 1
 *  $Id$
d21 4
a24 1
 *  $Log$
d34 1
d56 2
@
