2 * Copyright (C) 2013 Oracle.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
20 int list_has_string(struct string_list
*str_list
, const char *str
)
28 FOR_EACH_PTR(str_list
, tmp
) {
29 cmp
= strcmp(tmp
, str
);
35 } END_FOR_EACH_PTR(tmp
);
39 int insert_string(struct string_list
**str_list
, const char *_new
)
41 char *new = (char *)_new
;
45 FOR_EACH_PTR(*str_list
, tmp
) {
46 cmp
= strcmp(tmp
, new);
52 INSERT_CURRENT(alloc_string(new), tmp
);
55 } END_FOR_EACH_PTR(tmp
);
56 new = alloc_string(new);
57 add_ptr_list(str_list
, new);
61 struct string_list
*clone_str_list(struct string_list
*orig
)
64 struct string_list
*ret
= NULL
;
66 FOR_EACH_PTR(orig
, tmp
) {
67 add_ptr_list(&ret
, tmp
);
68 } END_FOR_EACH_PTR(tmp
);
72 struct string_list
*combine_string_lists(struct string_list
*one
, struct string_list
*two
)
74 struct string_list
*ret
;
77 ret
= clone_str_list(one
);
78 FOR_EACH_PTR(two
, tmp
) {
79 insert_string(&ret
, tmp
);
80 } END_FOR_EACH_PTR(tmp
);