Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/trio/triop.h
2 views
1
/*************************************************************************
2
*
3
* $Id$
4
*
5
* Copyright (C) 2000 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
* Private functions, types, etc. used for callback functions.
19
*
20
* The ref pointer is an opaque type and should remain as such.
21
* Private data must only be accessible through the getter and
22
* setter functions.
23
*
24
************************************************************************/
25
26
#ifndef TRIO_TRIOP_H
27
#define TRIO_TRIOP_H
28
29
#include "triodef.h"
30
31
#include <stdlib.h>
32
#if defined(TRIO_COMPILER_ANCIENT)
33
# include <varargs.h>
34
#else
35
# include <stdarg.h>
36
#endif
37
38
#ifdef __cplusplus
39
extern "C" {
40
#endif
41
42
/*************************************************************************
43
* Supported standards
44
*/
45
46
/*
47
* TRIO_C99 (=0 or =1)
48
*
49
* Define this to 0 to disable C99 format specifier extensions, or
50
* define to 1 to enable them. The format specifiers that are
51
* disabled by this switch are labelled with [C99] in the format
52
* specifier documentation.
53
*/
54
#if !defined(TRIO_C99)
55
# define TRIO_C99 1
56
#endif
57
58
/*
59
* TRIO_BSD (=0 or =1)
60
*
61
* Define this to 0 to disable BSD format specifier extensions, or
62
* define to 1 to enable them. The format specifiers that are
63
* disabled by this switch are labelled with [BSD] in the format
64
* specifier documentation.
65
*/
66
#if !defined(TRIO_BSD)
67
# define TRIO_BSD 1
68
#endif
69
70
/*
71
* TRIO_GNU (=0 or =1)
72
*
73
* Define this to 0 to disable GNU format specifier extensions, or
74
* define to 1 to enable them. The format specifiers that are
75
* disabled by this switch are labelled with [GNU] in the format
76
* specifier documentation.
77
*/
78
#if !defined(TRIO_GNU)
79
# define TRIO_GNU 1
80
#endif
81
82
/*
83
* TRIO_MISC (=0 or =1)
84
*
85
* Define this to 0 to disable miscellaneous format specifier
86
* extensions, or define to 1 to enable them. The format specifiers
87
* that are disabled by this switch are labelled with [MISC] in the
88
* format specifier documentation.
89
*/
90
#if !defined(TRIO_MISC)
91
# define TRIO_MISC 1
92
#endif
93
94
/*
95
* TRIO_UNIX98 (=0 or =1)
96
*
97
* Define this to 0 to disable UNIX98 format specifier extensions,
98
* or define to 1 to enable them. The format specifiers that are
99
* disabled by this switch are labelled with [UNIX98] in the format
100
* specifier documentation.
101
*/
102
#if !defined(TRIO_UNIX98)
103
# define TRIO_UNIX98 1
104
#endif
105
106
/*
107
* TRIO_MICROSOFT (=0 or =1)
108
*
109
* Define this to 0 to disable Microsoft Visual C format specifier
110
* extensions, or define to 1 to enable them. The format specifiers
111
* that are disabled by this switch are labelled with [MSVC] in the
112
* format specifier documentation.
113
*/
114
#if !defined(TRIO_MICROSOFT)
115
# define TRIO_MICROSOFT 1
116
#endif
117
118
/*
119
* TRIO_EXTENSION (=0 or =1)
120
*
121
* Define this to 0 to disable Trio-specific extensions, or define
122
* to 1 to enable them. This has two effects: it controls whether
123
* or not the Trio user-defined formating mechanism
124
* (trio_register() etc) is supported, and it enables or disables
125
* Trio's own format specifier extensions. The format specifiers
126
* that are disabled by this switch are labelled with [TRIO] in
127
* the format specifier documentation.
128
*/
129
#if !defined(TRIO_EXTENSION)
130
# define TRIO_EXTENSION 1
131
#endif
132
133
/*
134
* TRIO_DEPRECATED (=0 or =1)
135
*
136
* Define this to 0 to disable deprecated functionality, or define
137
* to 1 to enable them.
138
*/
139
#if !defined(TRIO_DEPRECATED)
140
# define TRIO_DEPRECATED 1
141
#endif
142
143
/*************************************************************************
144
* Features
145
*/
146
147
#if defined(TRIO_SNPRINTF_ONLY)
148
# define TRIO_FEATURE_SCANF 0
149
# define TRIO_FEATURE_FILE 0
150
# define TRIO_FEATURE_STDIO 0
151
# define TRIO_FEATURE_FD 0
152
# define TRIO_FEATURE_DYNAMICSTRING 0
153
# define TRIO_FEATURE_CLOSURE 0
154
# define TRIO_FEATURE_ARGFUNC 0
155
# define TRIO_FEATURE_STRERR 0
156
# define TRIO_FEATURE_LOCALE 0
157
# define TRIO_EMBED_NAN 1
158
# define TRIO_EMBED_STRING 1
159
#endif
160
161
/*
162
* TRIO_FEATURE_SCANF (=0 or =1)
163
*
164
* Define this to 0 to disable all the scanf() variants, or define to 1
165
* to enable them.
166
*/
167
#if !defined(TRIO_FEATURE_SCANF)
168
# define TRIO_FEATURE_SCANF 1
169
#endif
170
171
/*
172
* TRIO_FEATURE_FILE (=0 or =1)
173
*
174
* Define this to 0 to disable compilation of the trio_fprintf() and
175
* trio_fscanf() family of functions, or define to 1 to enable them.
176
*
177
* This may be useful on an embedded platform with no filesystem.
178
* Note that trio_printf() uses fwrite to write to stdout, so if you
179
* do not have an implementation of fwrite() at all then you must also
180
* define TRIO_FEATURE_STDIO to 0.
181
*/
182
#if !defined(TRIO_FEATURE_FILE)
183
# define TRIO_FEATURE_FILE 1
184
#endif
185
186
/*
187
* TRIO_FEATURE_STDIO (=0 or =1)
188
*
189
* Define this to 0 to disable compilation of the trio_printf() and
190
* trio_scanf() family of functions, or define to 1 to enable them.
191
*
192
* This may be useful on an embedded platform with no standard I/O.
193
*/
194
#if !defined(TRIO_FEATURE_STDIO)
195
# define TRIO_FEATURE_STDIO 1
196
#endif
197
198
/*
199
* TRIO_FEATURE_FD (=0 or =1)
200
*
201
* Define this to 0 to disable compilation of the trio_dprintf() and
202
* trio_dscanf() family of functions, or define to 1 to enable them.
203
*
204
* This may be useful on an embedded platform with no filesystem, or on
205
* a platform that supports file I/O using FILE* but not using raw file
206
* descriptors.
207
*/
208
#if !defined(TRIO_FEATURE_FD)
209
# define TRIO_FEATURE_FD 1
210
#endif
211
212
/*
213
* TRIO_FEATURE_DYNAMICSTRING (=0 or =1)
214
*
215
* Define this to 0 to disable compilation of the trio_aprintf()
216
* family of functions, or define to 1 to enable them.
217
*
218
* If you define both this and TRIO_MINIMAL to 0, then Trio will never
219
* call malloc or free.
220
*/
221
#if !defined(TRIO_FEATURE_DYNAMICSTRING)
222
# define TRIO_FEATURE_DYNAMICSTRING 1
223
#endif
224
225
/*
226
* TRIO_FEATURE_CLOSURE (=0 or =1)
227
*
228
* Define this to 0 to disable compilation of the trio_cprintf() and
229
* trio_cscanf() family of functions, or define to 1 to enable them.
230
*
231
* These functions are rarely needed. This saves a (small) amount of code.
232
*/
233
#if !defined(TRIO_FEATURE_CLOSURE)
234
# define TRIO_FEATURE_CLOSURE 1
235
#endif
236
237
/*
238
* TRIO_FEATURE_ARGFUNC (=0 or =1)
239
*
240
* Define this to 0 to disable compilation of trio_cprintff() and
241
* trio_cscanff() functions and related code (might have a tiny
242
* performance gain), or define to 1 to enable them.
243
*
244
* This functionality is needed only if you have to fetch the arguments using
245
* a pull model instead of passing them all at once (for example if you plan
246
* to plug the library into a script interpreter or validate the types).
247
*
248
* Only the closure family of functions are available with this interface,
249
* because if you need this, you usually provide custom input/output
250
* handling too (and so this forces TRIO_FEATURE_CLOSURE to enabled).
251
*/
252
#if !defined(TRIO_FEATURE_ARGFUNC)
253
# define TRIO_FEATURE_ARGFUNC 1
254
#endif
255
#if TRIO_FEATURE_ARGFUNC
256
# undef TRIO_FEATURE_CLOSURE
257
# define TRIO_FEATURE_CLOSURE 1
258
#endif
259
260
/*
261
* TRIO_FEATURE_ERRORCODE (=0 or =1)
262
*
263
* Define this to 0 to return -1 from the print and scan function on
264
* error, or define to 1 to return a negative number with debugging
265
* information as part of the return code.
266
*
267
* If enabled, the return code will be a negative number, which encodes
268
* an error code and an error location. These can be decoded with the
269
* TRIO_ERROR_CODE and TRIO_ERROR_POSITION macros.
270
*/
271
#if defined(TRIO_ERRORS)
272
# define TRIO_FEATURE_ERRORCODE TRIO_ERRORS
273
#endif
274
#if !defined(TRIO_FEATURE_ERRORCODE)
275
# define TRIO_FEATURE_ERRORCODE 1
276
#endif
277
278
/*
279
* TRIO_FEATURE_STRERR (=0 or =1)
280
*
281
* Define this to 0 if you do not use trio_strerror(), or define to 1 if
282
* you do use it.
283
*
284
* This saves a (small) amount of code.
285
*/
286
#if !defined(TRIO_FEATURE_STRERR)
287
# define TRIO_FEATURE_STRERR 1
288
#endif
289
290
/*
291
* TRIO_FEATURE_FLOAT (=0 or =1)
292
*
293
* Define this to 0 to disable all floating-point support, or define
294
* to 1 to enable it.
295
*
296
* This is useful in restricted embedded platforms that do not support
297
* floating-point. Obviously you cannot use floating-point format
298
* specifiers if you define this.
299
*
300
* Do not compile trionan.c if you disable this.
301
*/
302
#if !defined(TRIO_FEATURE_FLOAT)
303
# define TRIO_FEATURE_FLOAT 1
304
#endif
305
306
/*
307
* TRIO_FEATURE_LOCALE (=0 or =1)
308
*
309
* Define this to 0 to disable customized locale support, or define
310
* to 1 to enable it.
311
*
312
* This saves a (small) amount of code.
313
*/
314
#if !defined(TRIO_FEATURE_LOCALE)
315
# define TRIO_FEATURE_LOCALE 1
316
#endif
317
318
/*
319
* TRIO_MINIMAL
320
*
321
* Define this to disable building the public trionan.h and triostr.h.
322
* If you define this, then you must not compile trionan.c and triostr.c
323
* separately.
324
*/
325
#if defined(TRIO_MINIMAL)
326
# if !defined(TRIO_EMBED_NAN)
327
# define TRIO_EMBED_NAN
328
# endif
329
# if !defined(TRIO_EMBED_STRING)
330
# define TRIO_EMBED_STRING
331
# endif
332
#endif
333
334
/* Does not work yet. Do not enable */
335
#ifndef TRIO_FEATURE_WIDECHAR
336
# define TRIO_FEATURE_WIDECHAR 0
337
#endif
338
339
/*************************************************************************
340
* Mapping standards to internal features
341
*/
342
343
#if !defined(TRIO_FEATURE_HEXFLOAT)
344
# define TRIO_FEATURE_HEXFLOAT (TRIO_C99 && TRIO_FEATURE_FLOAT)
345
#endif
346
347
#if !defined(TRIO_FEATURE_LONGDOUBLE)
348
# define TRIO_FEATURE_LONGDOUBLE TRIO_FEATURE_FLOAT
349
#endif
350
351
#if !defined(TRIO_FEATURE_ERRNO)
352
# define TRIO_FEATURE_ERRNO TRIO_GNU
353
#endif
354
355
#if !defined(TRIO_FEATURE_QUAD)
356
# define TRIO_FEATURE_QUAD (TRIO_BSD || TRIO_GNU)
357
#endif
358
359
#if !defined(TRIO_FEATURE_SIZE_T)
360
# define TRIO_FEATURE_SIZE_T TRIO_C99
361
#endif
362
363
#if !defined(TRIO_FEATURE_SIZE_T_UPPER)
364
# define TRIO_FEATURE_SIZE_T_UPPER TRIO_GNU
365
#endif
366
367
#if !defined(TRIO_FEATURE_PTRDIFF_T)
368
# define TRIO_FEATURE_PTRDIFF_T TRIO_C99
369
#endif
370
371
#if !defined(TRIO_FEATURE_INTMAX_T)
372
# define TRIO_FEATURE_INTMAX_T TRIO_C99
373
#endif
374
375
#if !defined(TRIO_FEATURE_FIXED_SIZE)
376
# define TRIO_FEATURE_FIXED_SIZE TRIO_MICROSOFT
377
#endif
378
379
#if !defined(TRIO_FEATURE_POSITIONAL)
380
# define TRIO_FEATURE_POSITIONAL TRIO_UNIX98
381
#endif
382
383
#if !defined(TRIO_FEATURE_USER_DEFINED)
384
# define TRIO_FEATURE_USER_DEFINED TRIO_EXTENSION
385
#endif
386
387
#if !defined(TRIO_FEATURE_BINARY)
388
# define TRIO_FEATURE_BINARY TRIO_EXTENSION
389
#endif
390
391
#if !defined(TRIO_FEATURE_QUOTE)
392
# define TRIO_FEATURE_QUOTE TRIO_EXTENSION
393
#endif
394
395
#if !defined(TRIO_FEATURE_STICKY)
396
# define TRIO_FEATURE_STICKY TRIO_EXTENSION
397
#endif
398
399
#if !defined(TRIO_FEATURE_VARSIZE)
400
# define TRIO_FEATURE_VARSIZE TRIO_EXTENSION
401
#endif
402
403
#if !defined(TRIO_FEATURE_ROUNDING)
404
# define TRIO_FEATURE_ROUNDING TRIO_EXTENSION
405
#endif
406
407
/*************************************************************************
408
* Memory handling
409
*/
410
#ifndef TRIO_MALLOC
411
# define TRIO_MALLOC(n) malloc(n)
412
#endif
413
#ifndef TRIO_REALLOC
414
# define TRIO_REALLOC(x,n) realloc((x),(n))
415
#endif
416
#ifndef TRIO_FREE
417
# define TRIO_FREE(x) free(x)
418
#endif
419
420
421
/*************************************************************************
422
* User-defined specifiers
423
*/
424
425
typedef int (*trio_callback_t) TRIO_PROTO((trio_pointer_t));
426
427
trio_pointer_t trio_register TRIO_PROTO((trio_callback_t callback, const char *name));
428
void trio_unregister TRIO_PROTO((trio_pointer_t handle));
429
430
TRIO_CONST char *trio_get_format TRIO_PROTO((trio_pointer_t ref));
431
TRIO_CONST trio_pointer_t trio_get_argument TRIO_PROTO((trio_pointer_t ref));
432
433
/* Modifiers */
434
int trio_get_width TRIO_PROTO((trio_pointer_t ref));
435
void trio_set_width TRIO_PROTO((trio_pointer_t ref, int width));
436
int trio_get_precision TRIO_PROTO((trio_pointer_t ref));
437
void trio_set_precision TRIO_PROTO((trio_pointer_t ref, int precision));
438
int trio_get_base TRIO_PROTO((trio_pointer_t ref));
439
void trio_set_base TRIO_PROTO((trio_pointer_t ref, int base));
440
int trio_get_padding TRIO_PROTO((trio_pointer_t ref));
441
void trio_set_padding TRIO_PROTO((trio_pointer_t ref, int is_padding));
442
int trio_get_short TRIO_PROTO((trio_pointer_t ref)); /* h */
443
void trio_set_shortshort TRIO_PROTO((trio_pointer_t ref, int is_shortshort));
444
int trio_get_shortshort TRIO_PROTO((trio_pointer_t ref)); /* hh */
445
void trio_set_short TRIO_PROTO((trio_pointer_t ref, int is_short));
446
int trio_get_long TRIO_PROTO((trio_pointer_t ref)); /* l */
447
void trio_set_long TRIO_PROTO((trio_pointer_t ref, int is_long));
448
int trio_get_longlong TRIO_PROTO((trio_pointer_t ref)); /* ll */
449
void trio_set_longlong TRIO_PROTO((trio_pointer_t ref, int is_longlong));
450
int trio_get_longdouble TRIO_PROTO((trio_pointer_t ref)); /* L */
451
void trio_set_longdouble TRIO_PROTO((trio_pointer_t ref, int is_longdouble));
452
int trio_get_alternative TRIO_PROTO((trio_pointer_t ref)); /* # */
453
void trio_set_alternative TRIO_PROTO((trio_pointer_t ref, int is_alternative));
454
int trio_get_alignment TRIO_PROTO((trio_pointer_t ref)); /* - */
455
void trio_set_alignment TRIO_PROTO((trio_pointer_t ref, int is_leftaligned));
456
int trio_get_spacing TRIO_PROTO((trio_pointer_t ref)); /* (space) */
457
void trio_set_spacing TRIO_PROTO((trio_pointer_t ref, int is_space));
458
int trio_get_sign TRIO_PROTO((trio_pointer_t ref)); /* + */
459
void trio_set_sign TRIO_PROTO((trio_pointer_t ref, int is_showsign));
460
#if TRIO_FEATURE_QUOTE
461
int trio_get_quote TRIO_PROTO((trio_pointer_t ref)); /* ' */
462
void trio_set_quote TRIO_PROTO((trio_pointer_t ref, int is_quote));
463
#endif
464
int trio_get_upper TRIO_PROTO((trio_pointer_t ref));
465
void trio_set_upper TRIO_PROTO((trio_pointer_t ref, int is_upper));
466
#if TRIO_FEATURE_INTMAX_T
467
int trio_get_largest TRIO_PROTO((trio_pointer_t ref)); /* j */
468
void trio_set_largest TRIO_PROTO((trio_pointer_t ref, int is_largest));
469
#endif
470
#if TRIO_FEATURE_PTRDIFF_T
471
int trio_get_ptrdiff TRIO_PROTO((trio_pointer_t ref)); /* t */
472
void trio_set_ptrdiff TRIO_PROTO((trio_pointer_t ref, int is_ptrdiff));
473
#endif
474
#if TRIO_FEATURE_SIZE_T
475
int trio_get_size TRIO_PROTO((trio_pointer_t ref)); /* z / Z */
476
void trio_set_size TRIO_PROTO((trio_pointer_t ref, int is_size));
477
#endif
478
479
/* Printing */
480
int trio_print_ref TRIO_PROTO((trio_pointer_t ref, const char *format, ...));
481
int trio_vprint_ref TRIO_PROTO((trio_pointer_t ref, const char *format, va_list args));
482
int trio_printv_ref TRIO_PROTO((trio_pointer_t ref, const char *format, trio_pointer_t *args));
483
484
void trio_print_int TRIO_PROTO((trio_pointer_t ref, int number));
485
void trio_print_uint TRIO_PROTO((trio_pointer_t ref, unsigned int number));
486
/* void trio_print_long TRIO_PROTO((trio_pointer_t ref, long number)); */
487
/* void trio_print_ulong TRIO_PROTO((trio_pointer_t ref, unsigned long number)); */
488
void trio_print_double TRIO_PROTO((trio_pointer_t ref, double number));
489
void trio_print_string TRIO_PROTO((trio_pointer_t ref, TRIO_CONST char *string));
490
void trio_print_pointer TRIO_PROTO((trio_pointer_t ref, trio_pointer_t pointer));
491
492
#ifdef __cplusplus
493
} /* extern "C" */
494
#endif
495
496
#endif /* TRIO_TRIOP_H */
497
498