1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
7 * C Implementation File *
11 * Copyright (C) 1992-2001 Free Software Foundation, Inc. *
13 * GNAT is free software; you can redistribute it and/or modify it under *
14 * terms of the GNU General Public License as published by the Free Soft- *
15 * ware Foundation; either version 2, or (at your option) any later ver- *
16 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
17 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
19 * for more details. You should have received a copy of the GNU General *
20 * Public License distributed with GNAT; see file COPYING. If not, write *
21 * to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
22 * MA 02111-1307, USA. *
24 * As a special exception, if you link this file with other files to *
25 * produce an executable, this file does not by itself cause the resulting *
26 * executable to be covered by the GNU General Public License. This except- *
27 * ion does not however invalidate any other reasons why the executable *
28 * file might be covered by the GNU Public License. *
30 * GNAT was originally developed by the GNAT team at New York University. *
31 * Extensive contributions were provided by Ada Core Technologies Inc. *
33 ****************************************************************************/
35 /* Routines for accessing command line arguments from both the runtime
36 library and from the compiler itself. In the former case, gnat_argc
37 and gnat_argv are the original argc and argv values as stored by the
38 binder generated main program, and these routines are accessed from
39 the Ada.Command_Line package. In the compiler case, gnat_argc and
40 gnat_argv are the values as modified by toplev, and these routines
41 are accessed from the Osint package. */
43 /* Also routines for accessing the environment from the runtime library.
44 Gnat_envp is the original envp value as stored by the binder generated
45 main program, and these routines are accessed from the
46 Ada.Command_Line.Environment package. */
59 /* argc and argv of the main program are saved under gnat_argc and gnat_argv,
60 envp of the main program is saved under gnat_envp. */
63 const char **gnat_argv
= (const char **) 0;
64 const char **gnat_envp
= (const char **) 0;
73 __gnat_len_arg (arg_num
)
76 return strlen (gnat_argv
[arg_num
]);
80 __gnat_fill_arg (a
, i
)
84 strncpy (a
, gnat_argv
[i
], strlen(gnat_argv
[i
]));
92 for (i
= 0; gnat_envp
[i
]; i
++)
98 __gnat_len_env (env_num
)
101 return strlen (gnat_envp
[env_num
]);
105 __gnat_fill_env (a
, i
)
109 strncpy (a
, gnat_envp
[i
], strlen (gnat_envp
[i
]));