00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TRIO_TRIO_H
00023 #define TRIO_TRIO_H
00024
00025 #if !defined(WITHOUT_TRIO)
00026
00027
00028
00029
00030
00031 #if defined(HAVE_CONFIG_H)
00032 # include <config.h>
00033 #endif
00034
00035 #include "triodef.h"
00036
00037 #include <stdio.h>
00038 #include <stdlib.h>
00039 #if defined(TRIO_COMPILER_ANCIENT)
00040 # include <varargs.h>
00041 #else
00042 # include <stdarg.h>
00043 #endif
00044
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048
00049
00050
00051
00052
00053
00054 enum {
00055 TRIO_EOF = 1,
00056 TRIO_EINVAL = 2,
00057 TRIO_ETOOMANY = 3,
00058 TRIO_EDBLREF = 4,
00059 TRIO_EGAP = 5,
00060 TRIO_ENOMEM = 6,
00061 TRIO_ERANGE = 7,
00062 TRIO_ERRNO = 8,
00063 TRIO_ECUSTOM = 9
00064 };
00065
00066
00067 #define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF)
00068 #define TRIO_ERROR_POSITION(x) ((-(x)) >> 8)
00069 #define TRIO_ERROR_NAME(x) trio_strerror(x)
00070
00071 typedef int (*trio_outstream_t) TRIO_PROTO((trio_pointer_t, int));
00072 typedef int (*trio_instream_t) TRIO_PROTO((trio_pointer_t));
00073
00074 TRIO_CONST char *trio_strerror TRIO_PROTO((int));
00075
00076
00077
00078
00079
00080 int trio_printf TRIO_PROTO((TRIO_CONST char *format, ...));
00081 int trio_vprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
00082 int trio_printfv TRIO_PROTO((TRIO_CONST char *format, void **args));
00083
00084 int trio_fprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...));
00085 int trio_vfprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
00086 int trio_fprintfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
00087
00088 int trio_dprintf TRIO_PROTO((int fd, TRIO_CONST char *format, ...));
00089 int trio_vdprintf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
00090 int trio_dprintfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
00091
00092 int trio_cprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
00093 TRIO_CONST char *format, ...));
00094 int trio_vcprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
00095 TRIO_CONST char *format, va_list args));
00096 int trio_cprintfv TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure,
00097 TRIO_CONST char *format, void **args));
00098
00099 int trio_sprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, ...));
00100 int trio_vsprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, va_list args));
00101 int trio_sprintfv TRIO_PROTO((char *buffer, TRIO_CONST char *format, void **args));
00102
00103 int trio_snprintf TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...));
00104 int trio_vsnprintf TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
00105 va_list args));
00106 int trio_snprintfv TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
00107 void **args));
00108
00109 int trio_snprintfcat TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...));
00110 int trio_vsnprintfcat TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format,
00111 va_list args));
00112
00113 char *trio_aprintf TRIO_PROTO((TRIO_CONST char *format, ...));
00114 char *trio_vaprintf TRIO_PROTO((TRIO_CONST char *format, va_list args));
00115
00116 int trio_asprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, ...));
00117 int trio_vasprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, va_list args));
00118
00119
00120
00121
00122 int trio_scanf TRIO_PROTO((TRIO_CONST char *format, ...));
00123 int trio_vscanf TRIO_PROTO((TRIO_CONST char *format, va_list args));
00124 int trio_scanfv TRIO_PROTO((TRIO_CONST char *format, void **args));
00125
00126 int trio_fscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...));
00127 int trio_vfscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args));
00128 int trio_fscanfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args));
00129
00130 int trio_dscanf TRIO_PROTO((int fd, TRIO_CONST char *format, ...));
00131 int trio_vdscanf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args));
00132 int trio_dscanfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args));
00133
00134 int trio_cscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
00135 TRIO_CONST char *format, ...));
00136 int trio_vcscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
00137 TRIO_CONST char *format, va_list args));
00138 int trio_cscanfv TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure,
00139 TRIO_CONST char *format, void **args));
00140
00141 int trio_sscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, ...));
00142 int trio_vsscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args));
00143 int trio_sscanfv TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, void **args));
00144
00145
00146
00147
00148 void trio_locale_set_decimal_point TRIO_PROTO((char *decimalPoint));
00149 void trio_locale_set_thousand_separator TRIO_PROTO((char *thousandSeparator));
00150 void trio_locale_set_grouping TRIO_PROTO((char *grouping));
00151
00152
00153
00154
00155 #ifdef TRIO_REPLACE_STDIO
00156
00157 #ifndef HAVE_PRINTF
00158 # define printf trio_printf
00159 #endif
00160 #ifndef HAVE_VPRINTF
00161 # define vprintf trio_vprintf
00162 #endif
00163 #ifndef HAVE_FPRINTF
00164 # define fprintf trio_fprintf
00165 #endif
00166 #ifndef HAVE_VFPRINTF
00167 # define vfprintf trio_vfprintf
00168 #endif
00169 #ifndef HAVE_SPRINTF
00170 # define sprintf trio_sprintf
00171 #endif
00172 #ifndef HAVE_VSPRINTF
00173 # define vsprintf trio_vsprintf
00174 #endif
00175 #ifndef HAVE_SNPRINTF
00176 # define snprintf trio_snprintf
00177 #endif
00178 #ifndef HAVE_VSNPRINTF
00179 # define vsnprintf trio_vsnprintf
00180 #endif
00181 #ifndef HAVE_SCANF
00182 # define scanf trio_scanf
00183 #endif
00184 #ifndef HAVE_VSCANF
00185 # define vscanf trio_vscanf
00186 #endif
00187 #ifndef HAVE_FSCANF
00188 # define fscanf trio_fscanf
00189 #endif
00190 #ifndef HAVE_VFSCANF
00191 # define vfscanf trio_vfscanf
00192 #endif
00193 #ifndef HAVE_SSCANF
00194 # define sscanf trio_sscanf
00195 #endif
00196 #ifndef HAVE_VSSCANF
00197 # define vsscanf trio_vsscanf
00198 #endif
00199
00200 #define dprintf trio_dprintf
00201 #define vdprintf trio_vdprintf
00202 #define aprintf trio_aprintf
00203 #define vaprintf trio_vaprintf
00204 #define asprintf trio_asprintf
00205 #define vasprintf trio_vasprintf
00206 #define dscanf trio_dscanf
00207 #define vdscanf trio_vdscanf
00208 #endif
00209
00210 #ifdef __cplusplus
00211 }
00212 #endif
00213
00214 #endif
00215
00216 #endif