1 /* libcomps - C alternative to yum.comps library 2 * Copyright (C) 2013 Jindrich Luza 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 * USA 18 */ 19 20 21 #ifndef COMPS_HSLIST_H 22 #define COMPS_HSLIST_H 23 24 25 struct _COMPS_HSListItem { 26 struct _COMPS_HSListItem * next; 27 void * data; 28 }; 29 30 typedef struct _COMPS_HSListItem COMPS_HSListItem; 31 32 typedef struct { 33 COMPS_HSListItem * first; 34 COMPS_HSListItem * last; 35 void(*data_destructor)(void*); 36 void*(*data_cloner)(void*); 37 void*(*data_constructor)(void*); 38 } COMPS_HSList; 39 40 COMPS_HSList * comps_hslist_create(); 41 void comps_hslist_destroy(COMPS_HSList ** hlist); 42 void comps_hslist_destroy_v(void ** hlist); 43 44 void comps_hslist_init(COMPS_HSList * hlist, 45 void*(*data_constructor)(void* data), 46 void*(*data_cloner)(void* data), 47 void(*data_destructor)(void* data)); 48 void comps_hslist_append(COMPS_HSList * hlist, void * data, 49 unsigned construct); 50 void comps_hslist_remove(COMPS_HSList * hlist, COMPS_HSListItem * it); 51 void* comps_hslist_data_at(COMPS_HSList * hlist, unsigned int index); 52 void comps_hslist_insert_after(COMPS_HSList * hslist, COMPS_HSListItem *item, 53 void *data, unsigned construct); 54 int comps_hslist_insert_at(COMPS_HSList * hslist, int pos, 55 void *data, unsigned construct); 56 void comps_hslist_prepend(COMPS_HSList * hslist, void *data, unsigned construct); 57 void* comps_hslist_shift(COMPS_HSList * hslist); 58 void* comps_hslist_pop(COMPS_HSList * hslist); 59 60 COMPS_HSList* comps_hslist_clone(COMPS_HSList * hslist); 61 void comps_hslist_clear(COMPS_HSList * hslist); 62 unsigned comps_hslist_values_equal(COMPS_HSList *hlist1, COMPS_HSList *hlist2, 63 char (*cmpf)(void*, void*)); 64 void comps_hslist_unique(COMPS_HSList *hslist1, char (*cmpf)(void*, void*)); 65 66 #endif 67