On 6/24/05, abe-t <[EMAIL PROTECTED]> wrote:
> Update of /cvsroot/naviserver/naviserver/nsd
> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15355/nsd
> 
> Modified Files:
>         driver.c binder.c
> Log Message:
>   Excluded Unix calls from Windows code since some of the structs needed
>     to compile them are missing in Windows.
> 
> 
> Index: driver.c
> ===================================================================
> RCS file: /cvsroot/naviserver/naviserver/nsd/driver.c,v
> retrieving revision 1.14
> retrieving revision 1.15
> diff -C2 -d -r1.14 -r1.15
> *** driver.c    19 Jun 2005 16:31:58 -0000      1.14
> --- driver.c    24 Jun 2005 08:36:29 -0000      1.15
> ***************
> *** 448,453 ****
> --- 448,455 ----
>           if (drvPtr->opts & NS_DRIVER_UDP) {
>               drvPtr->sock = Ns_SockListenUdp(drvPtr->bindaddr, drvPtr->port);
> + #ifndef _WIN32
>           } else if (drvPtr->opts & NS_DRIVER_UNIX) {
>               drvPtr->sock = Ns_SockListenUnix(drvPtr->bindaddr);
> + #endif
>           } else {
>               drvPtr->sock = Ns_SockListenEx(drvPtr->bindaddr, drvPtr->port,
> 
> Index: binder.c
> ===================================================================
> RCS file: /cvsroot/naviserver/naviserver/nsd/binder.c,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -C2 -d -r1.9 -r1.10
> *** binder.c    15 Jun 2005 04:14:04 -0000      1.9
> --- binder.c    24 Jun 2005 08:36:29 -0000      1.10
> ***************
> *** 36,40 ****
> 
>   #include "nsd.h"
> ! #include <sys/un.h>
> 
>   NS_RCSID("@(#) $Header$");
> --- 36,43 ----
> 
>   #include "nsd.h"
> !
> ! #ifndef _WIN32
> ! # include <sys/un.h>
> ! #endif
> 
>   NS_RCSID("@(#) $Header$");
> ***************
> *** 52,56 ****
>   #ifndef _WIN32
>   static void PreBind(char *line);
> - #endif
> 
> 
> --- 55,58 ----
> ***************
> *** 103,107 ****
>       return (SOCKET)sock;
>   }
> !
> 
>   /*
> --- 105,109 ----
>       return (SOCKET)sock;
>   }
> ! #endif /* _WIN32 */
> 
>   /*
> ***************
> *** 189,192 ****
> --- 191,195 ----
> 
> 
> + #ifndef _WIN32
>   /*
>    *----------------------------------------------------------------------
> ***************
> *** 237,241 ****
>       return (SOCKET)sock;
>   }
> !
> 
>   /*
> --- 240,244 ----
>       return (SOCKET)sock;
>   }
> ! #endif /* _WIN32 */
> 
>   /*
> ***************
> *** 275,278 ****
> --- 278,282 ----
> 
> 
> + #ifndef _WIN32
>   /*
>    *----------------------------------------------------------------------
> ***************
> *** 315,319 ****
>       return (SOCKET)sock;
>   }
> !
> 
>   /*
> --- 319,323 ----
>       return (SOCKET)sock;
>   }
> ! #endif /* _WIN32 */
> 
>   /*


You could have the functions return an error for Windows rather than
defining them out.  Something like::


SOCKET
Ns_SockListenUnix(char *path)
{
    int sock = -1;
    Tcl_HashEntry *hPtr;
    Tcl_HashSearch search;

+#ifdef _WIN32
+    Ns_Log(Error, "AF_UNIX sockets not supported on Windows: %s", path);
+    return -1;
+#else
+    Ns_MutexLock(&lock);
+    ...
+#endif


This has the advantage that you don't also have to ifdef around the
use of this function, as is done for the prebind functions and use of
Ns_SockListenUnix in driver.c.  It's easier for module writers, too.

I'm not sure why Ns_SockListenEx is no longer available on Windows. 
This is for simple TCP sockets, and it's called by Ns_SockListen in
sock.c.

Reply via email to