tpm2_tool_output.h 801 B

123456789101112131415161718192021222324252627282930
  1. #ifndef TPM2_TOOL_OUTPUT_H
  2. #define TPM2_TOOL_OUTPUT_H
  3. #include <stdio.h>
  4. extern bool output_enabled;
  5. /**
  6. * Output is enabled by default. This wrapper prevents code that
  7. * must disable output from accessing the global 'output_enabled'
  8. * variable directly.
  9. */
  10. #define tpm2_tool_output_disable() (output_enabled = false)
  11. /**
  12. * prints output to stdout respecting the quiet option.
  13. * Ie when quiet, don't print.
  14. * @param fmt
  15. * The format specifier, ala printf.
  16. * @param ...
  17. * The varargs, just like printf.
  18. */
  19. #define tpm2_tool_output(fmt, ...) \
  20. do { \
  21. if (output_enabled) { \
  22. printf(fmt, ##__VA_ARGS__); \
  23. } \
  24. } while (0)
  25. #endif