clowwindy/shadowsocks-libev — pull request #19 by boytm (2014-09-12 05:33:55+00:00)
Title: read_jconf() cannot work on MinGW 4.7

On win32 MinGW 4.7, function fread() always return 0 to varirable nread, but perror() shows no error happened. Below is my test code

int nread = fread(buf, pos, 1, f); // MinGW 4.7 always return 0 to nread. but VS2008 is ok
//int nread = fread(buf, 1, pos, f); // work well with MinGW 4.7
if (!nread) perror("Failed to read the config file.");
LOGD("read buf len %ld, ret %d", pos, nread);

Below is the output:

ss-local.exe -c shadowsocks.json
Failed to read the config file.: No error
2014-09-12 10:02:55 INFO: read buf len 316, ret 0

But I tested on vs2008, it can work well. On MinGW, the solution is
1) change open file mode to binary
or
2) swap fread()'s argument size and count.