(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

@ -36,12 +36,21 @@
#include <config.h>
#ifndef _WIN32
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
#endif
#include "misc.h"
#include "version.h"
#ifdef _WIN32
#define getuid() 0
#define getpwuid(uid) ((uid), w32_getpw())
#else
#define sysdep_init() ((void)0)
#endif
static void
print_usage(char *program_name)
{
@ -68,21 +77,6 @@ main(int argc, char **argv)
char *host;
char *port;
int sock;
#ifdef _WIN32
char unamebuf[128];
#endif
#ifdef _WIN32
/*
* stdout is unbuffered under Windows if connected to a character
* device, and putchar() screws up when printing multibyte strings
* bytewise to an unbuffered stream. Switch stdout to line-
* buffered mode. Unfortunately, ISO C allows implementations to
* screw that up, and of course Windows does. Manual flushing
* after each prompt is required.
*/
setvbuf(stdout, NULL, _IOLBF, 4096);
#endif
while ((opt = getopt(argc, argv, "2:kuhv")) != EOF) {
switch (opt) {
@ -124,7 +118,6 @@ main(int argc, char **argv)
host = empirehost;
uname = getenv("LOGNAME");
if (uname == NULL) {
#ifndef _WIN32
struct passwd *pwd;
pwd = getpwuid(getuid());
@ -133,17 +126,6 @@ main(int argc, char **argv)
exit(1);
}
uname = pwd->pw_name;
#else
DWORD unamesize;
unamesize = sizeof(unamebuf);
if (GetUserName(unamebuf, &unamesize)) {
uname = unamebuf;
if ((unamesize <= 0 ) || (strlen(uname) <= 0))
uname = "nobody";
} else
uname = "nobody";
#endif
}
getsose();
@ -152,13 +134,7 @@ main(int argc, char **argv)
exit(1);
}
#ifdef _WIN32
err = WSAStartup(MAKEWORD(2, 0), &WsaData);
if (err != 0) {
printf("WSAStartup Failed, error code %d\n", err);
exit(1);
}
#endif
sysdep_init();
sock = tcp_connect(host, port);