0b04d211b95cd547f78ec9cc2ebaf5b59f899fe1
2 * PuTTY miscellaneous Unix stuff
15 * We want to use milliseconds rather than microseconds or nanoseconds,
16 * because we need a decent number of them to fit into a 32-bit
17 * word so it can be used for keepalives.
19 unsigned long getticks(void)
22 #ifdef CLOCK_MONOTONIC
24 if (clock_gettime(CLOCK_MONOTONIC
, &ts
) == 0)
25 return ts
.tv_sec
* 1000 + ts
.tv_nsec
/ 1000000;
27 gettimeofday(&tv
, NULL
);
28 return tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
31 Filename
filename_from_str(const char *str
)
34 strncpy(ret
.path
, str
, sizeof(ret
.path
));
35 ret
.path
[sizeof(ret
.path
)-1] = '\0';
39 const char *filename_to_str(const Filename
*fn
)
44 int filename_equal(Filename f1
, Filename f2
)
46 return !strcmp(f1
.path
, f2
.path
);
49 int filename_is_null(Filename fn
)
55 static FILE *debug_fp
= NULL
;
60 debug_fp
= fopen("debug.log", "w");
63 write(1, buf
, strlen(buf
));
70 char *get_username(void)
74 char *user
, *ret
= NULL
;
77 * First, find who we think we are using getlogin. If this
78 * agrees with our uid, we'll go along with it. This should
79 * allow sharing of uids between several login names whilst
80 * coping correctly with people who have su'ed.
88 if (p
&& p
->pw_uid
== uid
) {
90 * The result of getlogin() really does correspond to
96 * If that didn't work, for whatever reason, we'll do
97 * the simpler version: look up our uid in the password
98 * file and map it straight to a name.
111 * Display the fingerprints of the PGP Master Keys to the user.
112 * (This is here rather than in uxcons because it's appropriate even for
115 void pgp_fingerprints(void)
117 fputs("These are the fingerprints of the PuTTY PGP Master Keys. They can\n"
118 "be used to establish a trust path from this executable to another\n"
119 "one. See the manual for more information.\n"
120 "(Note: these fingerprints have nothing to do with SSH!)\n"
122 "PuTTY Master Key (RSA), 1024-bit:\n"
123 " " PGP_RSA_MASTER_KEY_FP
"\n"
124 "PuTTY Master Key (DSA), 1024-bit:\n"
125 " " PGP_DSA_MASTER_KEY_FP
"\n", stdout
);