2015-11-24 17:58:32 +01:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
|
|
|
Copyright (c) 2015 LE Xuan Sang xsang.le@gmail.com
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef LIST_H
|
|
|
|
#define LIST_H
|
2020-08-25 16:40:24 +02:00
|
|
|
|
2019-12-15 12:10:06 +01:00
|
|
|
|
2019-12-22 17:33:35 +01:00
|
|
|
#define LIST_TYPE_ARRAY 0x5
|
|
|
|
#define LIST_TYPE_POINTER 0x4
|
|
|
|
#define LIST_TYPE_DOUBLE 0x2
|
|
|
|
#define LIST_TYPE_INT 0x1
|
|
|
|
#define LIST_TYPE_NIL 0x0
|
|
|
|
|
|
|
|
#define list_for_each(item, list) \
|
|
|
|
for(item = list;item!= NULL && item->type != LIST_TYPE_NIL; item = item->next)
|
2019-12-15 12:10:06 +01:00
|
|
|
|
2015-11-24 17:58:32 +01:00
|
|
|
typedef struct __item{
|
|
|
|
int type;
|
|
|
|
union{
|
|
|
|
int i;
|
|
|
|
double d;
|
2019-12-22 17:33:35 +01:00
|
|
|
void* ptr;
|
2015-11-24 17:58:32 +01:00
|
|
|
struct __item* array;
|
2015-10-22 11:39:11 +02:00
|
|
|
} value;
|
2015-11-24 17:58:32 +01:00
|
|
|
struct __item* next;
|
2019-12-15 12:10:06 +01:00
|
|
|
}*item_t;
|
|
|
|
typedef item_t list_t;
|
|
|
|
list_t list_init();
|
|
|
|
void list_put(list_t*,item_t);
|
|
|
|
void list_put_i(list_t*,int);
|
|
|
|
void list_put_d(list_t*,double);
|
2019-12-22 17:33:35 +01:00
|
|
|
void list_put_ptr(list_t*,void*);
|
2019-12-15 12:10:06 +01:00
|
|
|
void list_put_array(list_t*,list_t);
|
2019-12-22 17:33:35 +01:00
|
|
|
|
2019-12-15 12:10:06 +01:00
|
|
|
item_t list_last(list_t);
|
2019-12-22 17:33:35 +01:00
|
|
|
int list_remove(list_t*,int);
|
2019-12-15 12:10:06 +01:00
|
|
|
int list_size(list_t);
|
|
|
|
item_t list_at(list_t,int);
|
|
|
|
int list_empty(list_t);
|
|
|
|
item_t list_item(int type);
|
|
|
|
list_t split(const char*, const char*);
|
|
|
|
void list_put_special(list_t*, const char*);
|
|
|
|
void list_free(list_t *);
|
2015-11-24 17:58:32 +01:00
|
|
|
#endif
|