Mercurial > dovecot > originalhg > dovecot1.2
annotate src/lib/aqueue.h @ 9191:b340ecb24469 HEAD
Fix VPATH build of RQUOTA support.
Some rpcgen derive #include "..." paths from the infile argument.
This will be off for VPATH builds, as the generated rquota_xdr.c
code will look in $(srcdir), but we'll generate the rquota.h file in
$(builddir). Play safe and copy rquota.x to $(builddir) first.
This fixes the build on openSUSE 11.1.
author  Matthias Andree <matthias.andree@gmx.de> 

date  Tue, 07 Jul 2009 21:01:36 +0200 
parents  81806d402514 
children 
rev  line source 

7079
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

1 #ifndef AQUEUE_H 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

2 #define AQUEUE_H 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

3 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

4 /* Dynamically growing queue. Use the array directly to access the data, 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

5 for example: 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

6 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

7 count = queue_count(queue); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

8 for (i = 0; i < count; i++) { 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

9 data = array[queue_idx(i)]; 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

10 } 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

11 */ 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

12 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

13 struct aqueue { 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

14 struct array *arr; 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

15 unsigned int head, tail, area_size; 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

16 bool full; 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

17 }; 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

18 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

19 struct aqueue *aqueue_init(struct array *array); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

20 void aqueue_deinit(struct aqueue **aqueue); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

21 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

22 /* Append item to head */ 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

23 void aqueue_append(struct aqueue *aqueue, const void *data); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

24 /* Delete last item from tail */ 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

25 void aqueue_delete_tail(struct aqueue *aqueue); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

26 /* Remove item from n'th position */ 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

27 void aqueue_delete(struct aqueue *aqueue, unsigned int n); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

28 /* Clear the entire aqueue */ 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

29 void aqueue_clear(struct aqueue *aqueue); 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

30 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

31 /* Returns the number of items in aqueue. */ 
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
7079
diff
changeset

32 unsigned int aqueue_count(const struct aqueue *aqueue) ATTR_PURE; 
7079
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

33 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

34 /* Returns array index of n'th element in aqueue. */ 
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
7079
diff
changeset

35 static inline unsigned int ATTR_PURE 
7079
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

36 aqueue_idx(const struct aqueue *aqueue, unsigned int n) 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

37 { 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

38 return (aqueue>tail + n) % aqueue>area_size; 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

39 } 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

40 
d45c3058b91a
Renamed queue to aqueue ("array queue") because struct queue already exists
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset

41 #endif 