HP OpenVMS Systems Documentation |
HP C
|
Previous | Contents | Index |
Returns the length of the hypotenuse of a right triangle.
#include <math.h>double hypot (double x, double y);
float hypotf (float x, float y); (ALPHA ONLY)
long double hypotl (long double x, long double y); (ALPHA ONLY)
x
A real value.y
A real value.
The hypot functions return the length of the hypotenuse of a right triangle, where x and y represent the perpendicular sides of the triangle. The length is calculated as:
sqrt(x2 + y2)
On overflow, the return value is undefined, and errno is set to ERANGE.
x The length of the hypotenuse. HUGE_VAL Overflow occurred; errno is set to ERANGE. 0 Underflow occurred; errno is set to ERANGE. NaN x or y is NaN; errno is set to EDOM.
Converts characters coded in one codeset to characters coded in another codeset.
#include <iconv.h>size_t iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
cd
A conversion descriptor. This is returned by a successful call to iconv_open .inbuf
A pointer to a variable that points to the first character in the input buffer.inbytesleft
Initially, this argument is a pointer to a variable that indicates the number of bytes to the end of the input buffer (inbuf). When the conversion is completed, the variable indicates the number of bytes in inbuf not converted.outbuf
A pointer to a variable that points to the first available byte in the output buffer. The output buffer contains the converted characters.outbytesleft
Initially, this argument is a pointer to a variable that indicates the number of bytes to the end of the output buffer (outbuf). When the conversion is completed, the variable indicates the number of bytes left in outbuf.
The iconv function converts characters in the buffer pointed to by inbuf to characters in another code set. The resulting characters are stored in the buffer pointed to by outbuf. The conversion type is specified by the conversion descriptor cd. This descriptor is returned from a successful call to iconv_open .If an invalid character is found in the input buffer, the conversion stops after the last successful conversion. The variable pointed to by inbytesleft is updated to reflect the number of bytes in the input buffer that are not converted. The variable pointed to by outbytesleft is updated to reflect the number of bytes remaining in the output buffer.
x Number of nonidentical conversions performed. Indicates successful conversion. In most cases, 0 is returned. ( size_t ) - 1 Indicates an error condition. The function sets errno to one of the following:
- EBADF -- The cd argument is not a valid conversion descriptor.
- EILSEQ -- The conversion stops when an invalid character detected.
- E2BIG -- The conversion stops because of insufficient space in the output buffer.
- EINVAL -- The conversion stops because of an incomplete character at the end of the input buffer.
Deallocates a specified conversion descriptor and the resources allocated to the descriptor.
#include <iconv.h>int iconv_close (iconv_t cd);
cd
The conversion descriptor to be deallocated. A conversion descriptor is returned by a successful call to iconv_open .
0 Indicates that the conversion descriptor was successfully deallocated. - 1 Indicates an error occurred. The function sets errno to one of the following:
- EBADF -- The cd argument is not a valid conversion descriptor.
- EVMSERR -- Nontranslatable OpenVMS error occur. vaxc$errno contains the VMS error code.
Allocates a conversion descriptor for a specified codeset conversion.
#include <iconv.h>iconv_t iconv_open (const char *tocode, const char *fromcode);
tocode
The name of the codeset to which characters are converted.fromcode
The name of the source codeset. See Chapter 10 for information on obtaining a list of currently available codesets or for details on adding new codesets.
x A conversion descriptor. Indicates the call was successful. This descriptor is used in subsequent calls to iconv (iconv_t) - 1 Indicates an error occurred. The function sets errno to one of the following:
- EMFILE -- The process does not have enough I/O channels to open a file.
- ENOMEM -- Insufficient space is available.
- EINVAL -- The conversion specified by fromcode and tocode is not supported.
- EVMSERR -- Nontranslatable OpenVMS error occur. vaxc$errno contains the OpenVMS error code. A value of SS$_BADCHKSUM in vaxc$errno indicates that a conversion table file was found, but its contents is corrupted. A value of SS$_IDMISMATCH in vaxc$errno indicates that the conversion table file version does not match the version of the C Run-Time Library.
#include <stdio.h> #include <iconv.h> #include <errno.h> int main() { /* Declare variables to be used */ char fromcodeset[30]; char tocodeset[30]; int iconv_opened; iconv_t iconv_struct; /* Iconv descriptor */ /* Initialize variables */ sprintf(fromcodeset, "DECHANYU"); sprintf(tocodeset, "EUCTW"); iconv_opened = FALSE; /* Attempt to create a conversion descriptor for the */ /* codesets specified. If the return value from */ /* iconv_open is -1 then an error has occurred. */ /* Check the value of errno. */ if ((iconv_struct = iconv_open(tocodeset, fromcodeset)) == (iconv_t) - 1) { /* Check the value of errno */ switch (errno) { case EMFILE: case ENFILE: printf("Too many iconv conversion files open\n"); break; case ENOMEM: printf("Not enough memory\n"); break; case EINVAL: printf("Unsupported conversion\n"); break; default: printf("Unexpected error from iconv_open\n"); break; } } else /* Successfully allocated a conversion descriptor */ iconv_opened = TRUE; /* Was a conversion descriptor allocated */ if (iconv_opened) { /* Attempt to deallocate the conversion descriptor. */ /* If iconv_close returns -1 then an error has */ /* occurred. */ if (iconv_close(iconv_struct) == -1) { /* An error occurred. Check the value of errno */ switch (errno) { case EBADF: printf("Conversion descriptor is invalid\n"); break; default: printf("Unexpected error from iconv_close\n"); break; } } } return (EXIT_FAILURE); }
Return the character at the current cursor position on the specified window without making changes to the window. The inch function acts on the stdscr window.
#include <curses.h>char inch();
char winch (WINDOW *win);
win
A pointer to the window.
x The returned character. ERR Indicates an input error.
Search for a character in a string.
#include <strings.h>Function Variants The index function has variants named _index32 and _index64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.char *index (const char *s, int c);
s
The string to search.c
The character to search for.
The index function is identical to the strchr function, and is provided for compatibility with some UNIX implementations.
Initializes the terminal-type data and all screen functions. You must call initscr before using any of the curses functions.
#include <curses.h>void initscr (void);
The OpenVMS Curses version of the initscr function clears the screen before doing the initialization. The BSD-based Curses version does not.
Initializes random-number generators.
#include <stdlib.h>char *initstate (unsigned int seed, char *state, int size);
seed
An initial seed value.state
Pointer to an array of state information.size
The size of the state information array.
The initstate function initializes random-number generators. It lets you initialize, for future use, a state array passed as an argument. The size, in bytes, of the state array is used by the initstate function to decide how sophisticated a random-number generator to use; the larger the state array, the more random the numbers.Values for the amount of state information are 8, 32, 64, 128, and 256 bytes. Amounts less than 8 bytes generate an error, while other amounts are rounded down to the nearest known value.
The seed argument specifies a starting point for the random-number sequence and provides for restarting at the same point. The initstate function returns a pointer to the previous state information array.
Once you initialize a state, the setstate function allows rapid switching between states. The array defined by the state argument is used for further random-number generation until the initstate function is called or the setstate function is called again. The setstate function returns a pointer to the previous state array.
After initialization, you can restart a state array at a different point in one of two ways:
- Use the initstate function with the desired seed argument, state array, and size of the array.
- Use the setstate function with the desired state, followed by the srandom function with the desired seed. The advantage of using both functions is that you do not have to save the state array size once you initialize it.
See also setstate , srandom , and random .
x A pointer to the previous state array information. 0 Indicates an error. Call made with less than 8 bytes of state information. Further specified in the global errno .
Insert a character at the current cursor position in the specified window. The insch function acts on the stdscr window.
#include <curses.h>int insch (char ch);
int winsch (WINDOW *win, char ch);
win
A pointer to the window.ch
The character to be inserted.
After the character is inserted, each character on the line shifts to the right, and the last character in the line is deleted. For more information, see the scrollok function.
OK Indicates success. ERR Indicates that the function makes the screen scroll illegally.
Insert a line above the line containing the current cursor position. The insertln function acts on the stdscr window.
#include <curses.h>int insertln();
int winsertln (WINDOW *win);
win
A pointer to the window.
The current line and every line below it shifts down, and the bottom line disappears. The inserted line is blank and the current (y,x) coordinates remain the same. For more information, see the scrollok function.
OK Indicates success. ERR Indicates that the function makes the screen scroll illegally.
Insert a string at the current cursor position in the specified window. The insstr function acts on the stdscr window.
#include <curses.h>int insstr (char *str);
int winsstr (WINDOW *win, char *str);
win
A pointer to the window.str
A pointer to the string to be inserted.
Each character after the string shifts to the right, and the last character disappears. These functions are specific to HP C for OpenVMS Systems and are not portable.
OK Indicates success. ERR Indicates that the function makes the screen scroll illegally. For more information, see the scrollok function.
Indicates if a character is classed either as alphabetic or as a digit in the program's current locale.
#include <ctype.h>int isalnum (int character);
character
An object of type int . The value of character must be representable as an unsigned char or must equal the value of the macro EOF. If it has any other value, the behavior is undefined.
nonzero If alphanumeric. 0 If not alphanumeric.
Indicates if a character is classed as an alphabetic character in the program's current locale.
#include <ctype.h>int isalpha (int character);
character
An object of type int . The value of character must be representable as an unsigned char or must equal the value of the macro EOF. If it has any other value, the behavior is undefined.
nonzero If alphabetic. 0 If not alphabetic.
Indicates if a specified file descriptor is associated with a pipe.
#include <unixio.h>int isapipe (int file_desc);
file_desc
A file descriptor.
For more information about pipes, see Chapter 5.
1 Indicates an association with a pipe. 0 Indicates no association with a pipe. - 1 Indicates an error (for example, if the file descriptor is not associated with an open file).
Indicates if a character is an ASCII character.
#include <ctype.h>int isascii (int character);
character
An object of type char .
nonzero If ASCII. 0 If not ASCII.
Indicates if a specified file descriptor is associated with a terminal.
#include <unistd.h>int isatty (int file_desc);
file_desc
A file descriptor.
1 If the file descriptor is associated with a terminal. 0 If the file descriptor is not associated with a terminal. - 1 Indicates an error (for example, if the file descriptor is not associated with an open file).
Indicates if a character is classed as a control character in the program's current locale.
#include <ctype.h>int iscntrl (int character);
character
An object of type int . The value of character must be representable as an unsigned char or must equal the value of the macro EOF. If it has any other value, the behavior is undefined.
nonzero If a control character. 0 If not a control character.
Previous | Next | Contents | Index |