Created new data types `Filename' and `FontSpec', intended to be
[u/mdw/putty] / unix / uxmisc.c
index 76401ea..39ef7ed 100644 (file)
@@ -5,6 +5,8 @@
 #include <stdio.h>
 #include <sys/time.h>
 
+#include "putty.h"
+
 unsigned long getticks(void)
 {
     struct timeval tv;
@@ -15,3 +17,26 @@ unsigned long getticks(void)
      */
     return tv.tv_sec * 1000000 + tv.tv_usec;
 }
+
+Filename filename_from_str(char *str)
+{
+    Filename ret;
+    strncpy(ret.path, str, sizeof(ret.path));
+    ret.path[sizeof(ret.path)-1] = '\0';
+    return ret;
+}
+
+char *filename_to_str(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;
+}