]> Pileus Git - ~andy/fetchmail/blob - trio/trio.h
Add new gai.c debug source.
[~andy/fetchmail] / trio / trio.h
1 /*************************************************************************
2  *
3  * $Id: trio.h,v 1.19 2009/09/13 10:12:22 breese Exp $
4  *
5  * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14  * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
15  *
16  *************************************************************************
17  *
18  * http://ctrio.sourceforge.net/
19  *
20  ************************************************************************/
21
22 #ifndef TRIO_TRIO_H
23 #define TRIO_TRIO_H
24
25 #if !defined(WITHOUT_TRIO)
26
27 #if WANT_FETCHMAIL_CONFIG_H_FOR_TRIO - 0
28 /* if used as part of fetchmail, do not include config.h, as that would break
29  * the regression test. */
30
31 /*
32  * Use autoconf defines if present. Packages using trio must define
33  * HAVE_CONFIG_H as a compiler option themselves.
34  */
35 #if defined(HAVE_CONFIG_H)
36 # include <config.h>
37 #endif
38 #endif
39
40 #include "triop.h"
41
42 #include <stdio.h>
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /*
49  * Error codes.
50  *
51  * Remember to add a textual description to trio_strerror.
52  */
53 enum {
54   TRIO_EOF      = 1,
55   TRIO_EINVAL   = 2,
56   TRIO_ETOOMANY = 3,
57   TRIO_EDBLREF  = 4,
58   TRIO_EGAP     = 5,
59   TRIO_ENOMEM   = 6,
60   TRIO_ERANGE   = 7,
61   TRIO_ERRNO    = 8,
62   TRIO_ECUSTOM  = 9
63 };
64
65 /* Error macros */
66 #define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF)
67 #define TRIO_ERROR_POSITION(x) ((-(x)) >> 8)
68 #define TRIO_ERROR_NAME(x) trio_strerror(x)
69
70 typedef int (*trio_outstream_t) TRIO_PROTO((trio_pointer_t, int));
71 typedef int (*trio_instream_t) TRIO_PROTO((trio_pointer_t));
72
73 TRIO_CONST char *trio_strerror TRIO_PROTO((int));
74
75 /*************************************************************************
76  * Print Functions
77  */
78
79 int trio_printf TRIO_PROTO((TRIO_CONST char *format, ...));
80 int trio_vprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
81 int trio_printfv TRIO_PROTO((TRIO_CONST char *format, void **args));
82
83 int trio_fprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...));
84 int trio_vfprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
85 int trio_fprintfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
86
87 int trio_dprintf TRIO_PROTO((int fd, TRIO_CONST char *format, ...));
88 int trio_vdprintf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
89 int trio_dprintfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
90
91 int trio_cprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
92                              TRIO_CONST char *format, ...));
93 int trio_vcprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
94                               TRIO_CONST char *format, va_list args));
95 int trio_cprintfv TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
96                               TRIO_CONST char *format, void **args));
97
98 int trio_sprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, ...));
99 int trio_vsprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, va_list args));
100 int trio_sprintfv TRIO_PROTO((char *buffer, TRIO_CONST char *format, void **args));
101
102 int trio_snprintf TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...));
103 int trio_vsnprintf TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
104                    va_list args));
105 int trio_snprintfv TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
106                    void **args));
107
108 int trio_snprintfcat TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...));
109 int trio_vsnprintfcat TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
110                       va_list args));
111
112 #if defined(TRIO_DEPRECATED)
113 char *trio_aprintf TRIO_PROTO((TRIO_CONST char *format, ...));
114 char *trio_vaprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
115 #endif
116
117 int trio_asprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, ...));
118 int trio_vasprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, va_list args));
119 int trio_asprintfv TRIO_PROTO((char **result, TRIO_CONST char *format, trio_pointer_t * args));
120
121 /*************************************************************************
122  * Scan Functions
123  */
124 int trio_scanf TRIO_PROTO((TRIO_CONST char *format, ...));
125 int trio_vscanf TRIO_PROTO((TRIO_CONST char *format, va_list args));
126 int trio_scanfv TRIO_PROTO((TRIO_CONST char *format, void **args));
127
128 int trio_fscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...));
129 int trio_vfscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
130 int trio_fscanfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
131
132 int trio_dscanf TRIO_PROTO((int fd, TRIO_CONST char *format, ...));
133 int trio_vdscanf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
134 int trio_dscanfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
135
136 int trio_cscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
137                             TRIO_CONST char *format, ...));
138 int trio_vcscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
139                              TRIO_CONST char *format, va_list args));
140 int trio_cscanfv TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
141                              TRIO_CONST char *format, void **args));
142
143 int trio_sscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, ...));
144 int trio_vsscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args));
145 int trio_sscanfv TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, void **args));
146
147 /*************************************************************************
148  * Locale Functions
149  */
150 void trio_locale_set_decimal_point TRIO_PROTO((char *decimalPoint));
151 void trio_locale_set_thousand_separator TRIO_PROTO((char *thousandSeparator));
152 void trio_locale_set_grouping TRIO_PROTO((char *grouping));
153
154 /*************************************************************************
155  * Renaming
156  */
157 #ifdef TRIO_REPLACE_STDIO
158 /* Replace the <stdio.h> functions */
159 #ifndef HAVE_PRINTF
160 # undef printf
161 # define printf trio_printf
162 #endif
163 #ifndef HAVE_VPRINTF
164 # undef vprintf
165 # define vprintf trio_vprintf
166 #endif
167 #ifndef HAVE_FPRINTF
168 # undef fprintf
169 # define fprintf trio_fprintf
170 #endif
171 #ifndef HAVE_VFPRINTF
172 # undef vfprintf
173 # define vfprintf trio_vfprintf
174 #endif
175 #ifndef HAVE_SPRINTF
176 # undef sprintf
177 # define sprintf trio_sprintf
178 #endif
179 #ifndef HAVE_VSPRINTF
180 # undef vsprintf
181 # define vsprintf trio_vsprintf
182 #endif
183 #ifndef HAVE_SNPRINTF
184 # undef snprintf
185 # define snprintf trio_snprintf
186 #endif
187 #ifndef HAVE_VSNPRINTF
188 # undef vsnprintf
189 # define vsnprintf trio_vsnprintf
190 #endif
191 #ifndef HAVE_SCANF
192 # undef scanf
193 # define scanf trio_scanf
194 #endif
195 #ifndef HAVE_VSCANF
196 # undef vscanf
197 # define vscanf trio_vscanf
198 #endif
199 #ifndef HAVE_FSCANF
200 # undef fscanf
201 # define fscanf trio_fscanf
202 #endif
203 #ifndef HAVE_VFSCANF
204 # undef vfscanf
205 # define vfscanf trio_vfscanf
206 #endif
207 #ifndef HAVE_SSCANF
208 # undef sscanf
209 # define sscanf trio_sscanf
210 #endif
211 #ifndef HAVE_VSSCANF
212 # undef vsscanf
213 # define vsscanf trio_vsscanf
214 #endif
215 /* These aren't stdio functions, but we make them look similar */
216 #undef dprintf
217 #define dprintf trio_dprintf
218 #undef vdprintf
219 #define vdprintf trio_vdprintf
220 #undef aprintf
221 #define aprintf trio_aprintf
222 #undef vaprintf
223 #define vaprintf trio_vaprintf
224 #undef asprintf
225 #define asprintf trio_asprintf
226 #undef vasprintf
227 #define vasprintf trio_vasprintf
228 #undef dscanf
229 #define dscanf trio_dscanf
230 #undef vdscanf
231 #define vdscanf trio_vdscanf
232 #endif
233
234 #ifdef __cplusplus
235 } /* extern "C" */
236 #endif
237
238 #endif /* WITHOUT_TRIO */
239
240 #endif /* TRIO_TRIO_H */