xref: /openbmc/u-boot/include/env_attr.h (revision 9e336903)
1 /*
2  * (C) Copyright 2012
3  * Joe Hershberger, National Instruments, joe.hershberger@ni.com
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 
24 #ifndef __ENV_ATTR_H__
25 #define __ENV_ATTR_H__
26 
27 #define ENV_ATTR_LIST_DELIM	','
28 #define ENV_ATTR_SEP		':'
29 
30 /*
31  * env_attr_walk takes as input an "attr_list" that takes the form:
32  *	attributes = [^,:\s]*
33  *	entry = name[:attributes]
34  *	list = entry[,list]
35  * It will call the "callback" function with the "name" and attribute as "value"
36  * The callback may return a non-0 to abort the list walk.
37  * This return value will be passed through to the caller.
38  * 0 is returned on success.
39  */
40 extern int env_attr_walk(const char *attr_list,
41 	int (*callback)(const char *name, const char *value));
42 
43 /*
44  * env_attr_lookup takes as input an "attr_list" with the same form as above.
45  * It also takes as input a "name" to look for.
46  * If the name is found in the list, it's value is copied into "attributes".
47  * There is no protection on attributes being too small for the value.
48  * It returns -1 if attributes is NULL, 1 if "name" is not found, 2 if
49  * "attr_list" is NULL.
50  * Returns 0 on success.
51  */
52 extern int env_attr_lookup(const char *attr_list, const char *name,
53 	char *attributes);
54 
55 #endif /* __ENV_ATTR_H__ */
56