Commit 63cb99b2 63cb99b246587b180a0cf70074ef75e78968e6b8 by Alain Magloire

* mailbox2/include/mailutils/list.h: the typedef list_t

	is rename mu_list_t, as a suggestion from Sam R.
	* mailbox2/list.c: All the function names are prefix with "mu_".
1 parent 05649321
2001-08-28 Alain Magloire
* mailbox2/include/mailutils/list.h: the typedef list_t
is rename mu_list_t, as a suggestion from Sam R.
* mailbox2/list.c: All the function names are prefix with "mu_".
2001-08-27 Alain Magloire
* mailbox/folder_imap.c (imap_list): When \NoSelect, it is
......
......@@ -34,17 +34,17 @@ extern "C" {
#endif
struct _list;
typedef struct _list *list_t;
extern int list_create __P ((list_t *));
extern int list_destroy __P ((list_t));
extern int list_append __P ((list_t, void *));
extern int list_prepend __P ((list_t, void *));
extern int list_is_empty __P ((list_t));
extern int list_count __P ((list_t, size_t *));
extern int list_remove __P ((list_t, void *));
extern int list_get __P ((list_t, size_t, void **));
extern int list_get_iterator __P ((list_t, iterator_t *));
typedef struct _list *mu_list_t;
extern int mu_list_create __P ((mu_list_t *));
extern int mu_list_destroy __P ((mu_list_t));
extern int mu_list_append __P ((mu_list_t, void *));
extern int mu_list_prepend __P ((mu_list_t, void *));
extern int mu_list_is_empty __P ((mu_list_t));
extern int mu_list_count __P ((mu_list_t, size_t *));
extern int mu_list_remove __P ((mu_list_t, void *));
extern int mu_list_get __P ((mu_list_t, size_t, void **));
extern int mu_list_get_iterator __P ((mu_list_t, iterator_t *));
#ifdef __cplusplus
}
......
......@@ -40,16 +40,16 @@
extern "C" {
#endif
struct list_data
struct mu_list_data
{
void *item;
struct list_data *next;
struct list_data *prev;
struct mu_list_data *next;
struct mu_list_data *prev;
};
struct _list
{
struct list_data head;
struct mu_list_data head;
size_t count;
size_t index;
monitor_t lock;
......@@ -59,8 +59,8 @@ struct l_iterator
{
struct _iterator base;
unsigned int ref;
list_t list;
struct list_data *current;
mu_list_t list;
struct mu_list_data *current;
monitor_t lock;
};
......
......@@ -40,7 +40,7 @@ extern "C" {
struct _observable
{
list_t list;
mu_list_t list;
};
#ifdef __cplusplus
......
......@@ -54,7 +54,7 @@ struct _observer
struct _observable
{
list_t list;
mu_list_t list;
};
struct _dobserver
......
......@@ -29,9 +29,9 @@
need to be thread-safe. */
int
list_create (list_t *plist)
mu_list_create (mu_list_t *plist)
{
list_t list;
mu_list_t list;
int status;
if (plist == NULL)
return EINVAL;
......@@ -52,12 +52,12 @@ list_create (list_t *plist)
}
int
list_destroy (list_t list)
mu_list_destroy (mu_list_t list)
{
if (list)
{
struct list_data *current;
struct list_data *previous;
struct mu_list_data *current;
struct mu_list_data *previous;
monitor_lock (list->lock);
for (current = list->head.next; current != &(list->head);)
{
......@@ -73,10 +73,10 @@ list_destroy (list_t list)
}
int
list_append (list_t list, void *item)
mu_list_append (mu_list_t list, void *item)
{
struct list_data *ldata;
struct list_data *last;
struct mu_list_data *ldata;
struct mu_list_data *last;
if (list == NULL)
return EINVAL;
last = list->head.prev;
......@@ -95,10 +95,10 @@ list_append (list_t list, void *item)
}
int
list_prepend (list_t list, void *item)
mu_list_prepend (mu_list_t list, void *item)
{
struct list_data *ldata;
struct list_data *first;
struct mu_list_data *ldata;
struct mu_list_data *first;
if (list == NULL)
return EINVAL;
first = list->head.next;
......@@ -117,15 +117,15 @@ list_prepend (list_t list, void *item)
}
int
list_is_empty (list_t list)
mu_list_is_empty (mu_list_t list)
{
size_t n = 0;
list_count (list, &n);
mu_list_count (list, &n);
return (n == 0);
}
int
list_count (list_t list, size_t *pcount)
mu_list_count (mu_list_t list, size_t *pcount)
{
if (list == NULL || pcount == NULL)
return EINVAL;
......@@ -134,9 +134,9 @@ list_count (list_t list, size_t *pcount)
}
int
list_remove (list_t list, void *item)
mu_list_remove (mu_list_t list, void *item)
{
struct list_data *current, *previous;
struct mu_list_data *current, *previous;
int status = ENOENT;
if (list == NULL)
return EINVAL;
......@@ -159,9 +159,9 @@ list_remove (list_t list, void *item)
}
int
list_get (list_t list, size_t index, void **pitem)
mu_list_get (mu_list_t list, size_t index, void **pitem)
{
struct list_data *current;
struct mu_list_data *current;
size_t count;
int status = ENOENT;
if (list == NULL || pitem == NULL)
......@@ -203,7 +203,7 @@ static struct _iterator_vtable l_i_vtable =
};
int
list_get_iterator (list_t list, iterator_t *piterator)
mu_list_get_iterator (mu_list_t list, iterator_t *piterator)
{
struct l_iterator *l_iterator;
......@@ -270,7 +270,7 @@ static int
l_first (iterator_t iterator)
{
struct l_iterator *l_iterator = (struct l_iterator *)iterator;
list_t list = l_iterator->list;
mu_list_t list = l_iterator->list;
if (list)
{
monitor_lock (list->lock);
......@@ -284,7 +284,7 @@ static int
l_next (iterator_t iterator)
{
struct l_iterator *l_iterator = (struct l_iterator *)iterator;
list_t list = l_iterator->list;
mu_list_t list = l_iterator->list;
if (list)
{
if (l_iterator->current)
......@@ -304,7 +304,7 @@ l_is_done (iterator_t iterator)
{
struct l_iterator *l_iterator = (struct l_iterator *)iterator;
int done = 0;
list_t list = l_iterator->list;
mu_list_t list = l_iterator->list;
if (list)
{
monitor_lock (list->lock);
......@@ -318,7 +318,7 @@ static int
l_current (iterator_t iterator, void *item)
{
struct l_iterator *l_iterator = (struct l_iterator *)iterator;
list_t list = l_iterator->list;
mu_list_t list = l_iterator->list;
if (list)
{
monitor_lock (list->lock);
......
......@@ -41,7 +41,7 @@ observable_create (observable_t *pobservable)
observable = calloc (sizeof (*observable), 1);
if (observable == NULL)
return MU_ERROR_NO_MEMORY;
status = list_create (&(observable->list));
status = mu_list_create (&(observable->list));
if (status != 0 )
{
free (observable);
......@@ -64,7 +64,7 @@ observable_destroy (observable_t observable)
if (observable)
{
iterator_t iterator = NULL;
int status = list_get_iterator (observable->list, &iterator);
int status = mu_list_get_iterator (observable->list, &iterator);
if (status == 0)
{
struct observer_info *info;
......@@ -81,7 +81,7 @@ observable_destroy (observable_t observable)
}
iterator_release (iterator);
}
list_destroy (observable->list);
mu_list_destroy (observable->list);
free (observable);
}
return 0;
......@@ -98,7 +98,7 @@ observable_attach (observable_t observable, int type, observer_t observer)
return MU_ERROR_NO_MEMORY;
info->type = type;
info->observer = observer;
return list_append (observable->list, info);
return mu_list_append (observable->list, info);
}
int
......@@ -110,7 +110,7 @@ observable_detach (observable_t observable, observer_t observer)
struct observer_info *info;
if (observable == NULL ||observer == NULL)
return EINVAL;
status = list_get_iterator (observable->list, &iterator);
status = mu_list_get_iterator (observable->list, &iterator);
if (status != 0)
return status;
for (iterator_first (iterator); !iterator_is_done (iterator);
......@@ -127,7 +127,7 @@ observable_detach (observable_t observable, observer_t observer)
iterator_release (iterator);
if (found)
{
status = list_remove (observable->list, info);
status = mu_list_remove (observable->list, info);
free (info);
}
return status;
......@@ -142,7 +142,7 @@ observable_notify_all (observable_t observable, struct event evt)
if (observable == NULL)
return MU_ERROR_INVALID_PARAMETER;
status = list_get_iterator (observable->list, &iterator);
status = mu_list_get_iterator (observable->list, &iterator);
if (status != 0)
return status;
for (iterator_first (iterator); !iterator_is_done (iterator);
......