Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 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 | |
Bjorn Reese | 906ec8a | 2001-06-05 12:46:33 +0000 | [diff] [blame] | 29 | #include <stdlib.h> |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 30 | #include <stdarg.h> |
Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 31 | |
Bjorn Reese | 906ec8a | 2001-06-05 12:46:33 +0000 | [diff] [blame] | 32 | #ifdef __cplusplus |
| 33 | extern "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 Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 57 | #ifndef TRIO_WIDECHAR /* Does not work yet. Do not enable */ |
Bjorn Reese | 906ec8a | 2001-06-05 12:46:33 +0000 | [diff] [blame] | 58 | # 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 Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 73 | |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 74 | /************************************************************************* |
| 75 | * User-defined specifiers |
| 76 | */ |
| 77 | |
| 78 | typedef int (*trio_callback_t)(void *); |
Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 79 | |
| 80 | void *trio_register(trio_callback_t callback, const char *name); |
| 81 | void trio_unregister(void *handle); |
| 82 | |
| 83 | const char *trio_get_format(void *ref); |
| 84 | void *trio_get_argument(void *ref); |
| 85 | |
| 86 | /* Modifiers */ |
| 87 | int trio_get_width(void *ref); |
| 88 | void trio_set_width(void *ref, int width); |
| 89 | int trio_get_precision(void *ref); |
| 90 | void trio_set_precision(void *ref, int precision); |
| 91 | int trio_get_base(void *ref); |
| 92 | void trio_set_base(void *ref, int base); |
| 93 | int trio_get_padding(void *ref); |
| 94 | void trio_set_padding(void *ref, int is_padding); |
| 95 | int trio_get_short(void *ref); /* h */ |
| 96 | void trio_set_shortshort(void *ref, int is_shortshort); |
| 97 | int trio_get_shortshort(void *ref); /* hh */ |
| 98 | void trio_set_short(void *ref, int is_short); |
| 99 | int trio_get_long(void *ref); /* l */ |
| 100 | void trio_set_long(void *ref, int is_long); |
| 101 | int trio_get_longlong(void *ref); /* ll */ |
| 102 | void trio_set_longlong(void *ref, int is_longlong); |
| 103 | int trio_get_longdouble(void *ref); /* L */ |
| 104 | void trio_set_longdouble(void *ref, int is_longdouble); |
| 105 | int trio_get_alternative(void *ref); /* # */ |
| 106 | void trio_set_alternative(void *ref, int is_alternative); |
| 107 | int trio_get_alignment(void *ref); /* - */ |
| 108 | void trio_set_alignment(void *ref, int is_leftaligned); |
| 109 | int trio_get_spacing(void *ref); /* (space) */ |
| 110 | void trio_set_spacing(void *ref, int is_space); |
| 111 | int trio_get_sign(void *ref); /* + */ |
| 112 | void trio_set_sign(void *ref, int is_showsign); |
| 113 | int trio_get_quote(void *ref); /* ' */ |
| 114 | void trio_set_quote(void *ref, int is_quote); |
| 115 | int trio_get_upper(void *ref); |
| 116 | void trio_set_upper(void *ref, int is_upper); |
Bjorn Reese | 906ec8a | 2001-06-05 12:46:33 +0000 | [diff] [blame] | 117 | #if TRIO_C99 |
Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 118 | int trio_get_largest(void *ref); /* j */ |
| 119 | void trio_set_largest(void *ref, int is_largest); |
| 120 | int trio_get_ptrdiff(void *ref); /* t */ |
| 121 | void trio_set_ptrdiff(void *ref, int is_ptrdiff); |
| 122 | int trio_get_size(void *ref); /* z / Z */ |
| 123 | void trio_set_size(void *ref, int is_size); |
| 124 | #endif |
| 125 | |
| 126 | /* Printing */ |
| 127 | int trio_print_ref(void *ref, const char *format, ...); |
| 128 | int trio_vprint_ref(void *ref, const char *format, va_list args); |
| 129 | int trio_printv_ref(void *ref, const char *format, void **args); |
| 130 | |
| 131 | void trio_print_int(void *ref, int number); |
| 132 | void 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); */ |
| 135 | void trio_print_double(void *ref, double number); |
| 136 | void trio_print_string(void *ref, char *string); |
| 137 | void trio_print_pointer(void *ref, void *pointer); |
| 138 | |
Bjorn Reese | 906ec8a | 2001-06-05 12:46:33 +0000 | [diff] [blame] | 139 | #ifdef __cplusplus |
| 140 | } /* extern "C" */ |
| 141 | #endif |
| 142 | |
Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 143 | #endif /* TRIO_TRIOP_H */ |