Previous | Contents | Index |
Suspends a calling thread and waits for queued signals to arrive.
#include <signal.h>int sigwaitinfo (const sigset_t set, siginfo_t *info);
set
The set of signals to wait for.info
Pointer to a siginfo structure that is receiving data describing the signal, including any application-defined data specified when the signal was posted.
The sigwaitinfo function behaves the same as the sigwait function if the info argument is NULL.If the info argument is non-NULL, the sigwaitinfo function behaves the same as sigwait , except that the selected signal number is stored in the si_signo member of the siginfo structure, and the cause of the signal is stored in the si_code member. If any value is queued to the selected signal, the first such queued value is dequeued and the value is stored in the si_value member of info. The system resource used to queue the signal is released and made available to queue other signals. If no value is queued, the content of the si_value member is undefined. If no further signals are queued for the selected signal, the pending indication for that signal is reset.
See also sigtimedwait and sigwait .
See Section 4.2 for more information on signal handling.
x Upon successful completion, the signal number selected is returned. - 1 Indicates that an error occurred; errno is set to one of the following values:
- EINVAL -- The set argument contains an invalid or unsupported signal number.
- EINTR -- The wait was interrupted by an unblocked, intercepted signal.
Returns the sine of its radian argument.
#include <math.h>double sin (double x);
float sinf (float x); (INTEGRITY SERVERS, ALPHA)
long double sinl (long double x); (INTEGRITY SERVERS, ALPHA)
double sind (double x); (INTEGRITY SERVERS, ALPHA)
float sindf (float x); (INTEGRITY SERVERS, ALPHA)
long double sindl (long double x); (INTEGRITY SERVERS, ALPHA)
x
A radian expressed as a floating-point number.
The sin functions compute the sine of x measured in radians.The sind functions compute the sine of x measured in degrees.
x The sine of the argument. NaN x = ±Infinity or NaN; errno is set to EDOM. 0 Underflow occurred; errno is set to ERANGE.
Returns the hyperbolic sine of its argument.
#include <math.h>double sinh (double x);
float sinhf (float x); (INTEGRITY SERVERS, ALPHA)
long double sinhl (long double x); (INTEGRITY SERVERS, ALPHA)
x
A real number.
n The hyperbolic sine of the argument. HUGE_VAL Overflow occurred; errno is set to ERANGE. 0 Underflow occurred; errno is set to ERANGE. NaN x is NaN; errno is set to EDOM.
Suspends the execution of the current process (or thread in a threaded program) for at least the number of seconds indicated by its argument.
#include <unistd.h>unsigned int sleep (unsigned seconds); (_DECC_V4_SOURCE)
int sleep (unsigned seconds); (NOT _DECC_V4_SOURCE)
seconds
The number of seconds.
The sleep function sleeps for the specified number of seconds, or until a signal is received, or until the process (or thread in a threaded program) executes a call to SYS$WAKE.If a SIGALRM signal is generated, but blocked or ignored, the sleep function returns. For all other signals, a blocked or ignored signal does not cause sleep to return.
x The number of seconds that the process awoke early. 0 If the process slept the full number of seconds specified by seconds.
Performs formatted output to a string in memory.
#include <stdio.h>int snprintf (char *str, size_t n, const char *format_spec, ...);
str
The address of the string that will receive the formatted output.n
The size of the buffer referred to by str.format_spec
A pointer to a character string that contains the format specification. For more information about format specifications and conversion characters, see Chapter 2....
Optional expressions whose resultant types correspond to conversion specifications given in the format specification.If no conversion specifications are given, you may omit the output sources. Otherwise, the function calls must have at least as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.
Conversion specifications are matched to output sources in left-to-right order. Excess output pointers, if any, are ignored.
The snprintf function is identical to the sprintf function with the addition of the n argument, which specifies the size of the buffer referred to by str.On successful completion, snprintf returns the number of bytes (excluding the terminating null byte) that would be written to str if n is sufficiently large.
If n is 0, nothing is written, the number of bytes (excluding the terminating null) that would be written if n were sufficiently large are returned, and str might be a NULL pointer. Otherwise, output bytes beyond the n - 1st are discarded instead of being written to the array, and a null byte is written at the end of the bytes actually written into the array.
If an output error is encountered, a negative value is returned.
For a complete description of the format specification and the output source, see Chapter 2.
x The number of bytes (excluding the terminating null byte) that would be written to str if n is sufficiently large. Negative value Indicates an output error occurred. The function sets errno . For a list of errno values set by this function, see fprintf .
Performs formatted output to a string in memory.
#include <stdio.h>int sprintf (char *str, const char *format_spec, ...);
str
The address of the string that will receive the formatted output. It is assumed that this string is large enough to hold the output.format_spec
A pointer to a character string that contains the format specification. For more information about format specifications and conversion characters, see Chapter 2....
Optional expressions whose resultant types correspond to conversion specifications given in the format specification.If no conversion specifications are given, you may omit the output sources. Otherwise, the function calls must have at least as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.
Conversion specifications are matched to output sources in left-to-right order. Excess output pointers, if any, are ignored.
The sprintf function places output followed by the null character (\0) in consecutive bytes starting at *str. The user must ensure that enough space is available.Consider the following example of a conversion specification:
#include <stdio.h> main() { int temp = 4, temp2 = 17; char s[80]; sprintf(s, "The answers are %d, and %d.", temp, temp2); }In this example, character string s has the following contents:
The answers are 4, and 17.For a complete description of the format specification and the output source, see Chapter 2.
x The number of characters placed in the output string, not including the final null character. Negative value Indicates an output error occurred. The function sets errno . For a list of errno values set by this function, see fprintf .
Returns the square root of its argument.
#include <math.h>double sqrt (double x);
float sqrtf (float x); (INTEGRITY SERVERS, ALPHA)
long double sqrtl (long double x); (INTEGRITY SERVERS, ALPHA)
x
A real number.
val The square root of x, if x is nonnegative. 0 x is negative; errno is set to EDOM. NaN x is NaN; errno is set to EDOM.
Initializes the pseudorandom-number generator rand .
#include <stdlib.h>void srand (unsigned int seed);
seed
An unsigned integer.
The srand function uses the argument as a seed for a new sequence of pseudorandom numbers to be returned by subsequent calls to rand .If srand is then called with the same seed value, the sequence of pseudorandom numbers is repeated.
If rand is called before any calls to srand , the same sequence of pseudorandom numbers is generated as when srand is first called with a seed value of 1.
Initializes a 48-bit random-number generator.
#include <stdlib.h>void srand48 (long int seed_val);
seed_val
The initialization value to begin randomization. Changing this value changes the randomization pattern.
The srand48 function initializes the random-number generator. You can use this function in your program before calling the drand48 , lrand48 , or mrand48 functions. (Although it is not recommended practice, constant default initializer values are automatically supplied if you call drand48 , lrand48 , or mrand48 without calling an initialization function).The function works by generating a sequence of 48-bit integer values, Xi, according to the linear congruential formula:
Xn+1 = (aXn+c)mod m n >= 0The argument m equals 248 , so 48-bit integer arithmetic is performed. Unless you invoke the lcong48 function, the multiplier value a and the addend value c are:
a = 5DEECE66D16 = 2736731631558 c = B16 = 138The initializer function srand48 sets the high-order 32 bits of Xi to the low-order 32 bits contained in its argument. The low-order 16 bits of Xi are set to the arbitrary value 330E _16 .
See also drand48 , lrand48 , and mrand48 .
Initializes the pseudorandom-number generator random .
#include <stdlib.h>int srandom (unsigned seed);
seed
An initial seed value.
The srandom function uses the argument as a seed for a new sequence of pseudorandom numbers to be returned by subsequent calls to random . This function has virtually the same calling sequence and initialization properties as the srand function, but produce sequences that are more random.The srandom function initializes the current state with the initial seed value. The srandom function, unlike the srand function, does not return the old seed because the amount of state information used is more than a single word.
See also rand , srand , random , setstate , and initstate .
0 Indicates success. Initializes the state seed. - 1 Indicates an error, further specified in the global errno .
Reads input from a character string in memory, interpreting it according to the format specification.
#include <stdio.h>int sscanf (const char *str, const char *format_spec, ...);
str
The address of the character string that provides the input text to sscanf .format_spec
A pointer to a character string that contains the format specification. For more information about format specifications and conversion characters, see Chapter 2....
Optional expressions whose resultant types correspond to conversion specifications given in the format specification.If no conversion specifications are given, you can omit the input pointers. Otherwise, the function calls must have at least as many input pointers as there are conversion specifications, and the conversion specifications must match the types of the input pointers.
Conversion specifications are matched to input sources in left-to-right order. Excess input pointers, if any, are ignored.
The following is an example of a conversion specification:
main () { char str[] = "4 17"; int temp, temp2; sscanf(str, "%d %d", &temp, &temp2); printf("The answers are %d and %d.", temp, temp2); }This example produces the following output:
$ RUN EXAMPLE The answers are 4 and 17.For a complete description of the format specification and the input pointers, see Chapter 2.
x The number of successfully matched and assigned input items. EOF Indicates that a read error occurred before any conversion. The function sets errno . For a list of the values set by this function, see fscanf .
Allows you to specify the action to take when a particular signal is raised.
#include <signal.h>void (*ssignal (int sig, void (*func) (int, ...))) (int, ...);
sig
A number or mnemonic associated with a signal. The symbolic constants for signal values are defined in the <signal.h> header file (see Chapter 4).func
The action to take when the signal is raised, or the address of a function that is executed when the signal is raised.
The ssignal function is equivalent to the signal function except for the return value on error conditions.Since the signal function is defined by the ANSI C standard and the ssignal function is not, use signal for greater portability.
See Section 4.2 for more information on signal handling.
x The address of the function previously established as the action for the signal. The address may be the value SIG_DFL (0) or SIG_IGN (1). 0 Indicates errors. For this reason, there is no way to know whether a return status of 0 indicates failure, or whether it indicates that a previous action was SIG_DFL (0).
Deactivate the boldface attribute for the specified window. The standend function operates on the stdscr window.
#include <curses.h>int standend (void);
int wstandend (WINDOW *win);
win
A pointer to the window.
The standend and wstandend functions are equivalent to clrattr and wclrattr called with the attribute _BOLD.
OK Indicates success. ERR Indicates an error.
Activate the boldface attribute of the specified window. The standout function acts on the stdscr window.
#include <curses.h>int standout (void);
int wstandout (WINDOW *win);
win
A pointer to the window.
The standout and wstandout functions are equivalent to setattr and wsetattr called with the attribute _BOLD.
OK Indicates success. ERR Indicates an error.
Previous | Next | Contents | Index |