dputs.c 449 B

12345678910111213141516171819202122232425
  1. /*
  2. * Implementation of dputs() for Unix.
  3. *
  4. * The debug messages are written to standard output, and also into a
  5. * file called debug.log.
  6. */
  7. #include <unistd.h>
  8. #include "putty.h"
  9. static FILE *debug_fp = NULL;
  10. void dputs(const char *buf)
  11. {
  12. if (!debug_fp) {
  13. debug_fp = fopen("debug.log", "w");
  14. }
  15. if (write(1, buf, strlen(buf)) < 0) {} /* 'error check' to placate gcc */
  16. fputs(buf, debug_fp);
  17. fflush(debug_fp);
  18. }