You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _IPXE_VSPRINTF_H
  2. #define _IPXE_VSPRINTF_H
  3. /** @file
  4. *
  5. * printf() and friends
  6. *
  7. * Etherboot's printf() functions understand the following subset of
  8. * the standard C printf()'s format specifiers:
  9. *
  10. * - Flag characters
  11. * - '#' - Alternate form (i.e. "0x" prefix)
  12. * - '0' - Zero-pad
  13. * - Field widths
  14. * - Length modifiers
  15. * - 'hh' - Signed / unsigned char
  16. * - 'h' - Signed / unsigned short
  17. * - 'l' - Signed / unsigned long
  18. * - 'll' - Signed / unsigned long long
  19. * - 'z' - Signed / unsigned size_t
  20. * - Conversion specifiers
  21. * - 'd' - Signed decimal
  22. * - 'x','X' - Unsigned hexadecimal
  23. * - 'c' - Character
  24. * - 's' - String
  25. * - 'p' - Pointer
  26. *
  27. * Hexadecimal numbers are always zero-padded to the specified field
  28. * width (if any); decimal numbers are always space-padded. Decimal
  29. * long longs are not supported.
  30. *
  31. */
  32. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  33. #include <stdint.h>
  34. #include <stdarg.h>
  35. #include <stdio.h>
  36. /**
  37. * A printf context
  38. *
  39. * Contexts are used in order to be able to share code between
  40. * vprintf() and vsnprintf(), without requiring the allocation of a
  41. * buffer for vprintf().
  42. */
  43. struct printf_context {
  44. /**
  45. * Character handler
  46. *
  47. * @v ctx Context
  48. * @v c Character
  49. *
  50. * This method is called for each character written to the
  51. * formatted string.
  52. */
  53. void ( * handler ) ( struct printf_context *ctx, unsigned int c );
  54. /** Length of formatted string
  55. *
  56. * When handler() is called, @len will be set to the number of
  57. * characters written so far (i.e. zero for the first call to
  58. * handler()).
  59. */
  60. size_t len;
  61. };
  62. extern size_t vcprintf ( struct printf_context *ctx, const char *fmt,
  63. va_list args );
  64. extern int vssnprintf ( char *buf, ssize_t ssize, const char *fmt,
  65. va_list args );
  66. extern int __attribute__ (( format ( printf, 3, 4 ) ))
  67. ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... );
  68. #endif /* _IPXE_VSPRINTF_H */