Модуль Term Справочный лист

Постоянные

Этот раздел пуст.

Типы

Crossplatform Pipe Support

This tiny library is created for crossplatform pipe support. It is needed by the virtual terminal of Free Oberon. When a program is being run in the IDE, Free Oberon creates a child process and attaches a pipe to its stdin and stdout. This way a program may run both in real terminal and inside Free Oberon IDE, which itself acts as a terminal emulator.

When you run ./make.sh or make.bat in directory src, one of the two files is automatically selected for compilation: term_win32.c or term_linux.c:

- term_linux.c is a GNU/Linux version (tested on Debian, Ubuntu, Mint), it uses fork, dup2, execl, fcntl and waitpid.

- term_win32.c is a Windows version, it uses WinAPI (CreateNamedPipeA and other functions).

Term.Mod is an Oberon binding for this library, the binding is used as a cross-platform module.

CHAR8 = SHORTCHAR;

Переменные

Этот раздел пуст.

Процедуры

PROCEDURE -AAIncludeTermh;
  '#include "term/term.h"'
PROCEDURE -ProcessFinished (VAR err: INTEGER): BOOLEAN;
  'ProcessFinished(err)'

Returns TRUE if the process has finished. In this case puts in err the exit code of the process.

PROCEDURE -ReadFromProcess (VAR buf: ARRAY OF CHAR8; VAR len: INTEGER; limit: INTEGER);
  'ReadFromProcess(buf, len, limit)'

Reads at most limit 1-byte characters (bytes) from the standard output pipe of the started process to buf, puts in len the number of 1-byte characters read. Does not add 0X in the end of buf.

The process must first have been started with StartProcess or StartProcessIn.

PROCEDURE -RunProcess (cmd: ARRAY OF CHAR8; VAR buf: ARRAY OF CHAR8; limit: INTEGER; VAR len: INTEGER; VAR err: INTEGER): INTEGER;
  '(int)RunProcessIn((char *)cmd, (char *)0, (char *)buf, limit, len, err)'

Starts a process with the given path cmd to the executable, waits for it to finish and puts its output (as bytes, converted to 1-byte-wide SHORTCHARs) to buf, using at most len space. Puts in err the exit code of the finished process. Does not add 0X in the end of buf.

Returns 1 on success, 0 on failure.

PROCEDURE -RunProcessIn (cmd: ARRAY OF CHAR8; dir: ARRAY OF CHAR8; VAR buf: ARRAY OF CHAR8; limit: INTEGER; VAR len: INTEGER; VAR err: INTEGER): INTEGER;
  '(int)RunProcessIn((char *)cmd, (char *)dir, (char *)buf, limit, len, err)'

Starts a process with the given path cmd to the executable in the directory dir, waits for it to finish and puts its output (as bytes, converted to 1-byte-wide SHORTCHARs) to buf, using at most len space. Puts in err the exit code of the finished process. Does not add 0X in the end of buf.

Returns 1 on success, 0 on failure.

On Unix/Linux dir is ignored.

PROCEDURE -SearchPath (filename: ARRAY OF CHAR8; VAR result: ARRAY OF CHAR8): LONGINT;
  '(int)MySearchPath((char *)filename, (char *)result, result__len)'

Puts in result the full path to the executable filename if it is found in the PATH environment variable. Uses SearchPath WINAPI call on Windows. Returns 1 on success, 0 on failure.

On Unix/Linux just copies filename to result and returns 1.

PROCEDURE -StartProcess (cmd: ARRAY OF CHAR8): BOOLEAN;
  'StartProcessIn(cmd, (char *)0)'

Starts a process with the given path to the executable. Returns TRUE process has been started successfully.

PROCEDURE -StartProcessIn (cmd: ARRAY OF CHAR8; dir: ARRAY OF CHAR8): BOOLEAN;
  'StartProcessIn(cmd, dir)'

Starts a process with the path cmd to the executable, but starts it from a directory dir. Returns TRUE on success.

PROCEDURE -WriteToProcess (buf: ARRAY OF CHAR8; len: INTEGER);
  'WriteToProcess(buf, len)'

Writes len 1-byte characters (bytes) from buf to the standard input pipe of the started process.

The process must first have been started with StartProcess or StartProcessIn.