Style
This commit is contained in:
parent
36c53e7551
commit
26f70a5277
@ -50,7 +50,8 @@ extern const char *applet;
|
|||||||
* 0 = no changes (nothing to do)
|
* 0 = no changes (nothing to do)
|
||||||
* 1+ = number of runlevels updated
|
* 1+ = number of runlevels updated
|
||||||
*/
|
*/
|
||||||
static int add (const char *runlevel, const char *service)
|
static int
|
||||||
|
add(const char *runlevel, const char *service)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
@ -70,7 +71,8 @@ static int add (const char *runlevel, const char *service)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int delete (const char *runlevel, const char *service)
|
static int
|
||||||
|
delete(const char *runlevel, const char *service)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
@ -90,7 +92,8 @@ static int delete (const char *runlevel, const char *service)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show (RC_STRINGLIST *runlevels, bool verbose)
|
static void
|
||||||
|
show(RC_STRINGLIST *runlevels, bool verbose)
|
||||||
{
|
{
|
||||||
RC_STRINGLIST *services = rc_services_in_runlevel(NULL);
|
RC_STRINGLIST *services = rc_services_in_runlevel(NULL);
|
||||||
RC_STRING *service;
|
RC_STRING *service;
|
||||||
@ -148,7 +151,8 @@ static const char * const longopts_help[] = {
|
|||||||
#define DODELETE (1 << 2)
|
#define DODELETE (1 << 2)
|
||||||
#define DOSHOW (1 << 3)
|
#define DOSHOW (1 << 3)
|
||||||
|
|
||||||
int rc_update(int argc, char **argv)
|
int
|
||||||
|
rc_update(int argc, char **argv)
|
||||||
{
|
{
|
||||||
RC_STRINGLIST *runlevels;
|
RC_STRINGLIST *runlevels;
|
||||||
RC_STRING *runlevel;
|
RC_STRING *runlevel;
|
||||||
@ -189,7 +193,7 @@ int rc_update(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
eerrorx("%s: invalid command `%s'", applet, argv[optind]);
|
eerrorx("%s: invalid command `%s'", applet, argv[optind]);
|
||||||
}
|
}
|
||||||
if (! action)
|
if (!action)
|
||||||
action = DOSHOW;
|
action = DOSHOW;
|
||||||
|
|
||||||
runlevels = rc_stringlist_new();
|
runlevels = rc_stringlist_new();
|
||||||
@ -215,14 +219,14 @@ int rc_update(int argc, char **argv)
|
|||||||
if (action & DOSHOW) {
|
if (action & DOSHOW) {
|
||||||
if (service)
|
if (service)
|
||||||
rc_stringlist_add(runlevels, service);
|
rc_stringlist_add(runlevels, service);
|
||||||
if (! TAILQ_FIRST(runlevels)) {
|
if (!TAILQ_FIRST(runlevels)) {
|
||||||
free(runlevels);
|
free(runlevels);
|
||||||
runlevels = rc_runlevel_list();
|
runlevels = rc_runlevel_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
show (runlevels, verbose);
|
show (runlevels, verbose);
|
||||||
} else {
|
} else {
|
||||||
if (! service)
|
if (!service)
|
||||||
eerror ("%s: no service specified", applet);
|
eerror ("%s: no service specified", applet);
|
||||||
else {
|
else {
|
||||||
if (action & DOADD) {
|
if (action & DOADD) {
|
||||||
@ -231,22 +235,22 @@ int rc_update(int argc, char **argv)
|
|||||||
actfunc = delete;
|
actfunc = delete;
|
||||||
} else {
|
} else {
|
||||||
rc_stringlist_free(runlevels);
|
rc_stringlist_free(runlevels);
|
||||||
eerrorx ("%s: invalid action", applet);
|
eerrorx("%s: invalid action", applet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! TAILQ_FIRST(runlevels)) {
|
if (!TAILQ_FIRST(runlevels)) {
|
||||||
p = rc_runlevel_get();
|
p = rc_runlevel_get();
|
||||||
rc_stringlist_add(runlevels, p);
|
rc_stringlist_add(runlevels, p);
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! TAILQ_FIRST(runlevels)) {
|
if (!TAILQ_FIRST(runlevels)) {
|
||||||
free(runlevels);
|
free(runlevels);
|
||||||
eerrorx ("%s: no runlevels found", applet);
|
eerrorx ("%s: no runlevels found", applet);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH (runlevel, runlevels, entries) {
|
TAILQ_FOREACH(runlevel, runlevels, entries) {
|
||||||
if (! rc_runlevel_exists(runlevel->value)) {
|
if (!rc_runlevel_exists(runlevel->value)) {
|
||||||
eerror ("%s: runlevel `%s' does not exist",
|
eerror ("%s: runlevel `%s' does not exist",
|
||||||
applet, runlevel->value);
|
applet, runlevel->value);
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user