Add hppa-openbsd target
[official-gcc.git] / gcc / ada / argv.c
blob60174dbf38fc9825bf306693d9c00674da44db9d
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * A R G V *
6 * *
7 * C Implementation File *
8 * *
9 * *
10 * Copyright (C) 1992-2001 Free Software Foundation, Inc. *
11 * *
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. *
22 * *
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. *
28 * *
29 * GNAT was originally developed by the GNAT team at New York University. *
30 * It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). *
31 * *
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. */
47 #ifdef IN_RTS
48 #include "tconfig.h"
49 #include "tsystem.h"
50 #include <sys/stat.h>
51 #else
52 #include "config.h"
53 #include "system.h"
54 #endif
56 #include "adaint.h"
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. */
61 int gnat_argc = 0;
62 const char **gnat_argv = (const char **) 0;
63 const char **gnat_envp = (const char **) 0;
65 int
66 __gnat_arg_count ()
68 return gnat_argc;
71 int
72 __gnat_len_arg (arg_num)
73 int arg_num;
75 return strlen (gnat_argv[arg_num]);
78 void
79 __gnat_fill_arg (a, i)
80 char *a;
81 int i;
83 strncpy (a, gnat_argv[i], strlen(gnat_argv[i]));
86 int
87 __gnat_env_count ()
89 int i;
91 for (i = 0; gnat_envp[i]; i++)
93 return i;
96 int
97 __gnat_len_env (env_num)
98 int env_num;
100 return strlen (gnat_envp[env_num]);
103 void
104 __gnat_fill_env (a, i)
105 char *a;
106 int i;
108 strncpy (a, gnat_envp[i], strlen (gnat_envp[i]));