HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


cabs

Returns the absolute value of a complex number.

Format

#include <math.h>

double cabs (cabs_t z);

float cabsf (cabsf_t z); (INTEGRITY SERVERS, ALPHA)

long double cabsl (cabsl_t z); (INTEGRITY SERVERS, ALPHA)


Argument

z

A structure of type cabs_t , cabsf_t , or cabsl_t . These types are defined in the <math.h> header file as follows:


typedef struct {double x,y;} cabs_t; 
 
typedef struct { float x, y; } cabsf_t; (INTEGRITY SERVERS, ALPHA) 
typedef struct { long double x, y; } cabsl_t; (INTEGRITY SERVERS, ALPHA) 


Description

The cabs functions return the absolute value of a complex number by computing the Euclidean distance between its two points as the square root of their respective squares:

sqrt(x2 + y2)

On overflow, the return value is undefined.

The cabs , cabsf , and cabsl functions are equivalent to the hypot , hypotf , and hypotl functions, respectively.


cacos (INTEGRITY SERVERS, ALPHA)

Returns the complex arc cosine of its argument.

Format

#include <complex.h>

double complex cacos (double complex z);

float complex cacosf (float complex z);

long double complex cacosl (long double complex z);


Argument

z

A complex value.

Description

The cacos functions compute the complex arc cosine of z, with branch cuts outside the interval [ - 1, +1] along the real axis.

Return Values

