summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2012-04-10 06:14:37 +0200
committerGuillem Jover <guillem@debian.org>2012-04-14 09:16:03 +0200
commitc78e21281a15ca218182b18c3c891df901403e89 (patch)
treed6aac2e9b051f9f9368e36bb04ef1786479fe256
parent1fcb0305c9378eb461db5a5a1b930270c6773824 (diff)
downloaddpkg-c78e21281a15ca218182b18c3c891df901403e89.tar.gz
u-a: Refactor get selections into alternative_get_selections()
-rw-r--r--utils/update-alternatives.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 2c56136b3..542afc831 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2025,6 +2025,28 @@ get_argv_string(int argc, char **argv)
}
static void
+alternative_get_selections(void)
+{
+ struct alternative_map *alt_map_obj;
+ struct alternative_map *am;
+
+ alt_map_obj = alternative_map_new(NULL, NULL);
+ alternative_map_load_names(alt_map_obj);
+
+ for (am = alt_map_obj; am && am->item; am = am->next) {
+ char *current;
+
+ current = alternative_get_current(am->item);
+ printf("%-30s %-8s %s\n", am->key,
+ alternative_status_string(am->item->status),
+ current ? current : "");
+ free(current);
+ }
+
+ alternative_map_free(alt_map_obj);
+}
+
+static void
alternative_set_selection(struct alternative_map *all, const char *name,
const char *status, const char *choice)
{
@@ -2480,24 +2502,7 @@ main(int argc, char **argv)
config_all();
exit(0);
} else if (strcmp(action, "get-selections") == 0) {
- struct alternative_map *alt_map_obj;
- struct alternative_map *am;
-
- alt_map_obj = alternative_map_new(NULL, NULL);
- alternative_map_load_names(alt_map_obj);
-
- for (am = alt_map_obj; am && am->item; am = am->next) {
- char *current;
-
- current = alternative_get_current(am->item);
- printf("%-30s %-8s %s\n", am->key,
- alternative_status_string(am->item->status),
- current ? current : "");
- free(current);
- }
-
- alternative_map_free(alt_map_obj);
-
+ alternative_get_selections();
exit(0);
} else if (strcmp(action, "set-selections") == 0) {
struct alternative_map *alt_map_obj;