1 /* do not edit automatically generated by mc from Args. */
2 /* Args.mod provide access to command line arguments.
4 Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius@glam.ac.uk>.
7 This file is part of GNU Modula-2.
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)
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.
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.
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/>. */
31 # if !defined (PROC_D)
33 typedef void (*PROC_t
) (void);
34 typedef struct { PROC_t proc
; } PROC
;
40 # include "GUnixArgs.h"
44 # define MaxString 4096
45 typedef struct Args__T2_a Args__T2
;
47 typedef Args__T2
*Args__T1
;
49 typedef struct Args__T3_a Args__T3
;
51 struct Args__T2_a
{ Args__T3
* array
[MaxArgs
+1]; };
52 struct Args__T3_a
{ char array
[MaxString
+1]; };
53 static Args__T1 Source
;
56 GetArg - returns the nth argument from the command line.
57 The success of the operation is returned.
60 extern "C" bool Args_GetArg (char *a
, unsigned int _a_high
, unsigned int n
);
63 Narg - returns the number of arguments available from
67 extern "C" unsigned int Args_Narg (void);
71 GetArg - returns the nth argument from the command line.
72 The success of the operation is returned.
75 extern "C" bool Args_GetArg (char *a
, unsigned int _a_high
, unsigned int n
)
84 if (i
< (UnixArgs_GetArgC ()))
86 Source
= static_cast<Args__T1
> (UnixArgs_GetArgV ());
87 while ((j
< High
) && ((*(*Source
).array
[i
]).array
[j
] != ASCII_nul
))
89 const_cast<char *>(a
)[j
] = (*(*Source
).array
[i
]).array
[j
];
95 const_cast<char *>(a
)[j
] = ASCII_nul
;
97 return i
< (UnixArgs_GetArgC ());
98 /* static analysis guarentees a RETURN statement will be used before here. */
99 __builtin_unreachable ();
104 Narg - returns the number of arguments available from
108 extern "C" unsigned int Args_Narg (void)
110 return UnixArgs_GetArgC ();
111 /* static analysis guarentees a RETURN statement will be used before here. */
112 __builtin_unreachable ();
115 extern "C" void _M2_Args_init (__attribute__((unused
)) int argc
, __attribute__((unused
)) char *argv
[], __attribute__((unused
)) char *envp
[])
119 extern "C" void _M2_Args_fini (__attribute__((unused
)) int argc
, __attribute__((unused
)) char *argv
[], __attribute__((unused
)) char *envp
[])