On Posix systems, envp
points at a NIL-terminated list of
string pointers
UNSAFE MODULE; IMPORT RTLinker, Ctypes, M3toC; VAR env_c : CARDINAL := 0; PROCEDURE RTArgs ArgC (): CARDINAL = BEGIN RETURN RTLinker.argc; END ArgC; PROCEDUREGetArg (n: CARDINAL): TEXT = VAR p: Ctypes.char_star_star := RTLinker.argv + n * ADRSIZE (ADDRESS); a: ARRAY [0..1] OF INTEGER; BEGIN IF (n >= RTLinker.argc) THEN n := 2; n := a[n]; (* force a subscript fault *) END; RETURN M3toC.StoT (p^); END GetArg; PROCEDUREEnvC (): CARDINAL = VAR cnt : CARDINAL := 0; envp : Ctypes.char_star_star := RTLinker.envp; BEGIN IF (env_c = 0) THEN WHILE envp^ # NIL DO INC (envp, ADRSIZE (ADDRESS)); INC (cnt); END; env_c := cnt; END; RETURN env_c; END EnvC; PROCEDUREGetEnv (n: CARDINAL): TEXT = VAR p: Ctypes.char_star_star := RTLinker.envp + n * ADRSIZE (ADDRESS); a: ARRAY [0..1] OF INTEGER; BEGIN IF (n >= EnvC ()) THEN n := 2; n := a[n]; (* force a subscript fault *) END; RETURN M3toC.StoT (p^); END GetEnv; BEGIN END RTArgs.