summaryrefslogtreecommitdiff
path: root/source4/lib/util
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-08-30 11:29:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:16:54 -0500
commit0329d755a7611ba3897fc1ee9bdce410cc33d7f8 (patch)
tree93a738001fad5d9c2c9cc9efbcba00a4ad0b9450 /source4/lib/util
parent6c68f1ae9ec1ef6afbde634cd0ea591860916524 (diff)
downloadsamba-0329d755a7611ba3897fc1ee9bdce410cc33d7f8.tar.gz
samba-0329d755a7611ba3897fc1ee9bdce410cc33d7f8.tar.bz2
samba-0329d755a7611ba3897fc1ee9bdce410cc33d7f8.zip
r17930: Merge noinclude branch:
* Move dlinklist.h, smb.h to subsystem-specific directories * Clean up ads.h and move what is left of it to dsdb/ (only place where it's used) (This used to be commit f7afa1cb77f3cfa7020b57de12e6003db7cfcc42)
Diffstat (limited to 'source4/lib/util')
-rw-r--r--source4/lib/util/dlinklist.h109
-rw-r--r--source4/lib/util/util.h1
-rw-r--r--source4/lib/util/util_str.c2
3 files changed, 110 insertions, 2 deletions
diff --git a/source4/lib/util/dlinklist.h b/source4/lib/util/dlinklist.h
new file mode 100644
index 0000000000..527b211cd3
--- /dev/null
+++ b/source4/lib/util/dlinklist.h
@@ -0,0 +1,109 @@
+/*
+ Unix SMB/CIFS implementation.
+ some simple double linked list macros
+ Copyright (C) Andrew Tridgell 1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/* To use these macros you must have a structure containing a next and
+ prev pointer */
+
+
+/* hook into the front of the list */
+#define DLIST_ADD(list, p) \
+do { \
+ if (!(list)) { \
+ (list) = (p); \
+ (p)->next = (p)->prev = NULL; \
+ } else { \
+ (list)->prev = (p); \
+ (p)->next = (list); \
+ (p)->prev = NULL; \
+ (list) = (p); \
+ }\
+} while (0)
+
+/* remove an element from a list - element doesn't have to be in list. */
+#define DLIST_REMOVE(list, p) \
+do { \
+ if ((p) == (list)) { \
+ (list) = (p)->next; \
+ if (list) (list)->prev = NULL; \
+ } else { \
+ if ((p)->prev) (p)->prev->next = (p)->next; \
+ if ((p)->next) (p)->next->prev = (p)->prev; \
+ } \
+ if ((p) != (list)) (p)->next = (p)->prev = NULL; \
+} while (0)
+
+/* promote an element to the top of the list */
+#define DLIST_PROMOTE(list, p) \
+do { \
+ DLIST_REMOVE(list, p); \
+ DLIST_ADD(list, p); \
+} while (0)
+
+/* hook into the end of the list - needs a tmp pointer */
+#define DLIST_ADD_END(list, p, type) \
+do { \
+ if (!(list)) { \
+ (list) = (p); \
+ (p)->next = (p)->prev = NULL; \
+ } else { \
+ type tmp; \
+ for (tmp = (list); tmp->next; tmp = tmp->next) ; \
+ tmp->next = (p); \
+ (p)->next = NULL; \
+ (p)->prev = tmp; \
+ } \
+} while (0)
+
+/* insert 'p' after the given element 'el' in a list. If el is NULL then
+ this is the same as a DLIST_ADD() */
+#define DLIST_ADD_AFTER(list, p, el) \
+do { \
+ if (!(list) || !(el)) { \
+ DLIST_ADD(list, p); \
+ } else { \
+ p->prev = el; \
+ p->next = el->next; \
+ el->next = p; \
+ if (p->next) p->next->prev = p; \
+ }\
+} while (0)
+
+/* demote an element to the end of the list, needs a tmp pointer */
+#define DLIST_DEMOTE(list, p, tmp) \
+do { \
+ DLIST_REMOVE(list, p); \
+ DLIST_ADD_END(list, p, tmp); \
+} while (0)
+
+/* concatenate two lists - putting all elements of the 2nd list at the
+ end of the first list */
+#define DLIST_CONCATENATE(list1, list2, type) \
+do { \
+ if (!(list1)) { \
+ (list1) = (list2); \
+ } else { \
+ type tmp; \
+ for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
+ tmp->next = (list2); \
+ if (list2) { \
+ (list2)->prev = tmp; \
+ } \
+ } \
+} while (0)
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index 2517966d90..c7acc2ea33 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -22,7 +22,6 @@
#ifndef _SAMBA_UTIL_H_
#define _SAMBA_UTIL_H_
-#include "core.h"
#include "charset/charset.h"
/**
diff --git a/source4/lib/util/util_str.c b/source4/lib/util/util_str.c
index 62869198c3..163ef3828e 100644
--- a/source4/lib/util/util_str.c
+++ b/source4/lib/util/util_str.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-#include "smb.h"
+#include "libcli/raw/smb.h"
#include "pstring.h"
#include "lib/ldb/include/ldb.h"
#include "system/locale.h"