dump.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <stdarg.h>
  18. /*=====================================
  19. * DUMP INTERFACE
  20. *===================================== */
  21. /**
  22. * This operation behaves identically to the standard printf() function
  23. * with the exception that the offset at the begining of the line is
  24. * determined by the current indent settings.
  25. * \pre
  26. * - none
  27. *
  28. * \return
  29. * The number of characters sent to stdout.
  30. *
  31. * \post
  32. * - The formatted message will be sent to stdout.
  33. */
  34. /*lint -esym(534,lub_dump_printf) Ignoring return value of function */
  35. int lub_dump_printf(
  36. /**
  37. * printf-like format string
  38. */
  39. const char *fmt, ...
  40. );
  41. /**
  42. * This operation indicates that the offset for messages should be increased by
  43. * one level.
  44. *
  45. * \pre
  46. * - none
  47. *
  48. * \post
  49. * - An indentation divider will be sent to stdout to emphasise the change
  50. * in offset.
  51. * - Subsequent calls to lub_dump_printf() will output at this new offset.
  52. * - Client may call lub_undent() to restore offset.
  53. */
  54. void lub_dump_indent(void);
  55. /**
  56. * This operation indicates that the offset for messages should be decreased by
  57. * one level.
  58. *
  59. * \pre
  60. * - lub_dump_indent() should have been called at least one more time than
  61. * this function.
  62. *
  63. * \post
  64. * - An indentation divider will be sent to stdout to emphasise the change
  65. * in offset.
  66. * - Subsequent calls to lub_dump_printf() will output at this new offset.
  67. */
  68. void lub_dump_undent(void);
  69. #endif /* _lub_dump_h */
  70. /** @} lub_dump */