HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index

12.10 GNV

GNV is the mechanism by which the Open Group utilities are provided on OpenVMS systems. GNV is an open source project with updates released on the Sourceforge web site. GNV is also available on the OpenVMS Open Source CD.

Because GNV relies on the C RTL for all file access, no modifications are made to GNV for its provided utilities to behave as defined by the Open Group specification for symbolic links. To make use of the new symbolic-link and POSIX pathname support features, users should set the C RTL DECC$POSIX_COMPLIANT_PATHNAMES feature logical appropriately, before invoking BASH.

12.11 Restrictions

The following are known restrictions with symbolic link support:


Reference Section

This section describes the functions contained in the HP C Run-Time Library (RTL), listed alphabetically.


a64l (INTEGRITY SERVERS, ALPHA)

Converts a character string to a long integer.

Format

#include <stdlib.h>

long a64l (const char *s);


Argument

s

Pointer to the character string that is to be converted to a long integer.

Description

The a64l and l64a functions are used to maintain numbers stored in base-64 ASCII characters as follows:

Each character used for storing a long integer represents a numeric value from 0 through 63. Up to six characters can be used to represent a long integer.

The characters are translated as follows:

The a64l function takes a pointer to a base-64 representation, in which the first digit is the least significant, and returns a corresponding long value. If the string pointed to by the s parameter exceeds six characters, a64l uses only the first six characters.

If the first six characters of the string contain a null terminator, a64l uses only characters preceding the null terminator.

The a64l function translates a character string from left to right with the least significant number on the left, decoding each character as a 6-bit base-64 number.

If s is the NULL pointer or if the string pointed to by s was not generated by a previous call to l64a , the behavior of a64l is unspecified.

See also l64a .


Return Values

n Upon successful completion, the long value resulting from conversion of the input string.
0L Indicates that the string pointed to by s is an empty string.

abort

Sends the signal SIGABRT that terminates execution of the program.

Format

#include <stdlib.h>

void abort (void);


abs

Returns the absolute value of an integer.

Format

#include <stdlib.h>

int abs (int x);


Argument

x

An integer.

Return Value

x The absolute value of the input argument. If the argument is LONG_MIN, abs returns LONG_MIN because --LONG_MIN cannot fit in an int variable.

access

Checks a file to see whether a specified access mode is allowed.

Note

The access function does not accept network files as arguments.

Format

#include <unistd.h>

int access (const char *file_spec, int mode);


Arguments

file_spec

A character string that gives an OpenVMS or UNIX style file specification. The usual defaults and logical name translations are applied to the file specification.

mode

Interpreted as shown in Table REF-1.

Table REF-1 Interpretation of the mode Argument
Mode Argument Access Mode
F_OK Tests to see if the file exists
X_OK Execute
W_OK Write (implies delete access)
R_OK Read

Combinations of access modes are indicated by ORing the values. For example, to check to see if a file has RWED access mode, invoke access as follows:


access (file_spec, R_OK | W_OK | X_OK); 


Description

The access function checks a file to see whether a specified access mode is allowed. If the DECC$ACL_ACCESS_CHECK feature logical is enabled, this function checks OpenVMS Access Control Lists (ACLs) as well as the UIC protection.

Return Values

0 Indicates that the access is allowed.
- 1 Indicates that the access is not allowed.

Example


#include <unistd.h> 
#include <stdlib.h> 
#include <stdio.h> 
 
main() 
{ 
    if (access("sys$login:login.com", F_OK)) { 
        perror("ACCESS - FAILED"); 
        exit(2); 
    } 
} 


acos

Returns the arc cosine of its argument.

Format

#include <math.h>

double acos (double x);

float acosf (float x); (INTEGRITY SERVERS, ALPHA)

long double acosl (long double x); (INTEGRITY SERVERS, ALPHA)

double acosd (double x); (INTEGRITY SERVERS, ALPHA)

float acosdf (float x); (INTEGRITY SERVERS, ALPHA)

long double acosdl (long double x); (INTEGRITY SERVERS, ALPHA)


