---
name: "stuserio"
section: "3"
platform: "linux"
package: "atfs-dev"
version: "1.4pl6-15+b1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/stuserio"
---

# stuserio(3)

user interaction

## 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, preceded by the string \`programName - warning:', going to standard error.

- ST\_LOG\_ERROR

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

Additionally, when the flag

- ST\_LOG\_NONL

  is *or*ed 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)](/sprintf/3.md). 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.

## BUGS

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