summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-24 12:23:21 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-29 21:55:52 +0200
commite3ead6bb42f7c0f18d0ac100d33b71913fe4dcca (patch)
treede8cf6617b55f6aba1ae684d84e40dc95d62e799 /src/systemctl
parent56a730fa568f6ad168cb77ed46e57c042325eedb (diff)
systemctl: move strv_skip_first() out of systemctl.c
Make it generic, call it strv_skip() and move it to strv.[ch]
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index f7deb439da..059e51c2cd 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -146,12 +146,6 @@ static int daemon_reload(sd_bus *bus, char **args);
static int halt_now(enum action a);
static int check_one_unit(sd_bus *bus, const char *name, const char *good_states, bool quiet);
-static char** strv_skip_first(char **strv) {
- if (strv_length(strv) > 0)
- return strv + 1;
- return NULL;
-}
-
static void pager_open_if_enabled(void) {
if (arg_no_pager)
@@ -664,7 +658,7 @@ static int list_units(sd_bus *bus, char **args) {
pager_open_if_enabled();
- r = get_unit_list_recursive(bus, strv_skip_first(args), &unit_infos, &replies, &machines);
+ r = get_unit_list_recursive(bus, strv_skip(args, 1), &unit_infos, &replies, &machines);
if (r < 0)
return r;
@@ -870,7 +864,7 @@ static int list_sockets(sd_bus *bus, char **args) {
pager_open_if_enabled();
- n = get_unit_list_recursive(bus, strv_skip_first(args), &unit_infos, &replies, &machines);
+ n = get_unit_list_recursive(bus, strv_skip(args, 1), &unit_infos, &replies, &machines);
if (n < 0)
return n;
@@ -1178,7 +1172,7 @@ static int list_timers(sd_bus *bus, char **args) {
pager_open_if_enabled();
- n = get_unit_list_recursive(bus, strv_skip_first(args), &unit_infos, &replies, &machines);
+ n = get_unit_list_recursive(bus, strv_skip(args, 1), &unit_infos, &replies, &machines);
if (n < 0)
return n;
@@ -1368,7 +1362,7 @@ static int list_unit_files(sd_bus *bus, char **args) {
}
HASHMAP_FOREACH(u, h, i) {
- if (!output_show_unit_file(u, strv_skip_first(args)))
+ if (!output_show_unit_file(u, strv_skip(args, 1)))
continue;
units[c++] = *u;
@@ -1408,7 +1402,7 @@ static int list_unit_files(sd_bus *bus, char **args) {
unit_file_state_from_string(state)
};
- if (output_show_unit_file(&units[c], strv_skip_first(args)))
+ if (output_show_unit_file(&units[c], strv_skip(args, 1)))
c ++;
}
@@ -1889,7 +1883,7 @@ static int list_machines(sd_bus *bus, char **args) {
pager_open_if_enabled();
- r = get_machine_list(bus, &machine_infos, strv_skip_first(args));
+ r = get_machine_list(bus, &machine_infos, strv_skip(args, 1));
if (r < 0)
return r;
@@ -2121,7 +2115,7 @@ static int list_jobs(sd_bus *bus, char **args) {
while ((r = sd_bus_message_read(reply, "(usssoo)", &id, &name, &type, &state, &job_path, &unit_path)) > 0) {
struct job_info job = { id, name, type, state };
- if (!output_show_job(&job, strv_skip_first(args))) {
+ if (!output_show_job(&job, strv_skip(args, 1))) {
skipped = true;
continue;
}