blob: d379feea4981d500707f17ee5752edb854f778cb [file] [log] [blame]
Bernhard Reutner-Fischer421d9e52006-04-03 16:39:31 +00001/* vi:set ts=4:*/
Glenn L McGrathb9638752002-12-02 00:01:36 +00002/*
Bernhard Reutner-Fischer421d9e52006-04-03 16:39:31 +00003 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Glenn L McGrathb9638752002-12-02 00:01:36 +00004 */
5
6#include <string.h>
Bernhard Reutner-Fischer421d9e52006-04-03 16:39:31 +00007#include "libbb.h"
Glenn L McGrathb9638752002-12-02 00:01:36 +00008
9/* returns the array number of the string */
Rob Landleyca087712006-03-29 16:52:56 +000010int compare_string_array(const char * const string_array[], const char *key)
Glenn L McGrathb9638752002-12-02 00:01:36 +000011{
"Vladimir N. Oleynik"cc343442005-11-26 10:45:26 +000012 int i;
Glenn L McGrathb9638752002-12-02 00:01:36 +000013
14 for (i = 0; string_array[i] != 0; i++) {
15 if (strcmp(string_array[i], key) == 0) {
"Vladimir N. Oleynik"cc343442005-11-26 10:45:26 +000016 return i;
Glenn L McGrathb9638752002-12-02 00:01:36 +000017 }
18 }
"Vladimir N. Oleynik"cc343442005-11-26 10:45:26 +000019 return -i;
Manuel Novoa III cad53642003-03-19 09:13:01 +000020}
21