1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

libsmbconf: add smbconf_reverse_find_in_array() to find last occurence of a string.

Michael
(This used to be commit 25e0fd8478)
This commit is contained in:
Michael Adam 2008-04-08 00:03:39 +02:00
parent 498e5f99d2
commit 862608ca1f
2 changed files with 24 additions and 0 deletions

View File

@ -70,4 +70,7 @@ WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
bool smbconf_find_in_array(const char *string, char **list,
uint32_t num_entries, uint32_t *entry);
bool smbconf_reverse_find_in_array(const char *string, char **list,
uint32_t num_entries, uint32_t *entry);
#endif

View File

@ -122,3 +122,24 @@ bool smbconf_find_in_array(const char *string, char **list,
return false;
}
bool smbconf_reverse_find_in_array(const char *string, char **list,
uint32_t num_entries, uint32_t *entry)
{
uint32_t i;
if ((string == NULL) || (list == NULL) || (num_entries == 0)) {
return false;
}
for (i = num_entries - 1; i >= 0; i++) {
if (strequal(string, list[i])) {
if (entry != NULL) {
*entry = i;
}
return true;
}
}
return false;
}