about summary refs log tree commit diff
path: root/stdio-common/printf.h
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/printf.h')
-rw-r--r--stdio-common/printf.h49
1 files changed, 45 insertions, 4 deletions
diff --git a/stdio-common/printf.h b/stdio-common/printf.h
index 360cdcce1d..a11af02274 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993,1995-1999,2000,2001,2006
+/* Copyright (C) 1991-1993,1995-2001,2006,2009
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -29,6 +29,7 @@ __BEGIN_DECLS
 #define	__need_size_t
 #define __need_wchar_t
 #include <stddef.h>
+#include <stdarg.h>
 
 
 struct printf_info
@@ -48,6 +49,8 @@ struct printf_info
   unsigned int is_char:1;	/* hh flag.  */
   unsigned int wide:1;		/* Nonzero for wide character streams.  */
   unsigned int i18n:1;		/* I flag.  */
+  unsigned int __pad:4;		/* Unused so far.  */
+  unsigned short int user;	/* Bits for user-installed modifiers.  */
   wchar_t pad;			/* Padding character.  */
 };
 
@@ -68,18 +71,55 @@ typedef int printf_function (FILE *__stream,
 
 /* Type of a printf specifier-arginfo function.
    INFO gives information about the format specification.
-   N, ARGTYPES, and return value are as for parse_printf_format.  */
+   N, ARGTYPES, *SIZE has to contain the size of the parameter for
+   user-defined types, and return value are as for parse_printf_format
+   except that -1 should be returned if the handler cannot handle
+   this case.  This allows to partially overwrite the functionality
+   of existing format specifiers.  */
+
+typedef int printf_arginfo_size_function (__const struct printf_info *__info,
+					  size_t __n, int *__argtypes,
+					  int *__size);
+
+/* Old version of 'printf_arginfo_function' without a SIZE parameter.  */
 
 typedef int printf_arginfo_function (__const struct printf_info *__info,
 				     size_t __n, int *__argtypes);
 
+/* Type of a function to get a value of a user-defined from the
+   variable argument list.  */
+typedef void printf_va_arg_function (void *__mem, va_list *__ap);
+
 
 /* Register FUNC to be called to format SPEC specifiers; ARGINFO must be
    specified to determine how many arguments a SPEC conversion requires and
    what their types are.  */
 
+extern int register_printf_specifier (int __spec, printf_function __func,
+				      printf_arginfo_size_function __arginfo)
+  __THROW;
+
+
+/* Obsolete interface similar to register_printf_specifier.  It can only
+   handle basic data types because the ARGINFO callback does not return
+   information on the size of the user-defined type.  */
+
 extern int register_printf_function (int __spec, printf_function __func,
-				     printf_arginfo_function __arginfo);
+				     printf_arginfo_function __arginfo)
+  __THROW __attribute_deprecated__;
+
+
+/* Register a new modifier character sequence.  If the call succeeds
+   it returns a positive value representing the bit set in the USER
+   field in 'struct printf_info'.  */
+
+extern int register_printf_modifier (wchar_t *__str) __wur __THROW;
+
+
+/* Register variable argument handler for user type.  The return value
+   is to be used in ARGINFO functions to signal the use of the
+   type.  */
+extern int register_printf_type (printf_va_arg_function __fct) __wur __THROW;
 
 
 /* Parse FMT, and fill in N elements of ARGTYPES with the
@@ -100,7 +140,8 @@ extern size_t parse_printf_format (__const char *__restrict __fmt, size_t __n,
 /* Codes returned by `parse_printf_format' for basic types.
 
    These values cover all the standard format specifications.
-   Users can add new values after PA_LAST for their own types.  */
+   Users can reserve new values after PA_LAST for their own types
+   using 'register_printf_type'.  */
 
 enum
 {				/* C type: */