IGR_Extend_Stream¶
IGR_Extend_Stream allows the C / C++ API user to create a custom stream that accepts callbacks from Document Filters. The callbacks allow the passing of Additional information about the stream.
Prototype¶
IGR_LONG IGR_Extend_Stream(
IGR_Stream* Stream,
IGR_CALLBACK Callback,
void* Context,
IGR_Stream** ExtStream,
Error_Control_Block* ISYSError);
Parameters¶
Stream: Pointer to IGR_Stream
A valid IGR_Stream instance.
Callback: Pointer to callback function
Pointer to the API user’s function to handle callback generated while processing the stream.
Context: void Pointer
API user-supplied context information.
ExtStream: Pointer to IGR_Stream pointer
The extended stream which should be used instead of the original stream. See notes below.
ISYSError: Pointer to Error_Control_Block
Returns error details if the call fails.
Return value¶
Success: IGR_LONG
Returns IGR_OK.
Failure: IGR_LONG
Returns one of the possible IGR_E error codes.
Sample code¶
IGR_LONG HandleCallback(int actionID, void* actionData, void* context)
{
MyFileInfoStruct* pFileInfo;
IGR_T_ACTION_GET_STREAM_PART* pStreamPartInfo;
// Process the action...
pFileInfo = (MyFileInfoStruct*)context;
if (actionID == IGR_ACTION_GET_STREAM_PART)
{
pStreamPartInfo = (IGR_T_ACTION_GET_STREAM_PART*) actionData;
// Open a new stream based on the stream part info…
// The new stream does not need to be an extended stream.
}
return 0; // OK
}
void ProcessFile()
{
Error_Control_Block ISYSError;
IGR_Stream *pStream;
IGR_Stream* pExtendedStream;
MyFileInfoStruct fileInfo;
SetFileInfoName(fileInfo, "TEST.RAR");
if (IGR_Make_Stream_From_File(_UCS2(fileInfo.name), 0, &pStream,
&ISYSError) == IGR_OK)
{
if (IGR_Extend_Stream(pStream, &HandleCallback, &fileInfo, &pExtendedStream,
&ISYSError))
{
// Process the file using pExtendedStream only...
IGR_Open_Stream(pExtendedStream, ...);
// ...
pExtendedStream->Close(pExtendedStream);
}
}
}
Additional information¶
To create and use an Extended Stream, complete the following steps.
-
Get or create an instance of an ordinary stream.
-
Call IGR_Extend_Stream.
-
Use the returned Extended Stream instead of the original stream.
Once you have successfully created an Extended Stream, do not use the original stream pointer any further, and do not close or release it. When you are finished with the Extended Stream, call Close on the Extended Stream directly and the original stream closes automatically.