2 * PuTTY miscellaneous Unix stuff
13 unsigned long getticks(void)
16 gettimeofday(&tv
, NULL
);
18 * This will wrap around approximately every 4000 seconds, i.e.
19 * just over an hour, which is more than enough.
21 return tv
.tv_sec
* 1000000 + tv
.tv_usec
;
26 Filename
filename_from_str(const char *str
)
29 strncpy(ret
.path
, str
, sizeof(ret
.path
));
30 ret
.path
[sizeof(ret
.path
)-1] = '\0';
34 const char *filename_to_str(const Filename
*fn
)
39 int filename_equal(Filename f1
, Filename f2
)
41 return !strcmp(f1
.path
, f2
.path
);
44 int filename_is_null(Filename fn
)
50 static FILE *debug_fp
= NULL
;
55 debug_fp
= fopen("debug.log", "w");
58 write(1, buf
, strlen(buf
));
65 char *get_username(void)
69 char *user
, *ret
= NULL
;
72 * First, find who we think we are using getlogin. If this
73 * agrees with our uid, we'll go along with it. This should
74 * allow sharing of uids between several login names whilst
75 * coping correctly with people who have su'ed.
83 if (p
&& p
->pw_uid
== uid
) {
85 * The result of getlogin() really does correspond to
91 * If that didn't work, for whatever reason, we'll do
92 * the simpler version: look up our uid in the password
93 * file and map it straight to a name.