n The complex arc cosine value, in the range of a strip mathematically unbounded along the imaginary axis and in the interval [0, &#960;] along the real axis.

cacosh (INTEGRITY SERVERS, ALPHA)

Returns the complex arc hyperbolic cosine of its argument.

Format

#include <complex.h>

double complex cacosh (double complex z);

float complex cacoshf (float complex z);

long double complex cacoshl (long double complex z);


Argument

z

A complex value.

Description

The cacosh functions compute the complex arc hyperbolic cosine of z, with a branch cut at values less than 1 along the real axis.

Return Values

n The complex arc hyperbolic cosine value, in the range of a half-strip of non-negative values along the real axis and in the interval [ - i&#960;, +i&#960;] along the imaginary axis.

calloc

Allocates an area of zeroed memory. This function is AST-reentrant.

Format

#include <stdlib.h>

void *calloc (size_t number, size_t size);

Function Variants The calloc function has variants named _calloc32 and _calloc64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.9 for more information on using pointer-size-specific functions.

Arguments

number

The number of items to be allocated.

size

The size of each item.

Description

The calloc function initializes the items to 0. The maximum amount of memory allocated at once is limited to 0xFFFFD000.

See also malloc and realloc .


Return Values

x The address of the first byte, which is aligned on a quadword boundary (ALPHA ONLY) or an octaword boundary (INTEGRITY SERVERS ONLY) .
NULL Indicates an inability to allocate the space.

carg (INTEGRITY SERVERS, ALPHA)

Returns the phase angle of its complex argument.

Format

#include <complex.h>

double carg (double complex z);

float cargf (float complex z);

long double cargl (long double complex z);


Argument

z

A complex value.

Description

The carg functions compute the argument (also called phase angle) of z, with a branch cut along the negative real axis.

Return Values

n The value of the argument of z, in the interval [ - &#960;, +&#960;].

casin (INTEGRITY SERVERS, ALPHA)

Returns the complex arc sine of its argument.

Format

#include <complex.h>

double complex casin (double complex z);

float complex casinf (float complex z);

long double complex casinl (long double complex z);


Argument

z

A complex value.

Description

The casin functions compute the complex arc sine of z, with branch cuts outside the interval [ - 1, +1] along the real axis.

Return Values

n The complex arc sine value, in the range of a strip mathematically unbounded along the imaginary axis and in the interval [-&#960;/2, +&#960;/2] along the real axis.

casinh (INTEGRITY SERVERS, ALPHA)

Returns the complex arc hyperbolic sine of its argument.

Format

#include <complex.h>

double complex casinh (double complex z);

float complex casinhf (float complex z);

long double complex casinhl (long double complex z);


Argument

z

A complex value.

Description

The casinh functions compute the complex arc hyperbolic sine of z, with branch cuts outside the interval [ - i, +i] along the imaginary axis.

Return Values

n The complex arc hyperbolic sine value, in the range of a strip mathematically unbounded along the real axis and in the interval [ - i&#960;/2, +i&#960;/2] along the imaginary axis.

catan (INTEGRITY SERVERS, ALPHA)

Returns the complex arc tangent of its argument.

Format

#include <complex.h>

double complex catan (double complex z);

float complex catanf (float complex z);

long double complex catanl (long double complex z);


Argument

z

A complex value.

Description

The catan functions compute the complex arc tangent of z, with branch cuts outside the interval [ - i, +i] along the imaginary axis.

Return Values

n The complex arc tangent value, in the range of a strip mathematically unbounded along the imaginary axis and in the interval [-&#960;/2, +&#960;/2] along the real axis.

catanh (INTEGRITY SERVERS, ALPHA)

Returns the complex arc hyperbolic tangent of its argument.

Format

#include <complex.h>

double complex catanh (double complex z);

float complex catanhf (float complex z);

long double complex catanhl (long double complex z);


Argument

z

A complex value.

Description

The catanh functions compute the complex arc hyperbolic tangent of z, with branch cuts outside the interval [ - 1, +1] along the imaginary axis.

Return Values

n The complex arc hyperbolic tangent value, in the range of a strip mathematically unbounded along the real axis and in the interval [ - i&#960;/2, +i&#960;/2] along the imaginary axis.

catclose

Closes a message catalog.

Format

#include <nl_types.h>

int catclose (nl_catd catd);


Argument

catd

A message catalog descriptor. This is returned by a successful call to catopen.

Description

The catclose function closes the message catalog referenced by catd and frees the catalog file descriptor.

Return Values

0 Indicates that the catalog was successfully closed.
- 1 Indicates that an error occurred. The function sets errno to the following value:
  • EBADF -- The catalog descriptor is not valid.

catgets

Retrieves a message from a message catalog.

Format

#include <nl_types.h>

char *catgets (nl_catd catd, int set_id, int msg_id, const char *s);

Function Variants The catgets function has variants named _catgets32 and _catgets64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.9 for more information on using pointer-size-specific functions.

Arguments

catd

A message catalog descriptor. This is returned by a successful call to catopen.

set_id

An integer set identifier.

msg_id

An integer message identifier.

s

A pointer to a default message string that is returned by the function if the message cannot be retrieved.

Description

The catgets function retrieves a message identified by set_id and msg_id, in the message catalog catd. The message is stored in a message buffer in the nl_catd structure, which is overwritten by subsequent calls to catgets. If a message string needs to be preserved, it should be copied to another location by the program.

Return Values

x Pointer to the retrieved message.
s Pointer to the default message string. Indicates that the function is not able to retrieve the requested message from the catalog. This condition can arise if the requested pair ( set_d, msg_id) does not represent an existing message from the open catalog, or it indicates that an error occurred. If an error occurred, the function sets errno to one of the following values:
  • EBADF -- The catalog descriptor is not valid.
  • EVMSRR -- An OpenVMS I/O read error; the OpenVMS error code can be found in vaxc$errno .

Example


#include <nl_types.h> 
#include <locale.h> 
#include <stdarg.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <unixio.h> 
 
 /* This test makes use of all the message catalog routines. catopen  */ 
 /* opens the catalog ready for reading, then each of the three       */ 
 /* messages in the catalog are extracted in turn using catgets and   */ 
 /* printed out. catclose closes the catalog after use.               */ 
 /* The catalog source file used to create the catalog is as follows: */ 
 /* $ This is a message file 
 * $ 
 * $quote " 
 * $ another comment line 
 * $set 1 
 * 1 "First set, first message" 
 * 2 "second message - This long message uses a backslash \
 * for continuation." 
 * $set 2 
 * 1 "Second set, first message"                                      */ 
 
char *default_msg = "this is the first message."; 
 
main() 
{ 
  nl_catd catalog; 
  int msg1, 
      msg2, 
      retval; 
 
  char *cat = "sys$disk:[]catgets_example.cat"; /*Force local catalog*/ 
 
  char *msgtxt; 
 
  char string[128]; 
 
  /* Create the message test catalog */ 
 
  system("gencat catgets_example.msgx catgets_example.cat") ; 
 
  if ((catalog = catopen(cat, 0)) == (nl_catd) - 1) { 
      perror("catopen"); 
      exit(EXIT_FAILURE); 
  } 
 
  msgtxt = catgets(catalog, 1, 1, default_msg); 
  printf("%s\n", msgtxt); 
 
  msgtxt = catgets(catalog, 1, 2, default_msg); 
  printf("%s\n", msgtxt); 
 
  msgtxt = catgets(catalog, 2, 1, default_msg); 
  printf("%s\n", msgtxt); 
 
  if ((retval = catclose(catalog)) == -1) { 
      perror("catclose"); 
      exit(EXIT_FAILURE); 
  } 
 
  delete("catgets_example.cat;") ;  /* Remove the test catalog */ 
} 

Running the example program produces the following result:


First set, first message 
second message - This long message uses a backslash for 
                                                continuation. 
Second set, first message 


catopen

Opens a message catalog.

Format

#include <nl_types.h>

nl_catd catopen (const char *name, int oflag);


Arguments

name

The name of the message catalog to open.

oflag

An object of type int that determines whether the locale set for the LC_MESSAGES category in the current program's locale or the logical name LANG is used to search for the catalog file.

Description

The catopen function opens the message catalog identified by name.

If name contains a colon (:), a square opening bracket ([), or an angle bracket (<), or is defined as a logical name, then it is assumed that name is the complete file specification of the catalog.

If it does not include these characters, catopen assumes that name is a logical name pointing to an existing catalog file. If name is not a logical name, then the logical name NLSPATH is used to define the file specification of the message catalog. NLSPATH is defined in the user's process. If the NLSPATH logical name is not defined, or no message catalog can be opened in any of the components specified by the NLSPATH, then the SYS$NLSPATH logical name is used to search for a message catalog file.

Both NLSPATH and SYS$NLSPATH are comma-separated lists of templates. The catopen function uses each template to construct a file specification. For example, NLSPATH could be defined as:


DEFINE NLSPATH SYS$SYSROOT:[SYS$I18N.MSG]%N.CAT,SYS$COMMON:[SYSMSG]%N.CAT 

In this example, catopen first searches the directory SYS$SYSROOT:[SYS$I18N.MSG] for the named catalog. If the named catalog is not found there, the directory SYS$COMMON:[SYSMSG] is searched. The catalog name is constructed by substituting %N with the name passed to catopen , and adding the .cat suffix. %N is known as a substitution field. The following substitution fields are valid:

Field Meaning
%N Substitute the name passed to catopen
%L 1 Substitute the locale name.

The period (.) and at-sign (@) characters in the locale name are replaced by an underscore (_) character.

For example, the "zh_CN.dechanzi@radical" locale name results in a substitution of ZH_CN_DECHANZI_RADICAL.

%l 1 Substitute the language part of the locale name. For example, the language part of the en_GB.ISO8859-1 locale name is en.
%t 1 Substitute the territory part of the locale name. For example, the territory part of the en_GB.ISO8859-1 locale is GB.
%c 1 Substitute the codeset name from the locale name. For example, the codeset name of the en_GB.ISO8859-1 locale name is ISO8859-1.


1This substitution assumes that the locale name is of the form language_territory.codeset@mode

If the oflag argument is set to NL_CAT_LOCALE, then the current locale as defined for the LC_MESSAGES category is used to determine the substitution for the %L, %l, %t, and %c substitution fields. If the oflag argument is set to 0, then the value of the LANG environment variable is used as a locale name to determine the substitution for these fields. Note that using NL_CAT_LOCALE conforms to the XPG4 specification while a value of 0 (zero) exists for the purpose of preserving XPG3 compatibility. Note also, that catopen uses the value of the LANG environment variable without checking whether the program's locale can be set using this value. That is, catopen does not check whether this value can serve as a valid locale argument in the setlocale call.

If the substitution value is not defined, an empty string is substituted.

A leading comma or two adjacent commas (,,) is equivalent to specifying %N. For example,


DEFINE NLSPATH ",%N.CAT,SYS$COMMON:[SYSMSG.%L]%N.CAT" 

In this example, catopen searches in the following locations in the order shown:

  1. name (in the current directory)
  2. name.cat (in the current directory)
  3. SYS$COMMON:[SYSMSG.locale_name]name.cat


Return Values

x A message catalog file descriptor. Indicates the call was successful. This descriptor is used in calls to catgets and catclose .
(nl_catd) - 1 Indicates an error occurred. The function sets errno to one of the following values:
  • EACCES -- Insufficient privilege or file protection violation, or file currently locked by another user.
  • EMFILE -- Process channel count exceeded.
  • ENAMETOOLONG -- The full file specification for message catalog is too long
  • ENOENT -- Unable to find the requested message catalog.
  • ENOMEM -- Insufficient memory available.
  • ENOTDIR -- Part of the name argument is not a valid directory.
  • EVMSERR -- An error occurred that does not match any errno value. Check the value of vaxc$errno .

cbrt (INTEGRITY SERVERS, ALPHA)

Returns the rounded cube root of y.

Format

#include <math.h>

double cbrt (double y);

float cbrtf (float y);

long double cbrtl (long double y);


Argument

y

A real number.

ccos (INTEGRITY SERVERS, ALPHA)

Returns the complex cosine of its argument.

Format

#include <complex.h>

double complex ccos (double complex z);

float complex ccosf (float complex z);

long double complex ccosl (long double complex z);


Argument

z

A complex value.

Description

The ccos functions return the complex cosine of z.

Return Values

x The complex cosine value.


Previous Next Contents Index