Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/trio/trio.h
2 views
1
/*************************************************************************
2
*
3
* $Id$
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
/*
28
* Use autoconf defines if present. Packages using trio must define
29
* HAVE_CONFIG_H as a compiler option themselves.
30
*/
31
#if defined(HAVE_CONFIG_H)
32
# include <config.h>
33
#endif
34
35
#include "triop.h"
36
37
#include <stdio.h>
38
39
#ifdef __cplusplus
40
extern "C" {
41
#endif
42
43
/*
44
* Error codes.
45
*
46
* Remember to add a textual description to trio_strerror.
47
*/
48
enum {
49
TRIO_EOF = 1,
50
TRIO_EINVAL = 2,
51
TRIO_ETOOMANY = 3,
52
TRIO_EDBLREF = 4,
53
TRIO_EGAP = 5,
54
TRIO_ENOMEM = 6,
55
TRIO_ERANGE = 7,
56
TRIO_ERRNO = 8,
57
TRIO_ECUSTOM = 9
58
};
59
60
/* Error macros */
61
#define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF)
62
#define TRIO_ERROR_POSITION(x) ((-(x)) >> 8)
63
#define TRIO_ERROR_NAME(x) trio_strerror(x)
64
65
/* Argument function types */
66
enum {
67
TRIO_TYPE_POINTER = 1,
68
TRIO_TYPE_CHAR = 2,
69
TRIO_TYPE_SHORT = 3,
70
TRIO_TYPE_INT = 4,
71
TRIO_TYPE_LONG = 5,
72
TRIO_TYPE_ULONGLONG = 6,
73
TRIO_TYPE_UINTMAX = 7,
74
TRIO_TYPE_PTRDIFF = 8,
75
TRIO_TYPE_SIZE = 9,
76
TRIO_TYPE_PCHAR = 10,
77
TRIO_TYPE_PWCHAR = 11,
78
TRIO_TYPE_FLOAT = 12,
79
TRIO_TYPE_DOUBLE = 13,
80
TRIO_TYPE_LONGDOUBLE = 14
81
};
82
83
typedef trio_pointer_t (*trio_argfunc_t) TRIO_PROTO((trio_pointer_t, int, int));
84
typedef int (*trio_outstream_t) TRIO_PROTO((trio_pointer_t, int));
85
typedef int (*trio_instream_t) TRIO_PROTO((trio_pointer_t));
86
87
TRIO_CONST char *trio_strerror TRIO_PROTO((int));
88
89
/*************************************************************************
90
* Print Functions
91
*/
92
93
#if defined(TRIO_COMPILER_GCC) && !TRIO_EXTENSION
94
# define TRIO_PROTO_PRINTF(x,a) TRIO_PROTO(x) __attribute__ ((format (gnu_printf, a, a+1)))
95
# define TRIO_PROTO_SCANF(x,a) TRIO_PROTO(x) __attribute__ ((format (gnu_scanf, a, a+1)))
96
#else
97
# define TRIO_PROTO_PRINTF(x,a) TRIO_PROTO(x)
98
# define TRIO_PROTO_SCANF(x,a) TRIO_PROTO(x)
99
#endif
100
101
int trio_printf TRIO_PROTO_PRINTF((TRIO_CONST char *format, ...), 1);
102
int trio_vprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
103
int trio_printfv TRIO_PROTO((TRIO_CONST char *format, trio_pointer_t *args));
104
105
int trio_fprintf TRIO_PROTO_PRINTF((FILE *file, TRIO_CONST char *format, ...), 2);
106
int trio_vfprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
107
int trio_fprintfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, trio_pointer_t *args));
108
109
int trio_dprintf TRIO_PROTO_PRINTF((int fd, TRIO_CONST char *format, ...), 2);
110
int trio_vdprintf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
111
int trio_dprintfv TRIO_PROTO((int fd, TRIO_CONST char *format, trio_pointer_t *args));
112
113
int trio_cprintf TRIO_PROTO_PRINTF((trio_outstream_t stream, trio_pointer_t closure,
114
TRIO_CONST char *format, ...),
115
3);
116
int trio_vcprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
117
TRIO_CONST char *format, va_list args));
118
int trio_cprintfv TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
119
TRIO_CONST char *format, trio_pointer_t *args));
120
int trio_cprintff TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
121
TRIO_CONST char *format,
122
trio_argfunc_t func, trio_pointer_t context));
123
124
int trio_sprintf TRIO_PROTO_PRINTF((char *buffer, TRIO_CONST char *format, ...), 2);
125
int trio_vsprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, va_list args));
126
int trio_sprintfv TRIO_PROTO((char *buffer, TRIO_CONST char *format, trio_pointer_t *args));
127
128
int trio_snprintf TRIO_PROTO_PRINTF((char *buffer, size_t max, TRIO_CONST char *format, ...), 3);
129
int trio_vsnprintf TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
130
va_list args));
131
int trio_snprintfv TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
132
trio_pointer_t *args));
133
134
int trio_snprintfcat TRIO_PROTO_PRINTF((char *buffer, size_t max, TRIO_CONST char *format, ...), 3);
135
int trio_vsnprintfcat TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
136
va_list args));
137
138
#if defined(TRIO_DEPRECATED)
139
char *trio_aprintf TRIO_PROTO_PRINTF((TRIO_CONST char *format, ...), 1);
140
char *trio_vaprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
141
#endif
142
143
int trio_asprintf TRIO_PROTO_PRINTF((char **ret, TRIO_CONST char *format, ...), 2);
144
int trio_vasprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, va_list args));
145
int trio_asprintfv TRIO_PROTO((char **result, TRIO_CONST char *format, trio_pointer_t * args));
146
147
/*************************************************************************
148
* Scan Functions
149
*/
150
int trio_scanf TRIO_PROTO_SCANF((TRIO_CONST char *format, ...), 1);
151
int trio_vscanf TRIO_PROTO((TRIO_CONST char *format, va_list args));
152
int trio_scanfv TRIO_PROTO((TRIO_CONST char *format, void **args));
153
154
int trio_fscanf TRIO_PROTO_SCANF((FILE *file, TRIO_CONST char *format, ...), 2);
155
int trio_vfscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
156
int trio_fscanfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
157
158
int trio_dscanf TRIO_PROTO_SCANF((int fd, TRIO_CONST char *format, ...), 2);
159
int trio_vdscanf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
160
int trio_dscanfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
161
162
int trio_cscanf TRIO_PROTO_SCANF((trio_instream_t stream, trio_pointer_t closure,
163
TRIO_CONST char *format, ...),
164
3);
165
int trio_vcscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
166
TRIO_CONST char *format, va_list args));
167
int trio_cscanfv TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
168
TRIO_CONST char *format, void **args));
169
int trio_cscanff TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
170
TRIO_CONST char *format,
171
trio_argfunc_t func, trio_pointer_t context));
172
173
int trio_sscanf TRIO_PROTO_SCANF((TRIO_CONST char *buffer, TRIO_CONST char *format, ...), 2);
174
int trio_vsscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args));
175
int trio_sscanfv TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, void **args));
176
177
/*************************************************************************
178
* Locale Functions
179
*/
180
void trio_locale_set_decimal_point TRIO_PROTO((char *decimalPoint));
181
void trio_locale_set_thousand_separator TRIO_PROTO((char *thousandSeparator));
182
void trio_locale_set_grouping TRIO_PROTO((char *grouping));
183
184
/*************************************************************************
185
* Renaming
186
*/
187
#ifdef TRIO_REPLACE_STDIO
188
/* Replace the <stdio.h> functions */
189
#ifndef HAVE_PRINTF
190
# undef printf
191
# define printf trio_printf
192
#endif
193
#ifndef HAVE_VPRINTF
194
# undef vprintf
195
# define vprintf trio_vprintf
196
#endif
197
#ifndef HAVE_FPRINTF
198
# undef fprintf
199
# define fprintf trio_fprintf
200
#endif
201
#ifndef HAVE_VFPRINTF
202
# undef vfprintf
203
# define vfprintf trio_vfprintf
204
#endif
205
#ifndef HAVE_SPRINTF
206
# undef sprintf
207
# define sprintf trio_sprintf
208
#endif
209
#ifndef HAVE_VSPRINTF
210
# undef vsprintf
211
# define vsprintf trio_vsprintf
212
#endif
213
#ifndef HAVE_SNPRINTF
214
# undef snprintf
215
# define snprintf trio_snprintf
216
#endif
217
#ifndef HAVE_VSNPRINTF
218
# undef vsnprintf
219
# define vsnprintf trio_vsnprintf
220
#endif
221
#ifndef HAVE_SCANF
222
# undef scanf
223
# define scanf trio_scanf
224
#endif
225
#ifndef HAVE_VSCANF
226
# undef vscanf
227
# define vscanf trio_vscanf
228
#endif
229
#ifndef HAVE_FSCANF
230
# undef fscanf
231
# define fscanf trio_fscanf
232
#endif
233
#ifndef HAVE_VFSCANF
234
# undef vfscanf
235
# define vfscanf trio_vfscanf
236
#endif
237
#ifndef HAVE_SSCANF
238
# undef sscanf
239
# define sscanf trio_sscanf
240
#endif
241
#ifndef HAVE_VSSCANF
242
# undef vsscanf
243
# define vsscanf trio_vsscanf
244
#endif
245
/* These aren't stdio functions, but we make them look similar */
246
#undef dprintf
247
#define dprintf trio_dprintf
248
#undef vdprintf
249
#define vdprintf trio_vdprintf
250
#undef aprintf
251
#define aprintf trio_aprintf
252
#undef vaprintf
253
#define vaprintf trio_vaprintf
254
#undef asprintf
255
#define asprintf trio_asprintf
256
#undef vasprintf
257
#define vasprintf trio_vasprintf
258
#undef dscanf
259
#define dscanf trio_dscanf
260
#undef vdscanf
261
#define vdscanf trio_vdscanf
262
#endif
263
264
#ifdef __cplusplus
265
} /* extern "C" */
266
#endif
267
268
#endif /* WITHOUT_TRIO */
269
270
#endif /* TRIO_TRIO_H */
271
272