Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)
The TNS c89 utility looks for a file with the .so suffix (for example, libc.so) instead of a file
with the .srl suffix.
Porting a Guardian Program to the OSS Environment
When you make the decision to port your Guardian C or C++ program from the Guardian
environment to the OSS environment, there are more than C compiler issues to take into
consideration. You must also consider the following topics:
• “How Arguments Are Passed to the C or C++ Program” (page 158)
• “Differences in the Two Run-Time Environments” (page 158)
• “Which Run-Time Routines Are Available” (page 159)
• “Use of Common Run-Time Environment (CRE) Functions” (page 160)
• “Replacing Guardian Procedure Calls With Equivalent OSS Functions” (page 160)
• “Which IPC Mechanisms Can Be Used” (page 160)
• “Interactions Between Guardian and OSS Functions” (page 161).
How Arguments Are Passed to the C or C++ Program
A program, compiled as a Guardian program, can be executed using the RUN command from
the TACL command interpreter as follows:
RUN program-file [ / run-options / ] [ arg1 arg2 ... argn ]
program-file specifies the name of the program to run. run-options is a comma-separated
list of options to the RUN command, enclosed in slashes (/). The two most frequently specified
RUN options are IN and OUT. The option IN input-file specifies the name of the standard
input file (stdin) for the new process, and the option OUT output-file specifies the name of
the standard output file (stdout) for the new process. The arguments in the list of arguments to
be passed to the program (arg1 arg2 ... argn) are separated by spaces.
If the program is compiled as an OSS program, it can be run from the OSS shell prompt as follows:
program-file [ arg1 arg2 ... argn ] <input-file >output-file
You can also use the run command built into the OSS shell to run a process with Guardian
attributes.
Differences in the Two Run-Time Environments
Before executing the code in the program, the C run-time library initializes its run-time environment.
It also calls a CRE initialization function to establish the CRE 's internal data structures, I/O model,
and so forth, as well as shared facilities such as the user data heap. The C language-specific
initialization function sets up the data structures and the file I/O model specific to the C language.
For Guardian processes, the C run-time library performs several additional initialization tasks
during the process startup phase, including:
• Processing the startup message sent by the command interpreter
• Processing any command interpreter PARAM or ASSIGN messages
• 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).
158 Migrating Guardian Applications to the OSS Environment