|
Compaq C
Compaq C Run-Time Library Reference Manual for
OpenVMS Systems
rmdir
Removes a directory file.
Format
#include <unistd.h>
int rmdir (const char *path);
Arguments
path
A directory path name.
Description
This function removes a directory file whose name is specified in the
path argument. The directory is removed only if it is empty.
Restriction
When using OpenVMS format names, the path argument must be in
the form directory.dir.
Return Values
0
|
Indicates success.
|
--1
|
An error occurred;
errno
is set to indicate the error.
|
sbrk
Determines the lowest virtual address that is not used with the program.
Format
#include <unistd.h>
void *sbrk (long int incr);
Argument
incr
The number of bytes to add to the current break address.
Description
This function adds the number of bytes specified by its argument to the
current break address and returns the old break address.
When a program is executed, the break address is set to the highest
location defined by the program and data storage areas. Consequently,
sbrk
is needed only by programs that have growing data areas.
sbrk(0)
returns the current break address.
Return Values
x
|
The old break address.
|
(
void
*)(--1)
|
Indicates that the program is requesting too much memory.
|
Restriction
Unlike other C library implementations, the Compaq C RTL memory
allocation functions (such as
malloc
) do not rely on
brk
or
sbrk
to manage the program heap space. Consequently, on OpenVMS systems,
calling
brk
or
sbrk
can interfere with memory allocation routines. The
brk
and
sbrk
functions are provided only for compatibility purposes.
scalb (ALPHA ONLY)
Returns the exponent of a floating-point number.
Format
#include <math.h>
double scalb (double x, double n);
float scalbf (float x, float n);
long double scalbl (long double x, long double n);
Argument
x
A nonzero floating-point number.
n
An integer.
Description
The
scalb
functions return x*(2**n) for integer n.
Return Values
x
|
On successful completion,
x*(2**
n) is returned.
|
<pm symbol>HUGE_VAL
|
On overflow,
scalb
returns <pm symbol>HUGE_VAL (according to the sign of
x) and sets
errno
to ERANGE.
|
0
|
Underflow occurred;
errno
is set to ERANGE.
|
x
|
x is <pm symbol>Infinity.
|
NaN
|
x or
n is NaN;
errno
is set to EDOM.
|
scanf
Performs formatted input from the standard input (stdin), interpreting
it according to the format specification. See Chapter 2 for
information on format specifiers.
Format
#include <stdio.h>
int scanf (const char *format_spec, ...);
Arguments
format_spec
Pointer to a string containing the format specification. The format
spcification consists of characters to be taken literally from the
input or converted and placed in memory at the specified input sources.
For a list of conversion characters, see Chapter 2.
...
Optional expressions that are pointers to objects whose resultant types
correspond to conversion specifications given in the format
specification.
If no conversion specifications are given, you can omit these input
pointers. Otherwise, the function call 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.
Return Values
x
|
The number of successfully matched and assigned input items.
|
EOF
|
Indicates that a read error occurred prior to any successful
conversions.The function sets
errno
. For a list of
errno
values set by this function, see
fscanf
in this section.
|
[w]scanw
Perform a
scanf
on the window. The
scanw
function acts on the
stdscr
window.
Format
#include <curses.h>
int scanw (char *format_spec, ...);
int wscanw (WINDOW *win, char *format_spec, ...);
Arguments
win
A pointer to the window.
format_spec
A pointer to the format specification string.
...
Optional expressions that are pointers to objects whose resultant types
correspond to conversion specifications given in the format
specification. If no conversion specifications are given, you may omit
these input pointers.
Otherwise, the function call 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.
Description
The formatting specification (format_spec) and the other
arguments are identical to those used with the
scanf
function.
The
scanw
and
wscanw
functions accept, format, and return a line of text from the terminal
screen. For more information, see the
scrollok
and
scanf
functions in this section.
Return Values
OK
|
Indicates success.
|
ERR
|
Indicates that the function makes the screen scroll illegally or that
the scan was unsuccessful.
|
scroll
Moves all the lines on the window up one line. The top line scrolls off
the window and the bottom line becomes blank.
Format
#include <curses.h>
int scroll (WINDOW *win);
Argument
win
A pointer to the window.
Return Values
OK
|
Indicates success.
|
ERR
|
Indicates an error.
|
scrollok
Sets the scroll flag for the specified window.
Format
#include <curses.h>
scrollok (WINDOW *win, bool boolf);
Arguments
win
A pointer to the window.
boolf
A Boolean TRUE or FALSE value. If boolf is FALSE, scrolling is
not allowed. This is the default setting. The bool type is
defined in the
<curses.h>
header file as follows:
seed48
Initializes a 48-bit random number generator.
Format
#include <stdlib.h>
unsigned short *seed48 (unsigned short seed_16v[3]);
Arguments
seed_16v
An array of three
unsigned short int
that form a 48-bit seed value.
Description
The
seed48
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 supplied automatically 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 > 0
|
The 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 = 138
|
The initializer function
seed48
:
- Sets the value of Xi to the 48-bit value specified in the array
pointed to by seed_16v.
- Returns a pointer to a 48-bit internal buffer that contains the
previous value of Xi, used only by
seed48
.
The returned pointer allows you to restart the pseudorandom sequence at
a given point. Use the pointer to copy the previous Xi value into a
temporary array. To resume where the original sequence left off, you
can call
seed48
with a pointer to this array.
See also
drand48
,
lrand48
, and
mrand48
in this section.
Return Values
x
|
A pointer to a 48-bit internal buffer.
|
seekdir
Sets the position of a directory stream.
Format
#include <dirent.h>
void seekdir (DIR *dir_pointer, long int location);
Arguments
dir_pointer
A pointer to the
dir
structure of an open directory.
location
The number of an entry relative to the start of the directory.
Description
This function sets the position of the next
readdir
operation on the directory stream specified by dir_pointer to
the position specified by location. The value of
location should be returned from an earlier call to
telldir.
If the value of location was not returned by a call to the
telldir
function, or if there was an intervening call to the
rewinddir
function on this directory stream, the effect is unspecified.
The type
DIR
, defined in the
<dirent.h>
header file, represents a directory stream. A directory stream is an
ordered sequence of all the directory entries in a particular
directory. Directory entries represent files. You can remove files from
or add files to a directory asynchronously to the operation of the
readdir
function.
See
readdir
,
rewinddir
, and
telldir
in this section.
[w]setattr
Activate the video display attribute attr within the window.
The
setattr
function acts on the
stdscr
window.
Format
#include <curses.h>
int setattr (int attr);
int wsetattr (WINDOW *win, int attr);
Arguments
win
A pointer to the window.
attr
One of a set of video display attributes, which are blinking, boldface,
reverse video, and underlining, and are represented by the defined
constants _BLINK, _BOLD, _REVERSE, and _UNDERLINE, respectively. You
can set multiple attributes by separating them with a bitwise OR
operator (|) as follows:
setattr(_BLINK | _UNDERLINE);
|
Description
The
setattr
and
wsetattr
functions are specific to Compaq C for OpenVMS Systems and are not portable.
Return Values
OK
|
Indicates success.
|
ERR
|
Indicates an error.
|
setbuf
Associates a new buffer with an input or output file and potentially
modifies the buffering behavior.
Format
#include <stdio.h>
void setbuf (FILE *file_ptr, char *buffer);
Arguments
file_ptr
A file pointer.
buffer
A pointer to a character array, or a NULL pointer.
Description
You can use this function after the specified file is opened but before
any I/O operations are performed.
If buffer is a NULL pointer, then the call is equivalent to a
call to
setvbuf
with the same file_ptr, a NULL buffer pointer, a
buffering type of _IONBF (no buffering), and a buffer size of 0.
If buffer is not a NULL pointer, then the call is equivalent
to a call to
setvbuf
with the same file_ptr, the same buffer pointer, a
buffering type of _IOFBF, and a buffer size given by the value BUFSIZ
(defined in
<stdio.h>
). You should, therefore, use BUFSIZ to allocate the buffer
argument used in the call to
setbuf
. For example:
#include <stdio.h>
.
.
.
char my_buf[BUFSIZ];
.
.
.
setbuf(stdout, my_buf);
.
.
.
|
User programs must not depend on the contents of buffer once
I/O has been performed on the stream. The Compaq C RTL might or
might not use buffer for any given I/O operation.
The
setbuf
function originally allowed programmers to substitute larger buffers in
place of the system default buffers in obsolete versions of UNIX. The
large default buffer sizes in modern implementations of C make the use
of this function unnecessary most of the time. The
setbuf
function is retained in the ANSI C standard for compatibility with old
programs. New programs should use
setvbuf
instead, because it allows the programmer to bind the buffer size at
run time instead of compile time, and it returns a testable result
value.
setenv
Inserts or resets the environment variable name in the current
environment list.
Format
#include <stdlib.h>
int setenv (const char *name, const char *value, int
overwrite);
Arguments
name
A variable name in the environment variable list.
value
The value for the environment variable.
overwrite
A value of 0 or 1 indicating whether to reset the environment variable,
if it exists.
Description
This function inserts or resets the environment variable name
in the current environment list. If the variable name does not
exist in the list, it is inserted with the value argument. If
the variable does exist, the overwrite argument is tested.
When the overwrite argument value is:
- 0 (zero) -- then the variable is not reset.
- 1 -- then the variable is reset to value.
Return Values
0
|
Indicates success.
|
--1
|
Indicates an error.
errno
is set to ENOMEM---Not enough memory available to expand the
environment list.
|
setgid
With POSIX IDs disabled, implemented for program portability and serves
no function. It returns 0 (to indicate success).
With POSIX IDs enabled, sets the group IDs.
Format
#include <types.h>
#include <unistd.h>
int setgid (__gid_t gid); (_DECC_V4_SOURCE)
gid_t setgid (gid_t gid); (NOT _DECC_V4_SOURCE)
Arguments
gid
The value to which you want the group IDs set.
Description
This function can be used with POSIX-style identifiers enabled or
disabled.
Note
Currently, POSIX-style IDs are supported only by some OpenVMS versions
done for specific government agencies, but will be integrated into
future OpenVMS releases. OpenVMS Version 7.3-1 does not support
POSIX-style IDs, but it does support 32-bit identifiers.
|
With POSIX IDs disabled (the default), the
setgid
function is implemented for program portability and serves no function.
It returns 0 (to indicate success).
With POSIX-style IDs enabled:
- If the process has the IMPERSONATE privilege, the
setgid
function sets the real group ID, effective group ID, and the saved
set-group-ID to gid.
- If the process does not have appropriate privileges but
gid is equal to the real group ID or to the saved
set-group-ID, then the
setgid
function sets the effective group ID to gid. The real group ID
and saved set-group-ID remain unchanged.
- Any supplementary group IDs of the calling process remain unchanged.
Return Values
0
|
Successful completion.
|
-1
|
Indicates an error. The function sets
errno to one of the following values:
- EINVAL -- The value of the
gid argument is invalid and not supported by the
implementation.
- EPERM -- The process does not have appropriate privileges and
gid does not match the real group ID or the saved set-group-ID.
|
setitimer
Sets the value of interval timers.
Format
#include <time.h>
int setitimer (int which, struct itimerval *value,
struct itimerval *ovalue);
Arguments
which
The type of interval timer. The Compaq C RTL only supports
ITIMER_REAL.
value
A pointer to an
itimerval
structure whose members specify a timer interval and the time left to
the end of the interval.
ovalue
A pointer to an
itimerval
structure whose members specify a current timer interval and the time
left to the end of the interval.
Description
This function sets the timer specified by which to the value
specified by value, returning the previous value of the timer
if ovalue is nonzero.
A timer value is defined by the
itimerval
structure:
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
|
The value of the
itimerval
structure members are: as follows
itimerval Member Value |
Meaning |
it_interval
= 0
|
Disables a timer after its next expiration (Assumes
it_value
is nonzero).
|
it_interval
= nonzero
|
Specifies a value used in reloading
it_value
when the timer expires.
|
it_value
= 0
|
Disables a timer.
|
it_value
= nonzero
|
Indicates the time to the next timer expiration.
|
Time values smaller than the resolution of the system clock are rounded
up to this resolution.
The
getitimer
function provides one interval timer, defined in the
<time.h>
header file as ITIMER_REAL. This timer decrements in real time. When
the timer expires, it delivers a SIGALARM signal.
Note
The interaction between
setitimer
and any of
alarm
,
sleep
, or
usleep
is unspecified.
|
Return Values
0
|
Indicates success.
|
--1
|
An error occurred;
errno
is set to indicate the error.
|
|
|
|