Find a string on the list. Assumes the last element on the list is NULL \param list - a list \param what - a string to find \return string position on the list on success, -1 if string not found or if string is empty */
| 1034 | -1 if string not found or if string is empty |
| 1035 | */ |
| 1036 | int find_on_list(char **list, const char *what) |
| 1037 | { |
| 1038 | int i = 0; |
| 1039 | |
| 1040 | if (!what) |
| 1041 | { |
| 1042 | return -1; |
| 1043 | } |
| 1044 | |
| 1045 | if (!list[i]) |
| 1046 | { |
| 1047 | return -1; |
| 1048 | } |
| 1049 | |
| 1050 | while (list[i] != NULL) |
| 1051 | { |
| 1052 | if (strcmp(list[i], what) == 0) |
| 1053 | { |
| 1054 | return i; |
| 1055 | } |
| 1056 | else |
| 1057 | { |
| 1058 | i++; |
| 1059 | } |
| 1060 | } |
| 1061 | |
| 1062 | return i; |
| 1063 | } |