CONTENTS Title Page Copyright Page Preface 1 Program Development 1.1 Highlights of the Development Process 1.2 Compiling C Programs 1.2.1 C Definition Modules Provided by VAXELN 1.2.2 C Definition Modules Provided by VAX C 1.2.3 Definition Module Environments 1.2.4 CC Command 1.3 Linking C Programs 1.3.1 VAXELN Libraries Used in Linking 1.3.1.1 VAXELN C Runtime Library Files 1.3.1.2 VAXELN General Runtime Library Files 1.3.2 LINK Command 1.4 Debugging C Programs 2 The C Interface to the VAXELN Operating System 2.1 VAXELNC Text Library 2.2 Interface to the VAXELN Kernel and the Runtime Library 2.3 Data Types Specific to VAXELN 2.3.1 C Language Considerations for Programming Kernel Data Types 2.3.1.1 Align AREA_LOCK_VARIABLE and MUTEX Variables 2.3.1.2 Pass PORT Values by Reference 2.3.2 BOOLEAN Data Type 2.3.2.1 C Language Example 2.3.3 LARGE_INTEGER Data Type 2.3.3.1 LARGE_INTEGER Operations 2.3.3.2 Internal Representation of LARGE_INTEGER Data 2.3.3.3 C Language Example 2.3.3.4 C Language Notes 2.3.4 VARYING_STRING Pseudo Data Type 2.3.4.1 Internal Representation of VARYING_STRING Data 2.3.4.2 C Language Example 2.3.4.3 C Language Notes 2.4 Concurrent Programming 2.5 Interprocess Data Sharing 2.6 Interjob Data Sharing 2.7 Accessing Program Arguments 2.7.1 Method Compatible with the UNIX Operating System 2.7.2 Method Specific to VAXELN 3 Input and Output 3.1 Standard I/O 3.2 UNIX I/O 3.3 Stream Files 3.3.1 Stream Access to Stream Files 3.3.2 Stream Access to Record Files 3.4 Predefined Files 3.5 Redirecting Terminal I/O 3.6 C Interface to Disk and File Utilities 3.6.1 Creating and Running the Application 3.6.2 Sample Application 4 Device Drivers 4.1 Device Driver Programs 4.1.1 Single-Unit Program Example 4.1.2 Multiple-Unit Example 4.2 Interrupt Service Routines 4.2.1 Interrupt Handling 4.2.2 Power-Recovery Handling 4.2.2.1 Program Example 5 Exception Handlers 5.1 Establishing an Exception Handler 5.2 Canceling an Exception Handler 5.3 Exception Handler Definition Module 5.4 Exception Arguments and Data Types 5.4.1 Signal Arguments 5.4.2 Mechanism Arguments 5.5 Program Examples 6 C Library Functions and Macros 6.1 Errno Values for Error Detection 6.1.1 Error Detection in Mathematical Functions 6.1.2 Program Example Using Errno 6.2 Accessing Variable-Length Argument Lists 6.2.1 Program Example abort abs (See also fabs) accept acos asin assert atan atan2 atof (See also atoi and atol) atoi, atol (See also atof) bind bsearch cabs (See also hypot) calloc ceil cfree (See also free) chmod chown clearerr close connect cos cosh creat ctime delete div dup, dup2 ecvt, fcvt (See also gcvt) exit, _exit exp fabs fclose fdopen (See also fopen) feof ferror fflush fgetc (See also getc) fgetname (See also getname) fgets (See also gets) fileno floor fmod fopen fprintf (See also printf) fputc (See also putc) fputs (See also puts) fread free (See also cfree) freopen (See also fopen) frexp fscanf (See also scanf) fseek ftell ftime fwrite gcvt (See also ecvt, fcvt) getc (See also fgetc, getchar, and getw) getchar (See also getc) getenv getname (See also fgetname) getpeername gets (See also fgets) getsockname getsockopt getw (See also getc) gsignal htonl htons hypot (See also cabs) inet_addr inet_lnaof inet_makeaddr inet_netof inet_network inet_ntoa isalnum isalpha isascii isatty iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit ldexp ldiv listen localtime log log10 longjmp, setjmp lseek malloc memchr memcmp memcpy, memmove memset modf ntohl ntohs open pause perror pow printf (See also fprintf and sprintf) putc (See also fputc, putchar, and putw) putchar (See also putc) puts (See also fputs) putw (See also putc) qsort rand (See also srand) read realloc recv recvfrom recvmsg rewind scanf (See also fscanf and sscanf) select send sendmsg sendto setbuf setsockopt shutdown sigblock signal sigpause sigsetmask sigstack sigvec sin sinh sleep socket sprintf (See also printf) sqrt srand (See also rand) sscanf (See also scanf) ssignal strcat (See also strncat) strchr (See also strrchr) strcmp (See also strncmp) strcpy (See also strncpy) strcspn strerror strlen strncat (See also strcat) strncmp (See also strcmp) strncpy (See also strcpy) strpbrk strrchr (See also strchr) strspn strstr strtod strtok strtol strtoul tan tanh time times tmpfile toascii tolower, _tolower toupper, _toupper umask ungetc va_arg va_count va_end va_start va_start_1 vaxc$establish vaxc$get_sdc vaxc$socket_control write A C Runtime Function Compatibility FIGURES 1-1 Highlights of the C Program Development Process 1-2 The Compiling Process 1-3 The Linking Process 2-1 LARGE_INTEGER Representation 2-2 VARYING_STRING(n) Representation TABLES 1-1 VAXELNC Definition Modules 1-2 VAXCDEF Definition Modules That Can Be Used with VAXELN 2-1 VAXELN Data Types 3-1 First-Byte Character Mapping into the Emulated Stream 3-2 Examples of Job Arguments 6-1 C Library Functions and Macros 6-2 Errno Symbolic Values 6-3 Keywords for File Access Blocks and Record Access Blocks 6-4 VAX C Signals 6-5 Signals and Allowable Codes 6-6 Conversion Characters for Formatted Output 6-7 Conversion Characters for Formatted Input A-1 Functional Differences Between the VAXELN C RTL and Other Runtime Environments