summaryrefslogtreecommitdiff
path: root/src/rc/rc-update.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-23 21:31:22 +0000
committerRoy Marples <roy@marples.name>2009-04-23 21:31:22 +0000
commitade85d4bd81d7257f5a7e2e4ed40b9cbbbe23651 (patch)
tree278e8ec69f53fac2bc51b5122e6980e625ffeeca /src/rc/rc-update.c
parent69534746553adb52d3ede38a4cf8cd3630c97091 (diff)
downloadopenrc-ade85d4bd81d7257f5a7e2e4ed40b9cbbbe23651.tar.gz
openrc-ade85d4bd81d7257f5a7e2e4ed40b9cbbbe23651.tar.bz2
openrc-ade85d4bd81d7257f5a7e2e4ed40b9cbbbe23651.tar.xz
Improve style for KNF
Diffstat (limited to 'src/rc/rc-update.c')
-rw-r--r--src/rc/rc-update.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 3e0c795..6b31ba1 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -1,7 +1,7 @@
/*
- rc-update
- Manage init scripts and runlevels
- */
+ rc-update
+ Manage init scripts and runlevels
+*/
/*
* Copyright 2007-2009 Roy Marples <roy@marples.name>
@@ -57,19 +57,21 @@ add(const char *runlevel, const char *service)
if (!rc_service_exists(service)) {
if (errno == ENOEXEC)
- eerror("%s: service `%s' is not executeable", applet, service);
+ eerror("%s: service `%s' is not executeable",
+ applet, service);
else
- eerror("%s: service `%s' does not exist", applet, service);
+ eerror("%s: service `%s' does not exist",
+ applet, service);
} else if (rc_service_in_runlevel(service, runlevel)) {
ewarn ("%s: %s already installed in runlevel `%s'; skipping",
- applet, service, runlevel);
+ applet, service, runlevel);
retval = 0;
} else if (rc_service_add(runlevel, service)) {
einfo ("%s added to runlevel %s", service, runlevel);
retval = 1;
} else
eerror("%s: failed to add service `%s' to runlevel `%s': %s",
- applet, service, runlevel, strerror (errno));
+ applet, service, runlevel, strerror (errno));
return retval;
}
@@ -87,10 +89,10 @@ delete(const char *runlevel, const char *service)
if (errno == ENOENT)
eerror ("%s: service `%s' is not in the runlevel `%s'",
- applet, service, runlevel);
+ applet, service, runlevel);
else
eerror ("%s: failed to remove service `%s' from runlevel `%s': %s",
- applet, service, runlevel, strerror (errno));
+ applet, service, runlevel, strerror (errno));
return retval;
}
@@ -112,7 +114,7 @@ show(RC_STRINGLIST *runlevels, bool verbose)
TAILQ_FOREACH(runlevel, runlevels, entries) {
if (rc_service_in_runlevel(service->value,
- runlevel->value))
+ runlevel->value))
{
rc_stringlist_add(in, runlevel->value);
inone = true;
@@ -127,7 +129,7 @@ show(RC_STRINGLIST *runlevels, bool verbose)
if (inone || verbose) {
printf(" %20s |", service->value);
TAILQ_FOREACH(runlevel, in, entries)
- printf (" %s", runlevel->value);
+ printf (" %s", runlevel->value);
printf ("\n");
}
rc_stringlist_free(in);
@@ -137,9 +139,9 @@ show(RC_STRINGLIST *runlevels, bool verbose)
}
#include "_usage.h"
-#define usagestring "" \
- "Usage: rc-update [options] add service <runlevel>\n" \
- " rc-update [options] del service <runlevel>\n" \
+#define usagestring "" \
+ "Usage: rc-update [options] add service <runlevel>\n" \
+ " rc-update [options] del service <runlevel>\n" \
" rc-update [options] show"
#define getoptstring "u" getoptstring_COMMON
static const struct option longopts[] = {
@@ -172,13 +174,13 @@ rc_update(int argc, char **argv)
int ret;
while ((opt = getopt_long(argc, argv, getoptstring,
- longopts, (int *)0)) != -1)
+ longopts, (int *)0)) != -1)
switch (opt) {
case 'u':
_rc_deptree_load(-1, &ret);
return ret;
- case_RC_COMMON_GETOPT
- }
+ case_RC_COMMON_GETOPT
+ }
verbose = rc_yesno(getenv ("EINFO_VERBOSE"));
@@ -192,14 +194,15 @@ rc_update(int argc, char **argv)
if (strcmp(argv[optind], "add") == 0)
action = DOADD;
else if (strcmp(argv[optind], "delete") == 0 ||
- strcmp(argv[optind], "del") == 0)
+ strcmp(argv[optind], "del") == 0)
action = DODELETE;
else if (strcmp(argv[optind], "show") == 0)
action = DOSHOW;
if (action)
optind++;
else
- eerrorx("%s: invalid command `%s'", applet, argv[optind]);
+ eerrorx("%s: invalid command `%s'",
+ applet, argv[optind]);
}
if (!action)
action = DOSHOW;
@@ -219,7 +222,7 @@ rc_update(int argc, char **argv)
else {
rc_stringlist_free(runlevels);
eerrorx ("%s: `%s' is not a valid runlevel",
- applet, argv[optind]);
+ applet, argv[optind]);
}
}
@@ -254,13 +257,13 @@ rc_update(int argc, char **argv)
if (!TAILQ_FIRST(runlevels)) {
free(runlevels);
- eerrorx ("%s: no runlevels found", applet);
+ eerrorx("%s: no runlevels found", applet);
}
TAILQ_FOREACH(runlevel, runlevels, entries) {
if (!rc_runlevel_exists(runlevel->value)) {
eerror ("%s: runlevel `%s' does not exist",
- applet, runlevel->value);
+ applet, runlevel->value);
continue;
}
@@ -273,8 +276,8 @@ rc_update(int argc, char **argv)
if (retval == EXIT_SUCCESS &&
num_updated == 0 && action & DODELETE)
ewarnx("%s: service `%s' not found in any"
- " of the specified runlevels",
- applet, service);
+ " of the specified runlevels",
+ applet, service);
}
}