DEC C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


getpagesize

Gets the system page size.

Format

#include <unistd.h>

int getpagesize (void);


Description

This function returns the number of bytes in a page. The system page size is useful for specifying arguments to memory management system calls.

The page size is a system page size and is not necessarily the same as the underlying hardware page size.


Return Values

x Always indicates success. Returns the number of bytes in a page.

getpid

Returns the process ID of the current process.

Format

#include <unistd.h>

pid_t getpid (void);


Return Value

x The process ID of the current process.

getppid

Returns the parent process ID of the calling process.

Format

#include <unistd.h>

pid_t getppid (void);


Return Values

x The parent process ID.
0 Indicates that the calling process does not have a parent process.

getpwnam

Accesses user-name information in the user database.

Format

#include <pwd.h>

struct passwd *getpwnam (const char name);


Arguments

name

The name of the user for which the attributes are to be read.

Description

This function returns the first user entry in the database with the pw_name member of the passwd structure that matches the name argument.

The passwd structure is defined in the <pwd.h> header file as follows:
pw_name The user's login name.
pw_uid The numerical user ID.
pw_gid The numerical group ID.
pw_dir The home directory of the user.
pw_shell The initial program for the user.

Note

All information generated by the getpwnam function is stored in a static area and is overwritten on subsequent calls to the function.

Return Values

x A pointer to a valid password structure.
NULL An error occurred. errno is set to indicate the error.

getpwuid

Accesses user-ID information in the rights database.

Format

#include <pwd.h>

struct passwd *getpwuid (uid_t uid);


Arguments

uid

The ID of the user for which the attributes are to be read.

Description

This function accesses the identifier names of all identifiers in the rights database. It returns the first user entry in the rights database with a pw_uid member of the passwd structure that matches the uid argument.

The passwd structure is defined in the <pwd.h> header file as follows:
pw_name The user's login name.
pw_uid The numerical user ID.
pw_gid The numerical group ID.
pw_dir The home directory of the user.
pw_shell The initial program for the user.

To check for error situations, applications should set errno to zero before calling getpwuid . If errno is non-zero on return, then an error occurred.

Note

All information generated by the getpwuid function is stored in a per-thread static area and is overwritten on subsequent calls to the function.

Return Values

x A pointer to a valid password structure.
NULL An error occurred. errno is set to indicate the error.

gets

Reads a line from the standard input (stdin).

Format

#include <stdio.h>

char *gets (char *str);

Function Variants This function also has variants named _gets32 and _gets64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Argument

str

A pointer to a character string that is large enough to hold the information fetched from stdin.

Description

The new-line character (\n) that ends the line is replaced by the function with an ASCII null character (\0).

When stdin is opened in record mode, gets treats the end of a record the same as a new-line character and, therefore, reads up to and including a new-line character or to the end of the record.


Return Values

x A pointer to the str argument.
NULL Indicates that an error has occurred or that the end-of-file was encountered before a new-line character was encountered. The contents of str are undefined if a read error occurs.

[w]getstr

Get a string from the terminal screen, store it in the variable str, and echo it on the specified window. The getstr function works on the stdscr window.

Format

#include <curses.h>

int getstr (char *str);

int wgetstr (WINDOW *win, char *str);


Arguments

win

A pointer to the window.

str

Must be large enough to hold the character string fetched from the window.

Description

The getstr and wgetstr functions refresh the specified window before fetching a string. The new-line terminator is stripped from the fetched string. For more information, see the scrollok function in this section.

Return Values

OK Indicates success.
ERR Indicates that the function makes the screen scroll illegally.

gettimeofday

Gets date and time.

Format

#include <time.h>

int gettimeofday (struct timeval *tp, void *tpz);


Arguments

tp

Pointer to a timeval structure, defined in the <time.h> header file.

tpz

A NULL pointer. If this argument is not a NULL pointer, the behavior is unspecified.

Description

This function gets the current time (expressed as seconds and microseconds) since 00::00 Coordinated Universal Time, January 1, 1970. The current time is stored in the timeval structure pointed to by the tp argument.

The tzp argument is intended to hold time-zone information set by the kernel. However, because the OpenVMS kernel does not set time-zone information, the tzp argument should be NULL. If it is not NULL, it is ignored. This function is supported for compatibility with BSD programs.

If the value of the SYS$TIMEZONE_DIFFERENTIAL logical is wrong, the function fails with errno set to EINVAL.


Return Values

0 Indicates success.
--1 An error occurred. errno is set to indicate the error.

getuid

Returns, in OpenVMS terms, the member number from the user identification code (UIC). For example, if the UIC is [313,031], 031 is the member number.

Format

#include <unistd.h>

uid_t getuid (void);


Description

In DEC C for OpenVMS Systems, getuid and geteuid perform the same function.

For programs compiled with the _VMS_V6_SOURCE feature-test macro or programs that do not include the <unistd.h> header file, the getuid and geteuid functions return the member number of the OpenVMS UIC. For example, if the UIC is [313,31], then the member number, 31, is returned.

For programs compiled without the _VMS_V6_SOURCE feature-test macro that do include the <unistd.h> header file, the full UIC is returned. For example, if the UIC is [313, 31] then 20512799 (31 + 313 * 65536) is returned.


