Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)

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 functions specified by the XPG4 specifications. It also provides HP
extensions for input and output, memory management, string manipulation, and fault-tolerant
programming.
All ISO/ANSI C functions are available in both environments. Some of the XPG4 functions and
HP extension functions are available only in one environment. Refer to the API interoperability
tables in the Open System Services Programmer’s Guide to determine which functions are available
from the OSS environment. If a Guardian program uses a Guardian C run-time routine that is
available only in the Guardian environment, the routine needs to be replaced by an OSS routine
with equivalent behavior. The complete semantics and syntax of the Guardian C run-time routines
are described in the Guardian Native C Library Calls Reference Manual. For OSS C run-time
routines, refer to the Open System Services Library Calls Reference Manual.
When a program is migrated from the Guardian environment to the OSS environment, many of
the C run-time routines used in the program can be used as is. The exceptions are those that are
specific to the Guardian environment and those which have the same name in both environments
but use different arguments in the two environments. All calls to run-time routines that use a Guardian
filename argument need to be modified to use the OSS version of the run-time routines which use
an OSS pathname argument.
Porting a Guardian Program to the OSS Environment 159