Permalink
Switch branches/tags
vzctl.open-3.0.0-4 vzctl.open-3.0.0-3 vzctl.open-3.0.0-2 vzctl.open-3.0.0-1 vzctl.open-2.7.0-28 vzctl.open-2.7.0-27 vzctl.open-2.7.0-26 vzctl.open-2.7.0-25 vzctl.open-2.7.0-24 vzctl.open-2.7.0-23 vzctl-4.5.1 vzctl-4.5.1-20130928-funtoo vzctl-4.5.1-20130923-funtoo vzctl-4.5 vzctl-4.4 vzctl-4.3.1 vzctl-4.3.1-funtoo vzctl-4.3 vzctl-4.2 vzctl-4.1.2 vzctl-4.1.1 vzctl-4.1 vzctl-4.0 vzctl-3.3 vzctl-3.3-r3-funtoo vzctl-3.3-r2-funtoo vzctl-3.3-r1-funtoo vzctl-3.2.1 vzctl-3.2 vzctl-3.1 vzctl-3.0.30.2 vzctl-3.0.30.2-funtoo vzctl-3.0.30.1 vzctl-3.0.30 vzctl-3.0.29.3 vzctl-3.0.29.2 vzctl-3.0.29.1 vzctl-3.0.29 vzctl-3.0.28.3-funtoo vzctl-3.0.28.2 vzctl-3.0.28.1 vzctl-3.0.28 vzctl-3.0.27 vzctl-3.0.27-r1-funtoo vzctl-3.0.27-funtoo vzctl-3.0.26.3 vzctl-3.0.26.3-funtoo vzctl-3.0.26.2 vzctl-3.0.26.1 vzctl-3.0.26 vzctl-3.0.25.2 vzctl-3.0.25.1 vzctl-3.0.25.1-funtoo vzctl-3.0.25 vzctl-3.0.25-r3-funtoo vzctl-3.0.25-r2-funtoo vzctl-3.0.25-r1-funtoo vzctl-3.0.25-funtoo vzctl-3.0.24.2 vzctl-3.0.24.1 vzctl-3.0.24 vzctl-3.0.24-r4-funtoo vzctl-3.0.23.2 vzctl-3.0.23.1 vzctl-3.0.23 vzctl-3.0.22 vzctl-3.0.21 vzctl-3.0.20 vzctl-3.0.19 vzctl-3.0.19-1 vzctl-3.0.18 vzctl-3.0.17 vzctl-3.0.17-1 vzctl-3.0.16 vzctl-3.0.15 vzctl-3.0.14 vzctl-3.0.13-1 vzctl-3.0.12-1 vzctl-3.0.11 vzctl-3.0.11-3 vzctl-3.0.11-2 vzctl-3.0.10 vzctl-3.0.9-1 vzctl-3.0.0-8 vzctl-3.0.0-7 vzctl-3.0.0-6 vzctl-3.0.0-5 master-4.5.1 master-4.1.2 master-4.1.1 master-3.0.30.2 master-3.0.30.1 master-3.0.29.3 master-3.0.29.2 master-3.0.29.1 master-3.0.28.3 master-3.0.28.2 master-3.0.28.1 3.0.25.1-funtoo 3.0.25-r2-funtoo
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
143 lines (120 sloc) 3.91 KB
/*
* Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LIST_H_
#define _LIST_H_
struct list_head {
struct list_head *prev, *next;
};
typedef struct list_head list_head_t;
typedef struct list_head list_elem_t;
struct str_struct {
list_elem_t list;
char *val;
};
typedef struct str_struct str_param;
static inline void list_head_init(list_head_t *head)
{
head->next = head;
head->prev = head;
}
static inline void list_elem_init(list_elem_t *entry)
{
entry->next = entry;
entry->prev = entry;
}
static inline void list_add(list_elem_t *new, list_head_t *list)
{
new->next = list->next;
new->prev = list;
list->next->prev = new;
list->next = new;
}
static inline void list_add_tail(list_elem_t *new, list_head_t *list)
{
new->next = list;
new->prev = list->prev;
list->prev->next = new;
list->prev = new;
}
static inline void list_del(list_elem_t *el)
{
el->prev->next = el->next;
el->next->prev = el->prev;
el->prev = (void *)0x5a5a5a5a;
el->next = (void *)0xa5a5a5a5;
}
static inline void list_del_init(list_elem_t *el)
{
el->prev->next = el->next;
el->next->prev = el->prev;
list_elem_init(el);
}
static inline int list_is_init(list_head_t *h)
{
return h->next == NULL;
}
static inline int list_empty(list_head_t *h)
{
if (list_is_init(h))
return 1;
return h->next == h;
}
static inline int list_elem_inserted(list_elem_t *el)
{
return el->next != el;
}
static inline void list_moveall(list_head_t *src, list_head_t *dst)
{
list_add(dst, src);
list_del(src);
list_head_init(src);
}
#define list_entry(ptr, type, field) \
((type *)(void *)((char *)(ptr)-(unsigned long)(&((type *)0)->field)))
#define list_first_entry(head, type, field) \
list_entry((head)->next, type, field)
#define list_for_each(entry, head, field) \
for (entry = list_entry((head)->next, typeof(*entry), field);\
&entry->field != (head); \
entry = list_entry(entry->field.next, typeof(*entry), field))
#define list_for_each_prev(entry, head, field) \
for (entry = list_entry((head)->prev, typeof(*entry), field);\
&entry->field != (head); \
entry = list_entry(entry->field.prev, typeof(*entry), field))
#define list_for_each_safe(entry, tmp, head, field) \
for (entry = list_entry((head)->next, typeof(*entry), field),\
tmp = list_entry(entry->field.next, typeof(*entry), field); \
&entry->field != (head); \
entry = tmp, \
tmp = list_entry(tmp->field.next, typeof(*tmp), field))
char *list2str_c(char *name, char c, list_head_t *head);
char *list2str(char *name, list_head_t *head);
char **list2arg(list_head_t *head);
int add_str_param(list_head_t *head, const char *str);
int add_str_param2(list_head_t *head, char *str);
int add_str2list(list_head_t *head, const char *val);
void free_str_param(list_head_t *head);
int copy_str_param(list_head_t *dst, list_head_t *src);
char *find_str(list_head_t *head, const char *val);
int __merge_str_list(int delall, list_head_t *old, list_head_t *add,
list_head_t *del, list_head_t *merged,
char* (*find_fn)(list_head_t*, const char*));
int merge_str_list(int delall, list_head_t *old, list_head_t *add,
list_head_t *del, list_head_t *merged);
int list_size(list_head_t *head);
#endif /* _LIST_H_ */