blob: ead673a12581fc09702b6ed9bfcfb243a0866325 [file] [log] [blame]
Bjorn Reese70a9da52001-04-21 16:57:29 +00001/*************************************************************************
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
Bjorn Reese906ec8a2001-06-05 12:46:33 +000029#include <stdlib.h>
Bjorn Reese026d29f2002-01-19 15:40:18 +000030#include <stdarg.h>
Bjorn Reese70a9da52001-04-21 16:57:29 +000031
Bjorn Reese906ec8a2001-06-05 12:46:33 +000032#ifdef __cplusplus
33extern "C" {
34#endif
35
36#ifndef TRIO_C99
37# define TRIO_C99 1
38#endif
39#ifndef TRIO_BSD
40# define TRIO_BSD 1
41#endif
42#ifndef TRIO_GNU
43# define TRIO_GNU 1
44#endif
45#ifndef TRIO_MISC
46# define TRIO_MISC 1
47#endif
48#ifndef TRIO_UNIX98
49# define TRIO_UNIX98 1
50#endif
51#ifndef TRIO_MICROSOFT
52# define TRIO_MICROSOFT 1
53#endif
54#ifndef TRIO_EXTENSION
55# define TRIO_EXTENSION 1
56#endif
Bjorn Reese026d29f2002-01-19 15:40:18 +000057#ifndef TRIO_WIDECHAR /* Does not work yet. Do not enable */
Bjorn Reese906ec8a2001-06-05 12:46:33 +000058# define TRIO_WIDECHAR 0
59#endif
60#ifndef TRIO_ERRORS
61# define TRIO_ERRORS 1
62#endif
63
64#ifndef TRIO_MALLOC
65# define TRIO_MALLOC(n) malloc(n)
66#endif
67#ifndef TRIO_REALLOC
68# define TRIO_REALLOC(x,n) realloc((x),(n))
69#endif
70#ifndef TRIO_FREE
71# define TRIO_FREE(x) free(x)
72#endif
Bjorn Reese70a9da52001-04-21 16:57:29 +000073
Bjorn Reese026d29f2002-01-19 15:40:18 +000074/*************************************************************************
75 * User-defined specifiers
76 */
77
78typedef int (*trio_callback_t)(void *);
Bjorn Reese70a9da52001-04-21 16:57:29 +000079
80void *trio_register(trio_callback_t callback, const char *name);
81void trio_unregister(void *handle);
82
83const char *trio_get_format(void *ref);
84void *trio_get_argument(void *ref);
85
86/* Modifiers */
87int trio_get_width(void *ref);
88void trio_set_width(void *ref, int width);
89int trio_get_precision(void *ref);
90void trio_set_precision(void *ref, int precision);
91int trio_get_base(void *ref);
92void trio_set_base(void *ref, int base);
93int trio_get_padding(void *ref);
94void trio_set_padding(void *ref, int is_padding);
95int trio_get_short(void *ref); /* h */
96void trio_set_shortshort(void *ref, int is_shortshort);
97int trio_get_shortshort(void *ref); /* hh */
98void trio_set_short(void *ref, int is_short);
99int trio_get_long(void *ref); /* l */
100void trio_set_long(void *ref, int is_long);
101int trio_get_longlong(void *ref); /* ll */
102void trio_set_longlong(void *ref, int is_longlong);
103int trio_get_longdouble(void *ref); /* L */
104void trio_set_longdouble(void *ref, int is_longdouble);
105int trio_get_alternative(void *ref); /* # */
106void trio_set_alternative(void *ref, int is_alternative);
107int trio_get_alignment(void *ref); /* - */
108void trio_set_alignment(void *ref, int is_leftaligned);
109int trio_get_spacing(void *ref); /* (space) */
110void trio_set_spacing(void *ref, int is_space);
111int trio_get_sign(void *ref); /* + */
112void trio_set_sign(void *ref, int is_showsign);
113int trio_get_quote(void *ref); /* ' */
114void trio_set_quote(void *ref, int is_quote);
115int trio_get_upper(void *ref);
116void trio_set_upper(void *ref, int is_upper);
Bjorn Reese906ec8a2001-06-05 12:46:33 +0000117#if TRIO_C99
Bjorn Reese70a9da52001-04-21 16:57:29 +0000118int trio_get_largest(void *ref); /* j */
119void trio_set_largest(void *ref, int is_largest);
120int trio_get_ptrdiff(void *ref); /* t */
121void trio_set_ptrdiff(void *ref, int is_ptrdiff);
122int trio_get_size(void *ref); /* z / Z */
123void trio_set_size(void *ref, int is_size);
124#endif
125
126/* Printing */
127int trio_print_ref(void *ref, const char *format, ...);
128int trio_vprint_ref(void *ref, const char *format, va_list args);
129int trio_printv_ref(void *ref, const char *format, void **args);
130
131void trio_print_int(void *ref, int number);
132void trio_print_uint(void *ref, unsigned int number);
133/* void trio_print_long(void *ref, long number); */
134/* void trio_print_ulong(void *ref, unsigned long number); */
135void trio_print_double(void *ref, double number);
136void trio_print_string(void *ref, char *string);
137void trio_print_pointer(void *ref, void *pointer);
138
Bjorn Reese906ec8a2001-06-05 12:46:33 +0000139#ifdef __cplusplus
140} /* extern "C" */
141#endif
142
Bjorn Reese70a9da52001-04-21 16:57:29 +0000143#endif /* TRIO_TRIOP_H */