DRAFT: Full Featured Printf Hooks Design


The intention of this page is to serve as a starting point for identifying the scope of the printf-hooks extension design.

Useful Definitions


Design Preclusions

There are a number of preclusions which dictate the direction of the design. They are either definite or questionable. Questionable design preclusions should be finalized before this design document leaves DRAFT.






struct printf_info
  int prec;                     /* Precision.  */
  int width;                    /* Width.  */
  wchar_t spec;                 /* Format letter.  */
  unsigned int is_long_double:1;/* L flag.  */
  unsigned int is_short:1;      /* h flag.  */
  unsigned int is_long:1;       /* l flag.  */
  unsigned int alt:1;           /* # flag.  */
  unsigned int space:1;         /* Space flag.  */
  unsigned int left:1;          /* - flag.  */
  unsigned int showsign:1;      /* + flag.  */
  unsigned int group:1;         /* ' flag.  */
  unsigned int extra:1;         /* For special use.  */
  unsigned int is_char:1;       /* hh flag.  */
  unsigned int wide:1;          /* Nonzero for wide character streams.  */
  unsigned int i18n:1;          /* I flag.  */
  wchar_t pad;                  /* Padding character.  */
  unsigned int user;            /* 'flag character' or 'length modifier' override flags.  */

struct printf_overrides
  /* flag-character: Unknown.  */
  /* length-modifier: Used for setting user data-type flags.  */
  /* conversion-specification: Used for checking for user data-type flags.  */
  printf_arginfo_function     *arginfo_fn;

  /* flag-character: Unknown.  */
  /* length-modifier: sizeof(data-type).  Indicates how much space will be allocated
   *                  prior to a va_arg call-back invocation from a companion conv spec.  */
  /* conversion-specification: Un-used.  */
  size_t                      size;

  /* flag-character: Unknown.  */
  /* length-modifier: Un-used.  */
  /* conversion-specification: Used to peel user data-type from argument list.  */
  printf_va_arg_function      *va_arg_fn;

  /* flag-character: Unknown.  */
  /* length-modifier: Un-used.  */
  /* conversion-specification: Invoked to convert user data-type to string.  */
  printf_function             *override_fn;

/* List of supported format overrides.  */
  PF_NONE, /* Don't use.  */
  PF_LAST /* Don't use.  This is a place holder.  */

/* Flag bits that can be set by a 'flag character' or 'length modifier' override.  
 * Corresponding bits are set into the arginfo function's __argstype parameter.
 * and are copied into the `struct printf_info::user' member after a valid override
 * is detected.  */

#define PA_USER_MASK            0xffff0000

/* SPEC_CHARS: string of characters denoting the 'format specifier' that is to be overriden.
 * NCHARS: the number of characters in the 'format specifier'.
 * TYPE: the type of 'format specifier' as indicated by the enums enumerated above.
 * PFO: a table of override data (which may or may not be applicable to a
 *          particular 'format specifier') and data-type size (if applicable).  */

extern int register_printf_override (int *spec_chars,
                                     int nchars,
                                     int type,
                                     struct printf_overrides *pfo);

Issues and Questions

None: PrintfHooksDesign (last edited 2009-03-02 19:27:56 by RyanScottArnold)