diff --git a/source3/lib/smbconf/smbconf_private.h b/source3/lib/smbconf/smbconf_private.h index cba9148c7c8..44229e26ec3 100644 --- a/source3/lib/smbconf/smbconf_private.h +++ b/source3/lib/smbconf/smbconf_private.h @@ -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 diff --git a/source3/lib/smbconf/smbconf_util.c b/source3/lib/smbconf/smbconf_util.c index 99b08cdd708..ee79b6360fb 100644 --- a/source3/lib/smbconf/smbconf_util.c +++ b/source3/lib/smbconf/smbconf_util.c @@ -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; +}