beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-output-stream-private.h
blob2542646b86085df8260f1e38793d2dcc3daba71e
1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2006 Red Hat, Inc
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.
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
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
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/
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.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
32 * Author(s):
33 * Kristian Høgsberg <krh@redhat.com>
36 #ifndef CAIRO_OUTPUT_STREAM_PRIVATE_H
37 #define CAIRO_OUTPUT_STREAM_PRIVATE_H
39 #include "cairo-compiler-private.h"
40 #include "cairo-types-private.h"
42 #include <stdlib.h>
43 #include <stdio.h>
44 #include <stdarg.h>
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);
51 typedef cairo_status_t
52 (*cairo_output_stream_flush_func_t) (cairo_output_stream_t *output_stream);
54 typedef cairo_status_t
55 (*cairo_output_stream_close_func_t) (cairo_output_stream_t *output_stream);
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;
66 extern const cairo_private cairo_output_stream_t _cairo_output_stream_nil;
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);
74 cairo_private cairo_status_t
75 _cairo_output_stream_fini (cairo_output_stream_t *stream);
78 /* We already have the following declared in cairo.h:
80 typedef cairo_status_t (*cairo_write_func_t) (void *closure,
81 const unsigned char *data,
82 unsigned int length);
84 typedef cairo_status_t (*cairo_close_func_t) (void *closure);
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.
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.
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);
100 cairo_private cairo_output_stream_t *
101 _cairo_output_stream_create_in_error (cairo_status_t status);
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);
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);
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);
119 cairo_private void
120 _cairo_output_stream_write (cairo_output_stream_t *stream,
121 const void *data, size_t length);
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);
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);
133 cairo_private void
134 _cairo_output_stream_printf (cairo_output_stream_t *stream,
135 const char *fmt,
136 ...) CAIRO_PRINTF_FORMAT (2, 3);
138 /* Print matrix element values with rounding of insignificant digits. */
139 cairo_private void
140 _cairo_output_stream_print_matrix (cairo_output_stream_t *stream,
141 const cairo_matrix_t *matrix);
143 cairo_private long
144 _cairo_output_stream_get_position (cairo_output_stream_t *stream);
146 cairo_private cairo_status_t
147 _cairo_output_stream_get_status (cairo_output_stream_t *stream);
149 /* This function never returns %NULL. If an error occurs (NO_MEMORY or
150 * WRITE_ERROR) while trying to create the output stream this function
151 * returns a valid pointer to a nil output stream.
153 * Note: Even if a nil surface is returned, the caller should still
154 * call _cairo_output_stream_destroy (or _cairo_output_stream_close at
155 * least) in order to ensure that everything is properly cleaned up.
157 cairo_private cairo_output_stream_t *
158 _cairo_output_stream_create_for_filename (const char *filename);
160 /* This function never returns %NULL. If an error occurs (NO_MEMORY or
161 * WRITE_ERROR) while trying to create the output stream this function
162 * returns a valid pointer to a nil output stream.
164 * The caller still "owns" file and is responsible for calling fclose
165 * on it when finished. The stream will not do this itself.
167 cairo_private cairo_output_stream_t *
168 _cairo_output_stream_create_for_file (FILE *file);
170 cairo_private cairo_output_stream_t *
171 _cairo_memory_stream_create (void);
173 cairo_private void
174 _cairo_memory_stream_copy (cairo_output_stream_t *base,
175 cairo_output_stream_t *dest);
177 cairo_private int
178 _cairo_memory_stream_length (cairo_output_stream_t *stream);
180 cairo_private cairo_status_t
181 _cairo_memory_stream_destroy (cairo_output_stream_t *abstract_stream,
182 unsigned char **data_out,
183 unsigned long *length_out);
185 cairo_private cairo_output_stream_t *
186 _cairo_null_stream_create (void);
188 /* cairo-base85-stream.c */
189 cairo_private cairo_output_stream_t *
190 _cairo_base85_stream_create (cairo_output_stream_t *output);
192 /* cairo-base64-stream.c */
193 cairo_private cairo_output_stream_t *
194 _cairo_base64_stream_create (cairo_output_stream_t *output);
196 /* cairo-deflate-stream.c */
197 cairo_private cairo_output_stream_t *
198 _cairo_deflate_stream_create (cairo_output_stream_t *output);
201 #endif /* CAIRO_OUTPUT_STREAM_PRIVATE_H */