Having created and used uxsel, it actually turns out to be
[u/mdw/putty] / unix / uxmisc.c
index 76401ea..6889bca 100644 (file)
@@ -3,8 +3,11 @@
  */
 
 #include <stdio.h>
+#include <unistd.h>
 #include <sys/time.h>
 
+#include "putty.h"
+
 unsigned long getticks(void)
 {
     struct timeval tv;
@@ -15,3 +18,42 @@ unsigned long getticks(void)
      */
     return tv.tv_sec * 1000000 + tv.tv_usec;
 }
+
+Filename filename_from_str(const char *str)
+{
+    Filename ret;
+    strncpy(ret.path, str, sizeof(ret.path));
+    ret.path[sizeof(ret.path)-1] = '\0';
+    return ret;
+}
+
+const char *filename_to_str(const Filename *fn)
+{
+    return fn->path;
+}
+
+int filename_equal(Filename f1, Filename f2)
+{
+    return !strcmp(f1.path, f2.path);
+}
+
+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