X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fldap_queue.h;h=0de4c9eefa84ec7ae83b235325aec6e803f831a6;hb=51f1b8ccd760da9fb347af452114d5a3b34eda61;hp=7366a2165278c6a323fa1c83bbcbf507823bf5a1;hpb=3dac1295271803ab142139def14fdf3c7d220f61;p=openldap
diff --git a/include/ldap_queue.h b/include/ldap_queue.h
index 7366a21652..0de4c9eefa 100644
--- a/include/ldap_queue.h
+++ b/include/ldap_queue.h
@@ -1,17 +1,19 @@
-/*
- * Copyright 2001 The OpenLDAP Foundation, Redwood City, California, USA
+/* ldap_queue.h -- queue macros */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2001-2003 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
+ * .
*/
-/* 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
@@ -44,6 +46,12 @@
*
* @(#)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_
@@ -135,6 +143,9 @@ struct { \
struct type *sle_next; /* next element */ \
}
+#define LDAP_SLIST_ENTRY_INITIALIZER(entry) \
+ { NULL }
+
/*
* Singly-linked List functions.
*/
@@ -195,6 +206,9 @@ struct { \
struct type *stqe_next; /* next element */ \
}
+#define LDAP_STAILQ_ENTRY_INITIALIZER(entry) \
+ { NULL }
+
/*
* Singly-linked Tail queue functions.
*/
@@ -278,6 +292,9 @@ struct { \
struct type **le_prev; /* address of previous next element */ \
}
+#define LDAP_LIST_ENTRY_INITIALIZER(entry) \
+ { NULL, NULL }
+
/*
* List functions.
*/
@@ -342,28 +359,37 @@ 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, headname, field) \
- for ((var) = LDAP_TAILQ_LAST((head), headname); \
+#define LDAP_TAILQ_FOREACH_REVERSE(var, head, type, field) \
+ for ((var) = LDAP_TAILQ_LAST((head), type, field); \
(var); \
- (var) = LDAP_TAILQ_PREV((var), headname, field))
+ (var) = LDAP_TAILQ_PREV((var), head, type, field))
#define LDAP_TAILQ_FIRST(head) ((head)->tqh_first)
-#define LDAP_TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define LDAP_TAILQ_LAST(head, type, field) \
+ (LDAP_TAILQ_EMPTY(head) ? \
+ NULL : \
+ ((struct type *) \
+ ((char *)((head)->tqh_last) - offsetof(struct type, field))))
#define LDAP_TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-#define LDAP_TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+#define LDAP_TAILQ_PREV(elm, head, type, field) \
+ ((struct type *)((elm)->field.tqe_prev) == LDAP_TAILQ_FIRST(head) ? \
+ NULL : \
+ ((struct type *) \
+ ((char *)((elm)->field.tqe_prev) - offsetof(struct type, field))))
#define LDAP_TAILQ_INIT(head) do { \
(head)->tqh_first = NULL; \