diff -Naur dmucs-0.6.1/AUTHORS dmucs-0.6.2/AUTHORS --- dmucs-0.6.1/AUTHORS 2006-01-10 15:43:28.000000000 +0000 +++ dmucs-0.6.2/AUTHORS 2007-04-23 15:31:37.000000000 +0000 @@ -0,0 +1,5 @@ +Original Author: +Victor Norman + +Port to native Windows: +Benoit Sigoure diff -Naur dmucs-0.6.1/COSMIC/Makefile dmucs-0.6.2/COSMIC/Makefile --- dmucs-0.6.1/COSMIC/Makefile 2006-06-22 13:47:15.000000000 +0000 +++ dmucs-0.6.2/COSMIC/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -# Makefile for the Simple Sockets Library (C version) -# -# Authors: Charles E. Campbell, Jr., Ph.D. -# Terry McRoberts -# -# -# Building the SSL: -# -# Some Unix (tm) boxes need to run a program called "ranlib" (ex. Sun) -# You will notice below a "#ranlib ..." line; if your machine needs it, -# remove the "#". -# -# Please modify the Makefile below for the following exceptions: -# -# Compiler Exceptions Loader Exceptions -# SCO -# Solaris 2.1 -# -# You may also wish to set the "RDCOLOR" environment variable in your -# login/profile/startup-sequence/etc file to be the string where the -# file is to be located. Furthermore, you may wish to -# modify the file to include escape sequences for your -# favorite terminal(s) (should be fairly obvious by inspection how to -# do so using some editor). -# -# Option: The PortMaster can optionally use a "firewall" to keep unwanted -# visitors out. The PortMaster (Spm) uses an environment variable -# (SPMFIREWALL) to specify where the firewall file is located. -# One may also start up the PortMaster (Spm -f firewallfilename). -# Please read the documentation on this. - -CC = cc - -OBJ = Saccept.o Sprintf.o Stest.o outofmem.o \ - Sclose.o Sprtskt.o Stimeoutwait.o rdcolor.o \ - Sgets.o Sputs.o Svprintf.o sprt.o \ - Smaskwait.o Sread.o Swait.o srmtrblk.o \ - Smkskt.o Sreadbytes.o Swrite.o stpblk.o \ - Sopen.o Srmsrvr.o error.o stpnxt.o \ - Sopenv.o Sscanf.o fopenv.o strnxtfmt.o \ - Speek.o cprt.o Speername.o Speeraddr.o \ - Sinit.o - -# LIB: name of library -LIB = simpleskts.a - -# EXETGT: where to put executables, as seen from the viewpoint of the EXE -# subdirectory -EXETGT=../EXE - -# usual compiler stuff -CFLAGS = -O -I./HDR -LOADLIBES = ../$(LIB) - -# for SCO UNIX: -# LOADLIBES = ../$(LIB) -lsocket - -# for Solaris 2.1 -# LOADLIBES = ../$(LIB) -lnsl - -# for g++ compiler: (tnx to Gary Johnson) -# CFLAGS= -Wall -ansi -pedantic -O -I./HDR - -# all : $(LIB) exes examples -all : $(LIB) - -$(LIB) : $(OBJ) - ar r simpleskts.a *.o -# ranlib simpleskts.a -# /bin/rm -f *.o - @echo "finished updating simpleskts.a" - -exes : $(LIB) - ( cd EXE; \ - make CC=$(CC) LIB=$(LIB) CFLAGS="-O -I../HDR" LOADLIBES=$(LOADLIBES) EXETGT=$(EXETGT) ) - -examples : $(LIB) - ( cd EXAMPLES; \ - make CC=$(CC) LIB=$(LIB) CFLAGS="-O -I../HDR" LOADLIBES=$(LOADLIBES) ) - -distclean clean : - @/bin/rm -f *.a *.bak *.err $(OBJ) - (cd EXE; make clean ) - (cd EXAMPLES ; make clean ) - @echo "All object files, the simpleskts library, and executables are now gone" - -install : diff -Naur dmucs-0.6.1/COSMIC/Makefile.am dmucs-0.6.2/COSMIC/Makefile.am --- dmucs-0.6.1/COSMIC/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ dmucs-0.6.2/COSMIC/Makefile.am 2007-04-23 15:26:11.000000000 +0000 @@ -0,0 +1,46 @@ +AM_CPPFLAGS = -I$(srcdir)/HDR +AM_CFLAGS = -O + +noinst_LIBRARIES = libsimpleskts.a +libsimpleskts_a_SOURCES = \ +cprt.c \ +error.c \ +fopenv.c \ +outofmem.c \ +rdcolor.c \ +Saccept.c \ +Sclose.c \ +Sgets.c \ +Sinit.c \ +Smaskwait.c \ +Smkskt.c \ +Sopen.c \ +Sopenv.c \ +Speek.c \ +Speeraddr.c \ +Speername.c \ +Sprintf.c \ +sprt.c \ +Sprtskt.c \ +Sputs.c \ +Sreadbytes.c \ +Sread.c \ +Srmsrvr.c \ +srmtrblk.c \ +Sscanf.c \ +Stest.c \ +Stimeoutwait.c \ +stpblk.c \ +stpnxt.c \ +strnxtfmt.c \ +Svprintf.c \ +Swait.c \ +Swrite.c \ +HDR/rdcolor.h \ +HDR/setproto.h \ +HDR/sockets.h \ +HDR/xstdlib.h \ +HDR/xtdio.h + +EXTRA_DIST = Makefile.old Makelib. Makeskt.bat Makeskt.com Mkwin95.bat \ + MAKEFILE.os2 diff -Naur dmucs-0.6.1/COSMIC/Makefile.old dmucs-0.6.2/COSMIC/Makefile.old --- dmucs-0.6.1/COSMIC/Makefile.old 1970-01-01 00:00:00.000000000 +0000 +++ dmucs-0.6.2/COSMIC/Makefile.old 2007-04-23 13:40:55.000000000 +0000 @@ -0,0 +1,88 @@ +# Makefile for the Simple Sockets Library (C version) +# +# Authors: Charles E. Campbell, Jr., Ph.D. +# Terry McRoberts +# +# +# Building the SSL: +# +# Some Unix (tm) boxes need to run a program called "ranlib" (ex. Sun) +# You will notice below a "#ranlib ..." line; if your machine needs it, +# remove the "#". +# +# Please modify the Makefile below for the following exceptions: +# +# Compiler Exceptions Loader Exceptions +# SCO +# Solaris 2.1 +# +# You may also wish to set the "RDCOLOR" environment variable in your +# login/profile/startup-sequence/etc file to be the string where the +# file is to be located. Furthermore, you may wish to +# modify the file to include escape sequences for your +# favorite terminal(s) (should be fairly obvious by inspection how to +# do so using some editor). +# +# Option: The PortMaster can optionally use a "firewall" to keep unwanted +# visitors out. The PortMaster (Spm) uses an environment variable +# (SPMFIREWALL) to specify where the firewall file is located. +# One may also start up the PortMaster (Spm -f firewallfilename). +# Please read the documentation on this. + +CC = cc +AR = ar + +OBJ = Saccept.o Sprintf.o Stest.o outofmem.o \ + Sclose.o Sprtskt.o Stimeoutwait.o rdcolor.o \ + Sgets.o Sputs.o Svprintf.o sprt.o \ + Smaskwait.o Sread.o Swait.o srmtrblk.o \ + Smkskt.o Sreadbytes.o Swrite.o stpblk.o \ + Sopen.o Srmsrvr.o error.o stpnxt.o \ + Sopenv.o Sscanf.o fopenv.o strnxtfmt.o \ + Speek.o cprt.o Speername.o Speeraddr.o \ + Sinit.o + +# LIB: name of library +LIB = simpleskts.a + +# EXETGT: where to put executables, as seen from the viewpoint of the EXE +# subdirectory +EXETGT=../EXE + +# usual compiler stuff +CFLAGS = -O -I./HDR +LOADLIBES = ../$(LIB) + +# for SCO UNIX: +# LOADLIBES = ../$(LIB) -lsocket + +# for Solaris 2.1 +# LOADLIBES = ../$(LIB) -lnsl + +# for g++ compiler: (tnx to Gary Johnson) +# CFLAGS= -Wall -ansi -pedantic -O -I./HDR + +# all : $(LIB) exes examples +all : $(LIB) + +$(LIB) : $(OBJ) + $(AR) r simpleskts.a *.o +# ranlib simpleskts.a +# /bin/rm -f *.o + @echo "finished updating simpleskts.a" + +exes : $(LIB) + ( cd EXE; \ + make CC=$(CC) LIB=$(LIB) CFLAGS="-O -I../HDR" LOADLIBES=$(LOADLIBES) EXETGT=$(EXETGT) ) + +examples : $(LIB) + ( cd EXAMPLES; \ + make CC=$(CC) LIB=$(LIB) CFLAGS="-O -I../HDR" LOADLIBES=$(LOADLIBES) ) + +distclean clean : + @/bin/rm -f *.a *.bak *.err $(OBJ) + (cd EXE; make clean ) + (cd EXAMPLES ; make clean ) + @echo "All object files, the simpleskts library, and executables are now gone" + +install : diff -Naur dmucs-0.6.1/ChangeLog dmucs-0.6.2/ChangeLog --- dmucs-0.6.1/ChangeLog 2006-07-20 16:18:09.000000000 +0000 +++ dmucs-0.6.2/ChangeLog 2007-04-23 15:57:14.000000000 +0000 @@ -33,3 +33,4 @@ 0.6.1 -- Fix compilation problems on Solaris with Solaris's cc compiler. Fix a few other minor things I found. +0.6.2 -- Add support for native Windows and cross-compilation. diff -Naur dmucs-0.6.1/Makefile.am dmucs-0.6.2/Makefile.am --- dmucs-0.6.1/Makefile.am 2006-05-19 19:12:10.000000000 +0000 +++ dmucs-0.6.2/Makefile.am 2007-04-23 15:23:41.000000000 +0000 @@ -1,22 +1,45 @@ SUBDIRS = COSMIC -bin_PROGRAMS = dmucs gethost loadavg monitor remhost +bin_PROGRAMS = gethost -dmucs_SOURCES = dmucs_resolve.cc dmucs_db.cc dmucs_host.cc \ - dmucs_hosts_file.cc dmucs_msg.cc dmucs_host_state.cc main.cc +if !NATIVE_WIN32 +bin_PROGRAMS += dmucs loadavg monitor remhost +endif + +LDADD = COSMIC/libsimpleskts.a +if NATIVE_WIN32 +LDADD += -lws2_32 +endif + +dmucs_headers = \ +dmucs.h \ +COSMIC/HDR/sockets.h \ +dmucs_resolve.h \ +dmucs_db.h \ +dmucs_dprop.h \ +dmucs_host.h \ +dmucs_hosts_file.h \ +dmucs_host_state.h \ +dmucs_msg.h \ +dmucs_pkt.h -LDADD = COSMIC/simpleskts.a +gethost_SOURCES = dmucs_resolve.cc gethost.cc $(dmucs_headers) -gethost_SOURCES = dmucs_resolve.cc gethost.cc +if !NATIVE_WIN32 +dmucs_SOURCES = dmucs_resolve.cc dmucs_db.cc dmucs_host.cc \ + dmucs_hosts_file.cc dmucs_msg.cc dmucs_host_state.cc main.cc \ + $(dmucs_headers) -loadavg_SOURCES = loadavg.cc +loadavg_SOURCES = loadavg.cc $(dmucs_headers) -monitor_SOURCES = monitor.cc +monitor_SOURCES = monitor.cc $(dmucs_headers) -remhost_SOURCES = remhost.cc +remhost_SOURCES = remhost.cc $(dmucs_headers) +endif # # Make -DPKGDATADIR= be passed on each compile. # AM_CPPFLAGS = -DPKGDATADIR=\"${pkgdatadir}\" +EXTRA_DIST = scripts/disable-host scripts/enable-host scripts/watch-ssaver diff -Naur dmucs-0.6.1/acinclude.m4 dmucs-0.6.2/acinclude.m4 --- dmucs-0.6.1/acinclude.m4 1970-01-01 00:00:00.000000000 +0000 +++ dmucs-0.6.2/acinclude.m4 2007-04-23 15:54:55.000000000 +0000 @@ -0,0 +1,47 @@ +dnl FreeBSD -pthread check - Jonathan McDowell +AC_DEFUN([AC_PTHREAD_FREEBSD], +[AC_MSG_CHECKING([if we need -pthread for threads]) +AC_CACHE_VAL(ac_ldflag_pthread, +[ac_save_LDFLAGS="$LDFLAGS" +LDFLAGS="-pthread $LDFLAGS" +AC_TRY_LINK( +[ +char pthread_create(); +], +pthread_create();, +eval "ac_ldflag_pthread=yes", +eval "ac_ldflag_pthread=no"), +LIBS="$ac_save_LDFLAGS" +]) +if eval "test \"`echo $ac_ldflag_pthread`\" = yes"; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +]) + +dnl @synopsis LIB_SOCKET_NSL +dnl +dnl This macro figures out what libraries are required on this platform +dnl to link sockets programs. +dnl +dnl The common cases are not to need any extra libraries, or to need +dnl -lsocket and -lnsl. We need to avoid linking with libnsl unless we +dnl need it, though, since on some OSes where it isn't necessary it +dnl will totally break networking. Unisys also includes gethostbyname() +dnl in libsocket but needs libnsl for socket(). +dnl +dnl @category Misc +dnl @author Russ Allbery +dnl @author Stepan Kasal +dnl @author Warren Young +dnl @version 2005-09-06 +dnl @license AllPermissive +dnl (Got this code from autoconf-archive.cryp.to.) +AC_DEFUN([LIB_SOCKET_NSL], +[ + AC_SEARCH_LIBS([gethostbyname], [nsl]) + AC_SEARCH_LIBS([socket], [socket], [], [ + AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], + [], [-lnsl])]) +]) diff -Naur dmucs-0.6.1/configure.ac dmucs-0.6.2/configure.ac --- dmucs-0.6.1/configure.ac 2006-07-20 16:18:09.000000000 +0000 +++ dmucs-0.6.2/configure.ac 2007-04-23 15:56:43.000000000 +0000 @@ -1,15 +1,16 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.58) -AC_INIT(dmucs, 0.5, vic.norman@gmail.com) +AC_PREREQ([2.58]) +AC_INIT([dmucs], [0.6.2], [vic.norman@gmail.com]) AC_CONFIG_SRCDIR([dmucs_msg.h]) AC_CONFIG_HEADER([config.h]) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([foreign -Wall]) # Checks for programs. AC_PROG_CXX AC_PROG_CC +AC_PROG_RANLIB # Checks for libraries. AC_CHECK_LIB([nsl], [gethostbyname]) @@ -85,55 +86,22 @@ AC_MSG_RESULT(no) ]) -dnl FreeBSD -pthread check - Jonathan McDowell -AC_DEFUN([AC_PTHREAD_FREEBSD], - [AC_MSG_CHECKING([if we need -pthread for threads]) - AC_CACHE_VAL(ac_ldflag_pthread, - [ac_save_LDFLAGS="$LDFLAGS" - LDFLAGS="-pthread $LDFLAGS" - AC_TRY_LINK([char pthread_create();], - pthread_create();, - eval "ac_ldflag_pthread=yes", - eval "ac_ldflag_pthread=no"), - LIBS="$ac_save_LDFLAGS" - ]) - if eval "test \"`echo $ac_ldflag_pthread`\" = yes"; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - ]) - AC_PTHREAD_FREEBSD +LIB_SOCKET_NSL - -dnl @synopsis LIB_SOCKET_NSL -dnl -dnl This macro figures out what libraries are required on this platform -dnl to link sockets programs. -dnl -dnl The common cases are not to need any extra libraries, or to need -dnl -lsocket and -lnsl. We need to avoid linking with libnsl unless we -dnl need it, though, since on some OSes where it isn't necessary it -dnl will totally break networking. Unisys also includes gethostbyname() -dnl in libsocket but needs libnsl for socket(). -dnl -dnl @category Misc -dnl @author Russ Allbery -dnl @author Stepan Kasal -dnl @author Warren Young -dnl @version 2005-09-06 -dnl @license AllPermissive -dnl (Got this code from autoconf-archive.cryp.to.) -AC_DEFUN([LIB_SOCKET_NSL], -[ - AC_SEARCH_LIBS([gethostbyname], [nsl]) - AC_SEARCH_LIBS([socket], [socket], [], [ - AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], - [], [-lnsl])]) +# Are we doing a native Windows build (not Cygwin) +AC_CACHE_CHECK([whether we are doing a native Windows build], + [ac_cv_native_windows], + [ac_cv_native_windows=no +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ +#ifndef _MSC_VER +# if !defined (WIN32) || defined (__CYGWIN__) +choke on me +# endif +#endif +]])], [ac_cv_native_windows=yes], [ac_cv_native_windows=no]) ]) +AM_CONDITIONAL([NATIVE_WIN32], [test x"$ac_cv_native_windows" = xyes]) -LIB_SOCKET_NSL - -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile COSMIC/Makefile]) AC_OUTPUT diff -Naur dmucs-0.6.1/dmucs_resolve.cc dmucs-0.6.2/dmucs_resolve.cc --- dmucs-0.6.1/dmucs_resolve.cc 2006-06-22 13:47:14.000000000 +0000 +++ dmucs-0.6.2/dmucs_resolve.cc 2007-04-23 06:40:46.000000000 +0000 @@ -21,16 +21,20 @@ #include "config.h" #include #include +#include +#ifdef WIN32 +#include +#else #include #include #include -#include #include #include +#endif #ifndef HAVE_GETHOSTBYADDR_R #ifdef HAVE_GETHOSTBYADDR -static pthread_mutex_t gethost_mutex = NULL; +static pthread_mutex_t gethost_mutex = NULL; #endif /* HAVE_GETHOSTBYADDR */ #endif /* !HAVE_GETHOSTBYADDR_R */ @@ -67,7 +71,13 @@ } pthread_mutex_unlock(&gethost_mutex); #else -#error HELP -- do not know how to compile gethostbyaddr + res = gethostbyaddr((char *)&(ipAddr.s_addr), sizeof(ipAddr.s_addr), + AF_INET); + if (res != NULL) { + strncpy(buffer, res->h_name, sizeof(buffer)); + buffer[sizeof(buffer) - 1] = '\0'; + he.h_name = buffer; + } #endif resolvedName = (res == NULL || res8 != 0) ? diff -Naur dmucs-0.6.1/gethost.cc dmucs-0.6.2/gethost.cc --- dmucs-0.6.1/gethost.cc 2006-06-22 13:47:14.000000000 +0000 +++ dmucs-0.6.2/gethost.cc 2007-04-23 14:41:45.000000000 +0000 @@ -22,14 +22,32 @@ #include "dmucs.h" #include "dmucs_resolve.h" #include -#include -#include -#include -#include + +# ifndef WIN32 +# ifdef _MSC_VER /* Are we compiling with Microsoft's compiler? */ +# define WIN32 +# endif +# endif /* !WIN32 */ + +#ifdef WIN32 +// This defines prevents Windows.h from including WinSock1 +# define _WINSOCKAPI_ +# include +# include +typedef int socklen_t; +# define WEXITSTATUS(W) (W) +# define waitpid(Pid, Status, Options) _cwait((Status), (Pid), WAIT_CHILD) +#else +# include +# include +# include +# include +# include +# include +# endif /* !WIN32 */ + #include #include -#include -#include #include #include #include @@ -38,7 +56,7 @@ #include "COSMIC/HDR/sockets.h" #ifdef HAVE_CONFIG_H -#include +# include #endif @@ -48,11 +66,13 @@ bool debugMode = false; +#if (! defined (__CYGWIN__) && ! defined (WIN32) && ! defined(__FreeBSD__)) void sigchld_handler(int stat) { int childstat; wait(&childstat); } +#endif int main(int argc, char *argv[]) @@ -68,7 +88,7 @@ * o Close the client socket. */ -#if (! defined (__CYGWIN__) && ! defined(__FreeBSD__)) +#if (! defined (__CYGWIN__) && ! defined (WIN32) && ! defined(__FreeBSD__)) /* install a SIGCHLD handler */ sigset(SIGCHLD, sigchld_handler); #endif @@ -226,6 +246,7 @@ } #endif +#ifdef HAVE_FORK int forkret = fork(); if (forkret == 0) { /* child process */ @@ -234,14 +255,19 @@ return -1; } return 0; - } else if (forkret < 0) { + } +#else + int forkret = _spawnvp(_P_NOWAIT, argv[nextarg], &argv[nextarg]); + DMUCS_DEBUG((stderr, "child process is %d\n", forkret)); +#endif + if (forkret < 0) { fprintf(stderr, "Failed to fork a process!\n"); return -1; } /* parent process -- just wait for the child */ int status = 0; - (void) wait(&status); + (void) waitpid(forkret, &status, 0); Sclose(client_sock);