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:
parent
498e5f99d2
commit
862608ca1f
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user