Pubtex Output 2001.04.27:1405
Total Page:16
File Type:pdf, Size:1020Kb
SAS/C® Library Reference, Volume 2, Release 7.00 The correct bibliographic citation for this manual is as follows: SAS Institute Inc., SAS/C Library Reference, Volume 2, Release 7.00, Cary, NC: SAS Institute Inc., 2001. SAS/C Library Reference, Volume 2, Release 7.00 Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved. 1–58025–733–X All rights reserved. Produced in the United States of America. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, by any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute, Inc. U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227–19 Commercial Computer Software-Restricted Rights (June 1987). SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513. 1st printing, April 2001 SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, CD-ROM, hard copy books, and Web-based training, visit the SAS Publishing Web site at www.sas.com/pubs or call 1-800-727–3228. SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. IBM® and all other International Business Machines Corporation product or service names are registered trademarks or trademarks of International Business Machines Corporation in the USA and other countries. Other brand and product names are registered trademarks or trademarks of their respective companies. Contents PART1 Special Features of the SAS/C Library 1 Chapter 1 R Dynamic-Loading Functions 3 Introduction 3 Function Descriptions 4 Chapter 2 R CMS Low-Level I/O Functions 19 Introduction 19 Related Utility Functions 26 Chapter 3 R MVS Low-Level I/O Functions 29 Introduction 29 DCBs and DCB Exit Routines 30 The Record-Oriented BSAM Interface 36 Chapter 4 R OS/390 Multitasking and Other Low-Level System Interfaces 71 Introduction 71 Multitasking SAS/C Applications 71 Compatibility Changes 72 Function Descriptions 73 Chapter 5 R Inter-User Communications Vehicle (IUCV) Functions 103 Introduction 103 IUCV Communications Overview 103 IUCV, Signal Handling, and Message Processing 105 IUCV Parameter Lists and External Interrupt Data Formats 107 Message Queues 109 Return Codes 109 Function Descriptions 110 An Example of IUCV Communication 116 Guidelines and Cautions 122 Chapter 6 R APPC/VM Functions 123 Introduction 123 APPC/VM Parameter Lists and External Interrupt Data Formats 124 Function Descriptions 126 APPC/VM Communication Example Programs 129 Guidelines and Cautions 138 Chapter 7 R The Subcommand Interface to EXECs and CLISTs 139 Introduction 139 Subcommand Processing in C Programs 139 iv Overview of the SUBCOM Environment 141 Function Descriptions 144 Examples of SUBCOM Processing 159 Guidelines for Subcommand Processing 165 Chapter 8 R The CMS REXX SAS/C Interface 167 Introduction 167 REXX Concepts and Background 167 How the Library Interfaces with REXX 169 Function Descriptions 172 An Example of a REXX Function Package 181 Additional Guidelines and Related Topics 183 Chapter 9 R Coprocessing Functions 185 Introduction 185 cocall and coreturn 186 Coprocess States 187 Passing Data between Coprocesses 188 Coprocess Data Types and Constants 189 Coprocess Identifiers 190 Restrictions 190 A Coprocessing Example 190 Advanced Topics: Program Termination 193 Advanced Topics: Signal Handling 194 Function Descriptions 195 Chapter 10 R Localization 207 Introduction 207 Locales and Categories 208 The "S370" Locale 210 The "POSIX" Locale 210 Library-Supplied Locales 211 Function Descriptions 212 User-Added Locales 221 Chapter 11 R Multibyte Character Functions 235 Introduction 235 SAS/C Implementation of Multibyte Character Sequences 235 Locales and Multibyte Character Sequences 238 Function Descriptions 238 Chapter 12 R User-Added Signals 247 Introduction 247 Notes on Handlers for User-Defined Signals 248 Restrictions on Synchronous and Asynchronous Signals 248 Summary of Routines for Adding Signals 248 SAS/C Library Routines for Adding New Signals 254 v Chapter 13 R Getting Environmental Information 257 Introduction 257 The L$UENVR Routine 257 Function Descriptions 259 PART2 SAS/C Socket Library for TCP/IP 265 Chapter 14 R The TCP/IP Protocol Suite 267 Overview of TCP/IP 267 Internet Protocol (IP) 268 User Datagram Protocol (UDP) 268 Transmission Control Protocol (TCP) 269 Domain Name System (DNS) 269 OS/390 and CMS TCP/IP Implementation 270 Chapter 15 R The BSD UNIX Socket Library 271 Introduction 272 Overview of the BSD UNIX Socket Library 272 Header Files 273 Socket Functions 283 Chapter 16 R Porting UNIX Socket Applications to the SAS/C Environment 289 Introduction 289 Integrated and Non-Integrated Sockets 289 Socket Library Restrictions 290 Function Names 291 Header Filenames 292 errno 292 BSD Library Dependencies 293 INETD and BSD Kernel Routine Dependencies 293 Character Sets 294 The Resolver 295 Chapter 17 R Network Administration 297 Introduction 297 Configuration Data Sets 297 Search Logic 298 Specifying TCPIP_PREFIX for OS/390 300 Specifying TCPIP_MACH 300 gethostbyname and Resolver Configuration 300 Configuring for the CMS Environment 301 Configuring for the OS/390 Environment 301 Chapter 18 R Socket Function Reference 303 Introduction 303 vi PART3 SAS/C POSIX Support 403 Chapter 19 R Introduction to POSIX 405 POSIX and UNIX System Services Concepts 405 The errno Variable 408 SAS/C USS Interfaces 410 Chapter 20 R POSIX Function Reference 419 Introduction 419 Index 623 1 PART1 Special Features of the SAS/C Library Chapter 1..........Dynamic-Loading Functions 3 Chapter 2..........CMS Low-Level I/O Functions 19 Chapter 3..........MVS Low-Level I/O Functions 29 Chapter 4..........OS/390 Multitasking and Other Low-Level System Interfaces 71 Chapter 5..........Inter-User Communications Vehicle (IUCV) Functions 103 Chapter 6..........APPC/VM Functions 123 Chapter 7..........The Subcommand Interface to EXECs and CLISTs 139 Chapter 8..........The CMS REXX SAS/C Interface 167 Chapter 9..........Coprocessing Functions 185 Chapter 10.........Localization 207 Chapter 11.........Multibyte Character Functions 235 Chapter 12.........User-Added Signals 247 Chapter 13.........Getting Environmental Information 257 2 3 CHAPTER 1 Dynamic-Loading Functions Introduction 3 Cautions 3 Dynamic Load Modules 4 Function Descriptions 4 Introduction Although most C programs are linked together as a single load module, for large applications it is often convenient to divide a program into several load modules that can be loaded into memory and unloaded independently. The SAS/C Compiler and Library support multiple load module programs, but you must develop such programs carefully. As with any C program, program execution always begins with a function named main. The load module containing the main function must remain in memory at all times. Each subordinate (dynamically loaded) load module must contain a function named _dynamn (which is a contraction for dynamic main). From the perspective of the compiler, the _dynamn function serves the same role in the subordinate load module as main serves in the module containing the main program. Cautions Note that load modules linked with the SAS/C Library are of two distinct types: main modules and dynamically loadable modules. A main module is one which contains a main function, or which can cause the C environment to be created in conjunction with using the indep compiler option. A dynamically loadable module is one which contains a _dynamn function. It is not possible to create a load module which is of both types. Any attempt to do so will fail at link time or at execution time. Two consequences of this requirement are: You cannot link a main function and a _dynamn function into the same load module. In particular, this means that you cannot have a source file which includes both these functions. You cannot create a C framework by calling a function that was compiled with the indep option into a load module which includes a _dynamn function. This restriction is imposed so that dynamically loadable modules are not forced to include the large amount of code needed to create a new C framework. 4 Dynamic Load Modules R Chapter 1 Dynamic Load Modules Load modules subordinate to the main program module can be loaded by use of the loadm and unloadm functions. The second argument to loadm is a pointer to a function pointer in which the address of the loaded _dynamn routine will be stored. In addition to loadm and unloadm, the library provides functions to load and unload modules containing only data (loadd and unloadd) and a function that converts a load module entry point address to a function pointer (buildm). Two other functions, addsrch and delsrch, are provided, primarily for CMS, to define the load module search order. The search order consists of the possible locations of dynamically loaded modules and the order in which they are processed. Before any of these routines can be used, the source program must include the header file <dynam.h> using the #include statement. Transfers of control between load modules are possible only by using function pointers. However, through the use of appropriate pointers, a routine in one load module can call a routine in any other load module. The inability of one load module to call another directly is a special case of a more general restriction; namely, load modules cannot share external variables. More precisely, two external variables (or functions) of the same name in different load modules are independent of each other. (There are a few special cases such as the variable errno, which contains the number of the most recent run-time problem.) See Appendix 4, "Sharing extern Variables among Load Modules," in the SAS/C Compiler and Library User’s Guide for additional information.