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

Table Of Contents
Migrating Guardian Applications to the OSS
Environment
Open System Services Porting Guide520573-006
8-29
Which Run-Time Routines Are Available
Opening the standard input, output, and error files (stdin, stdout, stderr)
The arguments for the program are set up in an argument array that is accessible from
the main program. The run-time library also saves information in the environment array
for Guardian processes. The environment array contains environment parameters from
PARAM messages. The Guardian C run-time library includes functions that allow the
retrieval of the process startup message, the PARAM message, and the ASSIGN
messages. In the Guardian environment, the CRE automatically opens three standard
files (stdin, stdout, stderr).
The startup procedures are somewhat different in the OSS environment. The standard
files are controlled by the OSS file system, not the CRE. Also, because OSS
processes do not use startup messages, information is passed to a new OSS process
mainly by use of program arguments and environment variables. These differences
must be taken into consideration when migrating a Guardian program to the OSS
environment. The environment information saved by the C library during program
startup can be accessed by calling the getenv() library function and by declaring
parameters to the main() function. Your program can access both the environment
and argument arrays using the parameters passed to main().
The Guardian and OSS C run-time libraries consist of two overlapping sets of
procedures in the following areas
malloc() and free()
getenv() or putenv() and **environ
errno
stdin, stdout, and stderr file pointers
ANSI file input and output
Routines in the embedded set
Unified CRE Master Control Block (MCB)
All of these procedures can run equally well, and are interchangeable, in Guardian or
OSS processes. They have only one implementation, or if there are two, the
implementations are so coordinated as to make the difference invisible. These
implementations involve the same set of type definitions, flags, literals, and so on, in
the header files for the objects which are interoperable.
Which Run-Time Routines Are Available
There are two implementations of some of the file system routines: one for the
Guardian environment and one for the OSS environment. The set of procedures that
operate on Guardian objects but are callable from Guardian or OSS processes, for
example fopen($A.B.C,...), is different from the set of procedures that operate on
OSS objects but are callable from Guardian or OSS processes, for example,
fopen (/a/b/c/d , ... ).
The Guardian and OSS run-time environments are defined by facilities available
through the use of the CRE and by the more than 300 predefined macros and
functions available in the C run-time library. The C run-time library provides the
complete set of functions specified by the ISO/ANSI C standard and additional