env_attr.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2012
  4. * Joe Hershberger, National Instruments, joe.hershberger@ni.com
  5. */
  6. #ifndef __ENV_ATTR_H__
  7. #define __ENV_ATTR_H__
  8. #define ENV_ATTR_LIST_DELIM ','
  9. #define ENV_ATTR_SEP ':'
  10. /*
  11. * env_attr_walk takes as input an "attr_list" that takes the form:
  12. * attributes = [^,:\s]*
  13. * entry = name[:attributes]
  14. * list = entry[,list]
  15. * It will call the "callback" function with the "name" and "attributes"
  16. * The callback may return a non-0 to abort the list walk.
  17. * This return value will be passed through to the caller.
  18. * 0 is returned on success.
  19. */
  20. int env_attr_walk(const char *attr_list,
  21. int (*callback)(const char *name, const char *attributes, void *priv),
  22. void *priv);
  23. /*
  24. * env_attr_lookup takes as input an "attr_list" with the same form as above.
  25. * It also takes as input a "name" to look for.
  26. * If the name is found in the list, it's value is copied into "attributes".
  27. * There is no protection on attributes being too small for the value.
  28. * It returns -1 if attributes is NULL, 1 if "name" is not found, 2 if
  29. * "attr_list" is NULL.
  30. * Returns 0 on success.
  31. */
  32. int env_attr_lookup(const char *attr_list, const char *name, char *attributes);
  33. #endif /* __ENV_ATTR_H__ */