(w32_getpw, w32_socket, w32_connect, w32_recv, w32_send,

w32_writev_socket, w32_close_socket, getpass, w32_openfd,
w32_openhandle, w32_readv_handle, w32_close_handle,
sysdep_init, sysdep_stdin_init, w32_select, w32_signal_handler,
sigaction, stdin_read_thread, w32_ring_from_file_to_bounce_buf)
[_WIN32]: New w32 equivalent functions for POSIX functions.
(recvline, sendcmd, tcp_connect, hostconnect, getpass,
main, intr, play, ring_to_file, ring_from_file, doexecute,
doredir) [_WIN32]: Use new WIN32 equivalent functions.
(main) [_WIN32]: Add sysdep_init() to support system dependent
initialization for equivalence functions.
(play) [_WIN32]: Add sysdef_stdin_init() to support system
dependent initialization for reading stdin.
(recv_input, play) [_WIN32]: Replace the calls to ring_to_file()
and select() with WIN32 specific enhanced versions.

Makefile.in: update dependencies with new files.
Make.mk: Add using of getopt.c and getopt.h
from src/lib/w32 directory.  Add getopt.c and getopt.h
to tar for client.
This commit is contained in:
Ron Koenderink 2007-12-11 22:00:25 +00:00
parent 006c4bcce4
commit f082ef9fa6
12 changed files with 750 additions and 110 deletions

View file

@ -48,8 +48,7 @@
#include <netdb.h>
#include <unistd.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#define close(fd) w32_close_socket((fd))
#endif
#include "misc.h"
@ -83,11 +82,7 @@ tcp_connect(char *host, char *serv)
if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0)
break; /* success */
#ifdef _WIN32
closesocket(sockfd); /* ignore this one */
#else
close(sockfd); /* ignore this one */
#endif
} while ((res = res->ai_next) != NULL);
if (res == NULL) { /* errno set from final connect() */
@ -147,19 +142,11 @@ hostconnect(struct sockaddr_in *addr)
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0) {
#ifdef _WIN32
errno = WSAGetLastError();
#endif
return -1;
}
addr->sin_family = AF_INET;
if (connect(s, (struct sockaddr *)addr, sizeof(*addr)) < 0) {
#ifdef _WIN32
errno = WSAGetLastError();
(void)closesocket(s);
#else
(void)close(s);
#endif
return -1;
}
return s;