printf-args.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* Decomposed printf argument list.
  2. Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with this program; if not, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #ifndef _PRINTF_ARGS_H
  15. #define _PRINTF_ARGS_H
  16. /* Get size_t. */
  17. #include <stddef.h>
  18. /* Get wchar_t. */
  19. #ifdef HAVE_WCHAR_T
  20. # include <stddef.h>
  21. #endif
  22. /* Get wint_t. */
  23. #ifdef HAVE_WINT_T
  24. # include <wchar.h>
  25. #endif
  26. /* Get va_list. */
  27. #include <stdarg.h>
  28. /* Argument types */
  29. typedef enum
  30. {
  31. TYPE_NONE,
  32. TYPE_SCHAR,
  33. TYPE_UCHAR,
  34. TYPE_SHORT,
  35. TYPE_USHORT,
  36. TYPE_INT,
  37. TYPE_UINT,
  38. TYPE_LONGINT,
  39. TYPE_ULONGINT,
  40. #ifdef HAVE_LONG_LONG_INT
  41. TYPE_LONGLONGINT,
  42. TYPE_ULONGLONGINT,
  43. #endif
  44. TYPE_DOUBLE,
  45. #ifdef HAVE_LONG_DOUBLE
  46. TYPE_LONGDOUBLE,
  47. #endif
  48. TYPE_CHAR,
  49. #ifdef HAVE_WINT_T
  50. TYPE_WIDE_CHAR,
  51. #endif
  52. TYPE_STRING,
  53. #ifdef HAVE_WCHAR_T
  54. TYPE_WIDE_STRING,
  55. #endif
  56. TYPE_POINTER,
  57. TYPE_COUNT_SCHAR_POINTER,
  58. TYPE_COUNT_SHORT_POINTER,
  59. TYPE_COUNT_INT_POINTER,
  60. TYPE_COUNT_LONGINT_POINTER
  61. #ifdef HAVE_LONG_LONG_INT
  62. , TYPE_COUNT_LONGLONGINT_POINTER
  63. #endif
  64. } arg_type;
  65. /* Polymorphic argument */
  66. typedef struct
  67. {
  68. arg_type type;
  69. union
  70. {
  71. signed char a_schar;
  72. unsigned char a_uchar;
  73. short a_short;
  74. unsigned short a_ushort;
  75. int a_int;
  76. unsigned int a_uint;
  77. long int a_longint;
  78. unsigned long int a_ulongint;
  79. #ifdef HAVE_LONG_LONG_INT
  80. long long int a_longlongint;
  81. unsigned long long int a_ulonglongint;
  82. #endif
  83. float a_float;
  84. double a_double;
  85. #ifdef HAVE_LONG_DOUBLE
  86. long double a_longdouble;
  87. #endif
  88. int a_char;
  89. #ifdef HAVE_WINT_T
  90. wint_t a_wide_char;
  91. #endif
  92. const char* a_string;
  93. #ifdef HAVE_WCHAR_T
  94. const wchar_t* a_wide_string;
  95. #endif
  96. void* a_pointer;
  97. signed char * a_count_schar_pointer;
  98. short * a_count_short_pointer;
  99. int * a_count_int_pointer;
  100. long int * a_count_longint_pointer;
  101. #ifdef HAVE_LONG_LONG_INT
  102. long long int * a_count_longlongint_pointer;
  103. #endif
  104. }
  105. a;
  106. }
  107. argument;
  108. typedef struct
  109. {
  110. size_t count;
  111. argument *arg;
  112. }
  113. arguments;
  114. /* Fetch the arguments, putting them into a. */
  115. #ifdef STATIC
  116. STATIC
  117. #else
  118. extern
  119. #endif
  120. int printf_fetchargs (va_list args, arguments *a);
  121. #endif /* _PRINTF_ARGS_H */