tst7 checks for memory leaks
[yaz-moved-to-github.git] / comstack / unix.c
index fa26bb8..0cccf5f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2002, Index Data
  * See the file LICENSE for details.
  *
- * $Id: unix.c,v 1.3 2002-07-03 13:36:55 adam Exp $
+ * $Id: unix.c,v 1.6 2002-09-20 22:23:13 adam Exp $
  * UNIX socket COMSTACK. By Morten Bøgeskov.
  */
 #ifndef WIN32
 /* Chas added the following, so we get the definition of completeBER */
 #include <yaz/odr.h>
 
+#ifndef YAZ_SOCKLEN_T
+#define YAZ_SOCKLEN_T int
+#endif
+
 int unix_close(COMSTACK h);
 int unix_put(COMSTACK h, char *buf, int size);
 int unix_get(COMSTACK h, char **buf, int *bufsize);
@@ -43,6 +47,10 @@ COMSTACK unix_accept(COMSTACK h);
 char *unix_addrstr(COMSTACK h);
 void *unix_straddr(COMSTACK h, const char *str);
 
+#ifndef SUN_LEN
+#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
+                     + strlen ((ptr)->sun_path))
+#endif
 #if 0
 #define TRC(x) x
 #else
@@ -301,11 +309,7 @@ int unix_listen(COMSTACK h, char *raddr, int *addrlen,
                void *cd)
 {
     struct sockaddr_un addr;
-#ifdef __cplusplus
-    socklen_t len = SUN_LEN(&addr);
-#else
-    int len = SUN_LEN(&addr);
-#endif
+    YAZ_SOCKLEN_T len = SUN_LEN(&addr);
 
     TRC(fprintf(stderr, "unix_listen pid=%d\n", getpid()));
     if (h->state != CS_ST_IDLE)