X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f7f273099c8798f70611550bfc06b417e5c28ac7..f7f9fb5cb0f779bc1a648b264805d7e12abc4260:/unix/uxmisc.c?ds=sidebyside diff --git a/unix/uxmisc.c b/unix/uxmisc.c index 76401ea1..6889bcaf 100644 --- a/unix/uxmisc.c +++ b/unix/uxmisc.c @@ -3,8 +3,11 @@ */ #include +#include #include +#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