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