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

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