From 426104d68d6a92f5781ce02b698597e6010e4540 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Sun, 15 Feb 2004 01:36:56 +0000 Subject: [PATCH] Fix for building under linux (no ipv6) and add in the library file. --- ChangeLog | 5 +++++ Makefile.in | 23 +++++++++++++++-------- generic/udp_tcl.c | 38 +++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index e734115..75123a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-02-14 Pat Thoyts + + * generic/udp_tcl.c: Fix to build under Linux (no ipv6) + * Makefile: Add installation for the library files. + 2004-02-13 Pat Thoyts * generic/udp_tcl.c: An extensive interface rewrite. We now have diff --git a/Makefile.in b/Makefile.in index dde947d..13a9809 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/generic/udp_tcl.c b/generic/udp_tcl.c index 187729a..129c317 100644 --- a/generic/udp_tcl.c +++ b/generic/udp_tcl.c @@ -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 */ -- 2.23.0