Subversion Repositories Scribus

Rev

Rev 14952 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14952 fschmid 1
/* cairo - a vector graphics library with display and print output
2
 *
3
 * Copyright © 2006 Red Hat, Inc
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it either under the terms of the GNU Lesser General Public
7
 * License version 2.1 as published by the Free Software Foundation
8
 * (the "LGPL") or, at your option, under the terms of the Mozilla
9
 * Public License Version 1.1 (the "MPL"). If you do not alter this
10
 * notice, a recipient may use your version of this file under either
11
 * the MPL or the LGPL.
12
 *
13
 * You should have received a copy of the LGPL along with this library
14
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
18122 mrdocs 15
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14952 fschmid 16
 * You should have received a copy of the MPL along with this library
17
 * in the file COPYING-MPL-1.1
18
 *
19
 * The contents of this file are subject to the Mozilla Public License
20
 * Version 1.1 (the "License"); you may not use this file except in
21
 * compliance with the License. You may obtain a copy of the License at
22
 * http://www.mozilla.org/MPL/
23
 *
24
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26
 * the specific language governing rights and limitations.
27
 *
28
 * The Original Code is the cairo graphics library.
29
 *
30
 * The Initial Developer of the Original Code is Red Hat, Inc.
31
 *
32
 * Author(s):
33
 *      Kristian Høgsberg <krh@redhat.com>
34
 */
35
 
36
#ifndef CAIRO_OUTPUT_STREAM_PRIVATE_H
37
#define CAIRO_OUTPUT_STREAM_PRIVATE_H
38
 
39
#include "cairo-compiler-private.h"
40
#include "cairo-types-private.h"
41
 
42
#include <stdlib.h>
43
#include <stdio.h>
44
#include <stdarg.h>
45
 
46
typedef cairo_status_t
47
(*cairo_output_stream_write_func_t) (cairo_output_stream_t *output_stream,
48
                                     const unsigned char   *data,
49
                                     unsigned int           length);
50
 
51
typedef cairo_status_t
52
(*cairo_output_stream_flush_func_t) (cairo_output_stream_t *output_stream);
53
 
54
typedef cairo_status_t
55
(*cairo_output_stream_close_func_t) (cairo_output_stream_t *output_stream);
56
 
57
struct _cairo_output_stream {
58
    cairo_output_stream_write_func_t write_func;
59
    cairo_output_stream_flush_func_t flush_func;
60
    cairo_output_stream_close_func_t close_func;
61
    unsigned long                    position;
62
    cairo_status_t                   status;
63
    cairo_bool_t                     closed;
64
};
65
 
66
extern const cairo_private cairo_output_stream_t _cairo_output_stream_nil;
67
 
68
cairo_private void
69
_cairo_output_stream_init (cairo_output_stream_t            *stream,
70
                           cairo_output_stream_write_func_t  write_func,
71
                           cairo_output_stream_flush_func_t  flush_func,
72
                           cairo_output_stream_close_func_t  close_func);
73
 
74
cairo_private cairo_status_t
75
_cairo_output_stream_fini (cairo_output_stream_t *stream);
76
 
77
 
78
/* We already have the following declared in cairo.h:
79
 
80
typedef cairo_status_t (*cairo_write_func_t) (void                *closure,
81
                                              const unsigned char *data,
82
                                              unsigned int         length);
83
*/
84
typedef cairo_status_t (*cairo_close_func_t) (void *closure);
85
 
86
 
87
/* This function never returns %NULL. If an error occurs (NO_MEMORY)
88
 * while trying to create the output stream this function returns a
89
 * valid pointer to a nil output stream.
90
 *
91
 * Note that even with a nil surface, the close_func callback will be
92
 * called by a call to _cairo_output_stream_close or
93
 * _cairo_output_stream_destroy.
94
 */
95
cairo_private cairo_output_stream_t *
96
_cairo_output_stream_create (cairo_write_func_t         write_func,
97
                             cairo_close_func_t         close_func,
98
                             void                       *closure);
99
 
100
cairo_private cairo_output_stream_t *
101
_cairo_output_stream_create_in_error (cairo_status_t status);
102
 
