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