DEC C

DEC C

Run-Time Library Reference Manual for OpenVMS Systems

Order Number: AA--PUNEE--TK


November 1995

This manual describes the functions and macros in the DEC C Run-Time Library for OpenVMS systems.

Revision/Update Information: This revised manual supersedes the DEC C Run-Time Library Reference Manual for OpenVMS Systems (Order No. AA--PUNED--TK).

Software Version: DEC C Version 5.2 for OpenVMS Systems

Digital Equipment Corporation
Maynard, Massachusetts


First Printing, May 1982 Revised, April 1985 Revised, March 1987 Revised, January 1989 Revised, December 1989 Revised, February 1991 Revised, November 1992 Revised, June 1993 Revised, May 1994 Revised, May 1995 Revised, November 1995

The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document.

The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license.

Restricted Rights: Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013.

Copyright ©1982, 1985, 1987, 1989, 1991, 1992, 1993, 1994, 1995

The following are trademarks of Digital Equipment Corporation: DEC, DECnet, DECtalk, DECthreads, Digital, OpenVMS, ULTRIX, VAX, VAX DOCUMENT, VAX RMS, VMS, VMS/ULTRIX Connection, VT100, and the DIGITAL logo.

The following are third-party trademarks:

UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company Ltd.

XPG4 is a registered trademark of X/Open Co. Ltd.

IEEE is a registered trademark of the Institute of Electrical and Electronics Engineers, Inc.

ZK5763

This document is available on CD-ROM.

This document was prepared using VAX DOCUMENT, Version V3.2-1a.

Portions of the DEC C Run-Time Library have been implemented using source copyrighted by the University of California, Berkley and its contributors.

Copyright (c) 1981 Regents of the University of California.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors.
  4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Contents Index


Preface

This manual describes the DEC C Run-Time Library (RTL). It provides reference information about the RTL functions and macros that perform input/output (I/O) operations, character and string manipulation, mathematical operations, error detection, subprocess creation, system access, and screen management.

It also notes portability concerns between operating systems, where applicable, and describes the DEC C for OpenVMS socket routines used for writing Internet application programs for the DEC TCP/IP Services for OpenVMS (formerly the VMS/ULTRIX Connection) product, or other implementations of the TCP/IP protocol.

The DEC C RTL contains XPG4-compliant internationalization support, providing functions to help you develop software that can run in different languages and cultures.

You can send comments or suggestions regarding this manual or any DEC C document by filling out one of the Reader's Comments forms at the back of this manual or by sending electronic mail to the following Internet address:

decc_docs@bookie.enet.dec.com

Intended Audience

This manual is intended for experienced and novice programmers who need reference information on the functions and macros found in the DEC C RTL.

Document Structure

This manual has the following chapters, reference section, and appendixes:

Associated Documents

The following documents may be useful when programming in DEC C for OpenVMS Systems:

Conventions Used in this Document

Convention Meaning
[Return] The symbol [Return] represents a single stroke of the Return key on a terminal.
Ctrl/X The symbol Ctrl/X, where letter X represents a terminal control character, is generated by holding down the Ctrl key while pressing the key of the specified terminal character.
switch statement
int data type
fprintf function
<stdio.h> header file
Monospace type identifies language keywords and the names of DEC C functions and header files. Monospace type is also used when referring to a specific variable name used in an example.
arg1 Italic type indicates a placeholder, such as an argument or parameter name, and the introduction of new terms.
$ run cprog [return] Interactive examples show user input in boldface type.
float x;
.
.
.

