Reorganisation of misc.c: Minefield has moved out to winmisc.c, and
[u/mdw/putty] / unix / uxmisc.c
index 39ef7ed..6889bca 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <unistd.h>
 #include <sys/time.h>
 
 #include "putty.h"
@@ -18,7 +19,7 @@ unsigned long getticks(void)
     return tv.tv_sec * 1000000 + tv.tv_usec;
 }
 
-Filename filename_from_str(char *str)
+Filename filename_from_str(const char *str)
 {
     Filename ret;
     strncpy(ret.path, str, sizeof(ret.path));
@@ -26,9 +27,9 @@ Filename filename_from_str(char *str)
     return ret;
 }
 
-char *filename_to_str(Filename fn)
+const char *filename_to_str(const Filename *fn)
 {
-    return fn.path;
+    return fn->path;
 }
 
 int filename_equal(Filename f1, Filename f2)
@@ -40,3 +41,19 @@ int filename_is_null(Filename fn)
 {
     return !*fn.path;
 }
+
+#ifdef DEBUG
+static FILE *debug_fp = NULL;
+
+void dputs(char *buf)
+{
+    if (!debug_fp) {
+       debug_fp = fopen("debug.log", "w");
+    }
+
+    write(1, buf, strlen(buf));
+
+    fputs(buf, debug_fp);
+    fflush(debug_fp);
+}
+#endif