HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


toupper

Converts a character to uppercase.

Format

#include <ctype.h>

int toupper (int character);


Argument

character

An object of type int representable as an unsigned char or the value of EOF. For any other value, the behavior is undefined.

Description

If the argument represents a lowercase letter, and there is a corresponding uppercase letter, as defined by character type information in the program locale category LC_CTYPE, the corresponding uppercase letter is returned.

If the argument is not a lowercase character, it is returned unchanged.


Return Value

x The uppercase letter corresponding to the argument. Or, the unchanged argument, if the argument is not a lowercase character.

_toupper

Converts a lowercase character to uppercase.

Format

#include <ctype.h>

int _toupper (int character);


Argument

character

This argument must be a lowercase letter.

Description

The _toupper macro is equivalent to the toupper function except that its argument must be a lowercase letter (not uppercase, not EOF).

As of OpenVMS Version 8.3 and to comply with the C99 ANSI standard and X/Open Specification, the _toupper macro by default does not evaluate parameters more than once. It simply calls the toupper function. This avoids side effects (such as i++ or function calls) where the user can tell how many times an expression is evaluated.

To keep the older, optimized _toupper macro behavior, compile with /DEFINE=_FAST_TOUPPER. Then, as in previous releases, _toupper optimizes the call to avoid the overhead of a runtime call. The parameters are checked to determine how to calculate the result, thereby creating unwanted side effects. So when compiling with /DEFINE=_FAST_TOUPPER, do not use the _toupper macro with arguments that contain side-effect operations. For instance, the following example will not return the expected result:


d = _toupper (c++); 


Return Value

x The uppercase letter corresponding to the argument.

towctrans

Maps one wide character to another according to a specified mapping descriptor.

Format

#include <wctype.h>

wint_t towctrans (wint_t wc, wctrans_t desc);


Arguments

wc

The wide character that you want to map.

desc

Description of the mapping obtained through a call to the wctrans function.

Description

The towctrans function maps the wide character specified in wc, using the mapping described by desc .

The current setting of the LC_CTYPE category must be the same as during the call to the wctrans function that returned the value of desc.


Return Value

x The mapped value of the wc wide character, if this character exists in the mapping described by desc. Otherwise, the value of wc is returned.

towlower

Converts the argument, a wide-character code, to lowercase. If the argument is not an uppercase character, it is returned unchanged.

Format

#include <wctype.h> (ISO C)

#include <wchar.h> (XPG4)

int towlower (wint_t wc);


Argument

wc

An object of type wint_t representable as a valid wide character in the current locale, or the value of WEOF. For any other value, the behavior is undefined.

Description

If the argument is an uppercase wide character, the corresponding lowercase wide character (as defined in the LC_CTYPE category of the locale) is returned, if it exists. If it does not exist, the function returns the input argument unchanged.

towupper

Converts the argument, a wide character, to uppercase. If the argument is not a lowercase character, it is returned unchanged.

Format

#include <wctype.h> (ISO C)

#include <wchar.h> (XPG4)

int towupper (wint_t wc);


Argument

wc

An object of type wint_t representable as a valid wide character in the current locale, or the value of WEOF. For any other value, the behavior is undefined.

Description

If the argument is a lowercase wide character, the corresponding uppercase wide character (as defined in the LC_CTYPE category of the locale) is returned, if it exists. If it does not exist, the function returns the input argument unchanged.

trunc (ALPHA, I64)

Truncates the argument to an integral value.

Format

#include <math.h>

double trunc (double x);

float truncf (float x,);

long double truncl (long double x);


Argument

x

A floating-point number.

Return Value

n The truncated, integral value of the argument.

truncate

Changes file length to a specified length, in bytes.

Format

#include <unistd.h>

int truncate (const char *path, off_t length);


Arguments

path

The name of a file that is to be truncated. This argument must point to a pathname that names a regular file for which the calling process has write permission.

length

The new length of the file, in bytes. The off_t type of length is either a 64-bit or 32-bit integer. The 64-bit interface allows for file sizes greater than 2 GB, and can be selected at compile time by defining the _LARGEFILE feature-test macro as follows:


CC/DEFINE=_LARGEFILE 


Description

The truncate function changes the length of a file to the size, in bytes, specified by the length argument.

If the new length is less than the previous length, the function removes all data beyond length bytes from the specified file. All file data between the new End-of-File and the previous End-of-File is discarded.

