~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to lib/tevent/tevent_util.h

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
   Unix SMB/CIFS implementation.
3
3
 
4
 
   Copyright (C) Andrew Tridgell 1998-2005
 
4
   Copyright (C) Andrew Tridgell 1998-2010
5
5
   Copyright (C) Jelmer Vernooij 2005
6
6
 
7
7
   This program is free software; you can redistribute it and/or modify
24
24
#ifndef _DLINKLIST_H
25
25
#define _DLINKLIST_H
26
26
 
27
 
 
28
 
/* hook into the front of the list */
 
27
/*
 
28
  February 2010 - changed list format to have a prev pointer from the
 
29
  list head. This makes DLIST_ADD_END() O(1) even though we only have
 
30
  one list pointer.
 
31
 
 
32
  The scheme is as follows:
 
33
 
 
34
     1) with no entries in the list:
 
35
          list_head == NULL
 
36
 
 
37
     2) with 1 entry in the list:
 
38
          list_head->next == NULL
 
39
          list_head->prev == list_head
 
40
 
 
41
     3) with 2 entries in the list:
 
42
          list_head->next == element2
 
43
          list_head->prev == element2
 
44
          element2->prev == list_head
 
45
          element2->next == NULL
 
46
 
 
47
     4) with N entries in the list:
 
48
          list_head->next == element2
 
49
          list_head->prev == elementN
 
50
          elementN->prev == element{N-1}
 
51
          elementN->next == NULL
 
52
 
 
53
  This allows us to find the tail of the list by using
 
54
  list_head->prev, which means we can add to the end of the list in
 
55
  O(1) time
 
56
 
 
57
 
 
58
  Note that the 'type' arguments below are no longer needed, but
 
59
  are kept for now to prevent an incompatible argument change
 
60
 */
 
61
 
 
62
 
 
63
/*
 
64
   add an element at the front of a list
 
65
*/
29
66
#define DLIST_ADD(list, p) \
30
67
do { \
31
68
        if (!(list)) { \
32
 
                (list) = (p); \
33
 
                (p)->next = (p)->prev = NULL; \
 
69
                (p)->prev = (list) = (p);  \
 
70
                (p)->next = NULL; \
34
71
        } else { \
 
72
                (p)->prev = (list)->prev; \
35
73
                (list)->prev = (p); \
36
74
                (p)->next = (list); \
37
 
                (p)->prev = NULL; \
38
75
                (list) = (p); \
39
 
        }\
 
76
        } \
40
77
} while (0)
41
78
 
42
 
/* remove an element from a list - element doesn't have to be in list. */
 
79
/*
 
80
   remove an element from a list
 
81
   Note that the element doesn't have to be in the list. If it
 
82
   isn't then this is a no-op
 
83
*/
43
84
#define DLIST_REMOVE(list, p) \
44
85
do { \
45
86
        if ((p) == (list)) { \
 
87
                if ((p)->next) (p)->next->prev = (p)->prev; \
46
88
                (list) = (p)->next; \
47
 
                if (list) (list)->prev = NULL; \
 
89
        } else if ((list) && (p) == (list)->prev) {     \
 
90
                (p)->prev->next = NULL; \
 
91
                (list)->prev = (p)->prev; \
48
92
        } else { \
49
93
                if ((p)->prev) (p)->prev->next = (p)->next; \
50
94
                if ((p)->next) (p)->next->prev = (p)->prev; \
51
95
        } \
52
 
        if ((p) != (list)) (p)->next = (p)->prev = NULL; \
53
 
} while (0)
54
 
 
55
 
/* promote an element to the top of the list */
56
 
#define DLIST_PROMOTE(list, p) \
57
 
do { \
58
 
          DLIST_REMOVE(list, p); \
59
 
          DLIST_ADD(list, p); \
60
 
} while (0)
61
 
 
62
 
/* hook into the end of the list - needs a tmp pointer */
63
 
#define DLIST_ADD_END(list, p, type) \
64
 
do { \
65
 
                if (!(list)) { \
66
 
                        (list) = (p); \
67
 
                        (p)->next = (p)->prev = NULL; \
68
 
                } else { \
69
 
                        type tmp; \
70
 
                        for (tmp = (list); tmp->next; tmp = tmp->next) ; \
71
 
                        tmp->next = (p); \
72
 
                        (p)->next = NULL; \
73
 
                        (p)->prev = tmp; \
74
 
                } \
75
 
} while (0)
 
