HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


div

Returns the quotient and the remainder after the division of its arguments.

Format

#include <stdlib.h>

div_t div (int numer, int denom);


Arguments

numer

A numerator of type int .

denom

A denominator of type int .

Description

The type div_t is defined in the standard header file <stdlib.h> as follows:


typedef struct 
        { 
             int   quot, rem; 
        } div_t; 


dlclose

Deallocates the address space for a shared library.

Format

#include <dlfcn.h>

void dlclose (void *handle);


Argument

handle

Pointer to the shared library.

Description

The dlclose function deallocates the address space allocated by the HP C RTL for the handle.

There is no way on OpenVMS systems to unload a shareable image dynamically loaded by the LIB$FIND_IMAGE_SYMBOL routine, which is the routine called by the dlsym function. In other words, there is no way on OpenVMS systems to release the address space occupied by the shareable image brought into memory by dlsym .


dlerror

Returns a string describing the last error that occurred from a call to dlopen , dlclose , or dlsym .

Format

#include <dlfcn.h>

char *dlerror (void);


Return Value

x A string describing the last error that occurred from a call to dlopen , dlclose , or dlsym .

dlopen

Provides an interface to the dynamic library loader to allow shareable images to be loaded and called at run time.

Format

#include <dlfcn.h>

void *dlopen (char *pathname, int mode);


Arguments

pathname

The name of the shareable image. This name is saved for subsequent use by the dlsym function.

mode

This argument is ignored on OpenVMS systems.

Description

The dlopen function provides an interface to the dynamic library loader to allow shareable images to be loaded and called at run time.

This function does not load a shareable image but rather saves its pathname argument for subsequent use by the dlsym function. dlsym is the function that actually loads the shareable image through a call to LIB$FIND_IMAGE_SYMBOL.

The pathname argument of the dlopen function must be the name of the shareable image. This name is passed as-is by the dlsym function to the LIB$FIND_IMAGE_SYMBOL routine as the filename argument. No image-name argument is specified in the call to LIB$FIND_IMAGE_SYMBOL, so default file specification of SYS$SHARE:.EXE is applied to the image name.

The dlopen function returns a handle that is used by a dlsym or dlclose call. If an error occurs, a NULL pointer is returned.


Return Values

x A handle to be used by a dlsym or dlclose call.
NULL Indicates an error.

dlsym

Returns the address of the symbol name found in a shareable image.

Format

#include <dlfcn.h>

void *dlsym (void *handle, char *name);


Arguments

handle

Pointer to the shareable image.

name

Pointer to the symbol name.

Description

The dlsym function returns the address of the symbol name found in the shareable image corresponding to handle. If the symbol is not found, a NULL pointer is returned.

As of OpenVMS Version 7.3-2, library symbols containing lowercase characters can be loaded using the dlsym function. More generally, the functions that dynamically load libraries ( dlopen , dlsym , dlclose , dlerror ) are enhanced to provide the following capabilities:


Return Values

x Address of the symbol name found.
NULL Indicates that the symbol was not found.

drand48

Generates uniformly distributed pseudorandom-number sequences. Returns 48-bit, nonnegative, double-precision floating-point values.

Format

#include <stdlib.h>

double drand48 (void);


Description

The drand48 function generates pseudorandom numbers using the linear congruential algorithm and 48-bit integer arithmetic.

It returns nonnegative, double-precision, floating-point values uniformly distributed over the range of y values such that 0.0 <= y < 1.0.

Before you call drand48 , use either srand48 , seed48 , or lcong48 to initialize the random-number generator. You must initialize prior to invoking the drand48 function because it stores the last 48-bit Xi generated into an internal buffer. (Although it is not recommended, constant default initializer values are supplied automatically if the drand48 , lrand48 , or mrand48 functions are called without first calling an initialization function.)

The drand48 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 lcong48 , the multiplier value a and the addend value c are:


     a = 5DEECE66D16 = 2736731631558
     c = B16 = 138

The values returned by drand48 are computed by first generating the next 48-bit Xi in the sequence. Then the appropriate bits, according to the type of returned data item, are copied from the high-order (most significant) bits of Xi and transformed into the returned value.

See also srand48 , seed48 , lcong48 , lrand48 , and mrand48 .


Return Value

n A nonnegative, double-precision, floating-point value.

dup, dup2

Allocate a new descriptor that refers to a file specified by a file descriptor returned by open , creat , or pipe .

Format

#include <unistd.h>

int dup (int file_desc1);

int dup2 (int file_desc1, int file_desc2);


Arguments

file_desc1

The file descriptor being duplicated.

file_desc2

The new file descriptor to be assigned to the file designated by file_desc1.

Description

The dup function causes a previously unallocated descriptor to refer to its argument, while the dup2 function causes its second argument to refer to the same file as its first argument.

The argument file_desc1 is invalid if it does not describe an open file; file_desc2 is invalid if the new file descriptor cannot be allocated. If file_desc2 is connected to an open file, that file is closed.


Return Values

n The new file descriptor.
- 1 Indicates that an invalid argument was passed to the function.

[no]echo

Set the terminal so that characters may or may not be echoed on the terminal screen. This mode of single-character input is only supported with Curses.