For stream files, if the new length is greater than the previous length, new file data between the previous End-of-File and the new End-of-File is added, consisting of all zeros. (For record files, it is not possible to extend the file in this manner.)


Return Values

0 Indicates success.
- 1 An error occurred; errno is set to indicate the error.

ttyname, ttyname_r

Find the pathname of a terminal.

Format

#include <unixio.h> (COMPATABILITY)

char *ttyname (void); (COMPATABILITY)

#include <unistd.h> (OPENVMS V7.3-2 AND HIGHER)

char *ttyname (int filedes); (OPENVMS V7.3-2 AND HIGHER)

int ttyname_r (int filedes, char name, size_t namesize); (OPENVMS V7.3-2 AND HIGHER), (ALPHA, I64)


Arguments

filedes

An open file descriptor.

name

Pointer to a buffer in which the terminal name is stored.

namesize

The length of the buffer pointed to by the name argument.

Description

The implementation of the ttyname function that takes no argument is provided only for backward compatibility. This legacy implementation returns a pointer to the null-terminated name of the terminal device associated with file descriptor 0, the default input device ( stdin ). A value of 0 is returned if SYS$INPUT is not a TTY device.

The ttyname_r function and the implementation of ttyname that takes a filedes argument are UNIX standard compliant and are available with only OpenVMS Version 7.3-2 and higher.

The standard compliant ttyname function returns a pointer to a string containing a null-terminated pathname of the terminal associated with file descriptor filedes. The return value might point to static data whose content is overwritten by each call. The ttyname interface need not be reentrant.

The ttyname_r function returns a pointer to store the null-terminated pathname of the terminal associated with the file descriptor filedes in the character array referenced by name. The array is namesize characters long and should have space for the name and the terminating null character. The maximum length of the terminal name is TTY_NAME_MAX.

If successful, ttyname returns a pointer to a string. Otherwise, a NULL pointer is returned and errno is set to indicate the error.

If successful, ttyname_r stores the terminal name as a null-terminated string in the buffer pointed to by name and returns 0. Otherwise, an error number is returned to indicate the error.


Return Values

x Upon successful completion, ttyname returns a pointer to a null-terminated string.
NULL Upon failure, ttyname returns a NULL pointer and sets errno to indicate the failure:
  • EBADF -- The fildes argument is not a valid file descriptor.
  • ENOTTY -- The fildes argument does not refer to a terminal device.
0 Upon successful completion, ttyname_r returns 0.
n Upon failure, ttyname_r sets errno to indicate the failure, and returns the same errno code:
  • EBADF -- The fildes argument is not a valid file descriptor.
  • ENOTTY -- The fildes argument does not refer to a TTY device.
  • ERANGE -- The value of namesize is smaller than the length of the string to be returned including the terminating null character.
0 For the legacy ttyname , indicates that SYS$INPUT is not a TTY device.

tzset

Sets and accesses time-zone conversion.

Format

#include <time.h>

void tzset (void);

extern char *tzname[];

extern long int timezone;

extern int daylight;


Description

The tzset function initializes time-conversion information used by the ctime , localtime , mktime , strftime , and wcsftime functions.

The tzset function sets the following external variables:

The environment variable TZ specifies how tzset initializes time conversion information:

Table REF-11 Time-Zone Initialization Rules
TZ Format Meaning
: UTC is used.
: pathname The characters following the colon specify the pathname of a tzfile format file from which to read the time-conversion information. A pathname beginning with a slash (/) represents an absolute pathname; otherwise, the pathname is relative to the system time-conversion information directory specified by SYS$TZDIR, which by default is SYS$COMMON:[SYS$ZONEINFO.SYSTEM].
stdoffset[ dst[ offset]
[,rule]]
The value is first used as the pathname of a file (as described for the : pathname format) from which to read the time-conversion information.

If that file cannot be read, the value is then interpreted as a direct specification of the time-conversion information, as follows:

  std and dst---Three or more characters that are the designation for the time zone:
  • std---Standard time zone. Required.
  • dst---Daylight Savings Time zone. Optional. If dst is omitted, Daylight Savings Time does not apply.

Uppercase and lowercase letters are explicitly allowed. Any characters are allowed, except the following:

  • digits
  • leading colon (:)
  • comma (,)
  • minus ( - )
  • plus (+)
  • ASCII null character
  offset---The value added to the local time to arrive at UTC. The offset has the following format:
hh[:
mm[:
ss]]