96
        if ((p) != (list)) (p)->next = (p)->prev = NULL;        \
 
97
} while (0)
 
98
 
 
99
/*
 
100
   find the head of the list given any element in it.
 
101
   Note that this costs O(N), so you should avoid this macro
 
102
   if at all possible!
 
103
*/
 
104
#define DLIST_HEAD(p, result_head) \
 
105
do { \
 
106
       (result_head) = (p); \
 
107
       while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \
 
108
} while(0)
 
109
 
 
110
/* return the last element in the list */
 
111
#define DLIST_TAIL(list) ((list)?(list)->prev:NULL)
 
112
 
 
113
/* return the previous element in the list. */
 
114
#define DLIST_PREV(p) (((p)->prev && (p)->prev->next != NULL)?(p)->prev:NULL)
76
115
 
77
116
/* insert 'p' after the given element 'el' in a list. If el is NULL then
78
117
   this is the same as a DLIST_ADD() */
81
120
        if (!(list) || !(el)) { \
82
121
                DLIST_ADD(list, p); \
83
122
        } else { \
84
 
                p->prev = el; \
85
 
                p->next = el->next; \
86
 
                el->next = p; \
87
 
                if (p->next) p->next->prev = p; \
 
123
                (p)->prev = (el);   \
 
124
                (p)->next = (el)->next;         \
 
125
                (el)->next = (p);               \
 
126
                if ((p)->next) (p)->next->prev = (p);   \
 
127
                if ((list)->prev == (el)) (list)->prev = (p); \
88
128
        }\
89
129
} while (0)
90
130
 
91
 
/* demote an element to the end of the list, needs a tmp pointer */
92
 
#define DLIST_DEMOTE(list, p, tmp) \
93
 
do { \
94
 
                DLIST_REMOVE(list, p); \
95
 
                DLIST_ADD_END(list, p, tmp); \
96
 
} while (0)
97
 
 
98
 
/* concatenate two lists - putting all elements of the 2nd list at the
99
 
   end of the first list */
100
 
#define DLIST_CONCATENATE(list1, list2, type) \
101
 
do { \
102
 
                if (!(list1)) { \
103
 
                        (list1) = (list2); \
104
 
                } else { \
105
 
                        type tmp; \
106
 
                        for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
107
 
                        tmp->next = (list2); \
108
 
                        if (list2) { \
109
 
                                (list2)->prev = tmp;    \
110
 
                        } \
 
131
 
 
132
/*
 
133
   add to the end of a list.
 
134
   Note that 'type' is ignored
 
135
*/
 
136
#define DLIST_ADD_END(list, p, type)                    \
 
137
do { \
 
138
        if (!(list)) { \
 
139
                DLIST_ADD(list, p); \
 
140
        } else { \
 
141
                DLIST_ADD_AFTER(list, p, (list)->prev); \
 
142
        } \
 
143
} while (0)
 
144
 
 
145
/* promote an element to the from of a list */
 
146
#define DLIST_PROMOTE(list, p) \
 
147
do { \
 
148
          DLIST_REMOVE(list, p); \
 
149
          DLIST_ADD(list, p); \
 
150
} while (0)
 
151
 
 
152
/*
 
153
   demote an element to the end of a list.
 
154
   Note that 'type' is ignored
 
155
*/
 
156
#define DLIST_DEMOTE(list, p, type)                     \
 
157
do { \
 
158
        DLIST_REMOVE(list, p); \
 
159
        DLIST_ADD_END(list, p, NULL);           \
 
160
} while (0)
 
161
 
 
162
/*
 
163
   concatenate two lists - putting all elements of the 2nd list at the
 
164
   end of the first list.
 
165
   Note that 'type' is ignored
 
166
*/
 
167
#define DLIST_CONCATENATE(list1, list2, type)   \
 
168
do { \
 
169
        if (!(list1)) { \
 
170
                (list1) = (list2); \
 
171
        } else { \
 
172
                (list1)->prev->next = (list2); \
 
173
                if (list2) { \
 
174
                        void *_tmplist = (void *)(list1)->prev; \
 
175
                        (list1)->prev = (list2)->prev; \
 
176
                        (list2)->prev = _tmplist; \
111
177
                } \
 
178
        } \
112
179
} while (0)
113
180
 
114
181
#endif /* _DLINKLIST_H */