(main) [_WIN32]: Don't call WSAStartup() until after option
processing, so that we can version and help even when it fails. Fix program exit status on failure.
This commit is contained in:
parent
0414ee66a2
commit
d01aa85577
1 changed files with 9 additions and 6 deletions
|
@ -125,12 +125,6 @@ main(int argc, char **argv)
|
||||||
* after each prompt is required.
|
* after each prompt is required.
|
||||||
*/
|
*/
|
||||||
setvbuf(stdout, NULL, _IOLBF, 4096);
|
setvbuf(stdout, NULL, _IOLBF, 4096);
|
||||||
wVersionRequested = MAKEWORD(2, 0);
|
|
||||||
err = WSAStartup(wVersionRequested, &WsaData);
|
|
||||||
if (err != 0) {
|
|
||||||
printf("WSAStartup Failed, error code %d\n", err);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
FD_ZERO(&mask);
|
FD_ZERO(&mask);
|
||||||
FD_ZERO(&savemask);
|
FD_ZERO(&savemask);
|
||||||
|
@ -204,6 +198,15 @@ main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
wVersionRequested = MAKEWORD(2, 0);
|
||||||
|
err = WSAStartup(wVersionRequested, &WsaData);
|
||||||
|
if (err != 0) {
|
||||||
|
printf("WSAStartup Failed, error code %d\n", err);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sock = tcp_connect(host, port);
|
sock = tcp_connect(host, port);
|
||||||
|
|
||||||
if (!login(sock, uname, country, passwd, send_kill, utf8)) {
|
if (!login(sock, uname, country, passwd, send_kill, utf8)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue