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-16
Object Type Being Manipulated
remove(), tmpfile(), and tmpnam(). These functions have an explicit per-
environment name: for example, fopen_oss() and fopen_guardian().
By calling the OSS variant of the function (for example, fopen_oss()) explicitly from
a Guardian program, the correct version of the function is called for the action to be
taken.
You can write a module that can fit into either a Guardian or OSS program. The
fread(), fwrite(), printf(), and perror() functions will work regardless of the
underlying file environment. A stream must still be opened using the appropriate-
environment version of fopen(), however.
Although ISO/ANSI C allows the user not to use header files, any Guardian program
that contains any type of interoperable code must use the header files provided with
the system to get appropriate function prototypes and defines.
Object Type Being Manipulated
Both process and file objects exist in the Guardian and OSS environments. The
functions tend to operate on objects of their own type. All Guardian functions can
manipulate Guardian objects in a Guardian program. Some OSS functions can
manipulate Guardian objects in a Guardian program. All OSS functions that can be
used in a Guardian program can manipulate OSS objects. A general rule is that
operations on an object of environment type X obey the rules of environment X,
regardless of the API in use. Thus, operations on OSS files obey POSIX.1 security
rules, whether manipulated by Guardian or OSS functions.
A Guardian process using Guardian functions can operate on Guardian objects without
restriction, but cross-object use is subject to conditions. These conditions are
documented in the appropriate reference pages. An OSS function called from a
Guardian process can operate on a Guardian object, but this use is not recommended.
In such cases, the operation is governed by the restrictions of the API (for example,
can you name the given object using the expected syntax?) and by the attributes of the
Guardian process (for example, do you have enough security to do this request?).
Language or C Environment Type
The language in which the Guardian program is written and whether the program is
CRE-compliant affect what can operate or interoperate in the Guardian environment.
Modules of C code can be mixed with modules written in other languages, typically
TAL. Programs with a C main() function are CRE-compliant. Normally, the Guardian
and OSS C functions exist inside programs that are defined to be CRE-compliant. CRE
provides the framework for such things as file I/O, errno, the data heap, and so on.
By default, all C programs are CRE-compliant.
All OSS functions are provided only in C language (prototype) form, and can only be
called directly from C code. However, routines in Guardian programs can be in other
languages, such as TAL, which is not always CRE-compliant. However, it is possible to
call OSS functions from a Guardian program consisting of modules written in C and in
TAL. Refer to the C/C++ Programmer’s Guide and the Open System Services