Am Dienstag, den 13.09.2011, 09:03 +0200 schrieb Thomas Arp: > 1. libnetmd/common.c : sleep() is not defined/implemented > I fixed this using windows Sleep() function by adding following lines > to common.c > > #ifdef WIN32 /* use windows internal Sleep() function */ > #include <windows.h> > #define sleep(x) Sleep(x) > #endif Good start, but not quite. #define sleep(x) Sleep(x*1000) even better: #ifdef WIN32 #include <windows.h> #define msleep(x) Sleep(x) #else #include <unistd.h> #define msleep(x) usleep(1000*x) #endif and replace the "sleep(1)" by "msleep(200)". A polling frequency of 1Hz is quite low. I guess sleep was originally used, as there is common belief (even I fell into that trap) that sleep would be portable ANSI C. > 2. libnetmd/utils.h and utils.c : "int min(int a,int b)" is already > defined in windows.h > I fixed this by defining NOMINMAX to not use the windows function. > I just added following line to libnetmd.pro and netmdcli.pro > > win32:DEFINES += NOMINMAX Great, that change is fine. The other alternative would be to rename out min funciton. > 3. libnetmd/utils.h : missind definition of ETIMEDOUT in errno.h > I fixed this by defining it. > #ifdef WIN32 /* add missing definitions for errno on windows */ > #define ETIMEDOUT 70 // Operation timed out > #endif NACK. We are using a libusb 1.0 call here, and the libusb documentation documents "LIBUSB_ERROR_TIMEOUT" as the right value to compare against. Replace ETIMEDOUT by that, don't try to define ETIMEDOUT. > 4. libnetmd/secure.c and netmdcli/netmdcli.c : ramdo) is not defined > and implemented > I fixed this as a "bloody hack" in utils.h using > #ifdef WIN32 > #include <stdlib.h> > #include <time.h> > static int random(){srand(time(NULL));return rand();}; > #endif Reseding every time is a real bad idea(tm). It is quite likely that time(NULL) returns the same value on two successive calls (it changes once per second). As we don't care about sniffing, just using rand() in the library should be fine, if the caller didn't srand so be it. In netmdcli.c, add "srand(time(NULL));" to the beginning of main. Then replace random by rand. Regards, Michael Karcher