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

Programmer’s Guide discusses accessing terminals from the OSS environment, including details
on static and dynamic windows, terminal parameters, and control characters, where managing
I/O is discussed. There is also a discussion of the OSSTTY facility.
The OSS terminal interface is described in detail in the termios(4) and tty(7) reference
pages, either online or in the Open System Services System Calls Reference Manual.
Printer I/O
The OSS API has no function that accesses printers or spoolers directly. To print from an OSS
program or get information about a print job, you can use the popen() function to call the lp or
lpstat utility. For information about these utilities, refer to the lp(1) and lpstat(1) reference
pages either online or in the Open System Services Shell and Utilities Reference Manual, or refer
to the Open System Services User’s Guide.
An alternative is to write OSS files and send output directly to a printer or to the Guardian spooler
using the Guardian API, and take advantage of the spooler features. For example, your program
can examine the queues of available printers and move a job to a printer whose queue becomes
unexpectedly shorter because of a job cancellation, or away from a printer that is experiencing
delays. You can also access spoolers that are on other systems than the file you want to print.
You can send an OSS file to the spooler and control the spooler from an OSS program using
Guardian spooler procedures. The printer is opened using FILE_OPEN_; then, SPOOLSTART is
called to establish a level-3 spooling session. The Open System Services Programmer’s Guide
contains an example of using Guardian spooler procedures, in the discussion about managing
I/O.
Mixed-Module Programming
In general, a program that runs as an OSS process is composed of modules compiled for the OSS
environment (OSS modules). Likewise, a program that runs as a Guardian process is composed
of modules compiled for the Guardian environment (Guardian modules). A mixed-module program
is composed of at least one OSS module and at least one Guardian module and runs as either an
OSS process or a Guardian process; it cannot run as a process in both environments. The
environment of the module containing the main() function determines the environment in which
a process runs.
Figure 3 illustrates mixed-module programming; one Guardian and two OSS modules are linked
together with the third c89 command listed in the figure. gdnmod.c and ossmod.c are each
compiled with a separate c89 invocation. The third c89 command compiles ossmain.c and
links it with gdnmod.o and ossmod.o. The resulting program will run as an OSS process because
the main() function is in the OSS module called ossmain.c.
82 Interoperating Between Programming Environments