qdf_parse.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2018 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: Text parsing related abstractions, not related to a specific type
  21. */
  22. #ifndef __QDF_PARSE_H
  23. #define __QDF_PARSE_H
  24. #include "qdf_status.h"
  25. typedef QDF_STATUS (*qdf_ini_section_cb)(void *context, const char *name);
  26. typedef QDF_STATUS (*qdf_ini_item_cb)(void *context,
  27. const char *key,
  28. const char *value);
  29. /**
  30. * qdf_ini_parse() - parse an ini file
  31. * @ini_path: The full file path of the ini file to parse
  32. * @context: The caller supplied context to pass into callbacks
  33. * @item_cb: Ini item (key/value pair) handler callback function
  34. * Return QDF_STATUS_SUCCESS to continue parsing, else to abort
  35. * @section_cb: Ini section header handler callback function
  36. * Return QDF_STATUS_SUCCESS to continue parsing, else to abort
  37. *
  38. * The *.ini file format is a simple format consisting of a list of key/value
  39. * pairs (items), separated by an '=' character. Comments are initiated with
  40. * a '#' character. Sections are also supported, using '[' and ']' around the
  41. * section name. e.g.
  42. *
  43. * # comments are started with a '#' character
  44. * # items are key/value string pairs, separated by the '=' character
  45. * someKey1=someValue1
  46. * someKey2=someValue2 # this is also a comment
  47. *
  48. * # section headers are enclosed in square brackets
  49. * [some section header] # new section begins
  50. * someKey3=someValue3
  51. *
  52. * Return: QDF_STATUS
  53. */
  54. QDF_STATUS
  55. qdf_ini_parse(const char *ini_path, void *context,
  56. qdf_ini_item_cb item_cb, qdf_ini_section_cb section_cb);
  57. /**
  58. * qdf_ini_section_parse() - parse a section from ini file
  59. * @ini_path: The full file path of the ini file to parse
  60. * @context: The caller supplied context to pass into callbacks
  61. * @item_cb: Ini item (key/value pair) handler callback function
  62. * Return QDF_STATUS_SUCCESS to continue parsing, else to abort
  63. * @section_name: Ini section name to be parsed from file
  64. * Return QDF_STATUS_SUCCESS to continue parsing, else to abort
  65. *
  66. * The *.ini file format is a simple format consisting of a list of key/value
  67. * pairs (items), separated by an '=' character. Comments are initiated with
  68. * a '#' character. Sections are also supported, using '[' and ']' around the
  69. * section name. e.g.
  70. *
  71. * # comments are started with a '#' character
  72. * # items are key/value string pairs, separated by the '=' character
  73. * someKey1=someValue1
  74. * someKey2=someValue2 # this is also a comment
  75. *
  76. * # section headers are enclosed in square brackets
  77. * [some section header] # new section begins
  78. * someKey3=someValue3
  79. *
  80. * Return: QDF_STATUS
  81. */
  82. QDF_STATUS qdf_ini_section_parse(const char *ini_path, void *context,
  83. qdf_ini_item_cb item_cb,
  84. const char *section_name);
  85. /**
  86. * qdf_valid_ini_check() - check ini file for invalid characters
  87. * @path: path to ini file
  88. *
  89. * Return: true if no invalid character found, false otherwise
  90. */
  91. bool qdf_valid_ini_check(const char *path);
  92. #endif /* __QDF_PARSE_H */