1 /* Copyright (c) 2002,2004,2005 Joerg Wunsch 2 Copyright (c) 2008 Dmitry Xmelkov 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are met: 7 8 * Redistributions of source code must retain the above copyright 9 notice, this list of conditions and the following disclaimer. 10 11 * Redistributions in binary form must reproduce the above copyright 12 notice, this list of conditions and the following disclaimer in 13 the documentation and/or other materials provided with the 14 distribution. 15 16 * Neither the name of the copyright holders nor the names of 17 contributors may be used to endorse or promote products derived 18 from this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _SCANF_PRIVATE_H_ 34 #define _SCANF_PRIVATE_H_ 35 36 #if !defined (SCANF_LEVEL) 37 # define SCANF_LEVEL SCANF_DBL 38 # ifndef _FORMAT_DEFAULT_DOUBLE 39 # define vfscanf __d_vfscanf 40 # endif 41 #endif 42 43 #if defined(STRTOF) 44 # define _NEED_IO_FLOAT 45 #elif defined(STRTOD) 46 # define _NEED_IO_DOUBLE 47 #elif defined(STRTOLD) 48 # define _NEED_IO_DOUBLE 49 # define _NEED_IO_LONG_DOUBLE 50 #elif SCANF_LEVEL == SCANF_MIN 51 # define _NEED_IO_SHRINK 52 # if defined(_WANT_MINIMAL_IO_LONG_LONG) && __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ 53 # define _NEED_IO_LONG_LONG 54 # endif 55 # ifdef _WANT_IO_C99_FORMATS 56 # define _NEED_IO_C99_FORMATS 57 # endif 58 #elif SCANF_LEVEL == SCANF_STD 59 # define _NEED_IO_BRACKET 60 # ifdef _WANT_IO_POS_ARGS 61 # define _NEED_IO_POS_ARGS 62 # endif 63 # if defined(_WANT_IO_LONG_LONG) && __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ 64 # define _NEED_IO_LONG_LONG 65 # endif 66 # ifdef _WANT_IO_C99_FORMATS 67 # define _NEED_IO_C99_FORMATS 68 # endif 69 # ifdef _WANT_IO_PERCENT_B 70 # define _NEED_IO_PERCENT_B 71 # endif 72 int vfscanf (FILE * stream, const char *fmt, va_list ap) __attribute__((weak)); 73 #elif SCANF_LEVEL == SCANF_LLONG 74 # define _NEED_IO_BRACKET 75 # ifdef _WANT_IO_POS_ARGS 76 # define _NEED_IO_POS_ARGS 77 # endif 78 # if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ 79 # define _NEED_IO_LONG_LONG 80 # endif 81 # ifdef _WANT_IO_C99_FORMATS 82 # define _NEED_IO_C99_FORMATS 83 # endif 84 # ifdef _WANT_IO_PERCENT_B 85 # define _NEED_IO_PERCENT_B 86 # endif 87 #elif SCANF_LEVEL == SCANF_FLT 88 # define _NEED_IO_BRACKET 89 # if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ 90 # define _NEED_IO_LONG_LONG 91 # endif 92 # define _NEED_IO_POS_ARGS 93 # define _NEED_IO_C99_FORMATS 94 # ifdef _WANT_IO_PERCENT_B 95 # define _NEED_IO_PERCENT_B 96 # endif 97 # define _NEED_IO_FLOAT 98 #elif SCANF_LEVEL == SCANF_DBL 99 # define _NEED_IO_BRACKET 100 # define _NEED_IO_WCHAR 101 # if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ 102 # define _NEED_IO_LONG_LONG 103 # endif 104 # define _NEED_IO_POS_ARGS 105 # define _NEED_IO_C99_FORMATS 106 # ifdef _WANT_IO_PERCENT_B 107 # define _NEED_IO_PERCENT_B 108 # endif 109 # define _NEED_IO_DOUBLE 110 # if defined(_WANT_IO_LONG_DOUBLE) && __SIZEOF_LONG_DOUBLE__ > __SIZEOF_DOUBLE__ 111 # define _NEED_IO_LONG_DOUBLE 112 # endif 113 #else 114 # error "Not a known scanf level." 115 #endif 116 117 #if defined(WIDE_CHARS) && !defined(_NEED_IO_WCHAR) 118 #define _NEED_IO_WCHAR 119 #endif 120 121 typedef unsigned int width_t; 122 123 #define FL_STAR 0x01 /* '*': skip assignment */ 124 #define FL_WIDTH 0x02 /* width is present */ 125 #define FL_LONG 0x04 /* 'long' type modifier */ 126 #if defined(_NEED_IO_LONG_LONG) || defined(_NEED_IO_LONG_DOUBLE) 127 #define FL_LONGLONG 0x08 /* 'long long' type modifier */ 128 #else 129 #define FL_LONGLONG 0x00 /* 'long long' type modifier */ 130 #endif 131 #define FL_CHAR 0x10 /* 'char' type modifier */ 132 #define FL_SHORT 0x20 /* 'short' type modifier */ 133 #define FL_MINUS 0x40 /* minus flag (field or value) */ 134 #define FL_ANY 0x80 /* any digit was read */ 135 #define FL_OVFL 0x100 /* significand overflowed */ 136 #define FL_DOT 0x200 /* decimal '.' was */ 137 #define FL_MEXP 0x400 /* exponent 'e' is neg. */ 138 #define FL_FHEX 0x800 /* hex significand */ 139 140 #endif /* _SCANF_PRIVATE_H_ */ 141