Blame SOURCES/0068-lib-add-function-index_of_string_in_list.patch

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