(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:
parent
006c4bcce4
commit
f082ef9fa6
12 changed files with 750 additions and 110 deletions
|
@ -44,6 +44,15 @@
|
|||
#endif
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define recv(sock, buffer, buf_size, flags) \
|
||||
w32_recv((sock), (buffer), (buf_size), (flags))
|
||||
#define read(sock, buffer, buf_size) \
|
||||
w32_recv((sock), (buffer), (buf_size), 0)
|
||||
#define write(sock, buffer, buf_size) \
|
||||
w32_send((sock), (buffer), (buf_size), 0)
|
||||
#endif
|
||||
|
||||
int
|
||||
recvline(int s, char *buf)
|
||||
{
|
||||
|
@ -55,15 +64,10 @@ recvline(int s, char *buf)
|
|||
int cc;
|
||||
|
||||
size = 1024;
|
||||
#ifndef _WIN32
|
||||
(void)alarm(30);
|
||||
#endif
|
||||
ptr = buf;
|
||||
n = recv(s, ptr, size, MSG_PEEK);
|
||||
if (n <= 0) {
|
||||
#ifdef _WIN32
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
perror("recv");
|
||||
return 0;
|
||||
}
|
||||
|
@ -71,15 +75,8 @@ recvline(int s, char *buf)
|
|||
buf[n] = '\0';
|
||||
if ((p = strchr(ptr, '\n')) == NULL) {
|
||||
do {
|
||||
#ifndef _WIN32
|
||||
cc = read(s, ptr, n);
|
||||
#else
|
||||
cc = recv(s, ptr, n, 0);
|
||||
#endif
|
||||
if (cc < 0) {
|
||||
#ifdef _WIN32
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
perror("expect: read");
|
||||
return 0;
|
||||
}
|
||||
|
@ -89,9 +86,6 @@ recvline(int s, char *buf)
|
|||
}
|
||||
ptr += n;
|
||||
if ((n = recv(s, ptr, size, MSG_PEEK)) <= 0) {
|
||||
#ifdef _WIN32
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
perror("recv");
|
||||
return 0;
|
||||
}
|
||||
|
@ -102,15 +96,8 @@ recvline(int s, char *buf)
|
|||
*p = 0;
|
||||
} else
|
||||
newline = 1 + p - ptr;
|
||||
#ifndef _WIN32
|
||||
cc = read(s, buf, newline);
|
||||
#else
|
||||
cc = recv(s, buf, newline, 0);
|
||||
#endif
|
||||
if (cc < 0) {
|
||||
#ifdef _WIN32
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
perror("expect: read #2");
|
||||
return 0;
|
||||
}
|
||||
|
@ -120,9 +107,7 @@ recvline(int s, char *buf)
|
|||
return 0;
|
||||
}
|
||||
buf[newline] = '\0';
|
||||
#ifndef _WIN32
|
||||
(void)alarm(0);
|
||||
#endif
|
||||
if (!isxdigit(buf[0]) || buf[1] != ' ') {
|
||||
fprintf(stderr, "Malformed line %s\n", buf);
|
||||
return 0;
|
||||
|
@ -146,15 +131,8 @@ sendcmd(int s, char *cmd, char *arg)
|
|||
|
||||
(void)sprintf(buf, "%s %s\n", cmd, arg != NULL ? arg : "");
|
||||
len = strlen(buf);
|
||||
#ifndef _WIN32
|
||||
cc = write(s, buf, len);
|
||||
#else
|
||||
cc = send(s, buf, len, 0);
|
||||
#endif
|
||||
if (cc < 0) {
|
||||
#ifdef _WIN32
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
perror("sendcmd: write");
|
||||
}
|
||||
if (cc != len) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue