Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) spt_getsx(2)
NAME
spt_getsx - Gets a string from the standard input stream (thread-aware version)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <stdio.h>]
#include <spthread.h>
char spt_getsx (
char string
);
PARAMETERS
string Points to a string to receive bytes.
DESCRIPTION
The spt_getsx() function is the thread-aware version of the gets() function.
The spt_getsx() function reads bytes from the standard input stream, stdin, into the array pointed
to by the string parameter. Data is read until a newline character is read or an end-of-file condi-
tion is encountered. If reading is stopped due to a newline character, the newline character is
discarded and the string is terminated with a NULL character.
NOTES
The macro to map gets() to spt_getsx() is available in C applications when
SPT_THREAD_AWARE_NONBLOCK has been defined in the following manner before
including spthread.h:
#define SPT_THREAD_AWARE_NONBLOCK
The alias to link gets() to spt_getsx() is available in C++ applications when
SPT_THREAD_AWARE_PRAGMA_NONBLOCK has been defined in the following manner
before including spthread.h:
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK
The spt_getsx() function does not check the input for a maximum size. Consequently, if more
bytes are entered than will fit in the space allocated for the string parameter, spt_getsx() will
write beyond the end of the allocated space, producing indeterminate results. To avoid this con-
dition, you should use spt_fgetsx() instead of spt_getsx().
RETURN VALUES
If the end of the file is encountered and no characters have been read, no characters are
transferred to string and a null pointer is returned. If a read error occurs, a null pointer is
returned. Otherwise, string is returned.
If the file descriptor underlying stdin becomes invalid (is closed by another thread), NULL is
returned with an errno value of [EBADF]. If a signal is received via the pthread_kill() function
and is not blocked, ignored, or handled, NULL is returned with an errno value of [EINTR].
ERRORS
If any of these conditions occur, the spt_getsx() function sets errno to the corresponding value:
[EAGAIN] The O_NONBLOCK flag is set for the underlying input stream and the process
would be delayed by the read operation.
527186-023 Hewlett-Packard Company 7267