]> git.sur5r.net Git - openldap/blobdiff - include/ldap_queue.h
ITS#5231 from HEAD
[openldap] / include / ldap_queue.h
index 78852f427aa275a9c93f925193c9e7b9161e7583..b880cc3a98d164cd3deb2ca8c3aad2b7e35d4686 100644 (file)
@@ -1,17 +1,19 @@
-/*
- * Copyright 2001-2002 The OpenLDAP Foundation, Redwood City, California, USA
+/* ldap_queue.h -- queue macros */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2001-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted only as authorized by the OpenLDAP
- * Public License.  A copy of this license is available at
- * http://www.OpenLDAP.org/license.html or in file LICENSE in the
- * top-level directory of the distribution.
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
-/* stolen from FreeBSD for use in OpenLDAP */
-/* $OpenLDAP$ */
-/*
- * Copyright (c) 1991, 1993
+/* Copyright (c) 1991, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  *
  *     @(#)queue.h     8.5 (Berkeley) 8/20/94
  * $FreeBSD: src/sys/sys/queue.h,v 1.32.2.5 2001/09/30 21:12:54 luigi Exp $
+ *
+ * See also: ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work is derived from FreeBSD queue.h work.  Adapted for use in
+ * OpenLDAP Software by Kurt D. Zeilenga.
  */
 
 #ifndef _LDAP_QUEUE_H_
  * _HEAD               +       +       +       +       +
  * _ENTRY              +       +       +       +       +
  * _INIT               +       +       +       +       +
+ * _ENTRY_INIT         +       +       +       +       +
  * _EMPTY              +       +       +       +       +
  * _FIRST              +       +       +       +       +
  * _NEXT               +       +       +       +       +
@@ -135,6 +144,9 @@ struct {                                                            \
        struct type *sle_next;  /* next element */                      \
 }
 
+#define LDAP_SLIST_ENTRY_INITIALIZER(entry)                            \
+       { NULL }
+
 /*
  * Singly-linked List functions.
  */
@@ -149,6 +161,10 @@ struct {                                                           \
        (head)->slh_first = NULL;                                       \
 }
 
+#define LDAP_SLIST_ENTRY_INIT(var, field) {                            \
+       (var)->field.sle_next = NULL;                                   \
+}
+
 #define LDAP_SLIST_INSERT_AFTER(slistelm, elm, field) do {             \
        (elm)->field.sle_next = (slistelm)->field.sle_next;             \
        (slistelm)->field.sle_next = (elm);                             \
@@ -195,6 +211,9 @@ struct {                                                            \
        struct type *stqe_next; /* next element */                      \
 }
 
+#define LDAP_STAILQ_ENTRY_INITIALIZER(entry)                           \
+       { NULL }
+
 /*
  * Singly-linked Tail queue functions.
  */
@@ -205,6 +224,10 @@ struct {                                                           \
        (head)->stqh_last = &(head)->stqh_first;                        \
 } while (0)
 
+#define LDAP_STAILQ_ENTRY_INIT(var, field) {                           \
+       (entry)->field.stqe_next = NULL;                                \
+}
+
 #define LDAP_STAILQ_FIRST(head)        ((head)->stqh_first)
 
 #define        LDAP_STAILQ_LAST(head, type, field)                             \
@@ -278,6 +301,9 @@ struct {                                                            \
        struct type **le_prev;  /* address of previous next element */  \
 }
 
+#define LDAP_LIST_ENTRY_INITIALIZER(entry)                     \
+       { NULL, NULL }
+
 /*
  * List functions.
  */
@@ -293,6 +319,11 @@ struct {                                                           \
        (head)->lh_first = NULL;                                        \
 } while (0)
 
+#define LDAP_LIST_ENTRY_INIT(var, field) do {                          \
+       (var)->field.le_next = NULL;                                    \
+       (var)->field.le_prev = NULL;                                    \
+} while (0)
+
 #define LDAP_LIST_INSERT_AFTER(listelm, elm, field) do {               \
        if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)  \
                (listelm)->field.le_next->field.le_prev =               \
@@ -342,13 +373,16 @@ struct {                                                          \
        struct type **tqe_prev; /* address of previous next element */  \
 }
 
+#define LDAP_TAILQ_ENTRY_INITIALIZER(entry)                            \
+       { NULL, NULL }
+
 /*
  * Tail queue functions.
  */
 #define        LDAP_TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
 
 #define LDAP_TAILQ_FOREACH(var, head, field)                           \
-       for (var = LDAP_TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
+       for (var = LDAP_TAILQ_FIRST(head); var; var = LDAP_TAILQ_NEXT(var, field))
 
 #define LDAP_TAILQ_FOREACH_REVERSE(var, head, type, field)             \
        for ((var) = LDAP_TAILQ_LAST((head), type, field);              \
@@ -376,6 +410,11 @@ struct {                                                           \
        (head)->tqh_last = &(head)->tqh_first;                          \
 } while (0)
 
+#define LDAP_TAILQ_ENTRY_INIT(var, field) do {                         \
+       (var)->field.tqe_next = NULL;                                   \
+       (var)->field.tqe_prev = NULL;                                   \
+} while (0)
+
 #define LDAP_TAILQ_INSERT_HEAD(head, elm, field) do {                  \
        if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \
                (head)->tqh_first->field.tqe_prev =                     \
@@ -456,6 +495,11 @@ struct {                                                           \
        (head)->cqh_last = (void *)(head);                              \
 } while (0)
 
+#define LDAP_CIRCLEQ_ENTRY_INIT(var, field) do {                       \
+       (var)->field.cqe_next = NULL;                                   \
+       (var)->field.cqe_prev = NULL;                                   \
+} while (0)
+
 #define LDAP_CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {      \
        (elm)->field.cqe_next = (listelm)->field.cqe_next;              \
        (elm)->field.cqe_prev = (listelm);                              \