summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-03-13 03:35:18 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-03-13 03:45:00 -0400
commit74df3ba2d823fde29b28ae3975e4ddfe09e4d69e (patch)
tree66b44c01eec50e4688bf24042a9660fff9745e3f /apps/misc.c
parenta9c62f2c39a74ccfc05fa7160efade49286da77c (diff)
downloadrockbox-74df3ba2d823fde29b28ae3975e4ddfe09e4d69e.tar.gz
rockbox-74df3ba2d823fde29b28ae3975e4ddfe09e4d69e.zip
add function string_option to misc.c use in skin_parser.c
function string_option allows a string to be found in a supplied list of options Change-Id: If9134090406b74ab11f4ef9ed6517a4b99b9d73e
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 2668ba714d..350537dc31 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1384,6 +1384,41 @@ int split_string(char *str, const char split_char, char *vector[], const int vec
1384 return i; 1384 return i;
1385} 1385}
1386 1386
1387/* returns match index from option list
1388 * returns -1 if option was not found
1389 * option list is array of char pointers with the final item set to null
1390 * ex - const char *option[] = { "op_a", "op_b", "op_c", NULL}
1391 */
1392
1393int string_option(const char *option, const char *const oplist[], bool ignore_case)
1394{
1395 int i;
1396 int ifound = -1;
1397 const char *op;
1398 if (ignore_case)
1399 {
1400 for (i=0; (op=oplist[i]) != NULL; i++)
1401 {
1402 if (strcasecmp(op, option) == 0)
1403 {
1404 ifound = i;
1405 break;
1406 }
1407 }
1408 }
1409 else
1410 {
1411 for (i=0; (op=oplist[i]) != NULL; i++)
1412 {
1413 if (strcmp(op, option) == 0)
1414 {
1415 ifound = i;
1416 break;
1417 }
1418 }
1419 }
1420 return ifound;
1421}
1387 1422
1388/** Open a UTF-8 file and set file descriptor to first byte after BOM. 1423/** Open a UTF-8 file and set file descriptor to first byte after BOM.
1389 * If no BOM is present this behaves like open(). 1424 * If no BOM is present this behaves like open().