|
@@ -18,38 +18,35 @@ along with Free Oberon. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*)
|
|
|
IMPORT SYSTEM;
|
|
|
(** 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), 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. *)
|
|
|
-
|
|
|
-TYPE CHAR = SHORTCHAR;
|
|
|
+ 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. *)
|
|
|
+
|
|
|
+TYPE CHAR8* = SHORTCHAR;
|
|
|
|
|
|
PROCEDURE -AAIncludeTermh* '#include "term/term.h"';
|
|
|
|
|
|
(** Starts a process with the given path to the executable.
|
|
|
Returns TRUE process has been started successfully *)
|
|
|
PROCEDURE -StartProcess*
|
|
|
- (cmd: ARRAY OF CHAR): BOOLEAN
|
|
|
+ (cmd: ARRAY OF CHAR8): BOOLEAN
|
|
|
"StartProcessIn(cmd, (char *)0)";
|
|
|
|
|
|
(** Starts a process with the path `cmd` to the executable, but
|
|
|
starts it from a directory `dir`. Returns TRUE on success *)
|
|
|
PROCEDURE -StartProcessIn*
|
|
|
- (cmd, dir: ARRAY OF CHAR): BOOLEAN
|
|
|
+ (cmd, dir: ARRAY OF CHAR8): BOOLEAN
|
|
|
"StartProcessIn(cmd, dir)";
|
|
|
|
|
|
(** Returns TRUE if the process has finished. In this case puts in `err`
|
|
@@ -62,7 +59,7 @@ PROCEDURE -ProcessFinished*(VAR err: INTEGER): BOOLEAN
|
|
|
The process must first have been started with StartProcess or
|
|
|
StartProcessIn *)
|
|
|
PROCEDURE -WriteToProcess*
|
|
|
- (buf: ARRAY OF CHAR; len: INTEGER)
|
|
|
+ (buf: ARRAY OF CHAR8; len: INTEGER)
|
|
|
"WriteToProcess(buf, len)";
|
|
|
|
|
|
(** Reads at most `limit` 1-byte characters (bytes) from the standard output
|
|
@@ -71,7 +68,7 @@ PROCEDURE -WriteToProcess*
|
|
|
The process must first have been started with StartProcess or
|
|
|
StartProcessIn *)
|
|
|
PROCEDURE -ReadFromProcess*
|
|
|
- (VAR buf: ARRAY OF CHAR; VAR len: INTEGER; limit: INTEGER)
|
|
|
+ (VAR buf: ARRAY OF CHAR8; VAR len: INTEGER; limit: INTEGER)
|
|
|
"ReadFromProcess(buf, len, limit)";
|
|
|
|
|
|
(** Starts a process with the given path `cmd` to the executable, waits for
|
|
@@ -80,7 +77,7 @@ PROCEDURE -ReadFromProcess*
|
|
|
exit code of the finished process. Does not add 0X in the end of `buf`.
|
|
|
Returns 1 on success, 0 on failure. *)
|
|
|
PROCEDURE -RunProcess*
|
|
|
- (cmd: ARRAY OF CHAR; VAR buf: ARRAY OF CHAR;
|
|
|
+ (cmd: ARRAY OF CHAR8; VAR buf: ARRAY OF CHAR8;
|
|
|
limit: INTEGER; VAR len, err: INTEGER): INTEGER
|
|
|
"(int)RunProcessIn((char *)cmd, (char *)0, (char *)buf, limit, len, err)";
|
|
|
|
|
@@ -92,7 +89,7 @@ PROCEDURE -RunProcess*
|
|
|
Returns 1 on success, 0 on failure.
|
|
|
On Unix/Linux `dir` is ignored *)
|
|
|
PROCEDURE -RunProcessIn*
|
|
|
- (cmd, dir: ARRAY OF CHAR; VAR buf: ARRAY OF CHAR;
|
|
|
+ (cmd, dir: ARRAY OF CHAR8; VAR buf: ARRAY OF CHAR8;
|
|
|
limit: INTEGER; VAR len, err: INTEGER): INTEGER
|
|
|
"(int)RunProcessIn((char *)cmd, (char *)dir, (char *)buf, limit, len, err)";
|
|
|
|
|
@@ -101,7 +98,7 @@ PROCEDURE -RunProcessIn*
|
|
|
on Windows. Returns 1 on success, 0 on failure.
|
|
|
On Unix/Linux just copies filename to result and returns 1 *)
|
|
|
PROCEDURE -SearchPath*
|
|
|
- (filename: ARRAY OF CHAR; VAR result: ARRAY OF CHAR): LONGINT
|
|
|
+ (filename: ARRAY OF CHAR8; VAR result: ARRAY OF CHAR8): LONGINT
|
|
|
"(int)MySearchPath((char *)filename, (char *)result, result__len)";
|
|
|
|
|
|
END Term.
|