33 lines
1.1 KiB
Modula-2
33 lines
1.1 KiB
Modula-2
|
DEFINITION MODULE Arguments;
|
||
|
(* Routines and variables to access the programs arguments and
|
||
|
environment
|
||
|
*)
|
||
|
|
||
|
VAR Argc: CARDINAL; (* Number of program arguments, including the program
|
||
|
name, so it is at least 1.
|
||
|
*)
|
||
|
|
||
|
PROCEDURE Argv( argnum : CARDINAL;
|
||
|
VAR argument : ARRAY OF CHAR
|
||
|
) : CARDINAL;
|
||
|
(* Stores the "argnum'th" argument in "argument", and returns its length,
|
||
|
including a terminating null-byte. If it returns 0, the argument was not
|
||
|
present, and if it returns a number larger than the size of "argument",
|
||
|
"argument" was'nt large enough.
|
||
|
Argument 0 contains the program name.
|
||
|
*)
|
||
|
|
||
|
PROCEDURE GetEnv( name : ARRAY OF CHAR;
|
||
|
VAR value : ARRAY OF CHAR
|
||
|
) : CARDINAL;
|
||
|
(* Searches the environment list for a string of the form
|
||
|
name=value
|
||
|
and stores the value in "value", if such a string is present.
|
||
|
It returns the length of the "value" part, including a terminating
|
||
|
null-byte. If it returns 0, such a string is not present, and
|
||
|
if it returns a number larger than the size of the "value",
|
||
|
"value" was'nt large enough.
|
||
|
The string in "name" must be null_terminated.
|
||
|
*)
|
||
|
END Arguments.
|