Argument

x

A radian expressed as a real value in the domain [ - 1,1].

Description

The acos functions compute the principal value of the arc cosine of x in the range [0,pi] radians for x in the domain [ - 1,1].

The acosd functions compute the principal value of the arc cosine of x in the range [0,180] degrees for x in the domain [ - 1,1].

For abs (x) > 1, the value of acos (x) is 0, and errno is set to EDOM.


acosh (INTEGRITY SERVERS, ALPHA)

Returns the hyperbolic arc cosine of its argument.

Format

#include <math.h>

double acosh (double x);

float acoshf (float x);

long double acoshl (long double x);


Argument

x

A radian expressed as a real value in the domain [1, +Infinity].

Description

The acosh functions return the hyperbolic arc cosine of x for x in the domain [1, +Infinity], where acosh (x) = ln(x + sqrt(x**2 - 1)).

The acosh function is the inverse function of cosh where acosh ( cosh (x)) = |x|.

x < 1 is an invalid argument.


[w]addch

Add a character to the window at the current position of the cursor.

Format

#include <curses.h>

int addch (char ch);

int waddch (WINDOW *win, char ch);


Arguments

win

A pointer to the window.

ch

The character to be added. A new-line character (\n) clears the line to the end, and moves the cursor to the next line at the same x coordinate. A return character (\r) moves the cursor to the beginning of the line on the window. A tab character (\t) moves the cursor to the next tabstop within the window.

Description

When the waddch function is used on a subwindow, it writes the character onto the underlying window as well.

The addch routine performs the same function as waddch , but on the stdscr window.

The cursor is moved after the character is written to the screen.


Return Values

OK Indicates success.
ERR Indicates that writing the character would cause the screen to scroll illegally. For more information, see the scrollok function.

[w]addstr

Add the string pointed to by str to the window at the current position of the cursor.

Format

#include <curses.h>

int addstr (char *str);

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


Arguments

win

A pointer to the window.

str

A pointer to a character string.

Description

When the waddstr function is used on a subwindow, the string is written onto the underlying window as well.

The addstr routine performs the same function as waddstr , but on the stdscr window.

The cursor position changes as a result of calling this routine.


Return Values

OK Indicates success.
ERR Indicates that the function causes the screen to scroll illegally, but it places as much of the string onto the window as possible. For more information, see the scrollok function.

alarm

Sends the signal SIGALRM (defined in the <signal.h> header file) to the invoking process after the number of seconds indicated by its argument has elapsed.

Format

#include <unistd.h>

unsigned int alarm (unsigned int seconds); (ISO POSIX-1)

int alarm (unsigned int seconds); (COMPATIBILITY)


Argument

seconds

Has a maximum limit of LONG_MAX seconds.

Description

Calling the alarm function with a 0 argument cancels any pending alarms.

Unless it is intercepted or ignored, the signal generated by alarm terminates the process. Successive alarm calls reinitialize the alarm clock. Alarms are not stacked.

Because the clock has a 1-second resolution, the signal may occur up to 1 second early. If the SIGALRM signal is intercepted, resumption of execution may be held up due to scheduling delays.

When the SIGALRM signal is generated, a call to SYS$WAKE is generated whether or not the process is hibernating. The pending wake causes the current pause () to return immediately (after completing any function that catches the SIGALRM).


Return Value

n The number of seconds remaining from a previous alarm request.

asctime, asctime_r

Converts a broken-down time in a tm structure into a 26-character string in the following form:


Sun Sep 16 01:03:52 1984\n\0 

All fields have a constant width.


Format

#include <time.h>

char *asctime (const struct tm *timeptr);

char *asctime_r (const struct tm *timeptr, char *buffer); (ISO POSIX-1)


Arguments

timeptr

A pointer to a structure of type tm , which contains the broken-down time.

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

buffer

A pointer to a character array that is at least 26 bytes long. This array is used to store the generated date-and-time string.

Description

The asctime and asctime_r functions convert the contents of tm into a 26-character string and returns a pointer to the string.