x = 5;
A vertical ellipsis indicates that not all of the text of a program or program output is illustrated. Only relevant material is shown in the example.
option,... A horizontal ellipsis indicates that additional parameters, options, or values can be entered. A comma that precedes the ellipsis indicates that successive items must be separated by commas.
[output-source,...] Square brackets, in function synopses and a few other contexts, indicate that a syntactic element is optional. Square brackets are not optional, however, when used to delimit a directory name in an OpenVMS file specification or when used to delimit the dimensions of a multidimensional array in DEC C source code.
sc-specifier ::=
auto
static
extern
register
In syntax definitions, items appearing on separate lines are mutually exclusive alternatives.
[a|b] Brackets surrounding two or more items separated by a vertical bar (|) indicate a choice; you must choose one of the two syntactic elements.
<ucDelta symbol> A delta symbol is used in some contexts to indicate a single ASCII space character.

Platform Labels

A platform is a combination of operating system and hardware that provides a distinct environment. This manual contains information applicable to the OpenVMS operating system on both the VAX and Alpha architectures.

The information in this manual applies to both of these platforms, except when specifically labeled, as follows:
Label Explanation
(ALPHA ONLY) Specific to an Alpha processor (Alpha architecture) running the OpenVMS operating system.
(VAX ONLY) Specific to a VAX processor running the OpenVMS operating system.

Summary of New Features

DEC C Version 5.2 for OpenVMS Systems provides new and modified DEC C Run-Time Library functions in support of:

Also new with DEC C Version 5.2 for OpenVMS systems is a new model for implementing date/time support and the use of feature-test macros to control the visibility of symbols in header files according to standards, multiversion support, and compatibility.

This manual now has an appendix containing version-dependency tables that list the DEC C RTL functions supported on different OpenVMS versions. See Appendix B.

The following sections give an overview of these new features.

New Functions for UNIX Compatibility

OpenVMS V7.0 added over 80 new DEC C RTL functions to provide compatibility with UNIX systems and to satisy other requests of application developers. These functions have been implemented on both OpenVMS Alpha V7.0 and OpenVMS VAX V7.0, and are documented in this manual. They are:


basename         index          rewinddir      sigprocmask 
bcmp             initstate      rindex         sigsetjmp 
bcopy            ioctl          rmdir          sigsuspend 
bzero            jrand48        seed48         srand48 
closedir         lcong48        seekdir        srandom 
confstr          lrand48        setenv         strcasecmp 
dirname          memccpy        setitimer      strdup 
drand48          mkstemp        tzset          strncasecmp 
erand48          mmap           ualarm         strsep 
ffs              mprotect       uname          swab 
fpathconf        mrand48        setstate       sysconf 
ftruncate        msync          sigaction      telldir 
ftw              munmap         sigaddset      tempnam 
getclock         nrand48        sigdelset      truncate 
getdtablesize    opendir        sigemptyset    unlink 
getitimer        pathconf       sigfillset     unsetenv 
getlogin         pclose         sigismember    usleep 
getpagesize      popen          siglongjmp     wait3 
getpwnam         putenv         sigmask        wait4 
getpwuid         random         sigpending     waitpid 
gettimeofday     readdir 

For a description of these functions, see the reference section.

New Functions in Support of ISO C Amendment

The following DEC C RTL functions are added for ISO C support (based on the document Programming Language-C, Amendment 1 C: Integrity).


btowc            mbsrtowcs      wcrtomb        wmemcpy 
fwide            swprintf       wcsrtombs      wmemmove 
fwprintf         swscanf        wcsstr         wmemset 
fwscanf          towctrans      wctob          wprintf 
mbrlen           vfwprintf      wctrans        wscanf 
mbrtowc          vswprintf      wmemchr 
mbsinit          vwprintf       wmemcmp 

For a description of these functions, see the reference section.

New Functions for 64-Bit Pointers (ALPHA ONLY)

OpenVMS Alpha Version 7.0 added support for 64-bit pointers to be passed to the DEC C RTL functions. Some functions have dual implementations: one for 32-bit pointers and one for 64-bit pointers. The following 64-bit specific entry points have been added:


