list.h 3.5 KB
Newer Older
1
/*
2 3 4 5 6
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  Belledonne Communications SARL

    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
7
    the Free Software Foundation, either version 2 of the License, or
8 9 10 11 12 13 14 15 16 17
    (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, see <http://www.gnu.org/licenses/>.
*/
18 19 20

#ifndef BELLE_SIP_LIST_H_
#define BELLE_SIP_LIST_H_
jehan's avatar
jehan committed
21 22 23 24 25
struct _belle_sip_list {
	struct _belle_sip_list *next;
	struct _belle_sip_list *prev;
	void *data;
};
26 27
typedef struct _belle_sip_list belle_sip_list_t;

Ghislain MARY's avatar
Ghislain MARY committed
28 29 30
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_append(belle_sip_list_t * elem, void * data);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_prepend(belle_sip_list_t * elem, void * data);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_last_elem(const belle_sip_list_t *l);
Sylvain Berfini's avatar
Sylvain Berfini committed
31
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_free(belle_sip_list_t * elem);
Ghislain MARY's avatar
Ghislain MARY committed
32 33
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_concat(belle_sip_list_t * first, belle_sip_list_t * second);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_remove(belle_sip_list_t * first, void *data);
34
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_pop_front(belle_sip_list_t *list, void **front_data);
Sylvain Berfini's avatar
Sylvain Berfini committed
35
BELLESIP_EXPORT int belle_sip_list_size(const belle_sip_list_t * first);
Ghislain MARY's avatar
Ghislain MARY committed
36
BELLESIP_EXPORT void belle_sip_list_for_each(const belle_sip_list_t * list, void (*func)(void *));
Sylvain Berfini's avatar
Sylvain Berfini committed
37
BELLESIP_EXPORT void belle_sip_list_for_each2(const belle_sip_list_t * list, void (*func)(void *, void *), void *user_data);
Ghislain MARY's avatar
Ghislain MARY committed
38 39 40 41
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_remove_link(belle_sip_list_t * list, belle_sip_list_t * elem);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_delete_link(belle_sip_list_t * list, belle_sip_list_t * elem);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_find(belle_sip_list_t * list, void *data);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_free(belle_sip_list_t *list);
42
/*frees list elements and associated data, using the supplied function pointer*/
43
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_free_with_data(belle_sip_list_t *list, void (*freefunc)(void*));
44 45

typedef  int (*belle_sip_compare_func)(const void *, const void*);
46
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_find_custom(const belle_sip_list_t * list, belle_sip_compare_func cmp, const void *user_data);
Ghislain MARY's avatar
Ghislain MARY committed
47 48 49 50 51
BELLESIP_EXPORT void * belle_sip_list_nth_data(const belle_sip_list_t * list, int index);
BELLESIP_EXPORT int belle_sip_list_position(const belle_sip_list_t * list, belle_sip_list_t * elem);
BELLESIP_EXPORT int belle_sip_list_index(const belle_sip_list_t * list, void *data);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_insert_sorted(belle_sip_list_t * list, void *data, belle_sip_compare_func cmp);
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_insert(belle_sip_list_t * list, belle_sip_list_t * before, void *data);
Sylvain Berfini's avatar
Sylvain Berfini committed
52
BELLESIP_EXPORT belle_sip_list_t * belle_sip_list_copy(const belle_sip_list_t * list);
jehan's avatar
jehan committed
53
/*copy list elements and associated data, using the supplied function pointer*/
Ghislain MARY's avatar
Ghislain MARY committed
54
BELLESIP_EXPORT belle_sip_list_t* belle_sip_list_copy_with_data(const belle_sip_list_t* list, void* (*copyfunc)(void*));
55 56 57


#endif /* BELLE_SIP_LIST_H_ */