f7f27309 |
1 | /* |
2 | * PuTTY miscellaneous Unix stuff |
3 | */ |
4 | |
5 | #include <stdio.h> |
d0912d1f |
6 | #include <unistd.h> |
f7f27309 |
7 | #include <sys/time.h> |
8 | |
9a30e26b |
9 | #include "putty.h" |
10 | |
f7f27309 |
11 | unsigned long getticks(void) |
12 | { |
13 | struct timeval tv; |
14 | gettimeofday(&tv, NULL); |
15 | /* |
16 | * This will wrap around approximately every 4000 seconds, i.e. |
17 | * just over an hour, which is more than enough. |
18 | */ |
19 | return tv.tv_sec * 1000000 + tv.tv_usec; |
20 | } |
9a30e26b |
21 | |
9fab77dc |
22 | Filename filename_from_str(const char *str) |
9a30e26b |
23 | { |
24 | Filename ret; |
25 | strncpy(ret.path, str, sizeof(ret.path)); |
26 | ret.path[sizeof(ret.path)-1] = '\0'; |
27 | return ret; |
28 | } |
29 | |
9fab77dc |
30 | const char *filename_to_str(const Filename *fn) |
9a30e26b |
31 | { |
9fab77dc |
32 | return fn->path; |
9a30e26b |
33 | } |
34 | |
35 | int filename_equal(Filename f1, Filename f2) |
36 | { |
37 | return !strcmp(f1.path, f2.path); |
38 | } |
39 | |
40 | int filename_is_null(Filename fn) |
41 | { |
42 | return !*fn.path; |
43 | } |
d0912d1f |
44 | |
45 | #ifdef DEBUG |
46 | static FILE *debug_fp = NULL; |
47 | |
48 | void dputs(char *buf) |
49 | { |
50 | if (!debug_fp) { |
51 | debug_fp = fopen("debug.log", "w"); |
52 | } |
53 | |
54 | write(1, buf, strlen(buf)); |
55 | |
56 | fputs(buf, debug_fp); |
57 | fflush(debug_fp); |
58 | } |
59 | #endif |