Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
UnixArgLists


NAME

UnixArgLists - construction of argument lists

SYNOPSIS

TYPE Arguments = SysArgs.Arguments;
TYPE Stream = POINTER TO StreamRec;
TYPE StreamRec = RECORD (Streams.StreamRec) END;


PROCEDURE Open(VAR list: Streams.Stream); PROCEDURE Next(list: Streams.Stream); PROCEDURE Close(VAR list: Streams.Stream; VAR arglist: Arguments);

DESCRIPTION

UnixArgLists is a convenient module to generate argument lists of type SysArgs.Arguments suitable for calls of SysProcess.Exec and SysProcess.ExecEnv. An argument list is a pointer to a vector of pointers to 0X-terminated character arrays.

Open opens list for the first argument (write-only). The returned stream is of type UnixArgLists.Stream. Next extends the argument list and opens for the next argument. Close is to be called instead of Streams.Close to get the argument list.

Argument lists of SysArgs are untraced and therefore allocated by UntaggedStorage.New. Thus, they have to be explicitly deallocated by UntaggedStorage.Dispose.

EXAMPLE

PROCEDURE ExecShell(cmd: ARRAY OF CHAR);
   VAR
      list: Streams.Stream;
      arglist: SysArgs.Arguments;
BEGIN
   UnixArgLists.Open(list);
   Write.StringS(list, "sh"); (* command name *)
   UnixArgLists.Next(list); Write.StringS(list, "-c");
   UnixArgLists.Next(list); Write.StringS(list, cmd);
   UnixArgLists.Close(list, arglist);
   SysProcess.Exec("/bin/sh", arglist);
   UntaggedStorage.Dispose(SYSTEM.VAL(Types.UntracedAddress, arglist));
END ExecShell;

SEE ALSO

SysProcess
SysProcess.Exec and SysProcess.ExecEnv
SysArgs
definition of SysArgs.Arguments
UnixArguments
processing of arguments
UntaggedStorage
allocation/deallocation of of untagged areas
Write
formatted output for streams

BUGS

Streams.Seek and Streams.Tell are not valid operations for an UnixArgLists.Stream.
Edited by: borchert, last change: 1996/09/16, revision: 1.6, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module