2 * PuTTY miscellaneous Unix stuff
13 unsigned long getticks(void)
16 gettimeofday(&tv
, NULL
);
18 * We want to use milliseconds rather than microseconds,
19 * because we need a decent number of them to fit into a 32-bit
20 * word so it can be used for keepalives.
22 return tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
25 Filename
filename_from_str(const char *str
)
28 strncpy(ret
.path
, str
, sizeof(ret
.path
));
29 ret
.path
[sizeof(ret
.path
)-1] = '\0';
33 const char *filename_to_str(const Filename
*fn
)
38 int filename_equal(Filename f1
, Filename f2
)
40 return !strcmp(f1
.path
, f2
.path
);
43 int filename_is_null(Filename fn
)
49 static FILE *debug_fp
= NULL
;
54 debug_fp
= fopen("debug.log", "w");
57 write(1, buf
, strlen(buf
));
64 char *get_username(void)
68 char *user
, *ret
= NULL
;
71 * First, find who we think we are using getlogin. If this
72 * agrees with our uid, we'll go along with it. This should
73 * allow sharing of uids between several login names whilst
74 * coping correctly with people who have su'ed.
82 if (p
&& p
->pw_uid
== uid
) {
84 * The result of getlogin() really does correspond to
90 * If that didn't work, for whatever reason, we'll do
91 * the simpler version: look up our uid in the password
92 * file and map it straight to a name.