[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here HP C

HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


gcvt

Converts its argument to a null-terminated string of ASCII digits and returns the address of the string.

Format

#include <stdlib.h>

char *gcvt (double value, int ndigit, char *buffer);

Function Variants The gcvt function has variants named _gcvt32 and _gcvt64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

Arguments

value

An object of type double that is converted to a null-terminated string of ASCII digits.

ndigit

The number of ASCII digits to use in the converted string. If ndigit is less than 6, the value of 6 is used.

buffer

A storage location to hold the converted string.

Description

The gcvt function places the converted string in a buffer and returns the address of the buffer. If possible, gcvt produces ndigit significant digits in F-format, or if not possible, in E-format. Trailing zeros are suppressed.

The ecvt , fcvt , and gcvt functions represent the following special values specified in the IEEE Standard for floating-point arithmetic:

Value Representation
Quiet NaN NaNQ
Signalling NaN NaNS
+Infinity Infinity
- Infinity - Infinity

The sign associated with each of these values is stored into the sign argument. In IEEE floating-point representation, a value of 0 (zero) can be positive or negative, as set by the sign argument.

See also fcvt and ecvt .


Return Value

x The address of the buffer.

getc

The getc macro returns the next character from a specified file.

Format

#include <stdio.h>

int getc (FILE *file_ptr);


Argument

file_ptr

A pointer to the file to be accessed.

Description

Since getc is a macro, a file pointer argument with side effects (for example, getc (*f++) ) might be evaluated incorrectly. In such a case, use the fgetc function instead. See the fgetc function.

Return Values

n The returned character.
EOF Indicates the end-of-file or an error.

[w]getch

Get a character from the terminal screen and echo it on the specified window. The getch function echoes the character on the stdscr window.

Format

#include <curses.h>

char getch();

char wgetch (WINDOW *win);


Argument

win

A pointer to the window.

Description

The getch and wgetch functions refresh the specified window before fetching a character. For more information, see the scrollok function.

Return Values

x The returned character.
ERR Indicates that the function makes the screen scroll illegally.

getchar

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

Format

#include <stdio.h>

int getchar (void);


Description

The getchar function is identical to fgetc ( stdin ).

Return Values

x The next character from stdin , converted to int .
EOF Indicates the end-of-file or an error.

getclock

Gets the current value of the systemwide clock.

Format

#include <timers.h>

int getclock (int clktyp, struct timespec *tp);


Arguments

clktyp

The type of systemwide clock.

tp

Pointer to a timespec structure space where the current value of the systemwide clock is stored.

Description

The getclock function sets the current value of the clock specified by clktyp into the location pointed to by tp.

The clktyp argument is given as a symbolic constant name, as defined in the <timers.h> header file. Only the TIMEOFDAY symbolic constant, which specifies the normal time-of-day clock to access for systemwide time, is supported.

For the clock specified by TIMEOFDAY , the value returned by this function is the elapsed time since the Epoch. The Epoch is referenced to 00:00:00 UTC (Coordinated Universal Time) 1 Jan 1970.

The getclock function returns a timespec structure, which is defined in the <timers.h> header file as follows:


 struct  timespec {

  unsigned long  tv_sec   /* Elapsed time in seconds since the Epoch*/
  long           tv_nsec  /* Elapsed time as a fraction of a second */
                          /* since the Epoch (in nanoseconds)       */

 };

Return Values

0 Indicates success.
- 1 Indicates an error; errno is set to one of the following values:
  • EINVAL -- The clktyp argument does not specify a known systemwide clock.

    Or, the value of SYS$TIMEZONE_DIFFERENTIAL logical is wrong.

  • EIO -- An error occurred when the systemwide clock specified by the clktyp argument was accessed.

getcwd

Returns a pointer to the file specification for the current working directory.

Format

#include <unistd.h>

char *getcwd (char *buffer, size_t size); (ISO POSIX-1)

char *getcwd (char *buffer, unsigned int size, ...); (HP C EXTENSION)

Function Variants The getcwd function has variants named _getcwd32 and _getcwd64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

Arguments

buffer

Pointer to a character string large enough to hold the directory specification.

If buffer is a NULL pointer, getcwd obtains size bytes of space using malloc . In this case, you can use the pointer returned by getcwd as the argument in a subsequent call to free .

size

The length of the directory specification to be returned.

...

An optional argument that can be either 1 or 0. If you specify 1, the directory specification is returned in OpenVMS format. If you specify 0, the directory specification (pathname) is returned in UNIX style format. If you omit this argument, getcwd returns the file name according to your current command-language interpreter (CLI). For more information about UNIX style directory specifications, see Section 1.4.3.

Return Values

x A pointer to the file specification.
NULL Indicates an error.

getdtablesize

Gets the total number of file descriptors that a process can have open simultaneously.

Format

#include <unistd.h>

int getdtablesize (void);


Description

The getdtablesize function returns the total number of file descriptors that a process can have open simultaneously. Each process is limited to a fixed number of open file descriptors.

The number of file descriptors that a process can have open is the minumum of the following:

  • HP C RTL open file limit---65535 on OpenVMS Alpha; 2048 on OpenVMS VAX.
  • SYSGEN CHANNELCNT parameter---permanent I/O channel count.
  • Process open file quota FILLM parameter---number of open files that can be opened by a process at one time.

Return Values

x The number of file descriptors that a process can have open simultaneously.
- 1 Indicates an error.

getegid

With POSIX IDs disabled, this function is equivalent to getgid and returns the group number from the user identification code (UIC).

With POSIX IDs enabled, this function returns the effective group ID of the calling process.


Format

#include <unistd.h>

gid_t getegid (void);


Description

The getegid function can be used with POSIX style identifiers (IDs) or with UIC-based identifiers.

POSIX style IDs are supported on OpenVMS Version 7.3-2 and higher.

With POSIX style IDs disabled, the getegid and getgid functions are equivalent and return the group number from the current UIC. For example, if the UIC is [313,031], 313 is the group number.

With POSIX style IDs enabled, getegid returns the effective group ID of the calling process, and getgid returns the real group ID of the calling process. The real group ID is specified at login time. The effective group ID is more transient, and determines additional access permission during execution of a set-group-ID process. It is for such processes that the getgid function is most useful.

The getegid function is always successful; no return value is reserved to indicate an error.

To enable/disable POSIX style IDs, see Section 1.7.

See also geteuid and getuid .


Return Value

x The effective group ID (POSIX IDs enabled), or the group number from the UIC (POSIX IDs disabled).

getenv

Searches the environment array for the current process and returns the value associated with a specified environment name.

Format

#include <stdlib.h>

char *getenv (const char *name);


Argument

name

One of the following values:
  • HOME---Your login directory
  • TERM---The type of terminal being used
  • PATH---The default device and directory
  • USER---The name of the user who initiated the process
  • Logical name or command-language interpreter (CLI) symbolic name
  • An environment variable set with setenv or putenv

The case of the specified name is important.


Description

In certain situations, the getenv function attempts to perform a logical name translation on the user-specified argument:
  1. If the argument to getenv does not match any of the environment strings present in your environment array, getenv attempts to translate your argument as a logical name by searching the logical name tables indicated by the LNM$FILE_DEV logical, as is done for file processing.
    getenv first does a case-sensitive lookup. If that fails, it does a case-insensitive lookup. In most instances, logical names are defined in uppercase, but getenv can also find logical names that include lowercase letters.
    getenv does not perform iterative logical name translation.
  2. If the logical name is a search list with multiple equivalence values, the returned value points to the first equivalence value. For example:


    $ DEFINE A B,C
    
    ptr = getenv("A");
    

    A returns a pointer to " B ".
  3. If no logical name exists, getenv attempts to translate the argument string as a CLI symbol. If it succeeds, it returns the translated symbol text. If it fails, the return value is NULL.
    getenv does not perform iterative CLI translation.

If your CLI is the DEC/Shell, the function does not attempt a logical name translation since Shell environment symbols are implemented as DCL symbols.

Notes

  • In OpenVMS Version 7.1, a cache of OpenVMS environment variables (that is, logical names and DCL symbols) was added to the getenv function to avoid the library making repeated calls to translate a logical name or to obtain the value of a DCL symbol. By default, the cache is disabled. If your application does not need to track changes in OpenVMS environment variables that can occur during its execution, the cache can be enabled by enabling the DECC$ENABLE_GETENV_CACHE logical before invoking the application.
  • Do not use the setenv , getenv , and putenv functions to manipulate symbols and logicals. Instead use the OpenVMS library calls lib$set_logical , lib$get_logical , lib$set_symbol , and lib$get_symbol . The * env functions deliberately provide UNIX behavior, and are not a substitute for these OpenVMS runtime library calls.

    OpenVMS DCL symbols, not logical names, are the closest analog to environment variables on UNIX systems. While getenv is a mechanism to retrieve either a logical name or a symbol, it maintains an internal cache of values for use with setenv and subsequent getenv calls. The setenv function does not write or create DCL symbols or OpenVMS logical names.

    This is consistent with UNIX behavior. On UNIX systems, setenv does not change or create any symbols that will be visible in the shell after the program exits.

Return Values

x Pointer to an array containing the translated symbol. An equivalence name is returned at index zero.
NULL Indicates that the translation failed.

geteuid

With POSIX IDs disabled, this function is equivalent to getuid and returns the member number (in OpenVMS terms) from the user identification code (UIC).

With POSIX IDs enabled, this function returns the effective user ID.


Format

#include <unistd.h>

uid_t geteuid (void);


Description

The geteuid function can be used with POSIX style identifiers (IDs) or with UIC-based identifiers.

POSIX style IDs are supported on OpenVMS Version 7.3-2 and higher.

With POSIX style IDs disabled (the default), the geteuid and getuid functions are equivalent and return the member number from the current UIC as follows:

  • 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.

With POSIX style IDs enabled, geteuid returns the effective user ID of the calling process, and getuid returns the real user ID of the calling process.

To enable/disable POSIX style IDs, see Section 1.7.

See also getegid and getgid .


Return Value

x The effective user ID (POSIX IDs enabled), or the member number from the current UIC or the full UIC (POSIX IDs disabled).

getgid

With POSIX IDs disabled, this function is equivalent to getegid and returns the group number from the user identification code (UIC).

With POSIX IDs enabled, this function returns the real group ID.


Format

#include <unistd.h>

gid_t getgid (void);


Description

The getgid function can be used with POSIX style identifiers or with UIC-based identifiers.

POSIX style IDs are supported on OpenVMS Version 7.3-2 and higher.

With POSIX style IDs disabled (the default), the getegid and getgid functions are equivalent and return the group number from the current UIC. For example, if the UIC is [313,031], 313 is the group number.

With POSIX style IDs enabled, getegid returns the effective group ID of the calling process, and getgid returns the real group ID of the calling process. The real group ID is specified at login time. The effective group ID is more transient, and determines additional access permission during execution of a set-group-ID process. It is for such processes that the getgid function is most useful.

To enable/disable POSIX style IDs, see Section 1.7.

See also geteuid and getuid .


Return Value

x The real group ID (POSIX IDs enabled), or the group number from the current UIC (POSIX IDs disabled).

getgrent (ALPHA ONLY)

Gets a group database entry.

Format

#include <grp.h>

struct group *getgrent (void);


Description

The getgrent function returns the next group in the sequential search, returning a pointer to a structure containing the broken-out fields of an entry in the group database.

When first called, getgrent returns a pointer to a group structure containing the first entry in the group database. Thereafter, it returns a pointer to the next group structure in the group database, so successive calls can be used to search the entire database.

If an end-of-file or an error is encountered on reading, getgrent returns a NULL pointer and sets errno .


Return Values

x Pointer to a group structure, if successful.
NULL Indicates that an error occurred. The function sets errno to one of the following values:
  • EACCES -- The user process does not have appropriate privileges enabled to access the user authorization file.
  • EINTR -- A signal was caught during the operation.
  • EIO -- Indicates that an I/O error occurred.
  • EMFILE -- OPEN_MAX file descriptors are currently open in the calling process.
  • ENFILE -- The maximum allowable number of files is currently open in the system.


Previous Next Contents Index