Lib:Stream Module
From GNUpdf
Contents |
Analysis
Process Analysis
Context
Process 1: stream
Process 1.1: filtering
TBD
Process 1.2: file backend
Process 1.3: memory backend
Data Analysis
N/A
Time and Events Analysis
N/A
Interfaces
Design
Structure Design
Process 1.2: file backend
Process 1.3: memory backend
Procedural Design
Internal Interfaces
Backend API
Each new backend should provide the virtual functions depicted in the pdf_stm_be_s structure.
| stream virtual functions | |
|---|---|
| function | description |
| init | This call should initialize the internal state of the backend |
| write_p, read_p, seek_p, size_p, peek_p, close_p, tell_p |
Those boolean functions tell the stream frontend if the backend accepts reading, writing, seeking, peeking, closing or getting its size |
| size |
Return the size (in octects) of the storage managed by the backend. This function should only be called when size_p returns true |
| seek |
Seek in the backend storage. This function should only be called when size_p returns true |
| tell |
Return the current position of the read/write pointer in the backend storage. This function should only be called when tell_p returns true |
| read |
Read data from the backend storage. This function should only be called when read_p returns true |
| write |
Write data to the backend storage. This function should only be called when write_p returns true |
| flush |
Flush the output buffer of the stream. This call may be ignored by some backends. The function return the number of bytes actually flushed (a zero value may not be an error if the storage backend do not implement flushing). This function should only be called when write_p returns true. |
| read_char |
Read a character from the backend storage and return it in a integer (may be PDF_EOF). This function should only be called when read_p returns true. |
| peek_char |
Peek a character from the backend storage and return it in an integer (may be PDF_EOF). This function should only be called when peek_p returns true. |
| close |
Closes the backend storage. This function should only be called when close_p returns true |
Filter API
The stream implementation support the concept of read/write filters.
Each filter should provide the virtual functions depicted in the pdf_stm_filter_s structure.
| filter virtual functions | |
|---|---|
| function | description |
| init | This call should initialize the internal state of the filter. |
| apply |
This functions apply an input buffer and writes the result of the application of the filter into an output buffer. If the contents of the input buffer doesnt conform valid data for the given buffer, this call should return false. |
| dealloc |
This function should dealloc all memory resources managed by the filter, and perform any needed finalization tasks. |
Codification