The difference between asctime_r and asctime is that the former puts the result into a user-specified buffer. The latter puts the result into thread-specific static memory allocated by the HP C RTL, which can be overwritten by subsequent calls to ctime or asctime ; you must make a copy if you want to save it.

On success, asctime returns a pointer to the string; asctime_r returns its second argument. On failure, these functions return the NULL pointer.

See the localtime function for a list of the members in tm .

Note

Generally speaking, UTC-based time functions can affect in-memory time-zone information, which is processwide 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 A pointer to the string, if successful.
NULL Indicates failure.

asin

Returns the arc sine of its argument.

Format

#include <math.h>

double asin (double x);

float asinf (float x); (INTEGRITY SERVERS, ALPHA)

long double asinl (long double x); (INTEGRITY SERVERS, ALPHA)

double asind (double x); (INTEGRITY SERVERS, ALPHA)

float asindf (float x); (INTEGRITY SERVERS, ALPHA)

long double asindl (long double x); (INTEGRITY SERVERS, ALPHA)


Argument

x

A radian expressed as a real number in the domain [ - 1,1].

Description

The asin functions compute the principal value of the arc sine of x in the range [ - pi/2,pi/2] radians for x in the domain [ - 1,1].

The asind functions compute the principal value of the arc sine of x in the range [ - 90,90] degrees for x in the domain [ - 1,1].

When abs (x) is greater than 1.0, the value of asin (x) is 0, and errno is set to EDOM.


asinh (INTEGRITY SERVERS, ALPHA)

Returns the hyperbolic arc sine of its argument.

Format

#include <math.h>

double asinh (double x);

float asinhf (float x);

long double asinhl (long double x);


Argument

x

A radian expressed as a real value in the domain [ - Infinity, +Infinity].

Description

The asinh functions return the hyperbolic arc sine of x for x in the domain [ - Infinity, +Infinity], where asinh (x) = ln(x + sqrt(x**2 + 1)).

The asinh function is the inverse function of sinh where asinh ( sinh (x)) = x.


assert

Used for implementing run-time diagnostics in programs.

Format

#include <assert.h>

void assert (int expression);


Argument

expression

An expression that has an int type.

Description

When assert is executed, if expression is false (that is, it evaluates to 0), assert writes information about the particular call that failed (including the text of the argument, the name of the source file, and the source line number; the latter two are, respectively, the values of the preprocessing macros __FILE__ and __LINE__ ) to the standard error file in an implementation-defined format. Then, it calls the abort function.

The assert function writes a message in the following form:


Assertion failed:  expression, file aaa, line nnn

If expression is true (that is, it evaluates to nonzero) or if the signal SIGABRT is being ignored, assert returns no value.

Note

If a null character ('\0') is part of the expression being asserted, then only the text up to and including the null character is printed, since the null character effectively terminates the string being output.

Compiling with the CC command qualifier /DEFINE=NDEBUG or with the preprocessor directive #define NDEBUG ahead of the #include assert statement causes the assert function to have no effect.


Example


#include <stdio.h> 
#include <assert.h> 
 
main() 
{ 
    printf("Only this and the assert\n"); 
    assert(1 == 2);     /* expression is FALSE */ 
 
    /* abort should be called so the printf will not happen. */ 
 
    printf("FAIL abort did not execute"); 
} 


atan


Format

#include <math.h>

double atan (double x);

float atanf (float x); (INTEGRITY SERVERS, ALPHA)

long double atanl (long double x); (INTEGRITY SERVERS, ALPHA)

double atand (double x); (INTEGRITY SERVERS, ALPHA)

float atandf (float x); (INTEGRITY SERVERS, ALPHA)

long double atandl (long double x); (INTEGRITY SERVERS, ALPHA)


Argument

x

A radian expressed as a real number.

Description

The atan functions compute the principal value of the arc tangent of x in the range [ -pi/2,pi/2 ] radians.

The atand functions compute the principal value of the arc tangent of x in the range [ - 90,90] degrees.


Previous Next Contents Index