From f79a926e85cab3392427c0830c1e8c77ea9edd52 Mon Sep 17 00:00:00 2001 From: Danilo Almeida Date: Tue, 1 Feb 2000 20:49:25 +0000 Subject: [PATCH] * gss-client.c, gss-server.c, gss-misc.c: Include Windows headers instead of Unix headers under Windows. * gss-server.c (usage): Fix usage info to reflect that service_name is required. * gss-misc.c (read_all, write_all): Change write to send and read to recv for portability. (gettimeofday): Add an implementation of gettimeofday() for Windows. * Makefile.in: Build under Windows. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11981 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/gss-sample/ChangeLog | 15 +++++++++++++++ src/appl/gss-sample/Makefile.in | 17 ++++++++++++----- src/appl/gss-sample/gss-client.c | 7 ++++++- src/appl/gss-sample/gss-misc.c | 26 ++++++++++++++++++++++++-- src/appl/gss-sample/gss-server.c | 7 ++++++- 5 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/appl/gss-sample/ChangeLog b/src/appl/gss-sample/ChangeLog index eccd50be6..fb37b228b 100644 --- a/src/appl/gss-sample/ChangeLog +++ b/src/appl/gss-sample/ChangeLog @@ -1,3 +1,18 @@ +2000-01-31 Danilo Almeida + + * gss-client.c, gss-server.c, gss-misc.c: Include Windows headers + instead of Unix headers under Windows. + + * gss-server.c (usage): Fix usage info to reflect that service_name is + required. + + * gss-misc.c (read_all, write_all): Change write to send and read + to recv for portability. + (gettimeofday): Add an implementation of gettimeofday() for + Windows. + + * Makefile.in: Build under Windows. + 1999-10-26 Tom Yu * Makefile.in: Clean up usage of CFLAGS, CPPFLAGS, DEFS, DEFINES, diff --git a/src/appl/gss-sample/Makefile.in b/src/appl/gss-sample/Makefile.in index d564f7ed8..8944ab7f1 100644 --- a/src/appl/gss-sample/Makefile.in +++ b/src/appl/gss-sample/Makefile.in @@ -11,7 +11,8 @@ SRCS= gss-client.c gss-misc.c gss-server.c OBJS= gss-client.o gss-misc.o gss-server.o -all:: gss-server gss-client +all-unix:: gss-server gss-client +all-windows:: $(OUTPRE)gss-server.exe $(OUTPRE)gss-client.exe gss-server: gss-server.o gss-misc.o $(GSS_DEPLIBS) $(KRB5_BASE_DEPLIBS) $(CC_LINK) -o gss-server gss-server.o gss-misc.o $(GSS_LIBS) $(KRB5_BASE_LIBS) @@ -19,9 +20,15 @@ gss-server: gss-server.o gss-misc.o $(GSS_DEPLIBS) $(KRB5_BASE_DEPLIBS) gss-client: gss-client.o gss-misc.o $(GSS_DEPLIBS) $(KRB5_BASE_DEPLIBS) $(CC_LINK) -o gss-client gss-client.o gss-misc.o $(GSS_LIBS) $(KRB5_BASE_LIBS) -clean:: +$(OUTPRE)gss-server.exe: $(OUTPRE)gss-server.obj $(OUTPRE)gss-misc.obj $(GLIB) $(KLIB) + link $(EXE_LINKOPTS) -out:$@ $** wsock32.lib + +$(OUTPRE)gss-client.exe: $(OUTPRE)gss-client.obj $(OUTPRE)gss-misc.obj $(GLIB) $(KLIB) + link $(EXE_LINKOPTS) -out:$@ $** wsock32.lib + +clean-unix:: $(RM) gss-server gss-client -install:: - $(INSTALL_PROGRAM) gss-client ${DESTDIR}$(CLIENT_BINDIR)/gss-client - $(INSTALL_PROGRAM) gss-server ${DESTDIR}$(SERVER_BINDIR)/gss-server +install-unix:: + $(INSTALL_PROGRAM) gss-client $(DESTDIR)$(CLIENT_BINDIR)/gss-client + $(INSTALL_PROGRAM) gss-server $(DESTDIR)$(SERVER_BINDIR)/gss-server diff --git a/src/appl/gss-sample/gss-client.c b/src/appl/gss-sample/gss-client.c index 33a7e963a..5e4ed6093 100644 --- a/src/appl/gss-sample/gss-client.c +++ b/src/appl/gss-sample/gss-client.c @@ -25,9 +25,13 @@ static char *rcsid = "$Header$"; #endif #include -#include #include #include +#ifdef _WIN32 +#include +#include +#else +#include #include #include #include @@ -36,6 +40,7 @@ static char *rcsid = "$Header$"; #include #include #include +#endif #include #include "gss-misc.h" diff --git a/src/appl/gss-sample/gss-misc.c b/src/appl/gss-sample/gss-misc.c index 67e898c1d..fedd3766a 100644 --- a/src/appl/gss-sample/gss-misc.c +++ b/src/appl/gss-sample/gss-misc.c @@ -25,8 +25,13 @@ static char *rcsid = "$Header$"; #endif #include +#ifdef _WIN32 +#include +#include +#else #include #include +#endif #include #ifdef HAVE_UNISTD_H #include @@ -53,7 +58,7 @@ static int write_all(int fildes, char *buf, unsigned int nbyte) char *ptr; for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) { - ret = write(fildes, ptr, nbyte); + ret = send(fildes, ptr, nbyte, 0); if (ret < 0) { if (errno == EINTR) continue; @@ -72,7 +77,7 @@ static int read_all(int fildes, char *buf, unsigned int nbyte) char *ptr; for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) { - ret = read(fildes, ptr, nbyte); + ret = recv(fildes, ptr, nbyte, 0); if (ret < 0) { if (errno == EINTR) continue; @@ -301,3 +306,20 @@ void print_token(tok) fprintf(display_file, "\n"); fflush(display_file); } + +#ifdef _WIN32 +#include +#include + +int gettimeofday (struct timeval *tv, void *ignore_tz) +{ + struct _timeb tb; + _tzset(); + _ftime(&tb); + if (tv) { + tv->tv_sec = tb.time; + tv->tv_usec = tb.millitm * 1000; + } + return 0; +} +#endif /* _WIN32 */ diff --git a/src/appl/gss-sample/gss-server.c b/src/appl/gss-sample/gss-server.c index df7de21f3..6a163db9a 100644 --- a/src/appl/gss-sample/gss-server.c +++ b/src/appl/gss-sample/gss-server.c @@ -25,10 +25,15 @@ static char *rcsid = "$Header$"; #endif #include +#ifdef _WIN32 +#include +#include +#else #include #include #include #include +#endif #ifdef HAVE_UNISTD_H #include #endif @@ -47,7 +52,7 @@ static char *rcsid = "$Header$"; void usage() { fprintf(stderr, "Usage: gss-server [-port port] [-verbose]\n"); - fprintf(stderr, " [-inetd] [-logfile file] [service_name]\n"); + fprintf(stderr, " [-inetd] [-logfile file] service_name\n"); exit(1); } -- 2.26.2