output.c 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*====================================================================*
  2. *
  3. * void output (signed indent, char const * format, ...);
  4. *
  5. * format.h
  6. *
  7. * print an indented and formatted string on stdout;
  8. *
  9. * Motley Tools by Charles Maier;
  10. * Copyright (c) 2001-2006 by Charles Maier Associates;
  11. * Licensed under the Internet Software Consortium License;
  12. *
  13. *--------------------------------------------------------------------*/
  14. #ifndef OUTPUT_SOURCE
  15. #define OUTPUT_SOURCE
  16. #include <stdio.h>
  17. #include <stdarg.h>
  18. #include <unistd.h>
  19. #include "../tools/format.h"
  20. #ifdef __GNUC__
  21. __attribute__ ((format (printf, 2, 3)))
  22. #endif
  23. void output (signed indent, char const * format, ...)
  24. {
  25. static char tab = '\t';
  26. static char end = '\n';
  27. while (indent-- > 0)
  28. {
  29. putc (tab, stdout);
  30. }
  31. if ((format) && (*format))
  32. {
  33. va_list arglist;
  34. va_start (arglist, format);
  35. vprintf (format, arglist);
  36. va_end (arglist);
  37. }
  38. putc (end, stdout);
  39. return;
  40. }
  41. #endif