Compaq C
Compaq C Run-Time Library Reference Manual for 
OpenVMS Systems
 
 
 
system
 
Passes a given string to the host environment to be executed by a 
command processor. This function is nonreentrant.
 
 
Format
#include <stdlib.h>
int system (const char *string);
 
  
 
Argument
string
A pointer to the string to be executed. If string is NULL, a nonzero 
value is returned. The string is a DCL command, not the name of an 
image. To execute an image, use one of the
exec
 routines.
 
 
Description
This function spawns a subprocess and executes the command specified by 
string in that subprocess. The
system
 function waits for the subprocess to complete before returning the 
 subprocess status as the return value of the function.
The subprocess is spawned within the
system
 call by a call to
vfork
. Because of this, a call to
system
should not be made after a call to
vfork
 and before the corresponding call to an exec function.
 
For OpenVMS Version 7.0 and higher systems, if you include
<stdlib.h>
 and compile with the _POSIX_EXIT feature-test macro set, then the
system
 function returns the status as if it called
waitpid
 to wait for the child. Therefore, use the WIFEXITED and WEXITSTATUS 
 macros to retrieve the exit status in the range of 0 to 255.
 
You set the _POSIX_EXIT feature-test macro by using /DEFINE=_POSIX_EXIT 
or #define _POSIX_EXIT at the top of your file, before any file 
inclusions.
  
 
Return Values
  
    | 
      nonzero value
     | 
    
If
string is NULL, a value of 1 is returned, indicating that the
system
 function is supported. If
      string is not NULL, the value is the subprocess OpenVMS return 
      status.
     | 
   
 
 
 
Example
 
  
    
       
      
#include <stdlib.h> 
#include <stdio.h> 
#include <unistd.h>     /* write, close */ 
#include <fcntl.h>      /* Creat */ 
 
main() 
{ 
    int status, 
        fd; 
 
    /* Creat a file we are sure is there        */ 
 
    fd = creat("system.test", 0); 
    write(fd, "this is an example of using system", 34); 
    close(fd); 
 
    if (system(NULL)) { 
        status = system("DIR/NOHEAD/NOTRAIL/SIZE SYSTEM.TEST"); 
        printf("system status = %d\n", status); 
    } 
    else 
        printf("system() not supported.\n"); 
} 
 |   
 
Running this example program produces the following result:
 
 
  
    
       
      
DISK3$:[JONES.CRTL.2059.SRC]SYSTEM.TEST;1 
                           1 
system status = 1 
 |   
 
tan
 
Returns a
double
 value that is the tangent of its radian argument.
 
 
Format
#include <math.h>
double tan (double x);
 
float tanf (float x);  (ALPHA ONLY)
 
long double tanl (long double x);  (ALPHA ONLY)
 
double tand (double x);  (ALPHA ONLY)
 
float tandf (float x);  (ALPHA ONLY)
 
long double tandl (long double x);  (ALPHA ONLY)
 
  
 
Argument
x
A radian expressed as a real number.
 
 
Description
The
tan
 functions compute the tangent of x, measured in radians.
The
tand
 functions compute the tangent of x, measured in degrees.
  
 
Return Values
  
    | 
      x
     | 
    
      The tangent of the argument.
     | 
   
  
    | 
      HUGE_VAL
     | 
    
      x is a singular point (...--3Pi sign/2, --Pi sign/2, Pi 
      sign/2...).
     | 
   
  
    | 
      NaN
     | 
    
x is NaN;
errno
       is set to EDOM.
     | 
   
  
    | 
      0
     | 
    
x is <pm symbol>Infinity;
errno
       is set to EDOM.
     | 
   
  
    | 
      <pm symbol>HUGE_VAL
     | 
    
Overflow occurred;
errno
       is set to ERANGE.
     | 
   
  
    | 
      0
     | 
    
Underflow occurred;
errno
       is set to ERANGE.
     | 
   
 
 
 
tanh
 
Returns the hyperbolic tangent of its argument.
 
 
Format
#include <math.h>
double tanh (double x);
 
float tanhf (float x);  (ALPHA ONLY)
 
long double tanhl (long double x);  (ALPHA ONLY)
 
  
 
Argument
x
A real number.
 
 
Description
The
tanh
 functions return the hyperbolic tangent their argument, calculated as 
 (e**x - e**(-x))/(e**x + e**(-x)).
 
 
