This section briefly describes the process of emulating in STDLIB.
The following are the steps to emulate in simple mode:
Create a single CTtyDesc
object
per thread and an instance of the basic console object.
Attach the CTtyDesc
object
to stdin
, stdout
and stderr
.
Pass the Requests made
on stdin
, stdout
and stderr
to CTtyDesc
.
There is a separate console per thread. Therefore, output is spread over a number of different consoles.
The following are the steps to emulate in complex mode:
Start the POSIX server
in the crt0
glue code.
Create either a single
instance of CW32StreamDesc
or CReDirDesc
in
the POSIX server.
Attach it to stdin
, stdout
and stderr
,
which is used by all threads.
Requests made on stdin
, stdout
and stderr
are
passed to the attached descriptor object.
Use CW32StreamDesc
for
the emulator only if the RWin32Stream
server was started
in the crt0
glue code.
If CW32StreamDesc
cannot
be used or code is compiled for hardware, then useCRedirDesc
instead.
CReDirDesc
connects
and passes the request to a redirection server. If connection fails the output
to stdout
and stderr
is lost. Nothing is
read from stdin
.
The client application
(for example, Java RT or the Test application) starts the redirection server.
The client also provides an implementation of CStreamFactoryBase2
.
This implementation deals with standard I/O data in a customised way.
Stdin/stdout on emulator in complex mode
A text EXE
running on the emulator can either use the wcrt0.lib
or wwcrt0.lib
crt0
libraries. These automatically start the RWin32Stream
server
to redirect stdin
, stdout
and stderr
to
the Win32 console.
Stdin/stdout on hardware in complex mode
A
test EXE running on target hardware has no default console. The test application
requires application/client specific C++ code to be written to create a new
thread and call CRedirServer2::NewL()
to start the redirection
server along with client specific derived classes to plumb the I/O to wherever
it is required. The POSIX server will then connect to this server when stdXXX
streams are used.