Debian Codegraph @

gcc/m2/pge-boot/GArgs.cc

raw
1 /* do not edit automatically generated by mc from Args. */
2 /* Args.mod provide access to command line arguments.
3
4 Copyright (C) 2001-2025 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <[email protected]>.
6
7 This file is part of GNU Modula-2.
8
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
22
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
27
28 #include <stdbool.h>
29 # if !defined (PROC_D)
30 # define PROC_D
31 typedef void (*PROC_t) (void);
32 typedef struct { PROC_t proc; } PROC;
33 # endif
34
35 #define _Args_C
36
37 #include "GArgs.h"
38 # include "GUnixArgs.h"
39 # include "GASCII.h"
40
41 # define MaxArgs 255
42 # define MaxString 4096
43 typedef struct Args__T2_a Args__T2;
44
45 typedef Args__T2 *Args__T1;
46
47 typedef struct Args__T3_a Args__T3;
48
49 struct Args__T2_a { Args__T3 * array[MaxArgs+1]; };
50 struct Args__T3_a { char array[MaxString+1]; };
51 static Args__T1 Source;
52
53 /*
54 GetArg - returns the nth argument from the command line.
55 The success of the operation is returned.
56 */
57
58 extern "C" bool Args_GetArg (char *a, unsigned int _a_high, unsigned int n);
59
60 /*
61 Narg - returns the number of arguments available from
62 command line.
63 */
64
65 extern "C" unsigned int Args_Narg (void);
66
67
68 /*
69 GetArg - returns the nth argument from the command line.
70 The success of the operation is returned.
71 */
72
73 extern "C" bool Args_GetArg (char *a, unsigned int _a_high, unsigned int n)
74 {
75 int i;
76 unsigned int High;
77 unsigned int j;
78
79 i = (int ) (n);
80 j = 0;
81 High = _a_high;
82 if (i < (UnixArgs_GetArgC ()))
83 {
84 Source = static_cast<Args__T1> (UnixArgs_GetArgV ());
85 while ((j < High) && ((*(*Source).array[i]).array[j] != ASCII_nul))
86 {
87 const_cast<char *>(a)[j] = (*(*Source).array[i]).array[j];
88 j += 1;
89 }
90 }
91 if (j <= High)
92 {
93 const_cast<char *>(a)[j] = ASCII_nul;
94 }
95 return i < (UnixArgs_GetArgC ());
96 /* static analysis guarentees a RETURN statement will be used before here. */
97 __builtin_unreachable ();
98 }
99
100
101 /*
102 Narg - returns the number of arguments available from
103 command line.
104 */
105
106 extern "C" unsigned int Args_Narg (void)
107 {
108 return UnixArgs_GetArgC ();
109 /* static analysis guarentees a RETURN statement will be used before here. */
110 __builtin_unreachable ();
111 }
112
113 extern "C" void _M2_Args_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
114 {
115 }
116
117 extern "C" void _M2_Args_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
118 {
119 }