Fix for building under linux (no ipv6) and add in the library file.
authorpatthoyts <patthoyts>
Sun, 15 Feb 2004 01:36:56 +0000 (01:36 +0000)
committerpatthoyts <patthoyts>
Sun, 15 Feb 2004 01:36:56 +0000 (01:36 +0000)
ChangeLog
Makefile.in
generic/udp_tcl.c

index e734115abc796fa5c50aa61e2fe466baae09c034..75123a4c8fdb49dac970e42a75bdcf8f56e6f27c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-14  Pat Thoyts  <patthoyts@users.sourceforge.net>
+
+       * generic/udp_tcl.c: Fix to build under Linux (no ipv6)
+       * Makefile: Add installation for the library files.
+
 2004-02-13  Pat Thoyts  <patthoyts@users.sourceforge.net>
 
        * generic/udp_tcl.c: An extensive interface rewrite. We now have
index dde947d98a18e8c1cde206ca96b7e7b6761d8f6a..13a9809c40e3a84f8716c3a7b73958ce2d0683ed 100644 (file)
@@ -27,7 +27,7 @@
 # unix subdirectory.
 #========================================================================
 
-udp_SOURCES    = $(srcdir)/generic/udp_tcl.c
+udp_SOURCES    = udp_tcl.c
 
 WIN_SOURCES    =
 UNIX_SOURCES   = 
@@ -93,6 +93,8 @@ datadir               = @datadir@
 mandir         = @mandir@
 includedir     = @includedir@
 
+TCLUDP_LIBRARY  = $(srcdir)/library
+
 DESTDIR                =
 
 PKG_DIR                = $(PACKAGE)$(VERSION)
@@ -180,7 +182,7 @@ COMPILE             = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(C
 # for the BINARIES that you specified above have already been done.
 #========================================================================
 
-all: binaries #libraries doc
+all: binaries libraries #doc
 
 #========================================================================
 # The binaries target builds executable programs, Windows .dll's, unix
@@ -211,12 +213,17 @@ install-binaries: binaries install-lib-binaries install-bin-binaries
 #========================================================================
 
 install-libraries: libraries
-       @mkdir -p $(DESTDIR)$(includedir)
-       @echo "Installing header files in $(DESTDIR)$(includedir)"
-       @for i in $(GENERIC_HDRS) ; do \
-           echo "Installing $$i" ; \
-           $(INSTALL_DATA) $$i $(DESTDIR)$(includedir) ; \
-       done;
+       @echo "Installing script library files in $(DESTDIR)$(pkglibdir)"
+       @for i in $(srcdir)/library/*.tcl; do \
+           echo "Installing $$i"; \
+           $(INSTALL_DATA) $$i $(DESTDIR)$(pkglibdir) ; \
+       done
+#      @mkdir -p $(DESTDIR)$(includedir)
+#      @echo "Installing header files in $(DESTDIR)$(includedir)"
+#      @for i in $(GENERIC_HDRS) ; do \
+#          echo "Installing $$i" ; \
+#          $(INSTALL_DATA) $$i $(DESTDIR)$(includedir) ; \
+#      done;
 
 #========================================================================
 # Install documentation.  Unix manpages should go in the $(mandir)
index 187729ae86fb89d8eb2458cbb8174d7bad997d71..129c31764649c824513052058bdcdaa2cdcfb535 100644 (file)
@@ -561,13 +561,7 @@ UdpPeek(ClientData clientData, Tcl_Interp *interp,
     int actual_size, socksize;
     int sock;
     char message[17];
-    /*struct hostent *name;*/
-#ifdef SIPC_IPV6
-    char *remotehost;
-    struct sockaddr_in6 recvaddr;
-#else
-    struct sockaddr_in recvaddr;
-#endif
+    sockaddr_t recvaddr;
     Tcl_Channel chan;
     UdpState *statePtr;
     
@@ -582,6 +576,8 @@ UdpPeek(ClientData clientData, Tcl_Interp *interp,
         buffer_size = atoi(argv[2]);
         if (buffer_size > 16) buffer_size = 16;
     }
+
+    socksize = sizeof(sockaddr_t);
     actual_size = recvfrom(sock, message, buffer_size, MSG_PEEK,
                            (struct sockaddr *)&recvaddr, &socksize);
     
@@ -590,15 +586,13 @@ UdpPeek(ClientData clientData, Tcl_Interp *interp,
         Tcl_AppendResult(interp, errBuf, (char *)NULL);
         return TCL_ERROR;
     }
-#ifdef SIPC_IPV6
-    memcpy(&statePtr->saddr6_peer, &recvaddr, sizeof(recvaddr));
-#else
     memcpy(&statePtr->saddr_peer, &recvaddr, sizeof(recvaddr));
-#endif
-    message[16]='\0';
+    message[actual_size]='\0';
     
+    Tcl_ResetResult(interp);
     Tcl_AppendResult(interp, message, (char *)NULL);
     return TCL_OK;
+
 #else /* WIN32 */
     Tcl_SetResult(interp, "udp_peek not implemented for this platform",
                   TCL_STATIC);
@@ -976,15 +970,15 @@ static void
 udpWatch(ClientData instanceData, int mask)
 {
 #ifndef WIN32
-    UdpState *fsPtr = (UdpState *) instanceData;
+    UdpState *statePtr = (UdpState *) instanceData;
     if (mask) {
         UDPTRACE("Tcl_CreateFileHandler\n");
-        Tcl_CreateFileHandler(fsPtr->sock, mask,
+        Tcl_CreateFileHandler(statePtr->sock, mask,
                               (Tcl_FileProc *) Tcl_NotifyChannel,
-                              (ClientData) fsPtr->channel);
+                              (ClientData) statePtr->channel);
     } else {
         UDPTRACE("Tcl_DeleteFileHandler\n");
-        Tcl_DeleteFileHandler(fsPtr->sock);
+        Tcl_DeleteFileHandler(statePtr->sock);
     }
 #endif
 }
@@ -1135,14 +1129,16 @@ udpInput(ClientData instanceData, char *buf, int bufSize, int *errorCode)
     memcpy(&statePtr->saddr_peer, &recvaddr, sizeof(recvaddr));
     
 #ifdef SIPC_IPV6
-    inet_ntop(recvaddr.sin_family, &statePtr->saddr_peer.sin_addr, 
-        number, 128);
+    inet_ntop(recvaddr.ipv6.sin_family,
+              &statePtr->saddr_peer.ipv6.sin_addr, 
+              number, 128);
 #else
-    inet_ntop(statePtr->saddr_peer.sin_family, &statePtr->saddr_peer.sin_addr, 
-        number, 128);
+    inet_ntop(statePtr->saddr_peer.ipv4.sin_family, 
+              &statePtr->saddr_peer.ipv4.sin_addr, 
+              number, 128);
 #endif
 
-    UDPTRACE("remotehost: %s:%d\n", number, ntohs(recvaddr.sin6_port));
+    UDPTRACE("remotehost: %s:%d\n", number, ntohs(recvaddr.ipv6.sin6_port));
 
 #endif /* ! WIN32 */