103
/* Tries to flush any buffer maintained by the stream or its delegates. */
104
cairo_private cairo_status_t
105
_cairo_output_stream_flush (cairo_output_stream_t *stream);
106
 
107
/* Returns the final status value associated with this object, just
108
 * before its last gasp. This final status value will capture any
109
 * status failure returned by the stream's close_func as well. */
110
cairo_private cairo_status_t
111
_cairo_output_stream_close (cairo_output_stream_t *stream);
112
 
113
/* Returns the final status value associated with this object, just
114
 * before its last gasp. This final status value will capture any
115
 * status failure returned by the stream's close_func as well. */
116
cairo_private cairo_status_t
117
_cairo_output_stream_destroy (cairo_output_stream_t *stream);
118
 
119
cairo_private void
120
_cairo_output_stream_write (cairo_output_stream_t *stream,
121
                            const void *data, size_t length);
122
 
123
cairo_private void
124
_cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
125
                                       const unsigned char *data,
126
                                       size_t length);
127
 
128
cairo_private void
129
_cairo_output_stream_vprintf (cairo_output_stream_t *stream,
130
                              const char *fmt,
131
                              va_list ap) CAIRO_PRINTF_FORMAT ( 2, 0);
132
 
133
cairo_private void
134
_cairo_output_stream_printf (cairo_output_stream_t *stream,
135
                             const char *fmt,
136
                             ...) CAIRO_PRINTF_FORMAT (2, 3);
137
 
138
cairo_private long
139
_cairo_output_stream_get_position (cairo_output_stream_t *stream);
140
 
141
cairo_private cairo_status_t
142
_cairo_output_stream_get_status (cairo_output_stream_t *stream);
143
 
144
/* This function never returns %NULL. If an error occurs (NO_MEMORY or
145
 * WRITE_ERROR) while trying to create the output stream this function
146
 * returns a valid pointer to a nil output stream.
147
 *
148
 * Note: Even if a nil surface is returned, the caller should still
149
 * call _cairo_output_stream_destroy (or _cairo_output_stream_close at
150
 * least) in order to ensure that everything is properly cleaned up.
151
 */
152
cairo_private cairo_output_stream_t *
153
_cairo_output_stream_create_for_filename (const char *filename);
154
 
155
/* This function never returns %NULL. If an error occurs (NO_MEMORY or
156
 * WRITE_ERROR) while trying to create the output stream this function
157
 * returns a valid pointer to a nil output stream.
158
 *
159
 * The caller still "owns" file and is responsible for calling fclose
160
 * on it when finished. The stream will not do this itself.
161
 */
162
cairo_private cairo_output_stream_t *
163
_cairo_output_stream_create_for_file (FILE *file);
164
 
165
cairo_private cairo_output_stream_t *
166
_cairo_memory_stream_create (void);
167
 
168
cairo_private void
169
_cairo_memory_stream_copy (cairo_output_stream_t *base,
170
                           cairo_output_stream_t *dest);
171
 
172
cairo_private int
173
_cairo_memory_stream_length (cairo_output_stream_t *stream);
174
 
175
cairo_private cairo_status_t
176
_cairo_memory_stream_destroy (cairo_output_stream_t *abstract_stream,
177
                              unsigned char **data_out,
178
                              unsigned int *length_out);
179
 
180
cairo_private cairo_output_stream_t *
181
_cairo_null_stream_create (void);
182
 
183
/* cairo-base85-stream.c */
184
cairo_private cairo_output_stream_t *
185
_cairo_base85_stream_create (cairo_output_stream_t *output);
186
 
187
/* cairo-base64-stream.c */
188
cairo_private cairo_output_stream_t *
189
_cairo_base64_stream_create (cairo_output_stream_t *output);
190
 
191
/* cairo-deflate-stream.c */
192
cairo_private cairo_output_stream_t *
193
_cairo_deflate_stream_create (cairo_output_stream_t *output);
194
 
195
 
196
#endif /* CAIRO_OUTPUT_STREAM_PRIVATE_H */