Return Values
  
    | 
      n
     | 
    
      The hyperbolic tangent of the argument.
     | 
   
  
    | 
      HUGE_VAL
     | 
    
The argument is too large;
errno
       is set to ERANGE.
     | 
   
  
    | 
      NaN
     | 
    
x is NaN;
errno
       is set to EDOM.
     | 
   
  
    | 
      0
     | 
    
Underflow occurred;
errno
       is set to ERANGE.
     | 
   
 
 
 
telldir
 
Returns the current location associated with a specified directory 
stream. Performs operations on directories.
 
 
Format
#include <dirent.h>
long int telldir (DIR *dir_pointer);
 
  
 
Arguments
dir_pointer
A pointer to the
DIR
 structure of an open directory.
 
 
Description
This function returns the current location associated with the 
specified directory stream.
 
 
Return Values
  
    | 
      x
     | 
    
      The current location.
     | 
   
  
    | 
      --1
     | 
    
Indicates an error and is further specified in the global
errno
      .
     | 
   
 
 
 
tempnam
 
Constructs the name for a temporary file.
 
 
Format
#include <stdio.h>
char *tempnam (const char *directory, const char 
*prefix);
 
  
 
Arguments
directory
A pointer to the pathname of the directory where you want to create a 
file.
prefix
A pointer to an initial character sequence of the filename. The 
prefix argument can be null, or it can point to a string of up 
to five characters used as the first characters of the temporary 
filename.
 
 
Description
This function generates filenames for temporary files. It allows you to 
control the choice of a directory.
If the directory argument is null or points to a string that 
is not a pathname for an appropriate directory, the pathname defined as
P_tmpdir
 in the <
stdio.h
> header file is used.
 
You can bypass the selection of a pathname by providing the
TMPDIR
 environment variable in the user environment. The value of the
TMPDIR
 variable is a pathname for the desired temporary file directory.
 
Use the prefix argument to specify a prefix of up to 5 
characters for the temporary filename.
 
The
tempnam
 function returns a pointer to the generated pathname, suitable for use 
 in a subsequent call to the
free
function. See also
free
 in this section.
 
 
  Note 
In contrast to
tmpnam
,
tempnam
 does not have to generate a different file name on each call.
tempnam
generates a new file name only if the file with the specified name 
exists. If you need a unique filename on each call, use
tmpnam
instead of
tempnam
. 
     | 
   
 
 
 
Return Values
  
    | 
      x
     | 
    
A pointer to the generated pathname, suitable for use in a subsequent 
call to the
free
       function.
     | 
   
  
    | 
      NULL
     | 
    
An error occurred;
errno
       is set to indicate the error.
     | 
   
 
 
 
time
 
Returns the time (expressed as Universal Coordinated Time) elapsed 
since 00:00:00, January 1, 1970, in seconds.
 
 
Format
#include <time.h>
time_t time (time_t *time_location);
 
  
Function Variants Compiling with the _DECC_V4_SOURCE and _VMS_V6_SOURCE 
feature-test macros defined enables a local-time-based entry point to 
this function that is equivalent to the behavior before OpenVMS Version 
7.0.
 
Argument
time_location
Either NULL or a pointer to the place where the returned time is also 
stored. The
time_t
 type is defined in the
<time.h>
  header file as follows:
 
  
    
       
      
typedef unsigned long int time_t; 
 
 |   
 
 
Return Values
  
    | 
      x
     | 
    
      The time elapsed past the epoch.
     | 
   
  
    | 
(
time_t
      )(--1)
     | 
    
Indicates an error. If the value of SYS$TIMEZONE_DIFFERENTIAL logical 
is wrong, the function will fail with
errno
       set to EINVAL.
     | 
   
 
 
 
times
 
Passes back the accumulated times of the current process and its 
terminated child processes.
 
 
Format
#include <times.h>
clock_t times (struct tms *buffer); (OPENVMS V7.0  AND HIGHER)
 
void times (tbuffer_t *buffer); (PRE  OPENVMS V7.0)
 
  
 
Argument
buffer
A pointer to the terminal buffer.
 
 
Description
For both process and children times, the structure breaks down the time 
by user and system time. Since the OpenVMS system does not 
differentiate between system and user time, all system times are 
returned as 0. Accumulated CPU times are returned in 10-millisecond 
units.
Only the accumulated times for child processes running a C main program 
or a program that calls
VAXC$CRTL_INIT
or
DECC$CRTL_INIT
 are included.
 
