CONTENTS Title Page Copyright Page Preface 1 VAX C Run-Time Library Information 1.1 Using the VAX C Run-Time Library 1.1.1 Using the VAX C RTL Object Libraries 1.1.2 Using the VAX C RTL as a Shareable Image 1.1.3 Macros 1.2 VAX C RTL Function and Macro Syntax 1.2.1 UNIX-Style File Specifications 1.3 Input and Output on VMS Systems 1.3.1 RMS Record and File Formats 1.3.2 Stream Access to RMS Record Files 1.4 Specific Portability Concerns 2 Understanding Input and Output 2.1 UNIX I/O 2.2 Standard I/O 2.3 Conversion Specifications 2.3.1 Converting Input Information 2.3.2 Converting Output Information 2.4 Terminal I/O 2.5 Program Examples 3 Character, String, and Argument List Functions and Macros 3.1 Character Classification Macros 3.2 Character Conversion Functions and Macros 3.3 String and Argument List-Handling Functions and Macros 3.4 Program Examples 4 Error- and Signal-Handling 4.1 Error Handling 4.2 Signal Handling 4.3 Program Example 5 Subprocess Functions 5.1 Implementing Child Processes in VAX C 5.2 The exec Functions 5.2.1 Exec Processing 5.2.2 Exec Error Conditions 5.3 Synchronizing Processes 5.4 Interprocess Communication 5.5 Program Examples 6 Curses Screen Management Functions and Macros 6.1 Curses Terminology 6.1.1 User-Defined Windows 6.2 Getting Started with Curses 6.3 Predefined Variables and Constants 6.4 Cursor Movement 6.5 Program Examples 7 Math Functions 8 Memory Allocation Functions 8.1 Program Example 9 System Functions Reference Section abort abs access acos [w]addch [w]addstr alarm asctime asin assert atan atan2 atexit atof atoi, atol box brk bsearch cabs calloc ceil cfree chdir chmod chown [w]clear clearerr clearok clock close [w]clrattr [w]clrtobot [w]clrtoeol cos cosh creat [no]crmode ctermid ctime cuserid [w]delch delete [w]deleteln delwin difftime div dup, dup2 [no]echo ecvt endwin [w]erase execl execle execlp execv execve execvp exit, _exit exp fabs fclose fcvt fdopen feof ferror fflush fgetc fgetname fgetpos fgets fileno floor fmod fopen fprintf fputc fputs fread free freopen frexp fscanf fseek fsetpos fstat ftell ftime fwrite gcvt getc [w]getch getchar getcwd getegid getenv geteuid getgid getname getpid getppid gets [w]getstr getuid getw getyx gmtime gsignal hypot [w]inch initscr [w]insch [w]insertln [w]insstr isalnum isalpha isapipe isascii isatty iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit kill labs ldexp ldiv leaveok localtime log, log10 longjmp longname lseek malloc memchr memcmp memcpy memmove memset mkdir mktemp modf [w]move mvcur mvwin mv[w]addch mv[w]addstr mv[w]delch mv[w]getch mv[w]getstr mv[w]inch mv[w]insch mv[w]insstr newwin nice [no]nl open overlay overwrite pause perror pipe pow printf [w]printw putc putchar puts putw qsort raise rand [no]raw read realloc [w]refresh remove rename rewind sbrk scanf [w]scanw scroll scrollok [w]setattr setbuf setgid setjmp setuid setvbuf sigblock signal sigpause sigsetmask sigstack sigvec sin sinh sleep sprintf sqrt srand sscanf ssignal [w]standend [w]standout stat strcat strchr strcmp strcpy strcspn strerror strlen strncat strncmp strncpy strpbrk strrchr strspn strstr strtod strtok strtol strtoul subwin system tan tanh time times tmpfile tmpnam toascii tolower, _tolower touchwin toupper, _toupper ttyname umask ungetc VAXC$CALLOC_OPT VAXC$CFREE_OPT VAXC$CRTL_INIT VAXC$ESTABLISH VAXC$FREE_OPT VAXC$MALLOC_OPT VAXC$REALLOC_OPT va_arg va_count va_end va_start, va_start_1 vfork vfprintf vprintf vsprintf wait wrapok write A VAX C RTL and RTLs of Other C Implementations B VAX C Run-Time Modules and Entry Points C VAX C Definition Modules D VAX C Socket Routine Reference D.1 Introduction D.2 Porting Considerations D.2.1 Calling an IPC Routine from an AST State D.2.2 Calling from KERNEL or EXEC Modes D.2.3 Standard I/O D.2.4 Event Flags D.2.5 Suppressing VAX C Compilation Warnings D.2.6 Header Files D.3 Linking an Internet Application Program D.4 VAX C Structures D.4.1 hostent Structure D.4.2 in_addr Structure D.4.3 iovec Structure D.4.4 linger Structure D.4.5 msghdr Structure D.4.6 netent Structure D.4.7 sockaddr Structure D.4.8 sockaddr_in Structure D.4.9 timeval Structure D.5 Internet Protocols D.5.1 Transmission Control Protocol D.5.2 User Datagram Protocol D.6 errno Values D.7 Basic Communication Routines accept bind close connect listen read recv recvfrom recvmsg select send sendmsg sendto shutdown socket write D.8 Auxiliary Communication Routines getpeername getsockname getsockopt setsockopt D.9 Communication Support Routines gethostbyaddr gethostbyname gethostent gethostname getnetbyaddr getnetbyname getnetent htonl htons inet_addr inet_lnaof inet_makeaddr inet_netof inet_network inet_ntoa ntohl ntohs vaxc$get_sdc D.10 Programming Examples EXAMPLES 2-1 Output of the Conversion Specifications 2-2 Using the Standard I/O Functions 2-3 I/O Using File Descriptors and Pointers 3-1 Character Classification Macros 3-2 Converting Double Values to an ASCII String 3-3 Changing Characters to and from Uppercase Letters 3-4 Concatenating Two Strings 3-5 Four Arguments to the strcspn Function 3-6 The varargs Functions, Macros, and Definitions 4-1 Suspending and Resuming Programs 5-1 Creating the Child Process 5-2 Passing Arguments to the Child Process 5-3 Checking the Status of Child Processes 5-4 Communicating Through a Pipe 6-1 A Curses Program 6-2 Manipulating Windows 6-3 Refreshing the Terminal Screen 6-4 Curses Predefined Variables 6-5 The Cursor Movement Functions 6-6 stdscr and Occluding Windows 6-7 Subwindows 7-1 Calculating and Verifying a Tangent Value 8-1 Allocating and Deallocating Memory for Structures 9-1 Accessing the User Name 9-2 A Second Way to Access the User Name 9-3 Accessing Terminal Information 9-4 Manipulating the Default Directory 9-5 Printing the Date and Time D-1 TCP/IP Server D-2 TCP/IP Client D-3 UDP Server D-4 UDP Client FIGURES 1-1 I/O Interface from C Programs 1-2 Mapping Standard I/O and UNIX I/O to RMS 5-1 Communications Links Between Parent and Child Processes 6-1 An Example of the stdscr Window 6-2 Displaying Windows and Subwindows 6-3 Updating the Terminal Screen 6-4 An Example of the getch Macro 6-5 An Example of Overwriting Windows REF-1 Reading and Writing to a Pipe TABLES 1-1 UNIX and VMS File Specification Delimiters 1-2 Valid and Invalid Specifications 2-1 I/O Functions and Macros 2-2 Conversion Characters for Formatted Input 2-3 Conversion Characters for Formatted Output 2-4 Allowable Characters Between the Percent Sign and Conversion Character 3-1 Character, String, and Argument List Functions and Macros 3-2 Character Classification Macros and their Return Values 3-3 Character Classification Macro Return Values (ASCII Table) 4-1 Error- and Signal-Handling Functions and Macros 4-2 The Errno Symbolic Values 4-3 VAX C Signals 5-1 Subprocess Functions 6-1 Curses Functions and Macros 6-2 Curses Predefined Variables and #define Constants 7-1 Math Functions 8-1 Memory Allocation Functions 9-1 System Functions REF-1 Interpretation of the mode Argument REF-2 File Protection Values and their Meanings REF-3 RMS Valid Keywords and Values REF-4 SIGFPE Arithmetic Trap Signal Codes REF-5 Member Names REF-6 RMS Valid Keywords and Values REF-7 SIGFPE Signal Codes REF-8 The vfork and fork Functions A-1 Relationship of VAX C RTL Functions and Macros to Other C RTL Functions and Macros B-1 VAX C Run-Time Modules B-2 VAX C Run-Time Entry Points B-3 Run-Time Library Procedures Called by VAX C C-1 VAX C Definition Modules D-1 errno Values D-2 Basic Communication Routines D-3 Auxiliary Communication Routines D-4 Supported Communication Routines