Scroll to navigation

stuserio(3) ShapeTools Toolkit Library stuserio(3)


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


#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);


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
Message to be sent to standard output.
Message to be sent to standard error.
Warning message, preceded by the string `programName - warning:', going to standard error.
Error message, preceded by the string `programName - error:', going to standard error.

Additionally, when the flag

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 character 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.


stGetTermWidth will not work on all machines properly. In it's current implementation, it is quite SUN specific.
Thu Jun 24 17:43:39 1993 sttk-1.7