On OpenVMS Version 7.0 and higher systems, the
times
function returns the elapsed real time in clock ticks since an 
arbitrary reference time in the past (for example, system startup 
time). This reference time does not change from one
times
 function call to another. The return value can overflow the possible 
 range of type
clock_t
 values. When
times
 fails, it returns a value of --1. The Compaq C RTL uses 
 system-boot time as its reference time.
  
 
Return Values
  
    | 
      x
     | 
    
      The elapsed real time in clock ticks since system-boot time.
     | 
   
  
    | 
(
clock_t
      )(--1)
     | 
    
      Indicates an error.
     | 
   
 
 
 
tmpfile
 
Creates a temporary file that is opened for update.
 
 
Format
#include <stdio.h>
FILE *tmpfile (void);
 
  
 
Description
The file exists only for the duration of the process, or until the file 
is closed and is preserved across calls to
vfork
.
 
 
Return Values
  
    | 
      x
     | 
    
The address of a file pointer (defined in the
<stdio.h>
       header file).
     | 
   
  
    | 
      NULL
     | 
    
      Indicates an error.
     | 
   
 
 
 
tmpnam
 
Generates file names that can be safely used for a temporary file.
 
 
Format
#include <stdio.h>
char *tmpnam (char *name);
 
  
Function Variants This function also has variants named
_tmpnam32
 and
_tmpnam64
 for use with 32-bit and 64-bit pointer sizes, respectively. See 
 Section 1.10 for more information on using pointer-size-specific 
 functions.
 
Argument
name
A character string containing a name to use in place of file-name 
arguments in functions or macros. Successive calls to
tmpnam
 with a null argument cause the function to overwrite the current name.
 
 
Return Value
  
    | 
      x
     | 
    
If the
name argument is the null pointer value NULL,
tmpnam
 returns the address of an internal storage area. If
name is not NULL, then it is considered the address of an area 
of length
L_tmpnam
 (defined in the
<stdio.h>
 header file). In this case,
tmpnam
 returns the
      name argument as the result.
     | 
   
 
 
 
toascii
 
Converts its argument, an 8-bit ASCII character, to a 7-bit ASCII 
character.
 
 
Format
#include <ctype.h>
int toascii (char character);
 
  
 
Argument
character
An object of type
char
.
 
 
Return Value
  
    | 
      x
     | 
    
      A 7-bit ASCII character.
     | 
   
 
 
 
tolower
 
Converts a character to lowercase.
 
 
Format
#include <ctype.h>
int tolower (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 an uppercase letter, and there is a 
corresponding lowercase letter, as defined by character type 
information in the program locale category LC_TYPE, the corresponding 
lowercase letter is returned.
 
If the argument is not an uppercase character, it is returned unchanged.
  
 
Return Value
  
    | 
      x
     | 
    
      The lowercase letter corresponding to the argument. Or, the unchanged 
      argument, if it is not an uppercase character.
     | 
   
 
 
 
_tolower
 
Converts an uppercase character to lowercase.
 
 
Format
#include <ctype.h>
int _tolower (int character);
 
  
 
Argument
character
This argument must be an uppercase letter.
 
 
Description
The
_tolower
 macro is equivalent to the
tolower
 function except that its argument must be an uppercase letter 
 (not lowercase, not EOF).
 
The
_tolower
 macro should not be used with arguments that contain side-effect 
 operations. For instance, the following example will not return the 
 expected result:
 
 
 
 
Return Value
  
    | 
      x
     | 
    
      The lowercase letter corresponding to the argument.
     | 
   
 
 
 
touchwin
 
Places the most recently edited version of the specified window on the 
terminal screen.
 
 
Format
#include <curses.h>
int touchwin (WINDOW *win);
 
  
 
Argument
win
A pointer to the window.
 
 
Description
This function is normally used only to refresh overlapping windows.
 
 
Return Values
  
    | 
      OK
     | 
    
      Indicates success.
     | 
   
  
    | 
      ERR
     | 
    
      Indicates an error.
     | 
   
 
 
 
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_TYPE, 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 an uppercase letter.
 
 
Description
The
_toupper
 macro is equivalent to the
toupper
 function except that its argument must be a lowercase letter 
 (not uppercase, not EOF).
 
The
_toupper
 macro should not be used with arguments that contain side-effect 
 operations. For instance, the following example will not return the 
 expected result:
 
 
 
 
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
This 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 Values
  
    | 
      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);
 
  
 
Arguments
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.
 
  
         |