kfile *kfreopen(
const char *path,
const char *type,
kfile *file)
none
kfreopen() will open a specified file on for an existing stream. The existings stream is closed before the new filename is opened. This function is typically used to open a specified file as one of the predefined streams; such as standard input, standard output, or standard error.
The kfreopen() function substitutes the specified data transport in place of the open data transport stream. The original stream is closed regardless of whether the kfreopen() function succeeds with the new data transport. The kfreopen() function is typically used to attach the preopened data transport streams associated with kstdin, kstdout, and kstderr to other data transport mechanisms.
Identifiers for Khoros data transport mechanisms include the following: 'file' (standard Unix file; local transport / permanent storage) 'pipe' (standard pipes; local transport / no permanent storage) 'mmap' (virtual memory; local transport / permanent storage) 'shm' (shared memory; local transport / permanent storage) 'socket' (sockets; local or remote transport / no permanent storage) 'stream' (named streams/pipes; local transport / no permanent storage)
The token is the type of identifier for that transport. For a file, it is simply the filename. For shared memory, it is the shared memory key. For a pipe, it is the input & output file descriptors, as in "pipe=[3,4]". For a socket, it is the number of the socket, as in "socket=5430".
Together, the identifier and the token identify the path to the data transport to be opened. The path must be in the form of an identifier and a token, separated by an "=" equal indicator, as in: "{identifier}={transport token}"
For example, the path parameter for opening shared memory might be: "shm=1032" The path parameter for opening a file might be: "file=/usr/tmp/vadd1235" When opening a file as the data transport mechanism, the identifier and the "=" sign may be omitted, as in: "./foobar"
none
none
$BOOTSTRAP/objects/library/kutils/src/kstdio.c