2016-03-27 18:37:15 +02:00
|
|
|
/*
|
|
|
|
This file is part of actube.
|
|
|
|
|
|
|
|
actube 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-02-28 13:41:45 +01:00
|
|
|
#ifndef __MLIST_H
|
|
|
|
#define __MLIST_H
|
|
|
|
|
2016-03-27 18:37:15 +02:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Mlist Mini list
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup MLIST MLIST
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Element of an mlist.
|
|
|
|
* It's a simple connected list, just with pone connection to the
|
|
|
|
* next element.
|
|
|
|
*/
|
2016-02-28 13:41:45 +01:00
|
|
|
struct mlist_elem {
|
2016-03-27 18:37:15 +02:00
|
|
|
/** Pointer to data */
|
2016-02-28 13:41:45 +01:00
|
|
|
void *data;
|
2016-03-27 18:37:15 +02:00
|
|
|
/**
|
|
|
|
* Pointer to next element
|
|
|
|
* The last element is determined by a NULL pointer
|
|
|
|
* */
|
2016-02-28 13:41:45 +01:00
|
|
|
struct mlist_elem *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlist {
|
|
|
|
void *data;
|
|
|
|
int (*cmp) (void *d1, void *d2);
|
|
|
|
struct mlist_elem *list;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct mlist mlist_t;
|
|
|
|
|
|
|
|
|
2016-03-27 18:37:15 +02:00
|
|
|
/**
|
|
|
|
* defgroup MLIST_FUNCTIONS
|
|
|
|
* @{
|
|
|
|
*/
|
2016-02-28 13:41:45 +01:00
|
|
|
extern mlist_t *mlist_create(int (*cmp) (void *v1, void *v2));
|
|
|
|
extern struct mlist_elem *mlist_append(mlist_t * l, void *data);
|
|
|
|
extern struct mlist_elem *mlist_find(mlist_t * l, struct mlist_elem *start, void *data);
|
|
|
|
extern struct mlist_elem *mlist_replace(mlist_t *l, struct mlist_elem *start, void *data);
|
|
|
|
|
2016-03-27 18:37:15 +02:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2016-03-28 10:45:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define mlist_foreach(i,l)\
|
|
|
|
for (i=l->data; i; i=i->next)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-27 18:37:15 +02:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2016-02-28 13:41:45 +01:00
|
|
|
|
|
|
|
#endif
|