4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2014, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * libcfs/include/libcfs/libcfs_string.h
34 * Generic string manipulation functions.
36 * Author: Nathan Rutman <nathan.rutman@sun.com>
39 #ifndef __LIBCFS_UTIL_STRING_H__
40 #define __LIBCFS_UTIL_STRING_H__
44 #include <linux/types.h>
45 #include <libcfs/util/list.h>
47 #ifndef HAVE_STRLCPY /* not in glibc for RHEL 5.x, remove when obsolete */
48 size_t strlcpy(char *tgt, const char *src, size_t tgt_len);
51 #ifndef HAVE_STRLCAT /* not in glibc for RHEL 5.x, remove when obsolete */
52 size_t strlcat(char *tgt, const char *src, size_t tgt_len);
56 * Structure to represent NULL-less strings.
64 * Structure to represent \<range_expr\> token of the syntax.
66 struct cfs_range_expr {
68 * Link to cfs_expr_list::el_exprs.
70 struct list_head re_link;
76 struct cfs_expr_list {
77 struct list_head el_link;
78 struct list_head el_exprs;
81 int cfs_expr_list_values(struct cfs_expr_list *expr_list, int max, __u32 **valpp);
82 int cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res);
83 int cfs_str2num_check(char *str, int nob, unsigned *num,
84 unsigned min, unsigned max);
85 int cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list);
86 int cfs_expr_list_print(char *buffer, int count,
87 struct cfs_expr_list *expr_list);
88 int cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max,
89 struct cfs_expr_list **elpp);
90 void cfs_expr_list_free(struct cfs_expr_list *expr_list);
91 void cfs_expr_list_free_list(struct list_head *list);
92 int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
93 int cfs_ip_addr_match(__u32 addr, struct list_head *list);