Haru Free PDF Library
hpdf_streams.h
Go to the documentation of this file.
1 /*
2  * << Haru Free PDF Library >> -- hpdf_streams.h
3  *
4  * URL: http://libharu.org
5  *
6  * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7  * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
8  *
9  * Permission to use, copy, modify, distribute and sell this software
10  * and its documentation for any purpose is hereby granted without fee,
11  * provided that the above copyright notice appear in all copies and
12  * that both that copyright notice and this permission notice appear
13  * in supporting documentation.
14  * It is provided "as is" without express or implied warranty.
15  *
16  * 2005.12.20 Created.
17  *
18  */
19 
20 #ifndef _HPDF_STREAMS_H
21 #define _HPDF_STREAMS_H
22 
23 #include "hpdf_list.h"
24 #include "hpdf_encrypt.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 
31 #define HPDF_STREAM_SIG_BYTES 0x5354524DL
32 
33 typedef enum _HPDF_StreamType {
39 
40 #define HPDF_STREAM_FILTER_NONE 0x0000
41 #define HPDF_STREAM_FILTER_ASCIIHEX 0x0100
42 #define HPDF_STREAM_FILTER_ASCII85 0x0200
43 #define HPDF_STREAM_FILTER_FLATE_DECODE 0x0400
44 #define HPDF_STREAM_FILTER_DCT_DECODE 0x0800
45 #define HPDF_STREAM_FILTER_CCITT_DECODE 0x1000
46 
47 typedef enum _HPDF_WhenceMode {
52 
53 typedef struct _HPDF_Stream_Rec *HPDF_Stream;
54 
55 typedef HPDF_STATUS
57  const HPDF_BYTE *ptr,
58  HPDF_UINT siz);
59 
60 
61 typedef HPDF_STATUS
63  HPDF_BYTE *ptr,
64  HPDF_UINT *siz);
65 
66 
67 typedef HPDF_STATUS
69  HPDF_INT pos,
70  HPDF_WhenceMode mode);
71 
72 
73 typedef HPDF_INT32
75 
76 
77 typedef void
79 
80 
81 typedef HPDF_UINT32
83 
84 
86 
87 
88 typedef struct _HPDF_MemStreamAttr_Rec {
97 
98 
99 typedef struct _HPDF_Stream_Rec {
111  void* attr;
113 
114 
115 
118  HPDF_UINT buf_siz);
119 
120 
121 HPDF_BYTE*
123  HPDF_UINT index,
124  HPDF_UINT *length);
125 
126 
127 HPDF_UINT
129 
130 
131 HPDF_UINT
133 
134 
137  HPDF_BYTE *buf,
138  HPDF_UINT size);
139 
140 
141 void
143 
144 
147  HPDF_Stream dst,
148  HPDF_UINT filter,
149  HPDF_Encrypt e);
150 
151 
154  const char *fname);
155 
156 
159  const char *fname);
160 
161 
164  HPDF_Stream_Read_Func read_fn,
165  HPDF_Stream_Seek_Func seek_fn,
166  HPDF_Stream_Tell_Func tell_fn,
167  HPDF_Stream_Size_Func size_fn,
168  void* data);
169 
170 
173  HPDF_Stream_Write_Func write_fn,
174  void* data);
175 
176 
177 void
179 
180 
183  char value);
184 
185 
188  const char *value);
189 
190 
193  HPDF_BYTE value);
194 
195 
198  HPDF_INT value);
199 
200 
203  HPDF_UINT value);
204 
205 
208  HPDF_REAL value);
209 
210 
213  const HPDF_BYTE *ptr,
214  HPDF_UINT size);
215 
216 
219  HPDF_BYTE *ptr,
220  HPDF_UINT *size);
221 
224  char *s,
225  HPDF_UINT *size);
226 
227 
230 
231 
234  HPDF_INT pos,
235  HPDF_WhenceMode mode);
236 
237 
238 HPDF_BOOL
240 
241 
244 
247 
248 
251  const char *value);
252 
253 
256  const char *text,
257  HPDF_UINT len);
258 
259 
262  const char *text);
263 
264 
267  const HPDF_BYTE *data,
268  HPDF_UINT len,
269  HPDF_Encrypt e);
270 
271 
274 
275 
276 #ifdef __cplusplus
277 }
278 #endif /* __cplusplus */
279 
280 #endif /* _HPDF_STREAMS_H */
HPDF_STATUS HPDF_Stream_WriteEscapeName(HPDF_Stream stream, const char *value)
void(* HPDF_Stream_Free_Func)(HPDF_Stream stream)
Definition: hpdf_streams.h:78
enum _HPDF_WhenceMode HPDF_WhenceMode
struct _HPDF_MemStreamAttr_Rec * HPDF_MemStreamAttr
Definition: hpdf_streams.h:85
HPDF_STATUS HPDF_Stream_Seek(HPDF_Stream stream, HPDF_INT pos, HPDF_WhenceMode mode)
HPDF_STATUS HPDF_Stream_WriteEscapeText2(HPDF_Stream stream, const char *text, HPDF_UINT len)
HPDF_STATUS(* HPDF_Stream_Write_Func)(HPDF_Stream stream, const HPDF_BYTE *ptr, HPDF_UINT siz)
Definition: hpdf_streams.h:56
HPDF_Stream HPDF_FileWriter_New(HPDF_MMgr mmgr, const char *fname)
HPDF_STATUS HPDF_Stream_WriteUChar(HPDF_Stream stream, HPDF_BYTE value)
HPDF_Stream HPDF_CallbackWriter_New(HPDF_MMgr mmgr, HPDF_Stream_Write_Func write_fn, void *data)
HPDF_UINT32(* HPDF_Stream_Size_Func)(HPDF_Stream stream)
Definition: hpdf_streams.h:82
HPDF_STATUS HPDF_Stream_Write(HPDF_Stream stream, const HPDF_BYTE *ptr, HPDF_UINT size)
HPDF_UINT32 HPDF_Stream_Size(HPDF_Stream stream)
HPDF_INT32 HPDF_Stream_Tell(HPDF_Stream stream)
HPDF_STATUS HPDF_Stream_WriteBinary(HPDF_Stream stream, const HPDF_BYTE *data, HPDF_UINT len, HPDF_Encrypt e)
HPDF_STATUS(* HPDF_Stream_Read_Func)(HPDF_Stream stream, HPDF_BYTE *ptr, HPDF_UINT *siz)
Definition: hpdf_streams.h:62
void HPDF_MemStream_FreeData(HPDF_Stream stream)
HPDF_STATUS HPDF_MemStream_Rewrite(HPDF_Stream stream, HPDF_BYTE *buf, HPDF_UINT size)
HPDF_STATUS(* HPDF_Stream_Seek_Func)(HPDF_Stream stream, HPDF_INT pos, HPDF_WhenceMode mode)
Definition: hpdf_streams.h:68
struct _HPDF_Stream_Rec HPDF_Stream_Rec
HPDF_STATUS HPDF_Stream_Read(HPDF_Stream stream, HPDF_BYTE *ptr, HPDF_UINT *size)
HPDF_STATUS HPDF_Stream_WriteUInt(HPDF_Stream stream, HPDF_UINT value)
HPDF_STATUS HPDF_Stream_Validate(HPDF_Stream stream)
HPDF_Stream HPDF_MemStream_New(HPDF_MMgr mmgr, HPDF_UINT buf_siz)
HPDF_STATUS HPDF_Stream_WriteReal(HPDF_Stream stream, HPDF_REAL value)
HPDF_STATUS HPDF_Stream_WriteEscapeText(HPDF_Stream stream, const char *text)
enum _HPDF_StreamType HPDF_StreamType
_HPDF_WhenceMode
Definition: hpdf_streams.h:47
@ HPDF_SEEK_SET
Definition: hpdf_streams.h:48
@ HPDF_SEEK_CUR
Definition: hpdf_streams.h:49
@ HPDF_SEEK_END
Definition: hpdf_streams.h:50
HPDF_Stream HPDF_CallbackReader_New(HPDF_MMgr mmgr, HPDF_Stream_Read_Func read_fn, HPDF_Stream_Seek_Func seek_fn, HPDF_Stream_Tell_Func tell_fn, HPDF_Stream_Size_Func size_fn, void *data)
HPDF_STATUS HPDF_Stream_WriteStr(HPDF_Stream stream, const char *value)
HPDF_STATUS HPDF_Stream_WriteChar(HPDF_Stream stream, char value)
void HPDF_Stream_Free(HPDF_Stream stream)
HPDF_UINT HPDF_MemStream_GetBufSize(HPDF_Stream stream)
struct _HPDF_MemStreamAttr_Rec HPDF_MemStreamAttr_Rec
HPDF_BOOL HPDF_Stream_EOF(HPDF_Stream stream)
HPDF_BYTE * HPDF_MemStream_GetBufPtr(HPDF_Stream stream, HPDF_UINT index, HPDF_UINT *length)
HPDF_Stream HPDF_FileReader_New(HPDF_MMgr mmgr, const char *fname)
_HPDF_StreamType
Definition: hpdf_streams.h:33
@ HPDF_STREAM_FILE
Definition: hpdf_streams.h:36
@ HPDF_STREAM_MEMORY
Definition: hpdf_streams.h:37
@ HPDF_STREAM_UNKNOWN
Definition: hpdf_streams.h:34
@ HPDF_STREAM_CALLBACK
Definition: hpdf_streams.h:35
struct _HPDF_Stream_Rec * HPDF_Stream
Definition: hpdf_streams.h:53
HPDF_STATUS HPDF_Stream_WriteInt(HPDF_Stream stream, HPDF_INT value)
HPDF_STATUS HPDF_Stream_Flush(HPDF_Stream stream)
HPDF_STATUS HPDF_Stream_ReadLn(HPDF_Stream stream, char *s, HPDF_UINT *size)
HPDF_STATUS HPDF_Stream_WriteToStream(HPDF_Stream src, HPDF_Stream dst, HPDF_UINT filter, HPDF_Encrypt e)
HPDF_INT32(* HPDF_Stream_Tell_Func)(HPDF_Stream stream)
Definition: hpdf_streams.h:74
HPDF_UINT HPDF_MemStream_GetBufCount(HPDF_Stream stream)
signed int HPDF_INT
Definition: hpdf_types.h:44
signed int HPDF_BOOL
Definition: hpdf_types.h:89
unsigned int HPDF_UINT
Definition: hpdf_types.h:45
unsigned int HPDF_UINT32
Definition: hpdf_types.h:57
float HPDF_REAL
Definition: hpdf_types.h:79
signed int HPDF_INT32
Definition: hpdf_types.h:56
unsigned char HPDF_BYTE
Definition: hpdf_types.h:74
unsigned long HPDF_STATUS
Definition: hpdf_types.h:94
Definition: hpdf_encrypt.h:76
Definition: hpdf_error.h:180
Definition: hpdf_list.h:30
Definition: hpdf_mmgr.h:40
Definition: hpdf_streams.h:88
HPDF_UINT buf_siz
Definition: hpdf_streams.h:90
HPDF_List buf
Definition: hpdf_streams.h:89
HPDF_UINT r_ptr_idx
Definition: hpdf_streams.h:93
HPDF_UINT w_pos
Definition: hpdf_streams.h:91
HPDF_UINT r_pos
Definition: hpdf_streams.h:94
HPDF_BYTE * r_ptr
Definition: hpdf_streams.h:95
HPDF_BYTE * w_ptr
Definition: hpdf_streams.h:92
Definition: hpdf_streams.h:99
HPDF_UINT32 sig_bytes
Definition: hpdf_streams.h:100
HPDF_Stream_Tell_Func tell_fn
Definition: hpdf_streams.h:109
HPDF_MMgr mmgr
Definition: hpdf_streams.h:102
HPDF_Stream_Read_Func read_fn
Definition: hpdf_streams.h:106
HPDF_Stream_Size_Func size_fn
Definition: hpdf_streams.h:110
void * attr
Definition: hpdf_streams.h:111
HPDF_Stream_Seek_Func seek_fn
Definition: hpdf_streams.h:107
HPDF_Stream_Free_Func free_fn
Definition: hpdf_streams.h:108
HPDF_UINT size
Definition: hpdf_streams.h:104
HPDF_Error error
Definition: hpdf_streams.h:103
HPDF_StreamType type
Definition: hpdf_streams.h:101
HPDF_Stream_Write_Func write_fn
Definition: hpdf_streams.h:105