libcomps
..
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
libcomps
src
comps_list.h
Go to the documentation of this file.
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
24
#ifndef COMPS_LIST_H
25
#define COMPS_LIST_H
26
27
#include <string.h>
28
#include <stdlib.h>
29
35
struct
COMPS_ListItem
{
37
struct
COMPS_ListItem
*
next
;
39
struct
COMPS_ListItem
*
prev
;
41
void
*
data
;
43
void (*
data_destructor
)(
void
*
data
);
44
};
45
typedef
struct
COMPS_ListItem
COMPS_ListItem
;
46
52
typedef
void (*
COMPS_ListWalkFunc
)(
53
COMPS_ListItem
*,
54
unsigned
int,
55
void
* user_data);
76
typedef
struct
{
77
COMPS_ListItem
* first;
78
COMPS_ListItem
* last;
79
int
len;
80
}
COMPS_List
;
81
82
COMPS_ListItem
* comps_list_item_create(
void
* data,
83
void
* (*data_constructor)(
void
* data),
84
void
(*data_destructor)(
void
* data));
85
void
comps_list_item_destroy(
COMPS_ListItem
* item);
86
87
COMPS_List
* comps_list_create();
88
unsigned
comps_list_init(
COMPS_List
* dl);
89
void
comps_list_destroy(
COMPS_List
** dl);
90
void
comps_list_destroy_v(
void
*dl);
91
void
comps_list_clear(
COMPS_List
* dl);
92
93
void
comps_list_insert(
COMPS_List
* dl,
COMPS_ListItem
* di,
unsigned
int
pos);
94
char
comps_list_append(
COMPS_List
* dl,
COMPS_ListItem
* di);
95
96
void
comps_list_remove_pos(
COMPS_List
* dl,
unsigned
int
pos);
97
COMPS_ListItem
* comps_list_remove_pos_r(
COMPS_List
* dl,
unsigned
int
pos);
98
void
comps_list_remove_item(
COMPS_List
* dl,
COMPS_ListItem
*it);
99
char
comps_list_remove_data(
COMPS_List
*dl,
void
* data);
100
COMPS_ListItem
* comps_list_pop(
COMPS_List
* dl);
101
COMPS_ListItem
* comps_list_shift(
COMPS_List
* dl);
102
103
COMPS_ListItem
* comps_list_at(
COMPS_List
* dl,
unsigned
int
pos);
104
void
comps_list_walk(
COMPS_List
* dl,
COMPS_ListWalkFunc
func,
105
void
* user_data);
106
107
#endif
Generated by
1.8.3.1