1 1.1 haad /* $NetBSD: lvm-string.h,v 1.1.1.1 2008/12/22 00:18:13 haad Exp $ */ 2 1.1 haad 3 1.1 haad /* 4 1.1 haad * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 5 1.1 haad * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 6 1.1 haad * 7 1.1 haad * This file is part of LVM2. 8 1.1 haad * 9 1.1 haad * This copyrighted material is made available to anyone wishing to use, 10 1.1 haad * modify, copy, or redistribute it subject to the terms and conditions 11 1.1 haad * of the GNU Lesser General Public License v.2.1. 12 1.1 haad * 13 1.1 haad * You should have received a copy of the GNU Lesser General Public License 14 1.1 haad * along with this program; if not, write to the Free Software Foundation, 15 1.1 haad * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1.1 haad */ 17 1.1 haad 18 1.1 haad #ifndef _LVM_STRING_H 19 1.1 haad #define _LVM_STRING_H 20 1.1 haad 21 1.1 haad #include <stdio.h> 22 1.1 haad #include <stdarg.h> 23 1.1 haad 24 1.1 haad #define NAME_LEN 128 25 1.1 haad 26 1.1 haad struct pool; 27 1.1 haad 28 1.1 haad int emit_to_buffer(char **buffer, size_t *size, const char *fmt, ...) 29 1.1 haad __attribute__ ((format(printf, 3, 4))); 30 1.1 haad 31 1.1 haad char *build_dm_name(struct dm_pool *mem, const char *vg, 32 1.1 haad const char *lv, const char *layer); 33 1.1 haad 34 1.1 haad int validate_name(const char *n); 35 1.1 haad 36 1.1 haad /* 37 1.1 haad * Returns number of occurrences of c in first len characters of str. 38 1.1 haad */ 39 1.1 haad unsigned count_chars(const char *str, size_t len, const int c); 40 1.1 haad 41 1.1 haad /* 42 1.1 haad * Returns what length of escaped string would be including terminating NUL. 43 1.1 haad */ 44 1.1 haad size_t escaped_len(const char *str); 45 1.1 haad 46 1.1 haad /* 47 1.1 haad * Copies a string from src to out. 48 1.1 haad * Double quotation marks and backslashes are quoted with a backslash. 49 1.1 haad * Caller must ensure *out has enough space - see escaped_len(). 50 1.1 haad * Returns *out. 51 1.1 haad */ 52 1.1 haad char *escape_double_quotes(char *out, const char *src); 53 1.1 haad 54 1.1 haad /* 55 1.1 haad * Removes quoting of double quotation marks and backslashes in situ. 56 1.1 haad */ 57 1.1 haad void unescape_double_quotes(char *src); 58 1.1 haad 59 1.1 haad #endif 60