[1] | 1 | /* Copyright (C) 2000 MySQL AB |
---|
| 2 | |
---|
| 3 | This program is free software; you can redistribute it and/or modify |
---|
| 4 | it under the terms of the GNU General Public License as published by |
---|
| 5 | the Free Software Foundation; either version 2 of the License, or |
---|
| 6 | (at your option) any later version. |
---|
| 7 | |
---|
| 8 | This program 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 |
---|
| 11 | GNU General Public License for more details. |
---|
| 12 | |
---|
| 13 | You should have received a copy of the GNU General Public License |
---|
| 14 | along with this program; if not, write to the Free Software |
---|
| 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
---|
| 16 | |
---|
| 17 | #ifndef _list_h_ |
---|
| 18 | #define _list_h_ |
---|
| 19 | |
---|
| 20 | #ifdef __cplusplus |
---|
| 21 | extern "C" { |
---|
| 22 | #endif |
---|
| 23 | |
---|
| 24 | typedef struct st_list { |
---|
| 25 | struct st_list *prev,*next; |
---|
| 26 | void *data; |
---|
| 27 | } LIST; |
---|
| 28 | |
---|
| 29 | typedef int (*list_walk_action)(void *,void *); |
---|
| 30 | |
---|
| 31 | extern LIST *list_add(LIST *root,LIST *element); |
---|
| 32 | extern LIST *list_delete(LIST *root,LIST *element); |
---|
| 33 | extern LIST *list_cons(void *data,LIST *root); |
---|
| 34 | extern LIST *list_reverse(LIST *root); |
---|
| 35 | extern void list_free(LIST *root,unsigned int free_data); |
---|
| 36 | extern unsigned int list_length(LIST *); |
---|
| 37 | extern int list_walk(LIST *,list_walk_action action,gptr argument); |
---|
| 38 | |
---|
| 39 | #define list_rest(a) ((a)->next) |
---|
| 40 | #define list_push(a,b) (a)=list_cons((b),(a)) |
---|
| 41 | #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); } |
---|
| 42 | |
---|
| 43 | #ifdef __cplusplus |
---|
| 44 | } |
---|
| 45 | #endif |
---|
| 46 | #endif |
---|