Calling Non-COBOL Subprograms
Total Page:16
File Type:pdf, Size:1020Kb
CodeBridge™ Calling Non-COBOL Subprograms ® ® Version 7.5 for UNIX and Windows This manual is a reference guide for Liant Software Corporation’s CodeBridge, a cross-language call system designed to simplify communication between RM/COBOL programs and non-COBOL subprogram libraries written in C (or C++). It is assumed that the reader is familiar with programming concepts and with the COBOL and C (or C++) languages in general. The information contained herein applies to systems running under Microsoft 32-bit Windows and UNIX-based operating systems. The information in this document is subject to change without prior notice. Liant Software Corporation assumes no responsibility for any errors that may appear in this document. Liant reserves the right to make improvements and/or changes in the products and programs described in this guide at any time without notice. Companies, names, and data used in examples herein are fictitious unless otherwise noted. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopied, recorded, or otherwise, without prior written permission of Liant Software Corporation. The software described in this document is furnished to the user under a license for a specific number of uses and may be copied (with inclusion of the copyright notice) only in accordance with the terms of such license. Copyright © 1999-2002 by Liant Software Corporation. All rights reserved. Printed in the United States of America. _____________________ RM, RM/COBOL, RM/COBOL-85, Relativity, Enterprise CodeBench, RM/InfoExpress, RM/Panels, VanGui Interface Builder, CodeWatch, CodeBridge, Cobol-WOW, InstantSQL, Liant, and the Liant logo are trademarks or registered trademarks of Liant Software Corporation. Microsoft, MS, MS-DOS, Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, and Windows XP are trademarks or registered trademarks of Microsoft Corporation in the USA and other countries. UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd. All other products, brand, or trade names used in this publication are the trademarks or registered trademarks of their respective trademark holders, and are used only for explanation purposes. Document Number 401208-0502 Table of Contents Preface .....................................................................................................xi Welcome to CodeBridge Version 7.5.......................................................................................... xi What's New.................................................................................................................................. xi Who Should Use CodeBridge .................................................................................................... xii Organization of Information...................................................................................................... xiii Related Publications...................................................................................................................xiv Symbols and Conventions ..........................................................................................................xiv Registration ................................................................................................................................xvi Technical Support ......................................................................................................................xvi Support Guidelines............................................................................................................... xvii Test Cases............................................................................................................................. xvii Enhancements.......................................................................................................................... xviii Version 7.1 .......................................................................................................................... xviii Version 7.0 .......................................................................................................................... xviii Chapter 1: Introduction....................................................................... 1-1 What is CodeBridge? ................................................................................................................ 1-1 CodeBridge Components....................................................................................................... 1-2 Benefits of Using CodeBridge................................................................................................... 1-2 Requirements............................................................................................................................. 1-3 Using this Manual...................................................................................................................... 1-3 Developers Who are New to C Programming ....................................................................... 1-3 Developers Who are Evaluating CodeBridge........................................................................ 1-4 Developers Who Wish to Use Existing C Libraries or Write New Non-COBOL Subprograms............................................................................................... 1-4 Developers Who Have Written Non-COBOL Subprograms for Previous Versions of RM/COBOL.................................................................................... 1-5 Developers Who Need Assistance in Testing and Debugging............................................... 1-5 Typical Development Process Overview................................................................................... 1-5 Typical Development Process Example .................................................................................... 1-8 Example 1: Calling a Standard C Library Function.............................................................. 1-8 CodeBridge iii Chapter 2: Concepts ........................................................................... 2-1 Using Template File Components ............................................................................................. 2-1 Attributes............................................................................................................................... 2-2 Attribute Lists........................................................................................................................ 2-2 Parameter Attribute Lists................................................................................................... 2-2 Sample Template File Using Parameter Attribute Lists ................................................ 2-4 Global Attribute Lists........................................................................................................ 2-5 Sample Template File Using Global Attribute Lists...................................................... 2-5 Passing Information to a C Function ......................................................................................... 2-6 Passing COBOL Arguments.................................................................................................. 2-6 Passing COBOL Numeric Arguments ............................................................................... 2-7 Numeric Arguments with C Integer Parameters ............................................................ 2-7 Numeric Arguments with C Floating-Point Parameters................................................. 2-8 Numeric Arguments with C Numeric String Parameters............................................... 2-9 Passing COBOL Non-Numeric Arguments..................................................................... 2-10 Non-Numeric Arguments with C String Parameters.................................................... 2-10 Groups with C String Parameters ................................................................................ 2-12 Passing COBOL Pointer Arguments ............................................................................... 2-12 Method 1: Passing Pointer Address and Pointer Length ............................................ 2-12 Method 2: Passing and Modifying Pointer Components ............................................ 2-13 Passing Null-Valued Pointer Arguments......................................................................... 2-13 Passing COBOL Argument Properties ................................................................................ 2-15 Passing COBOL Descriptor Data.................................................................................... 2-15 Passing String Length Information .................................................................................. 2-16 Passing Miscellaneous Information..................................................................................... 2-17 Managing Omitted Arguments ............................................................................................ 2-17 Returning C Error Values........................................................................................................2-19 Consistent Return Values .................................................................................................... 2-19 Specifying Both errno and get_last_error............................................................................ 2-20 Function Return Value