Daily bump.
[official-gcc.git] / gcc / ada / argv.c
blobe276f4d5b79dd2158f2c0dd5ade46f54f51cf2cb
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * A R G V *
6 * *
7 * C Implementation File *
8 * *
9 * $Revision: 1.1 $
10 * *
11 * Copyright (C) 1992-2001 Free Software Foundation, Inc. *
12 * *
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. *
23 * *
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. *
29 * *
30 * GNAT was originally developed by the GNAT team at New York University. *
31 * Extensive contributions were provided by Ada Core Technologies Inc. *
32 * *
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. */
48 #ifdef IN_RTS
49 #include "tconfig.h"
50 #include "tsystem.h"
51 #include <sys/stat.h>
52 #else
53 #include "config.h"
54 #include "system.h"
55 #endif
57 #include "adaint.h"
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. */
62 int gnat_argc = 0;
63 const char **gnat_argv = (const char **) 0;
64 const char **gnat_envp = (const char **) 0;
66 int
67 __gnat_arg_count ()
69 return gnat_argc;
72 int
73 __gnat_len_arg (arg_num)
74 int arg_num;
76 return strlen (gnat_argv[arg_num]);
79 void
80 __gnat_fill_arg (a, i)
81 char *a;
82 int i;
84 strncpy (a, gnat_argv[i], strlen(gnat_argv[i]));
87 int
88 __gnat_env_count ()
90 int i;
92 for (i = 0; gnat_envp[i]; i++)
94 return i;
97 int
98 __gnat_len_env (env_num)
99 int env_num;
101 return strlen (gnat_envp[env_num]);
104 void
105 __gnat_fill_env (a, i)
106 char *a;
107 int i;
109 strncpy (a, gnat_envp[i], strlen (gnat_envp[i]));