diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-03-13 14:31:02 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-03-13 14:31:02 -0400 |
commit | 2352cef6d0757a4d31a18561a09a10f031388e12 (patch) | |
tree | 81d555acb1f7382d7c8c7c4180cfb9aa5b028d8b /apps/shortcuts.c | |
parent | a62d36d9e7fd89adfd55ae2428fa9df4243bc435 (diff) | |
download | rockbox-2352cef6d0757a4d31a18561a09a10f031388e12.tar.gz rockbox-2352cef6d0757a4d31a18561a09a10f031388e12.zip |
replace more strcmp if then trees with string_option()
1
Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084
Diffstat (limited to 'apps/shortcuts.c')
-rw-r--r-- | apps/shortcuts.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c index f573d6fe4e..754bd83b80 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c | |||
@@ -312,18 +312,22 @@ static int readline_cb(int n, char *buf, void *parameters) | |||
312 | } | 312 | } |
313 | else if (sc && settings_parseline(buf, &name, &value)) | 313 | else if (sc && settings_parseline(buf, &name, &value)) |
314 | { | 314 | { |
315 | if (!strcmp(name, "type")) | 315 | static const char *nm_options[] = {"type", "name", "data", |
316 | "icon", "talkclip", NULL}; | ||
317 | int nm_op = string_option(name, nm_options, false); | ||
318 | |||
319 | if (nm_op == 0) /*type*/ | ||
316 | { | 320 | { |
317 | int t = 0; | 321 | int t = 0; |
318 | for (t=0; t<SHORTCUT_TYPE_COUNT && sc->type == SHORTCUT_UNDEFINED; t++) | 322 | for (t=0; t<SHORTCUT_TYPE_COUNT && sc->type == SHORTCUT_UNDEFINED; t++) |
319 | if (!strcmp(value, type_strings[t])) | 323 | if (!strcmp(value, type_strings[t])) |
320 | sc->type = t; | 324 | sc->type = t; |
321 | } | 325 | } |
322 | else if (!strcmp(name, "name")) | 326 | else if (nm_op == 1) /*name*/ |
323 | { | 327 | { |
324 | strlcpy(sc->name, value, MAX_SHORTCUT_NAME); | 328 | strlcpy(sc->name, value, MAX_SHORTCUT_NAME); |
325 | } | 329 | } |
326 | else if (!strcmp(name, "data")) | 330 | else if (nm_op == 2) /*data*/ |
327 | { | 331 | { |
328 | switch (sc->type) | 332 | switch (sc->type) |
329 | { | 333 | { |
@@ -357,7 +361,7 @@ static int readline_cb(int n, char *buf, void *parameters) | |||
357 | break; | 361 | break; |
358 | } | 362 | } |
359 | } | 363 | } |
360 | else if (!strcmp(name, "icon")) | 364 | else if (nm_op == 3) /*icon*/ |
361 | { | 365 | { |
362 | if (!strcmp(value, "filetype") && sc->type != SHORTCUT_SETTING && sc->u.path[0]) | 366 | if (!strcmp(value, "filetype") && sc->type != SHORTCUT_SETTING && sc->u.path[0]) |
363 | { | 367 | { |
@@ -368,7 +372,7 @@ static int readline_cb(int n, char *buf, void *parameters) | |||
368 | sc->icon = atoi(value); | 372 | sc->icon = atoi(value); |
369 | } | 373 | } |
370 | } | 374 | } |
371 | else if (!strcmp(name, "talkclip")) | 375 | else if (nm_op == 4) /*talkclip*/ |
372 | { | 376 | { |
373 | strlcpy(sc->talk_clip, value, MAX_PATH); | 377 | strlcpy(sc->talk_clip, value, MAX_PATH); |
374 | } | 378 | } |