_basename64      _mbsrtowcs64   _strpbrk64     _wcsncat64 
_bsearch64       _memccpy64     _strptime64    _wcsncpy64 
_calloc64        _memchr64      _strrchr64     _wcspbrk64 
_catgets64       _memcpy64      _strsep64      _wcsrchr64 
_ctermid64       _memmove64     _strstr64      _wcsrtombs64 
_cuserid64       _memset64      _strtod64      _wcsstr64 
_dirname64       _mktemp64      _strtok64      _wcstok64 
_fgetname64      _mmap64        _strtol64      _wcstol64 
_fgets64         _qsort64       _strtoll64     _wcstoul64 
_fgetws64        _realloc64     _strtoq64      _wcswcs64 
_gcvt64          _rindex64      _strtoul64     _wmemchr64 
_getcwd64        _strcat64      _strtoull64    _wmemcpy64 
_getname64       _strchr64      _strtouq64     _wmemmove64 
_gets64          _strcpy64      _tmpnam64      _wmemset64 
_index64         _strdup64      _wcscat64 
_longname64      _strncat64     _wcschr64 
_malloc64        _strncpy64     _wcscpy64 

For more information on DEC C RTL 64-bit pointer support, see Section 1.8.

New 4.4BSD Socket Routines

The following DEC C RTL functions are added for 4.4BSD socket support:


endhostent       gethostent     hstrerror      setprotoent 
endnetent        getservent     sethostent     setservent 
endprotoent      herror         setnetent      socket_fd 
endservent       hostalias 

For more information on these and other socket routines, see Appendix A.

New 4.4BSD Curses Functions (ALPHA ONLY)

OpenVMS Alpha Version 7.0 reintegrates the BSD Curses package with sources distributed with 4.4BSD. The following functions are added to the list of BSD curses functions. These functions are defined in the <curses.h> header file distributed with DEC C for OpenVMS Systems Version 5.2. The function names of the form _xxx64 are the 64-bit pointer versions of these functions.


baudrate         nl             resetty        touchline 
cbreak           nocbreak       savetty        touchoverlap 
echo             nodelay        tgetent        tputs 
erasechar        noecho         tgetflag       waddnstr 
fullname         nonl           tgetnum        wattroff 
idlok            noraw          tgetstr        wattron 
killchar         raw            tgoto          wattrset 

For more information on BSD curses and curses in general, see Chapter 6.

Feature-Test Macros

The DEC C RTL now supports the following feature-test macros:


_XOPEN_SOURCE_EXTENDED     <double_uscore>VMS_VER             _BSD44_CURSES 
_XOPEN_SOURCE              <double_uscore>DECC_VER            _VMS_CURSES 
_POSIX_C_SOURCE            _DECC_V4_SOURCE        _SOCKADDR_LEN 
_POSIX_EXIT                _VMS_V6_SOURCE 
_ANSI_C_SOURCE 

These feature-test macros provide a means for writing portable programs. They ensure that the symbolic names used by a program do not clash with the symbolic names supplied by the implementation.

When an application is defines a feature-test macro during compilation, the DEC C RTL header files supply the symbols and prototypes defined by that particular feature-test macro and nothing else. If a program does not define such macros, the DEC C RTL header files define symbols without restriction.

For more information on feature-test macros, see Section 1.5.

DEC C RTL DATE and Time Support

As of OpenVMS Version 7.0, the DEC C RTL is changing the model used to implement date/time support from one based on local time to one based on Universal Coordinated Time (UTC).

This allows the DEC C RTL to implement ANSI C/POSIX functionality that previously could not be implemented. A UTC time-based model also makes the DEC C RTL compatible with the behavior of the Digital UNIX and OpenVMS POSIX RTL time functions.

For more information on DEC C RTL date/time functions, see Chapter 11.

Other Enhancements

For additional DEC C RTL enhancements, see the release notes for DEC C Version 5.2, OpenVMS Alpha Version 7.0, and OpenVMS VAX Version 7.0.


Next Contents Index