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