Open System Services Programmer's Guide
Example 50 Example Logger Program Used With OSSTTY
/* Logger Program used with OSSTTY */
#pragma runnable, symbol, nolist, inspect
/* This is a simple logger program. It does the following:
- Opens its $RECEIVE for interprocess communication.
- Creates an EDIT file that is provided as run-time argument
during instantiation. It is used as a log file.
- Accepts an OPEN from an application and logs the data that
is being written to it.
On the reception of the system CLOSE message, the process
closes the log file and terminates.
Note: The program must be started with the log file name as an
argument.
Do not post a READ on the started process.
The log file will be purged and recreated by the process.
Messages other than OPEN and CLOSE are not handled.
Operations are Waited. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <tal.h>
#include <cextdecs(FILE_OPEN_, OPENEDIT_, READUPDATEX, REPLY, \
CLOSEALLEDIT, FILE_PURGE_, FILE_GETINFO_, WRITEEDIT)>
/* local macros and defines */
#define MAX_USRMSG 8*1024
#define RECV_QMAX 4047
#define FNAME32_LEN 64
#define O_WAITED_OPEN 0x00
/* public data */
short rcv_fd;
short U_data[4*1024];
short edit_fd ;
short rcv_cnt;
/* public functions */
void file_create(char* file_name);
short tty_info_fnum( short fd);
void dol_RECEIVE_opener(void);
short tty_open_file(char *name, short name_len, short nwio,
short nwopen, short excl, short access, long sync,
short *error);
/* private functions */
void user_message(void);
void system_message(void);
main(int argc, char** argv) {
Using OSSTTY to Redirect Input and Output to Guardian Objects 219