Infrasctucture CnvLnch Function Reference
CnvLnch
#include "cnvLnchr.h"
Conversational launcher is an API which facilitates launching an executable process then conversing with it, via stdin and stdout, as it runs.
It can be used to launch ssh and other secure interface software.
Kills the sub-process then closes the socket associated with it's stdin and
stdout, then cleans up all allocated resources.
The "hndl" argument is an integer handle associated with the running process.
Returns: OK.
Get the process pid belonging to handle "hndl".
Returns: integer pid else ERR.
| | |
|
int
|
clInit( int argc, char** argv )
|
Initializes all internals.
Only call once, it sets up internal signal handling a call-back for handling event Grim.
Returns argc.
Launch the sub-process and establish communication with it establishing a session.
Returns an integer handle for accessing the session, else ERR.
| | |
|
int
|
clSetDedCb( pfi_t func )
|
Set the dead child call back function.
| | |
|
int
|
clSetDedDev( int nbr, pfi_t func )
|
Set the SIGCHLD fires Delayed Event "nbr" which calls "func"
| | | |
|
int
|
clSndRcv( int hndl, char* rxDat, char* match, int maxRx, int timeOut, char* fmt, elipsis ... )
|
Send and Receive to/from (converse with) the sub-process.
If "fmt" (the format string) exists, output the expanded strng, immediately, to the sub-process' stdin.
If the "rxDat" and "rxMax" are both non-zero expect a
response and place it into the buffer pointed to by "rxDat".
Terminate receive if "rxMax" characters are received, or timeOut
miliseconds pass, or the input contains a "match" string.
The argument "hndl" is the session handle, "rxDat" points
to a buffer for holding the received data (sub-process stdout), "match"
contains a string to look for in the recieved data stream to terminate the input,
"maxRx" the integer sizeof the the recieve buffer, "timeOut"
time to wait for answer to be complete, "fmt" and "elipsis"
the ascii format string and arguments as in sprintf.
Returns: count of received bytes, else count of transmitted bytes, else
zero (timeout), else negative of errno.
| | |
|
int
|
clSystem( char* out, int maxOut, int timOut, char* fmt, ... elipsis )
|
The conversational launcher's version of the unix "system" command.
The "out" argument points to a buffer used to hold the output of the comand.
The "maxout" arg is the size of the output buffer.
The "timout" arg is the time out in milliseconds.
The "fmt" and "..." args create a formatted string that is the command to be executed.
Returns: OK else ERR.