X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fwin32%2Fsilcwin32util.c;h=0148a8e02b19e7f40cb7d752bdd8a9486685daf4;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=d7051c384abcd5424d3d77e54fa9300c7b5e7a4e;hpb=a818c5b5411bbc4436d1c5f011236985c96bb787;p=silc.git diff --git a/lib/silcutil/win32/silcwin32util.c b/lib/silcutil/win32/silcwin32util.c index d7051c38..0148a8e0 100644 --- a/lib/silcutil/win32/silcwin32util.c +++ b/lib/silcutil/win32/silcwin32util.c @@ -4,13 +4,12 @@ Author: Pekka Riikonen - Copyright (C) 2001 Pekka Riikonen + Copyright (C) 2001 - 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - + the Free Software Foundation; version 2 of the License. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -19,45 +18,42 @@ */ /* $Id$ */ -#include "silcincludes.h" +#include "silc.h" -/* XXX GNU regex may work on Win32 too!! */ -char *silc_string_regexify(const char *string) -{ - return strdup(string); -} +#define FILETIME_1970 0x019db1ded53e8000 +const BYTE DWLEN = sizeof(DWORD) * 8; -char *silc_string_regex_combine(const char *string1, const char *string2) +/* Return current time in struct timeval. Code ripped from some xntp + implementation. */ + +int silc_gettimeofday(struct timeval *tv) { - return strdup(string1); + FILETIME ft; + __int64 usec; + + GetSystemTimeAsFileTime(&ft); + usec = (__int64) ft.dwHighDateTime << DWLEN | ft.dwLowDateTime; + usec = (usec - FILETIME_1970) / 10; + tv->tv_sec = (long) (usec / 1000000); + tv->tv_usec = (long) (usec % 1000000); + + return 0; } -int silc_string_regex_match(const char *regex, const char *string) +char *silc_get_username(void) { - return TRUE; + DWORD maxlen = 128; + char username[128]; + GetUserName(username, &maxlen); + return silc_strdup(username); } -int silc_string_match(const char *string1, const char *string2) +char *silc_get_real_name(void) { - return TRUE; + return silc_get_username(); } -#define FILETIME_1970 0x019db1ded53e8000 -const BYTE DWLEN = sizeof(DWORD) * 8; - -/* Return current time in struct timeval. Code ripped from some xntp - implementation on http://src.openresources.com. */ - -int silc_gettimeofday(struct timeval *tv) +int silc_file_set_nonblock(int fd) { - FILETIME ft; - __SilcInt64 msec; - - GetSystemTimeAsFileTime(&ft); - msec = (__SilcInt64) ft.dwHighDateTime << DWLEN | ft.dwLowDateTime; - msec = (msec - FILETIME_1970) / 10; - tv->tv_sec = (long) (msec / 1000000); - tv->tv_usec = (long) (msec % 1000000); - return 0; }