xref: /plan9/sys/src/cmd/gs/src/spprint.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: spprint.h,v 1.6 2002/06/16 05:00:54 lpd Exp $ */
18 /* Print values in ASCII form on a stream */
19 
20 #ifndef spprint_INCLUDED
21 #  define spprint_INCLUDED
22 
23 /* Define an opaque type for streams. */
24 #ifndef stream_DEFINED
25 #  define stream_DEFINED
26 typedef struct stream_s stream;
27 #endif
28 
29 /* Put a character on a stream. */
30 #define stream_putc(s, c) spputc(s, c)
31 
32 /* Put a byte array on a stream. */
33 int stream_write(stream * s, const void *ptr, uint count);
34 
35 /* Put a string on a stream. */
36 int stream_puts(stream * s, const char *str);
37 
38 /*
39  * Print (a) floating point number(s) using a format.  This is needed
40  * because %f format always prints a fixed number of digits after the
41  * decimal point, and %g format may use %e format, which PDF disallows.
42  * These functions return a pointer to the next %-element of the format, or
43  * to the terminating 0.
44  */
45 const char *pprintg1(stream * s, const char *format, floatp v);
46 const char *pprintg2(stream * s, const char *format, floatp v1, floatp v2);
47 const char *pprintg3(stream * s, const char *format,
48 		     floatp v1, floatp v2, floatp v3);
49 const char *pprintg4(stream * s, const char *format,
50 		     floatp v1, floatp v2, floatp v3, floatp v4);
51 const char *pprintg6(stream * s, const char *format,
52 		     floatp v1, floatp v2, floatp v3, floatp v4,
53 		     floatp v5, floatp v6);
54 
55 /*
56  * The rest of these printing functions exist solely because the ANSI C
57  * "standard" for functions with a variable number of arguments is not
58  * implemented properly or consistently across compilers.
59  */
60 /* Print (an) int value(s) using a format. */
61 const char *pprintd1(stream * s, const char *format, int v);
62 const char *pprintd2(stream * s, const char *format, int v1, int v2);
63 const char *pprintd3(stream * s, const char *format,
64 		     int v1, int v2, int v3);
65 const char *pprintd4(stream * s, const char *format,
66 		     int v1, int v2, int v3, int v4);
67 
68 /* Print a long value using a format. */
69 const char *pprintld1(stream * s, const char *format, long v);
70 const char *pprintld2(stream * s, const char *format, long v1, long v2);
71 const char *pprintld3(stream * s, const char *format,
72 		      long v1, long v2, long v3);
73 
74 /* Print (a) string(s) using a format. */
75 const char *pprints1(stream * s, const char *format, const char *str);
76 const char *pprints2(stream * s, const char *format,
77 		     const char *str1, const char *str2);
78 const char *pprints3(stream * s, const char *format,
79 		     const char *str1, const char *str2, const char *str3);
80 
81 #endif /* spprint_INCLUDED */
82