From 1e15ffd07101d090925995b6287d1e745d0aca2c Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Thu, 11 Sep 2014 08:34:43 +0200
Subject: [LIBREPORT PATCH 68/93] lib: add function index_of_string_in_list
Related:rhbz#1067440
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
---
src/include/internal_libreport.h | 3 +++
src/lib/is_in_string_list.c | 10 ++++++++++
2 files changed, 13 insertions(+)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 52f466f..585b807 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -287,6 +287,9 @@ char *run_in_shell_and_save_output(int flags,
#define is_in_string_list libreport_is_in_string_list
bool is_in_string_list(const char *name, char **v);
+#define index_of_string_in_list libreport_index_of_string_in_list
+int index_of_string_in_list(const char *name, char **v);
+
#define is_in_comma_separated_list libreport_is_in_comma_separated_list
bool is_in_comma_separated_list(const char *value, const char *list);
#define is_in_comma_separated_list_of_glob_patterns libreport_is_in_comma_separated_list_of_glob_patterns
diff --git a/src/lib/is_in_string_list.c b/src/lib/is_in_string_list.c
index 663edff..e0ee26b 100644
--- a/src/lib/is_in_string_list.c
+++ b/src/lib/is_in_string_list.c
@@ -28,3 +28,13 @@ bool is_in_string_list(const char *name, char **v)
}
return false;
}
+
+int index_of_string_in_list(const char *name, char **v)
+{
+ for(int i = 0; v[i]; ++i)
+ {
+ if (strcmp(v[i], name) == 0)
+ return i;
+ }
+ return -1;
+}
--
1.8.3.1