5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2001 - 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
23 #define FILETIME_1970 0x019db1ded53e8000
24 const BYTE DWLEN = sizeof(DWORD) * 8;
26 /* Return current time in struct timeval. Code ripped from some xntp
29 int silc_gettimeofday(struct timeval *tv)
34 GetSystemTimeAsFileTime(&ft);
35 usec = (__int64) ft.dwHighDateTime << DWLEN | ft.dwLowDateTime;
36 usec = (usec - FILETIME_1970) / 10;
37 tv->tv_sec = (long) (usec / 1000000);
38 tv->tv_usec = (long) (usec % 1000000);
43 char *silc_get_username(void)
47 GetUserName(username, &maxlen);
48 return strdup(username);
51 char *silc_get_real_name(void)
53 return silc_get_username();
56 int silc_file_set_nonblock(int fd)