| 1 | /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB |
| 2 | |
| 3 | This library is free software; you can redistribute it and/or |
| 4 | modify it under the terms of the GNU Library General Public |
| 5 | License as published by the Free Software Foundation; either |
| 6 | version 2 of the License, or (at your option) any later version. |
| 7 | |
| 8 | This library is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | Library General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU Library General Public |
| 14 | License along with this library; if not, write to the Free |
| 15 | Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 16 | MA 02111-1301, USA */ |
| 17 | |
| 18 | #ifndef _list_h_ |
| 19 | #define _list_h_ |
| 20 | |
| 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | typedef struct st_list { |
| 26 | struct st_list *prev,*next; |
| 27 | void *data; |
| 28 | } LIST; |
| 29 | |
| 30 | typedef int (*list_walk_action)(void *,void *); |
| 31 | |
| 32 | extern LIST *list_add(LIST *root,LIST *element); |
| 33 | extern LIST *list_delete(LIST *root,LIST *element); |
| 34 | extern LIST *list_cons(void *data,LIST *root); |
| 35 | extern LIST *list_reverse(LIST *root); |
| 36 | extern void list_free(LIST *root,unsigned int free_data); |
| 37 | extern unsigned int list_length(LIST *list); |
| 38 | extern int list_walk(LIST *list,list_walk_action action,char * argument); |
| 39 | |
| 40 | #define list_rest(a) ((a)->next) |
| 41 | #define list_push(a,b) (a)=list_cons((b),(a)) |
| 42 | #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; ma_free((char *) old,MYF(MY_FAE)); } |
| 43 | |
| 44 | #ifdef __cplusplus |
| 45 | } |
| 46 | #endif |
| 47 | #endif |
| 48 | |