* gss-client.c, gss-server.c, gss-misc.c: Include Windows headers
authorDanilo Almeida <dalmeida@mit.edu>
Tue, 1 Feb 2000 20:49:25 +0000 (20:49 +0000)
committerDanilo Almeida <dalmeida@mit.edu>
Tue, 1 Feb 2000 20:49:25 +0000 (20:49 +0000)
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
src/appl/gss-sample/Makefile.in
src/appl/gss-sample/gss-client.c
src/appl/gss-sample/gss-misc.c
src/appl/gss-sample/gss-server.c

index eccd50be6791e48ca72e1241b79f40de9d06897a..fb37b228b9588e07bb33002af14c0dd60daa6f7f 100644 (file)
@@ -1,3 +1,18 @@
+2000-01-31  Danilo Almeida  <dalmeida@mit.edu>
+
+       * 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  <tlyu@mit.edu>
 
        * Makefile.in: Clean up usage of CFLAGS, CPPFLAGS, DEFS, DEFINES,
index d564f7ed862c535a650adc70b76e9ef3c963a0c0..8944ab7f18c1c46895546edde133eb607d385ffc 100644 (file)
@@ -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
index 33a7e963a38a159f7cd33cb1c58d18a6978f179c..5e4ed6093ef0693956f7b75120780a0092abda31 100644 (file)
@@ -25,9 +25,13 @@ static char *rcsid = "$Header$";
 #endif
 
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <winsock.h>
+#else
+#include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -36,6 +40,7 @@ static char *rcsid = "$Header$";
 #include <errno.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#endif
 
 #include <gssapi/gssapi_generic.h>
 #include "gss-misc.h"
index 67e898c1d6202a931f27749ec21bf0873214a378..fedd3766a9cc105aca32a79ff36c57e91bb0d35a 100644 (file)
@@ -25,8 +25,13 @@ static char *rcsid = "$Header$";
 #endif
 
 #include <stdio.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <winsock.h>
+#else
 #include <sys/types.h>
 #include <netinet/in.h>
+#endif
 #include <errno.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -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 <sys\timeb.h>
+#include <time.h>
+
+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 */
index df7de21f38b64b49c564858240d808b627269c90..6a163db9a8b061f6578fe2396deb5691b9366646 100644 (file)
@@ -25,10 +25,15 @@ static char *rcsid = "$Header$";
 #endif
 
 #include <stdio.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <winsock.h>
+#else
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <netinet/in.h>
+#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #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);
 }