2 * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #include "import-export.h"
20 #include "lvm-string.h"
22 char *alloc_printed_tags(struct dm_list *tags)
29 dm_list_iterate_items(sl, tags)
30 /* '"' + tag + '"' + ',' + ' ' */
31 size += strlen(sl->str) + 4;
32 /* '[' + ']' + '\0' */
35 if (!(buffer = buf = dm_malloc(size))) {
36 log_error("Could not allocate memory for tag list buffer.");
40 if (!emit_to_buffer(&buf, &size, "["))
43 dm_list_iterate_items(sl, tags) {
45 if (!emit_to_buffer(&buf, &size, ", "))
50 if (!emit_to_buffer(&buf, &size, "\"%s\"", sl->str))
54 if (!emit_to_buffer(&buf, &size, "]"))
64 int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct config_value *cv)
66 if (cv->type == CFG_EMPTY_ARRAY)
70 if (cv->type != CFG_STRING) {
71 log_error("Found a tag that is not a string");
75 if (!str_list_add(mem, tags, dm_pool_strdup(mem, cv->v.str)))