#include <rlspawn.h>
Public Member Functions | |
rlSpawn () | |
virtual | ~rlSpawn () |
int | spawn (const char *command) |
const char * | readLine () |
int | getchar () |
int | select (int timeout=50) |
int | writeString (const char *buf) |
int | write (const char *buf, int len) |
int | printf (const char *format,...) |
void | printAll () |
Public Attributes | |
int | pid |
Private Attributes | |
void * | toChild |
void * | fromChild |
char | line [4096] |
Spawn an external program. Redirect <stdin> <stdout> <stderr> of external program to this class
Now you can communicate with this external program over a pipe. Attention: This class is only available on unix like systems.
rlSpawn::rlSpawn | ( | ) |
Definition at line 33 of file rlspawn.cpp.
|
virtual |
int rlSpawn::getchar | ( | ) |
Read a char from the spawned command. When the command terminates EOF is returned.
Definition at line 111 of file rlspawn.cpp.
void rlSpawn::printAll | ( | ) |
Print all outputs from spawned command to <stdout>
Definition at line 146 of file rlspawn.cpp.
int rlSpawn::printf | ( | const char * | format, |
... | |||
) |
similar to printf Return: number of bytes written -1 error
Definition at line 127 of file rlspawn.cpp.
const char * rlSpawn::readLine | ( | ) |
Read a line from the spawned command. When the command terminates NULL is returned.
Definition at line 93 of file rlspawn.cpp.
int rlSpawn::select | ( | int | timeout = 50 | ) |
Wait for characters. return = 0 // timeout return = 1 // characters available
Definition at line 152 of file rlspawn.cpp.
int rlSpawn::spawn | ( | const char * | command | ) |
Start an operating system command. The output from the command can be read with readLine() You can write to the program with writeString() or write() Return: 0=success -1=error
Definition at line 45 of file rlspawn.cpp.
int rlSpawn::write | ( | const char * | buf, |
int | len | ||
) |
Write buf to <stdin> of spawned command Return: number of bytes written -1 error
Definition at line 117 of file rlspawn.cpp.
int rlSpawn::writeString | ( | const char * | buf | ) |
Write buf to <stdin> of spawned command buf must be 0 terminated Return: number of bytes written -1 error
Definition at line 140 of file rlspawn.cpp.