]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r19178: fix the standalone build of socket_wrapper by not using
authorStefan Metzmacher <metze@samba.org>
Sun, 8 Oct 2006 21:53:09 +0000 (21:53 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:20:50 +0000 (14:20 -0500)
samba's DLIST_ macros

metze
(This used to be commit 82abc39b559ccae832dd749495ebcfdffc2e5755)

source4/lib/socket_wrapper/socket_wrapper.c

index e3c0592085878287296334ee1eb65a0cedd104fc..3a72c5a74a0ecd0826c2b751110eaaa857f1d98c 100644 (file)
 #include "system/network.h"
 #include "system/filesys.h"
 
-#ifndef _DLINKLIST_H
-#include "lib/util/dlinklist.h"
-#endif
-
 #ifdef malloc
 #undef malloc
 #endif
 
 #define _PUBLIC_
 
-#error "dlinklist.h missing"
-
 #endif
 
+#define SWRAP_DLIST_ADD(list,item) do { \
+       if (!(list)) { \
+               (item)->prev    = NULL; \
+               (item)->next    = NULL; \
+               (list)          = (item); \
+       } else { \
+               (item)->prev    = NULL; \
+               (item)->next    = (list); \
+               (list)->prev    = (item); \
+               (list)          = (item); \
+       } \
+} while (0)
+
+#define SWRAP_DLIST_REMOVE(list,item) do { \
+       if ((list) == (item)) { \
+               (list)          = (item)->next; \
+               if (list) { \
+                       (list)->prev    = NULL; \
+               } \
+       } else { \
+               if ((item)->prev) { \
+                       (item)->prev->next      = (item)->next; \
+               } \
+               if ((item)->next) { \
+                       (item)->next->prev      = (item)->prev; \
+               } \
+       } \
+       (item)->prev    = NULL; \
+       (item)->next    = NULL; \
+} while (0)
+
 /* LD_PRELOAD doesn't work yet, so REWRITE_CALLS is all we support
  * for now */
 #define REWRITE_CALLS 
@@ -1076,7 +1101,7 @@ _PUBLIC_ int swrap_socket(int family, int type, int protocol)
        si->protocol = protocol;
        si->fd = fd;
 
-       DLIST_ADD(sockets, si);
+       SWRAP_DLIST_ADD(sockets, si);
 
        return si->fd;
 }
@@ -1145,7 +1170,7 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
        child_si->peername_len = *addrlen;
        child_si->peername = sockaddr_dup(addr, *addrlen);
 
-       DLIST_ADD(sockets, child_si);
+       SWRAP_DLIST_ADD(sockets, child_si);
 
        swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_SEND, NULL, 0);
        swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_RECV, NULL, 0);
@@ -1545,7 +1570,7 @@ _PUBLIC_ int swrap_close(int fd)
                return real_close(fd);
        }
 
-       DLIST_REMOVE(sockets, si);
+       SWRAP_DLIST_REMOVE(sockets, si);
 
        if (si->myname && si->peername) {
                swrap_dump_packet(si, NULL, SWRAP_CLOSE_SEND, NULL, 0);