5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2001 - 2008 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.
20 #include "silcruntime.h"
22 #define FILETIME_1970 0x019db1ded53e8000
23 const BYTE DWLEN = sizeof(DWORD) * 8;
25 /* Return current time in struct timeval. Code ripped from some xntp
28 int silc_gettimeofday(struct timeval *tv)
33 GetSystemTimeAsFileTime(&ft);
34 usec = (__int64) ft.dwHighDateTime << DWLEN | ft.dwLowDateTime;
35 usec = (usec - FILETIME_1970) / 10;
36 tv->tv_sec = (long) (usec / 1000000);
37 tv->tv_usec = (long) (usec % 1000000);
42 char *silc_get_username(void)
46 GetUserName(username, &maxlen);
47 return silc_strdup(username);
50 char *silc_get_real_name(void)
52 return silc_get_username();
55 int silc_file_set_nonblock(int fd)