In this format:

  • hh (hours) is a one-or two-digit value of 0--24.
  • mm (minutes) is a value of 0--59. (optional)
  • ss (seconds) is a value of 0--59. (optional)
  The offset following std is required. If no offset follows dst, summer time is assumed, one hour ahead of standard time. You can use one or more digits; the value is always interpreted as a decimal number.

If the time zone is preceded by a minus sign ( - ), the time zone is East of Greenwich; otherwise, it is West, which can also be indicated by a preceding plus sign (+).

  rule---Indicates when to change to and return from summer time. The rule has the form:
start[/
time],
end[/
time]

where:

  • start is the date when the change from standard time to summer time occurs.
  • end is the date for returning from summer time to standard time.
  If start and end are omitted, the default is the US Daylight Savings Time start and end dates. The format for start and end must be one of the following:
  • Jn---The Julian day n (1 < n < 365). Leap days are not counted. That is, in all years, including leap years, February 28 is day 59 and March 1 is day 60. You cannot explicitly refer to February 29.
  • n---The zero based Julian day (0 < n < 365). Leap days are counted, making it possible to refer to February 29.
  • Mm.n.d---The nth d day of month m, where:
    0 < n < 5
    0 < d < 6
    1 < m < 12

    When n is 5, it refers to the last d day of month m. Sunday is day 0.

  time---The time when, in current time, the change to or return from summer time occurs. The time argument has the same format as offset, except that you cannot use a leading minus ( - ) or plus (+) sign. If time is not specified, the default is 02:00:00.

If no rule is present in the TZ specification, the rules used are those specified by the tzfile format file defined by the SYS$POSIXRULES system logical in the system time-conversion information directory, with the standard and summer time offsets from UTC replaced by those specified by the offset values in TZ .

If TZ does not specify a tzfile format file and cannot be interpreted as a direct specification, UTC is used.

Note



The UTC-based time functions, introduced in OpenVMS Version 7.0, had degraded performance compared with the non-UTC-based time functions.

OpenVMS Version 7.1 added a cache for time-zone files to improve performance. The size of the cache is determined by the logical name DECC$TZ_CACHE_SIZE. To accommodate most countries changing the time twice per year, the default cache size is large enough to hold two time-zone files.

See also ctime , localtime , mktime , strftime , and wcsftime .


Sample TZ Specification


EST5EDT4,M4.1.0,M10.5.0 

This sample TZ specification describes the rule defined in 1987 for the Eastern time zone in the US:

Because time was not specified in either case, the changes occur at the default time, which is 2:00 A.M. The start and end dates did not need to be specified, because they are the defaults.

Note

1 The HP C RTL uses a public-domain, time-zone handling package that puts time-zone conversion rules in easily accessible and modifiable files. These files reside in the SYS$COMMON:[SYS$ZONEINFO.SYSTEM.SOURCES] directory. <tzfile.h> header file. The converted files are created with a root directory of SYS$COMMON:[SYS$ZONEINFO.SYSTEM], which is pointed to by the SYS$TZDIR system logical. This format is readable by the C library functions that handle time-zone information. For example, in the eastern United Stated, SYS$LOCALTIME is defined to be SYS$COMMON:[SYS$ZONEINFO.SYSTEM.US]EASTERN.

ualarm

Sets or changes the timeout of interval timers.

Format

#include <unistd.h>

useconds_t ualarm (useconds_t mseconds, useconds_t interval);


Arguments

mseconds

Specifies a number of real-time microseconds.

interval

Specifies the interval for repeating the timer.

Description

The ualarm function causes the SIGALRM signal to be generated for the calling process after the number of real-time microseconds specified by useconds has elapsed. When the interval argument is nonzero, repeated timeout notification occurs with a period in microseconds specified by interval. If the notification signal SIGALRM is not caught or is ignored, the calling process is terminated.

If you call a combination of ualarm and setitimer functions, and the AST status is disabled, the return value is invalid.

If you call a combination of ualarm and setitimer functions, and the AST status is enabled, the return value is valid.

This is because you cannot invoke an AST handler to clear the previous value of the timer when ASTs are disabled or invoked from a handler that was invoked at AST level.

Note

Interactions between ualarm and either alarm , or sleep are unspecified.

See also setitimer .


Return Values

n The number of microseconds remaining from the previous ualarm or setitimer call.
0 No timeouts are pending or ualarm not previously called.
- 1 Indicates an error.


Previous Next Contents Index