Return Value

x The member number from the current UIC, or the full UIC. See description.

getw

Returns characters from a specified file.

Format

#include <stdio.h>

int getw (FILE *file_ptr);


Argument

file_ptr

A pointer to the file to be accessed.

Description

This function returns the next four characters from the specified input file as an int .

Return Values

x The next four characters, in an int .
EOF Indicates that the end-of-file was encountered during the retrieval of any of the four characters and all four characters were lost. Since EOF is an acceptable integer, use feof and ferror to check the success of the function.

getwc

Reads the next character from a specified file, and converts it to a wide-character code.

Format

#include <wchar.h>

wint_t getwc (FILE *file_ptr);


Arguments

file_ptr

A pointer to the file to be accessed.

Description

Since getwc is implemented as a macro, a file pointer argument with side effects (for example getwc (*f++) ) might be evaluated incorrectly. In such a case, use the fgetwc function instead. See the fgetwc function in this section.

Return Values

n The returned character.
WEOF Indicates the end-of-file or an error. If an error occurs, the function sets errno . For a list of the values set by this function, see fgetwc in this section.

getwchar

Reads a single wide character from the standard input (stdin).

Format

#include <wchar.h>

wint_t getwchar (void);


Description

The getwchar function is identical to fgetwc(stdin) .

Return Values

x The next character from stdin, converted to wint_t .
WEOF Indicates the end-of-file or an error. If an error occurs, the function sets errno . For a list of the values set by this function, see fgetwc in this section.

getyx

Puts the (y,x) coordinates of the current cursor position on win in the variables y and x.

Format

#include <curses.h>

getyx (WINDOW *win, int y, int x);


Arguments

win

Must be a pointer to the window.

y

Must be a valid lvalue.

x

Must be a valid lvalue.

gmtime, gmtime_r

Converts time units to the broken-down UTC time.

Format

#include <time.h>

struct tm *gmtime (const time_t *timer);

struct tm *gmtime_r (const time_t *timer, struct tm *result);

(ISO POSIX-1)

Function Variants Compiling with the _DECC_V4_SOURCE and _VMS_V6_SOURCE feature-test macros defined enables a local-time-based entry point to this function that is equivalent to the behavior before OpenVMS Version 7.0.

Arguments

timer

Points to a variable that specifies a time value in seconds since the Epoch.

result

A pointer to a tm structure where the result is stored.

The tm structure is defined in the <time.h> header, and is also shown in Table REF-4 in the description of localtime .


Description

The gmtime and gmtime_r functions convert the time (in seconds since the Epoch) pointed to by timer into a broken-down time, expressed as Coordinated Universal Time (UTC), and store it in a tm structure.

The difference between the gmtime_r and gmtime functions is that the former puts the result into a user-specified tm structure where the result is stored. The latter puts the result into thread-specific static memory allocated by the DEC C RTL, and which is overwritten by subsequent calls to gmtime ; you must make a copy if you want to save it.

On success, gmtime returns a pointer to the tm structure; gmtime_r returns its second argument. On failure, these functions return the NULL pointer.

Note

Generally speaking, UTC-based time functions can affect in-memory time-zone information, which is process-wide data. However, if the system time zone remains the same during the execution of the application (which is the common case) and the cache of timezone files is enabled (which is the default), then the _r variant of the time functions asctime_r , ctime_r , gmtime_r and localtime_r , is both thread-safe and AST-reentrant.

If, however, the system time zone can change during the execution of the application or the cache of timezone files is not enabled, then both variants of the UTC-based time functions belong to the third class of functions, which are neither thread-safe nor AST-reentrant.

Return Values

x Pointer to a tm structure.
NULL Indicates an error; errno is set to one of the following values:
  • EINVAL -- The timer argument is NULL.

gsignal

Generates a specified software signal, which invokes the action routine established by a signal , ssignal , or sigvec function.

Format

#include <signal.h>

int gsignal (int sig [, int sigcode]);


Arguments

sig

The signal to be generated.

sigcode

An optional signal code. For example, signal SIGFPE---the arithmetic trap signal---has 10 different codes, each representing a different type of arithmetic trap.

The signal codes can be represented by mnemonics or numbers. The arithmetic trap codes are represented by the numbers 1 to 10, but the SIGILL codes are represented by the numbers 0 to 2. The code values are defined in the <signal.h> header file. See Tables 4-4 and 4-5 for a list of signal mnemonics, codes, and corresponding OpenVMS exceptions.


Description

Calling this function has one of the following results:

See also raise , signal , ssignal , and sigvec in this section.

See Chapter 4 for more information.


Return Values

0 Indicates a sig argument that is outside the range defined in the <signal.h> header file; errno is set to EINVAL.
sig Indicates that SIG_IGN (ignore signal) has been established as the action for the signal.
x Indicates that signal , ssignal , or sigvec has established an action function for the signal. That function is called, and its return value is returned by gsignal .

hypot

Returns the square root of the sum of the squares of two arguments:

sqrt(x2 + y2)


Format

#include <math.h>

double hypot (double x, double y);


Arguments

x

A real value.

y

A real value.

Description

On overflow, the return value is undefined.


Previous Next Contents Index