Format

#include <curses.h>

void echo (void);

void noecho (void);


Description

The noecho function may be helpful when accepting input from the terminal screen with wgetch and wgetstr ; it prevents the input characters from being written onto the screen.

ecvt

Converts its argument to a null-terminated string of ASCII digits and returns the address of the string. The string is stored in a thread-specific memory location created by the HP C RTL.

Format

#include <stdlib.h>

char *ecvt (double value, int ndigits, int *decpt, int *sign);


Arguments

value

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

ndigits

The number of ASCII digits to be used in the converted string.

decpt

The position of the decimal point relative to the first character in the returned string. A negative int value means that the decimal point is decpt number of spaces to the left of the returned digits (the spaces being filled with zeros). A 0 value means that the decimal point is immediately to the left of the first digit in the returned string.

sign

An integer value that indicates whether the value argument is positive or negative. If value is negative, the function places a nonzero value at the address specified by sign. Otherwise, the function assigns 0 to the address specified by sign.

Description

The ecvt function converts value to a null-terminated string of length ndigits, and returns a pointer to it. The resulting low-order digit is rounded to the correct digit for outputting ndigits digits in C E-format. The decpt argument is assigned the position of the decimal point relative to the first character in the string.

Repeated calls to the ecvt function overwrite any existing string.

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 gcvt and fcvt .


Return Value

x The value of the converted string.

encrypt

Encrypts a string using the key generated by the setkey function.

Format

#include <unistd.h>

#include <stdlib.h>

void encrypt (char *block[64], int edflag;)


Argument

block

A character array of length 64 containing 0s and 1s.

edflag

An integer. If edflag is 0, the argument is encrypted; if nonzero, it is decrypted.

Description

The encrypt function encrypts a string using the key generated by the setkey function.

The first argument to encrypt is a character array of length 64 containing 0s and 1s. The argument array is modified in place to a similar array representing the bits of the argument after having been subjected to the DES algorithm using the key set by setkey .

The second argument, edflag, determines whether the first argument is encrypted or decrypted: if edflag is 0, the first argument array is encrypted; if nonzero, it is decrypted.

No value is returned.

See also crypt and setkey .


Return Value

pointer Pointer to the encrypted password.

endgrent (INTEGRITY SERVERS, ALPHA)

Closes the group database when processing is complete.

Format

#include <grp.h>

void endgrent (void);


Description

The endgrent function closes the group database.

This function is always successful. No value is returned, and errno is not set.


endpwent

Closes the user database and any private stream used by getpwent .

Format

#include <pwd.h>

void endpwent (void);


Description

The endpwent function closes the user database and any private stream used by getpwent .

No value is returned. If an I/O error occurred, the function sets errno to EIO.

See also getpwent , getpwuid , getpwnam , and setpwent .


endwin

Clears the terminal screen and frees any virtual memory allocated to Curses data structures.

Format

#include <curses.h>

void endwin (void);


Description

A program that calls Curses functions must call the endwin function before exiting to restore the previous environment of the terminal screen.

erand48

Generates uniformly distributed pseudorandom-number sequences. Returns 48-bit nonnegative, double-precision, floating-point values.

Format

#include <stdlib.h>

double erand48 (unsigned short int xsubi[3]);


Argument

xsubi

An array of three short int s, which form a 48-bit integer when concatenated together.

Description

The erand48 function generates pseudorandom numbers using the linear congruential algorithm and 48-bit integer arithmetic.

It returns nonnegative, double-precision, floating-point values uniformly distributed over the range of y values, such that 0.0 <= y < 1.0.

The erand48 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 erand48 function requires that the calling program pass an array as the xsubi argument. For the first call, the array must be initialized to the value of the pseudorandom-number sequence. Unlike the drand48 function, it is not necessary to call an initialization function prior to the first call.

By using different arguments, the erand48 function allows separate modules of a large program to generate several independent sequences of pseudorandom numbers; for example, the sequence of numbers that one module generates does not depend upon how many times the function is called by other modules.


Return Value

n A nonnegative, double-precision, floating-point value.

[w]erase

Erases the window by painting it with blanks. The erase function acts on the stdscr window.

Format

#include <curses.h>

int erase();

int werase (WINDOW *win);


Argument

win

A pointer to the window.

Description

Both the erase and werase functions leave the cursor at the current position on the terminal screen after completion; they do not return the cursor to the home coordinates of (0,0).

Return Values

OK Indicates success.
ERR Indicates an error.

erf

Returns the error function of its argument.

Format

#include <math.h>

double erf (double x);

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

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

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

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

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


Argument

x

A radian expressed as a real number.

Description

The erf functions return the error function of x, where erf (x), erff (x), and erfl (x) equal 2/sqrt(pi) times the area under the curve e**( - t**2) between 0 and x.

The erfc functions return (1.0 - erf (x)). The erfc function can result in an underflow as x gets large.


Return Values

x The value of the error function ( erf ) or complementary error function ( erfc ).
NaN x is NaN; errno is set to EDOM.
0 Underflow occurred; errno is set to ERANGE.


Previous Next Contents Index