Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
Porting UNIX Applications to the OSS Environment
Open System Services Porting Guide520573-006
7-28
Calling Guardian Procedures
C compiler generates the appropriate interface code to call the Guardian system
procedures. The cextdecs.h header file contains function prototype declarations for
the Guardian procedures that can be called directly from a C program by specifying the
C names for the procedures in uppercase characters and providing a section for each
procedure using the SECTION pragma.
The Guardian procedures require nonstandard C syntax to describe the interfaces.
Code that calls Guardian procedures needs to be compiled with the -Wextensions
option; for example:
c89 -Wextensions foo.c
Many Guardian procedures return values that can be used directly in a C program.
Other Guardian procedures use condition codes, such as TAL procedures returning
_cc_status. You must include the tal.h header file to use these Guardian
procedures in your C program in the OSS environment. See Checking the Condition
Code on page 10-8.
For those Guardian procedures which use structure declarations, the use of the
appropriate header files in your programs is strongly recommended.
The most commonly used header files are:
To use Guardian procedures in your C program, you can specify only the names of the
procedures you want to include as section names. The following sample code
demonstrates using Guardian procedures in a C program:
#include <tal.h>
#include <cextdecs.h(FILE_OPEN_, READX)>
_cc_status CC;
...
retcode = FILE_OPEN_(pathname, , &filenum, 1, , , , 040);
...
CC = READX(filenum, buffer, 1024);
if (_status_eq(CC)) {
...
} else
...
The syntax of a Guardian procedure call determines whether a parameter is required
or optional. Refer to the Guardian Procedure Calls Reference Manual and the
Guardian Programmer’s Guide for more information on using Guardian procedures.
Refer to the Open System Services Programmer’s Guide for details on which Guardian
procedures can be called from C programs running in the OSS environment.
/G/system/zsysdefs/zsysc System data structures and literals
/G/system/zsysdefs/zfilc File system data structures and literals
/G/system/zsysdefs/zspic System program interface data structures and
literals