5 Package Orastream for XML C APIs
Orastream
APIs support handling of text and binary nodes that exceed 64K in an XML document.
The data types used by Orastream
are found in Datatypes for C; they include oracheck, oraerr, oraprop_id, oramemctx, oraprop, oraprop_t, oraprop_v, orastream, and orastreamhdl.
The error codes for the Orastream
interfaces are described in Table 5-1.
Table 5-1 Orastream Error Codes for XML C Implementation
Error Code | Description |
---|---|
|
Null pointer encountered. |
|
Invalid stream object. |
|
Stream object is defined for the opposite I/O direction. |
|
Unknown creation property. |
|
The I/O direction of the stream is undefined. |
|
The stream direction is incorrectly defined as using both I/O directions. |
|
The stream is not open. |
|
The stream is defined for the opposite char/byte mode. |
|
The stream cannot be opened. |
|
The stream cannot be closed. |
The Orastream
methods, listed in the following table, support unidirectional streams used to move data piecewise. The direction and mode of the stream is determined by the paramters that initialize the stream in the OraStreamInit() method.
Table 5-2 Summary of OraStream Methods for XML C Implementation
Function | Summary |
---|---|
Closes the stream. |
|
Returns the handle to the stream. |
|
Initializes the stream. |
|
Determines if the stream is open. |
|
Opens the stream. |
|
Reads bytes from the stream. |
|
Determines if the stream is readable. |
|
Reads characters from the stream. |
|
Sets the SID of a stream. |
|
Destroys the stream. |
|
Writes bytes to the stream. |
|
Determines if the stream is writable. |
|
Writes characters to the stream. |
OraStreamClose()
Closes the orastream
object.
The function is used to close the given stream by calling the 'close' callback function of the stream.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamClose( orastream *stream);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream that is closed |
OraStreamHandle()
Returns the handle of the orastream
object.
The handle contains the generic pointers and file descriptors.
Syntax
orastreamhdl *OraStreamHandle( orastream *stream);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream whose handle is returned |
OraStreamInit()
Creates and initializes a orastream
object.
Syntax
orastream *OraStreamInit(
void *sctx,
void *sid,
oraerr *err,
list);
Parameter | In/Out | Description |
---|---|---|
sctx |
IN |
The input context; may be |
sid |
IN |
The user-defined stream context identifier |
err |
OUT |
The error, if any. |
list |
IN |
|
OraStreamIsOpen()
Determines if the orastream
is open. Returns TRUE
or FALSE
.
Note that the stream must be open to perform read and write operations.
Syntax
boolean OraStreamIsOpen( orastream *stream);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
The stream that should be open for reads or writes. |
OraStreamOpen()
Opens the orastream
object.
The function opens the stream by calling the 'open' callback function of the stream.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamOpen( orastream *stream, ubig_ora *length)
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
The stream that is open |
length |
OUT |
Optional parameter; not used |
OraStreamRead()
Reads byte
s from the orastream
object.
The function is used to read the data from the stream into the specified buffer. It also returns TRUE
for the eoi
parameter if the end of stream is reached.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamRead( orastream *stream, oratext *dest, ubig_ora size, oratext **start, ubig_ora *nread, ub1 *eoi);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream that is being read |
dest |
IN |
The destination buffer |
size |
IN |
The size of the data to be read |
start |
OUT |
Pointer to the start of data being read |
nread |
OUT |
Number of bytes actually read from the stream |
eoi |
OUT |
Returns |
OraStreamReadable()
Determines if an existing orastream
object is readable.
Returns TRUE
or FALSE
.
Syntax
boolean OraStreamReadable( orastream *stream);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream that is checked for readability |
OraStreamReadChar()
Reads char
s from the orastream
object.
The function is used to read the data from the stream into the specified buffer. It also returns TRUE
for the eoi
parameter if the end of stream is reached.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamReadChar( orastream *stream, oratext *dest, ubig_ora size, oratext **start, ubig_ora *nread, ub1 *eoi);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream that is being read |
dest |
IN |
The destination buffer |
size |
IN |
The size of the data to be read |
start |
OUT |
Pointer to the start of data being read |
nread |
OUT |
Number of characters actually read from the stream |
eoi |
OUT |
Returns |
OraStreamSid()
Assigns an SID to an existing orastream
object. Returns the old SID through the OUT
parameter osid
.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamSid( orastream *stream, void *sid, void **osid);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
The stream whose SID is changed |
sid |
IN |
The new SID |
osid |
OUT |
The previous SID of the stream |
OraStreamTerm()
Destroys a orastream
object and frees its associated memory.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamTerm( orastream *stream);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream that is destroyed |
OraStreamWrite()
Writes byte
s to the orastream
object.
The number of bytes actually read are stored by the OUT
parameter nwrote
.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamWrite( orastream *stream, oratext *src, ubig_ora size, ubig_ora *nwrote);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream where the data is written |
src |
IN |
Buffer from which the data is written |
size |
IN |
Size of data to be written |
nwrote |
OUT |
Number of bytes written to the stream |
OraStreamWritable()
Determines if an existing orastream
object is writable.
Returns TRUE
or FALSE
.
Syntax
boolean OraStreamWritable( orastream *stream);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream that is checked for writability. |
OraStreamWriteChar()
Writes char
s to the orastream
object.
The number of characters actually written are stored by the OUT
parameter nwrote
.
Returns ORAERR_OK
for success, or the error code for failure.
Syntax
oraerr OraStreamWriteChar( orastream *stream, oratext *src, ubig_ora size, ubig_ora *nwrote);
Parameter | In/Out | Description |
---|---|---|
stream |
IN |
Stream where the data is written |
src |
IN |
Buffer from which the data is written |
size |
IN |
Size of data to be written |
nwrote |
OUT |
Number of characters written to the stream |