NPN Write
From MDC
« Gecko Plugin API Reference « Browser Side Plug-in API
Contents |
[edit] Summary
Pushes data into a stream produced by the plug-in and consumed by the browser
[edit] Syntax
#include <npapi.h>
int32 NPN_Write(NPP instance,
NPStream* stream,
int32 len,
void* buf);
[edit] Parameters
The function has the following parameters:
- instance
- Pointer to the current plug-in instance.
- stream
- Pointer to the current stream.
- len
- Length in bytes of buf.
- buf
- Buffer of data delivered for the stream.
[edit] Returns
- If successful, the function returns a positive integer representing the number of bytes written (consumed by the browser). This number depends on the size of the browser's memory buffers, the number of active streams, and other factors.
- If unsuccessful, the plug-in returns a negative integer. This indicates that the browser encountered an error while processing the data, so the plug-in should terminate the stream by calling NPN_DestroyStream.
[edit] Description
NPN_Write delivers a buffer from the stream to the instance. A plug-in can call this function multiple times after creating a stream with NPN_NewStream. The browser makes a copy of the buffer if necessary, so the plug-in can free the buffer as the method returns, if desired. See "Example of Sending a Stream" for an example that includes NPN_Write.