dump.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * dump.h
  3. */
  4. /**
  5. \ingroup lub
  6. \defgroup lub_dump dump
  7. @{
  8. \brief This utility provides a simple hierachical debugging mechanism.
  9. By indenting and undenting the output, printing nested debug messages is made
  10. easy.
  11. */
  12. #ifndef _lub_dump_h
  13. #define _lub_dump_h
  14. #define LUB_DUMP_NULL "(null)"
  15. #define LUB_DUMP_STR(str) ( str ? str : LUB_DUMP_NULL )
  16. #define LUB_DUMP_BOOL(val) ( val ? "true" : "false" )
  17. #define LUB_DUMP_TRI(val) ( val == TRI_UNDEFINED ? "undefined" : \
  18. (val == TRI_TRUE ? "true" : "false"))
  19. #include <stdarg.h>
  20. /*=====================================
  21. * DUMP INTERFACE
  22. *===================================== */
  23. /**
  24. * This operation behaves identically to the standard printf() function
  25. * with the exception that the offset at the begining of the line is
  26. * determined by the current indent settings.
  27. * \pre
  28. * - none
  29. *
  30. * \return
  31. * The number of characters sent to stdout.
  32. *
  33. * \post
  34. * - The formatted message will be sent to stdout.
  35. */
  36. /*lint -esym(534,lub_dump_printf) Ignoring return value of function */
  37. int lub_dump_printf(
  38. /**
  39. * printf-like format string
  40. */
  41. const char *fmt, ...
  42. );
  43. /**
  44. * This operation indicates that the offset for messages should be increased by
  45. * one level.
  46. *
  47. * \pre
  48. * - none
  49. *
  50. * \post
  51. * - An indentation divider will be sent to stdout to emphasise the change
  52. * in offset.
  53. * - Subsequent calls to lub_dump_printf() will output at this new offset.
  54. * - Client may call lub_undent() to restore offset.
  55. */
  56. void lub_dump_indent(void);
  57. /**
  58. * This operation indicates that the offset for messages should be decreased by
  59. * one level.
  60. *
  61. * \pre
  62. * - lub_dump_indent() should have been called at least one more time than
  63. * this function.
  64. *
  65. * \post
  66. * - An indentation divider will be sent to stdout to emphasise the change
  67. * in offset.
  68. * - Subsequent calls to lub_dump_printf() will output at this new offset.
  69. */
  70. void lub_dump_undent(void);
  71. #endif /* _lub_dump_h */
  72. /** @} lub_dump */