stuserio(3)

NAME
stLog, stQuietFlag, stShutupFlag, stProgramName, stMessage, stGetFromStdin, stAskConfirm, stGetTermWidth - user interaction

SYNOPSIS
#include <config.h>
#include <sttk.h.h>

void    stLog (char *logMsg, int logType);

int    stQuietFlag;

int    stShutupFlag;

char*    stProgramName;

char    stMessage[];

char*    stGetFromStdin (int termChar);

int    stAskConfirm (char *message, char *defaultAnswer);

int    stGetTermWidth (int fdes);

DESCRIPTION
These functions do the dialogue with the user. stLog outputs a message to the user's terminal. The message text is given in the logMsg buffer. logType is one of

ST_LOG_MSG
    Message to be sent to standard output.

ST_LOG_MSGERR
    Message to be sent to standard error.

ST_LOG_WARNING
    Warning message, preceeded by the string `programName - warning:', going to standard error.

ST_LOG_ERROR
    Error message, preceeded by the string `programName - error:', going to standard error.

Additionally, when the flag

ST_LOG_NONL
    is ored to the message type (e.g. `ST_LOG_MSG | ST_LOG_NONL'), the message is printed without adding a newline character. Otherwise, a newline is always added.

Whether a message really makes it's way to the user, depends on the variables stQuietFlag and stShutupFlag. When stQuietFlag is set to a non null value, all messages except error messages (ST_LOG_ERROR) will be suppressed. With the stShutupFlag set to a null value, all messages will be suppressed. Initially, both flags are set to NULL.

The stProgramName pointer should be set pointing to a buffer containing the name how the program was called. It is used for composing proper error messages and warnings (see above).

stMessage is a buffer for constructing messages using sprintf(3). It is designed to be large enough to hold a file's pathname and an additional short message. It's size is MAXPATHLEN+128.

stGetFromStdin reads from stdin a text terminated by ^D or by the specified single charcter termChar at the beginning of a new line. If termChar is -1 text is terminated by ^D.

stAskConfirm returns true if the answer is equivalent to defaultAnswer (assumption).

stGetTermWidth returns the actual with of the user's termainal in columns.

BUGS
stGetTermWidth will not work on all machines properly. In it's current implementation, it is quite SUN specific.