| 1 | /* |
| 2 | * PuTTY miscellaneous Unix stuff |
| 3 | */ |
| 4 | |
| 5 | #include <stdio.h> |
| 6 | #include <sys/time.h> |
| 7 | |
| 8 | #include "putty.h" |
| 9 | |
| 10 | unsigned long getticks(void) |
| 11 | { |
| 12 | struct timeval tv; |
| 13 | gettimeofday(&tv, NULL); |
| 14 | /* |
| 15 | * This will wrap around approximately every 4000 seconds, i.e. |
| 16 | * just over an hour, which is more than enough. |
| 17 | */ |
| 18 | return tv.tv_sec * 1000000 + tv.tv_usec; |
| 19 | } |
| 20 | |
| 21 | Filename filename_from_str(char *str) |
| 22 | { |
| 23 | Filename ret; |
| 24 | strncpy(ret.path, str, sizeof(ret.path)); |
| 25 | ret.path[sizeof(ret.path)-1] = '\0'; |
| 26 | return ret; |
| 27 | } |
| 28 | |
| 29 | char *filename_to_str(Filename fn) |
| 30 | { |
| 31 | return fn.path; |
| 32 | } |
| 33 | |
| 34 | int filename_equal(Filename f1, Filename f2) |
| 35 | { |
| 36 | return !strcmp(f1.path, f2.path); |
| 37 | } |
| 38 | |
| 39 | int filename_is_null(Filename fn) |
| 40 | { |
| 41 | return !*fn.path; |
| 42 | } |