Definition | #include <bs2cmd.h> int bs2cmd(const char *cmd, bs2cmd_rc *rc, int maxoutput, int flag
The command outputs can be buffered optionally. In this case the interface can also be used by an rlogin task without a SYSFILE environment. | |
Parameter | const char *cmd This parameter contains the command to be executed or a list of commands separated by semicolons. Except for strings enclosed in apostrophes, all characters are converted to uppercase letters in cmd before the call. bs2cmd_rc *rc rc is a pointer to the structure
typedef struct bs2cmd rc { unsigned char subcode2; unsigned char subcode1; unsigned short maincode; unsigned short progrc; char cmdmsg[8]; } bs2cmd rc; If the NULL pointer is passed when int maxoutput This parameter specifies the size of the buffer to be created for command output in bytes. When setting the buffer size you must take into account that administration information is also output in addition to the command output itself. The following constants can be specified: BS2CMD_DEFAULT A standard buffer of 256 KB is used. BS2CMD_NOBUFFER Output is not buffered. With this setting, commands that generate output can only be executed under rlogin tasks if the user provides a buffer (specification of BS2CMD_FLAG_USER_BUFFER in the parameter flag). If the buffer is set too small for the pending output, command execution is aborted. int flag This parameter specifies the interface configuration flags. The following flags and flag combinations (linked with "|") can currently be specified: BS2CMD_FLAG_STRIP The print control characters in the command output are removed before output is made. BS2CMD_FLAG_SPLIT The command outputs are split between stdout and stderr. Messages are output to stderr. BS2CMD_FLAG_USER_BUFFER
| |
Parameter | of the variable parameter list: The following parameters allow command outputs to be sent to a memory area provided by the user if BS2CMD_FLAG_USER_BUFFER is set in the parameter flag. int *outbuflen Length of the memory area for stdout outputs. After char *outbuf Address of the memory area for stdout outputs. int *errbuflen Length of the memory area for stderr outputs. After char *errbuf address of the memory area for stderr outputs. *errbuf is only relevant if the BS2CMD_-FLAG_SPLIT is set in the parameter flag. | |
Return val. |
| If the command is executed successfully, |
-1 | In the event of an error, EINVAL One of the arguments has an impermissible value (e.g. an empty command or a negative buffer size). ENOMEM There is not enough memory available for the buffers to be created. EFAULT After the command is executed, the contents of the output buffer cannot be interpreted or there is an EFBIG The output buffer is not large enough for the outputs. In the event of an error, the contents of the user buffer are undefined. | |
Notes |
If the size of the memory area is too small for the pending data, the value -1 is returned and EFBIG is set in If the value BS2CMD_NOBUFFER is specified for maxoutput and the value BS2CMD_FLAG_USER_BUFFER is simultaneously set for flag, no internal buffering is used and command outputs are sent directly to the buffer Caution! In the case described, the address of the memory area must be aligned to word boundaries, otherwise If no buffering is used, the flag values BS2CMD_FLAG_STRIP and BS2CMD_FLAG_SPLIT are not evaluated. Specifying these values is ignored. |