From abde759d5bf6028135667779297d30491f1f4688 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 11 Jan 2008 15:51:40 +0000 Subject: Re-indent to a standard tw of 8. --- src/libeinfo/libeinfo.c | 87 ++++++++++----------- src/librc/librc-daemon.c | 28 +++---- src/librc/librc-depend.c | 124 +++++++++++++++--------------- src/librc/librc-misc.c | 12 +-- src/librc/librc-strlist.c | 6 +- src/librc/librc.c | 62 +++++++-------- src/rc/_usage.c | 2 +- src/rc/checkpath.c | 16 ++-- src/rc/fstabinfo.c | 12 +-- src/rc/mountinfo.c | 32 ++++---- src/rc/rc-depend.c | 8 +- src/rc/rc-logger.c | 12 +-- src/rc/rc-misc.c | 8 +- src/rc/rc-plugin.c | 4 +- src/rc/rc-status.c | 14 ++-- src/rc/rc-update.c | 18 ++--- src/rc/rc.c | 188 ++++++++++++++++++++++----------------------- src/rc/runscript.c | 92 +++++++++++----------- src/rc/start-stop-daemon.c | 56 +++++++------- 19 files changed, 392 insertions(+), 389 deletions(-) diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c index bebb3ef3..a8bd8254 100644 --- a/src/libeinfo/libeinfo.c +++ b/src/libeinfo/libeinfo.c @@ -45,7 +45,7 @@ const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples"; #include #include #ifdef HAVE_TERMCAP -#include +# include #endif #include @@ -78,24 +78,24 @@ hidden_proto(ewarnx) hidden_proto(ewend) hidden_proto(ewendv) - /* Incase we cannot work out how many columns from ioctl, supply a default */ +/* Incase we cannot work out how many columns from ioctl, supply a default */ #define DEFAULT_COLS 80 -#define OK "ok" -#define NOT_OK "!!" +#define OK "ok" +#define NOT_OK "!!" /* Number of spaces for an indent */ #define INDENT_WIDTH 2 /* How wide can the indent go? */ -#define INDENT_MAX 40 +#define INDENT_MAX 40 /* Default colours */ -#define GOOD 2 -#define WARN 3 -#define BAD 1 -#define HILITE 6 -#define BRACKET 4 +#define GOOD 2 +#define WARN 3 +#define BAD 1 +#define HILITE 6 +#define BRACKET 4 /* We fallback to these escape codes if termcap isn't available * like say /usr isn't mounted */ @@ -106,6 +106,12 @@ hidden_proto(ewendv) #define ME "\033[m" #define UP "\033[A" +#define _GET_CAP(_d, _c) strlcpy (_d, tgoto (_c, 0, 0), sizeof (_d)); +#define _ASSIGN_CAP(_v) { \ + _v = p; \ + p += strlcpy (p, tmp, sizeof (ebuffer) - (p - ebuffer)) + 1; \ +} + /* A pointer to a string to prefix to einfo/ewarn/eerror messages */ static const char *_eprefix = NULL; @@ -246,17 +252,17 @@ static bool yesno (const char *value) } if (strcasecmp (value, "yes") == 0 || - strcasecmp (value, "y") == 0 || - strcasecmp (value, "true") == 0 || - strcasecmp (value, "on") == 0 || - strcasecmp (value, "1") == 0) + strcasecmp (value, "y") == 0 || + strcasecmp (value, "true") == 0 || + strcasecmp (value, "on") == 0 || + strcasecmp (value, "1") == 0) return (true); if (strcasecmp (value, "no") != 0 && - strcasecmp (value, "n") != 0 && - strcasecmp (value, "false") != 0 && - strcasecmp (value, "off") != 0 && - strcasecmp (value, "0") != 0) + strcasecmp (value, "n") != 0 && + strcasecmp (value, "false") != 0 && + strcasecmp (value, "off") != 0 && + strcasecmp (value, "0") != 0) errno = EINVAL; return (false); @@ -388,12 +394,6 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f) } #endif -#define _GET_CAP(_d, _c) strlcpy (_d, tgoto (_c, 0, 0), sizeof (_d)); -#define _ASSIGN_CAP(_v) { \ - _v = p; \ - p += strlcpy (p, tmp, sizeof (ebuffer) - (p - ebuffer)) + 1; \ -} - /* Now setup our colours */ p = ebuffer; for (i = 0; i < sizeof (ecolors) / sizeof (ecolors[0]); i++) { @@ -402,7 +402,7 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f) if (ecolors[i].name) { const char *bold = _md; c = ecolors[i].def; - + /* See if the user wants to override the colour * We use a :col;bold: format like 2;1: for bold green * and 1;0: for a normal red */ @@ -441,8 +441,8 @@ static bool colour_terminal (FILE * __EINFO_RESTRICT f) } _GET_CAP (tmp, _ce) - _ASSIGN_CAP (flush) - _GET_CAP (tmp, _up); + _ASSIGN_CAP (flush) + _GET_CAP (tmp, _up); _ASSIGN_CAP (up); strlcpy (tmp, _ch, sizeof (tmp)); _ASSIGN_CAP (goto_column); @@ -557,26 +557,27 @@ const char *ecolor (einfo_color_t color) return (_ecolor (f, color)); } -#define LASTCMD(_cmd) \ +#define LASTCMD(_cmd) { \ unsetenv ("EINFO_LASTCMD"); \ - setenv ("EINFO_LASTCMD", _cmd, 1); + setenv ("EINFO_LASTCMD", _cmd, 1); \ +} #define EINFOVN(_file, _color) \ { \ char *_e = getenv ("EINFO_LASTCMD"); \ if (_e && ! colour_terminal (_file) && strcmp (_e, "ewarn") != 0 && \ - _e[strlen (_e) - 1] == 'n') \ - fprintf (_file, "\n"); \ + _e[strlen (_e) - 1] == 'n') \ + fprintf (_file, "\n"); \ if (_eprefix) \ fprintf (_file, "%s%s%s|", _ecolor (_file, _color), _eprefix, _ecolor (_file, ECOLOR_NORMAL)); \ fprintf (_file, " %s*%s ", _ecolor (_file, _color), _ecolor (_file, ECOLOR_NORMAL)); \ retval += _eindent (_file); \ -{ \ - va_list _ap; \ - va_copy (_ap, ap); \ - retval += vfprintf (_file, fmt, _ap) + 3; \ - va_end (_ap); \ -} \ + { \ + va_list _ap; \ + va_copy (_ap, ap); \ + retval += vfprintf (_file, fmt, _ap) + 3; \ + va_end (_ap); \ + } \ if (colour_terminal (_file)) \ fprintf (_file, "%s", flush); \ } @@ -769,7 +770,7 @@ int ebegin (const char *__EINFO_RESTRICT fmt, ...) hidden_def(ebegin) static void _eend (FILE * __EINFO_RESTRICT fp, int col, einfo_color_t color, - const char *msg) + const char *msg) { int i; int cols; @@ -793,8 +794,8 @@ static void _eend (FILE * __EINFO_RESTRICT fp, int col, einfo_color_t color, if (cols > 0 && colour_terminal (fp)) { fprintf (fp, "%s%s %s[%s%s%s]%s\n", up, tgoto (goto_column, 0, cols), - ecolor (ECOLOR_BRACKET), ecolor (color), msg, - ecolor (ECOLOR_BRACKET), ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_BRACKET), ecolor (color), msg, + ecolor (ECOLOR_BRACKET), ecolor (ECOLOR_NORMAL)); } else { if (col > 0) for (i = 0; i < cols - col; i++) @@ -823,8 +824,8 @@ static int _do_eend (const char *cmd, int retval, const char *__EINFO_RESTRICT f } _eend (fp, col, - retval == 0 ? ECOLOR_GOOD : ECOLOR_BAD, - retval == 0 ? OK : NOT_OK); + retval == 0 ? ECOLOR_GOOD : ECOLOR_BAD, + retval == 0 ? OK : NOT_OK); return (retval); } @@ -1013,7 +1014,7 @@ hidden_def(ebeginv) int eendv (int retval, const char *__EINFO_RESTRICT fmt, ...) { va_list ap; - + if (! is_verbose ()) return (0); diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index 04852e0e..28c5adcf 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -98,7 +98,7 @@ static bool pid_is_exec (pid_t pid, const char *exec) } pid_t *rc_find_pids (const char *exec, const char *cmd, - uid_t uid, pid_t pid) + uid_t uid, pid_t pid) { DIR *procdir; struct dirent *entry; @@ -192,7 +192,7 @@ librc_hidden_def(rc_find_pids) # endif pid_t *rc_find_pids (const char *exec, const char *cmd, - uid_t uid, pid_t pid) + uid_t uid, pid_t pid) { static kvm_t *kd = NULL; char errbuf[_POSIX2_LINE_MAX]; @@ -212,7 +212,7 @@ pid_t *rc_find_pids (const char *exec, const char *cmd, #ifdef _KVM_GETPROC2 kp = kvm_getproc2 (kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), - &processes); + &processes); #else kp = kvm_getprocs (kd, KERN_PROC_PROC, 0, &processes); #endif @@ -226,7 +226,7 @@ pid_t *rc_find_pids (const char *exec, const char *cmd, if (cmd) { if (! _GET_KINFO_COMM (kp[i]) || - strcmp (cmd, _GET_KINFO_COMM (kp[i])) != 0) + strcmp (cmd, _GET_KINFO_COMM (kp[i])) != 0) continue; } @@ -262,8 +262,8 @@ librc_hidden_def(rc_find_pids) #endif static bool _match_daemon (const char *path, const char *file, - const char *mexec, const char *mname, - const char *mpidfile) + const char *mexec, const char *mname, + const char *mpidfile) { char *line; char *ffile = rc_strcatpaths (path, file, (char *) NULL); @@ -304,8 +304,8 @@ static bool _match_daemon (const char *path, const char *file, } bool rc_service_daemon_set (const char *service, const char *exec, - const char *name, const char *pidfile, - bool started) + const char *name, const char *pidfile, + bool started) { char *dirpath; char *file = NULL; @@ -325,7 +325,7 @@ bool rc_service_daemon_set (const char *service, const char *exec, } dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", - basename_c (service), (char *) NULL); + basename_c (service), (char *) NULL); if (exec) { i = strlen (exec) + 6; @@ -358,7 +358,7 @@ bool rc_service_daemon_set (const char *service, const char *exec, if (! oldfile) { if (_match_daemon (dirpath, d->d_name, - mexec, mname, mpidfile)) + mexec, mname, mpidfile)) { unlink (file); oldfile = file; @@ -402,7 +402,7 @@ bool rc_service_daemon_set (const char *service, const char *exec, librc_hidden_def(rc_service_daemon_set) bool rc_service_started_daemon (const char *service, const char *exec, - int indx) + int indx) { char *dirpath; char *file; @@ -416,8 +416,8 @@ bool rc_service_started_daemon (const char *service, const char *exec, return (false); dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename_c (service), - (char *) NULL); - + (char *) NULL); + i = strlen (exec) + 6; mexec = xmalloc (sizeof (char) * i); snprintf (mexec, i, "exec=%s", exec); @@ -468,7 +468,7 @@ bool rc_service_daemons_crashed (const char *service) return (false); dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename_c (service), - (char *) NULL); + (char *) NULL); if (! (dp = opendir (dirpath))) { free (dirpath); diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c index aece3858..cfc887ea 100644 --- a/src/librc/librc-depend.c +++ b/src/librc/librc-depend.c @@ -89,7 +89,7 @@ void rc_deptree_free (rc_depinfo_t *deptree) librc_hidden_def(rc_deptree_free) static rc_depinfo_t *get_depinfo (const rc_depinfo_t *deptree, - const char *service) + const char *service) { const rc_depinfo_t *di; @@ -104,7 +104,7 @@ static rc_depinfo_t *get_depinfo (const rc_depinfo_t *deptree, } static rc_deptype_t *get_deptype (const rc_depinfo_t *depinfo, - const char *type) + const char *type) { rc_deptype_t *dt; @@ -212,16 +212,16 @@ static bool valid_service (const char *runlevel, const char *service) rc_service_state_t state = rc_service_state (service); return ((strcmp (runlevel, bootlevel) != 0 && - rc_service_in_runlevel (service, bootlevel)) || - rc_service_in_runlevel (service, runlevel) || - state & RC_SERVICE_COLDPLUGGED || - state & RC_SERVICE_STARTED); + rc_service_in_runlevel (service, bootlevel)) || + rc_service_in_runlevel (service, runlevel) || + state & RC_SERVICE_COLDPLUGGED || + state & RC_SERVICE_STARTED); } static bool get_provided1 (const char *runlevel, struct lhead *providers, - rc_deptype_t *deptype, - const char *level, bool coldplugged, - rc_service_state_t state) + rc_deptype_t *deptype, + const char *level, bool coldplugged, + rc_service_state_t state) { char *service; int i; @@ -235,8 +235,8 @@ static bool get_provided1 (const char *runlevel, struct lhead *providers, ok = rc_service_in_runlevel (service, level); else if (coldplugged) ok = (s & RC_SERVICE_COLDPLUGGED && - ! rc_service_in_runlevel (service, runlevel) && - ! rc_service_in_runlevel (service, bootlevel)); + ! rc_service_in_runlevel (service, runlevel) && + ! rc_service_in_runlevel (service, bootlevel)); if (! ok) continue; @@ -249,8 +249,8 @@ static bool get_provided1 (const char *runlevel, struct lhead *providers, case RC_SERVICE_STARTING: case RC_SERVICE_STOPPING: ok = (s & RC_SERVICE_STARTING || - s & RC_SERVICE_STOPPING || - s & RC_SERVICE_INACTIVE); + s & RC_SERVICE_STOPPING || + s & RC_SERVICE_INACTIVE); break; default: break; @@ -276,8 +276,8 @@ static bool get_provided1 (const char *runlevel, struct lhead *providers, provided dependancy can change depending on runlevel state. */ static char **get_provided (const rc_depinfo_t *deptree, - const rc_depinfo_t *depinfo, - const char *runlevel, int options) + const rc_depinfo_t *depinfo, + const char *runlevel, int options) { rc_deptype_t *dt; struct lhead providers; @@ -286,7 +286,7 @@ static char **get_provided (const rc_depinfo_t *deptree, if (! deptree || ! depinfo) return (NULL); - + if (rc_service_exists (depinfo->service)) return (NULL); @@ -312,7 +312,7 @@ static char **get_provided (const rc_depinfo_t *deptree, { STRLIST_FOREACH (dt->services, service, i) if (rc_service_in_runlevel (service, runlevel) || - rc_service_in_runlevel (service, bootlevel)) + rc_service_in_runlevel (service, bootlevel)) rc_strlist_add (&providers.list, service); if (providers.list) @@ -373,7 +373,7 @@ static char **get_provided (const rc_depinfo_t *deptree, return (providers.list); if (bootlevel && (strcmp (runlevel, bootlevel) != 0) - && (get_provided1 (runlevel, &providers, dt, bootlevel, false, RC_SERVICE_STOPPED))) + && (get_provided1 (runlevel, &providers, dt, bootlevel, false, RC_SERVICE_STOPPED))) return (providers.list); /* Still nothing? OK, list all services */ @@ -384,10 +384,10 @@ static char **get_provided (const rc_depinfo_t *deptree, } static void visit_service (const rc_depinfo_t *deptree, - const char * const *types, - struct lhead *sorted, struct lhead *visited, - const rc_depinfo_t *depinfo, - const char *runlevel, int options) + const char * const *types, + struct lhead *sorted, struct lhead *visited, + const rc_depinfo_t *depinfo, + const char *runlevel, int options) { int i, j, k; char *lp; @@ -428,26 +428,26 @@ static void visit_service (const rc_depinfo_t *deptree, { di = get_depinfo (deptree, lp); if (di && (strcmp (item, "ineed") == 0 || - strcmp (item, "needsme") == 0 || - valid_service (runlevel, di->service))) + strcmp (item, "needsme") == 0 || + valid_service (runlevel, di->service))) visit_service (deptree, types, sorted, visited, di, - runlevel, options | RC_DEP_TRACE); + runlevel, options | RC_DEP_TRACE); } rc_strlist_free (provides); } else if (di && (strcmp (item, "ineed") == 0 || - strcmp (item, "needsme") == 0 || - valid_service (runlevel, service))) + strcmp (item, "needsme") == 0 || + valid_service (runlevel, service))) visit_service (deptree, types, sorted, visited, di, - runlevel, options | RC_DEP_TRACE); + runlevel, options | RC_DEP_TRACE); } } } /* Now visit the stuff we provide for */ if (options & RC_DEP_TRACE && - (dt = get_deptype (depinfo, "iprovide"))) + (dt = get_deptype (depinfo, "iprovide"))) { STRLIST_FOREACH (dt->services, service, i) { @@ -458,7 +458,7 @@ static void visit_service (const rc_depinfo_t *deptree, if (strcmp (lp, depinfo->service) == 0) { visit_service (deptree, types, sorted, visited, di, - runlevel, options | RC_DEP_TRACE); + runlevel, options | RC_DEP_TRACE); break; } rc_strlist_free (provides); @@ -475,7 +475,7 @@ static void visit_service (const rc_depinfo_t *deptree, } char **rc_deptree_depend (const rc_depinfo_t *deptree, - const char *service, const char *type) + const char *service, const char *type) { rc_depinfo_t *di; rc_deptype_t *dt; @@ -484,7 +484,7 @@ char **rc_deptree_depend (const rc_depinfo_t *deptree, char *svc; if (! (di = get_depinfo (deptree, service)) || - ! (dt = get_deptype (di, type))) + ! (dt = get_deptype (di, type))) { errno = ENOENT; return (NULL); @@ -499,9 +499,9 @@ char **rc_deptree_depend (const rc_depinfo_t *deptree, librc_hidden_def(rc_deptree_depend) char **rc_deptree_depends (const rc_depinfo_t *deptree, - const char *const *types, - const char *const *services, - const char *runlevel, int options) + const char *const *types, + const char *const *services, + const char *runlevel, int options) { struct lhead sorted; struct lhead visited; @@ -527,7 +527,7 @@ char **rc_deptree_depends (const rc_depinfo_t *deptree, } if (types) visit_service (deptree, types, &sorted, &visited, - di, runlevel, options); + di, runlevel, options); } rc_strlist_free (visited.list); @@ -535,9 +535,9 @@ char **rc_deptree_depends (const rc_depinfo_t *deptree, } librc_hidden_def(rc_deptree_depends) -static const char * const order_types[] = { "ineed", "iuse", "iafter", NULL }; + static const char * const order_types[] = { "ineed", "iuse", "iafter", NULL }; char **rc_deptree_order (const rc_depinfo_t *deptree, const char *runlevel, - int options) + int options) { char **list = NULL; char **services = NULL; @@ -553,8 +553,8 @@ char **rc_deptree_order (const rc_depinfo_t *deptree, const char *runlevel, /* When shutting down, list all running services */ if (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || - strcmp (runlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (runlevel, RC_LEVEL_REBOOT) == 0) + strcmp (runlevel, RC_LEVEL_SHUTDOWN) == 0 || + strcmp (runlevel, RC_LEVEL_REBOOT) == 0) { list = rc_services_in_state (RC_SERVICE_STARTED); @@ -585,8 +585,8 @@ char **rc_deptree_order (const rc_depinfo_t *deptree, const char *runlevel, /* Now we have our lists, we need to pull in any dependencies and order them */ services = rc_deptree_depends (deptree, order_types, (const char **) list, - runlevel, - RC_DEP_STRICT | RC_DEP_TRACE | options); + runlevel, + RC_DEP_STRICT | RC_DEP_TRACE | options); rc_strlist_free (list); if (reverse) @@ -680,10 +680,10 @@ bool rc_deptree_update_needed (void) /* Quick test to see if anything we use has changed */ if (! is_newer_than (RC_DEPTREE, RC_INITDIR) || - ! is_newer_than (RC_DEPTREE, RC_CONFDIR) || - ! is_newer_than (RC_DEPTREE, RC_INITDIR_LOCAL) || - ! is_newer_than (RC_DEPTREE, RC_CONFDIR_LOCAL) || - ! is_newer_than (RC_DEPTREE, "/etc/rc.conf")) + ! is_newer_than (RC_DEPTREE, RC_CONFDIR) || + ! is_newer_than (RC_DEPTREE, RC_INITDIR_LOCAL) || + ! is_newer_than (RC_DEPTREE, RC_CONFDIR_LOCAL) || + ! is_newer_than (RC_DEPTREE, "/etc/rc.conf")) return (true); /* Some init scripts dependencies change depending on config files @@ -701,14 +701,14 @@ bool rc_deptree_update_needed (void) } librc_hidden_def(rc_deptree_update_needed) -/* This is a 5 phase operation - Phase 1 is a shell script which loads each init script and config in turn - and echos their dependency info to stdout - Phase 2 takes that and populates a depinfo object with that data - Phase 3 adds any provided services to the depinfo object - Phase 4 scans that depinfo object and puts in backlinks - Phase 5 saves the depinfo object to disk - */ + /* This is a 5 phase operation + Phase 1 is a shell script which loads each init script and config in turn + and echos their dependency info to stdout + Phase 2 takes that and populates a depinfo object with that data + Phase 3 adds any provided services to the depinfo object + Phase 4 scans that depinfo object and puts in backlinks + Phase 5 saves the depinfo object to disk + */ bool rc_deptree_update (void) { char *depends; @@ -819,9 +819,9 @@ bool rc_deptree_update (void) /* .sh files are not init scripts */ len = strlen (depend); if (len > 2 && - depend[len - 3] == '.' && - depend[len - 2] == 's' && - depend[len - 1] == 'h') + depend[len - 3] == '.' && + depend[len - 2] == 's' && + depend[len - 1] == 'h') continue; rc_strlist_addsort (&deptype->services, depend); @@ -835,8 +835,8 @@ bool rc_deptree_update (void) } /* If we're after something, remove us from the before list */ if (strcmp (type, "iafter") == 0 || - strcmp (type, "ineed") == 0 || - strcmp (type, "iuse") == 0) { + strcmp (type, "ineed") == 0 || + strcmp (type, "iuse") == 0) { if ((dt = get_deptype (depinfo, "ibefore"))) rc_strlist_delete (&dt->services, depend); } @@ -886,8 +886,8 @@ next: if (strcmp (deptype->type, "ineed") == 0) { fprintf (stderr, - "Service `%s' needs non existant service `%s'\n", - depinfo->service, service); + "Service `%s' needs non existant service `%s'\n", + depinfo->service, service); } continue; } @@ -947,7 +947,7 @@ next: STRLIST_FOREACH (deptype->services, service, j) { fprintf (fp, "depinfo_%d_%s_%d='%s'\n", i, deptype->type, - k, service); + k, service); k++; } } diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c index 08f5e4e4..da52f980 100644 --- a/src/librc/librc-misc.c +++ b/src/librc/librc-misc.c @@ -39,15 +39,15 @@ bool rc_yesno (const char *value) } if (strcasecmp (value, "yes") == 0 || - strcasecmp (value, "y") == 0 || - strcasecmp (value, "true") == 0 || - strcasecmp (value, "1") == 0) + strcasecmp (value, "y") == 0 || + strcasecmp (value, "true") == 0 || + strcasecmp (value, "1") == 0) return (true); if (strcasecmp (value, "no") != 0 && - strcasecmp (value, "n") != 0 && - strcasecmp (value, "false") != 0 && - strcasecmp (value, "0") != 0) + strcasecmp (value, "n") != 0 && + strcasecmp (value, "false") != 0 && + strcasecmp (value, "0") != 0) errno = EINVAL; return (false); diff --git a/src/librc/librc-strlist.c b/src/librc/librc-strlist.c index 815c8370..ed3f10a6 100644 --- a/src/librc/librc-strlist.c +++ b/src/librc/librc-strlist.c @@ -71,9 +71,9 @@ char *rc_strlist_addu (char ***list, const char *item) librc_hidden_def(rc_strlist_addu) static char *_rc_strlist_addsort (char ***list, const char *item, - int (*sortfunc) (const char *s1, - const char *s2), - bool uniq) + int (*sortfunc) (const char *s1, + const char *s2), + bool uniq) { char **newlist; char **lst = *list; diff --git a/src/librc/librc.c b/src/librc/librc.c index 07652f4d..a03e2f12 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -90,8 +90,8 @@ static char **ls_dir (const char *dir, int options) /* .sh files are not init scripts */ if (l > 2 && d->d_name[l - 3] == '.' && - d->d_name[l - 2] == 's' && - d->d_name[l - 1] == 'h') + d->d_name[l - 2] == 's' && + d->d_name[l - 1] == 'h') continue; } if (options & LS_DIR) { @@ -227,7 +227,7 @@ bool rc_runlevel_exists (const char *runlevel) } librc_hidden_def(rc_runlevel_exists) -/* Resolve a service name to it's full path */ + /* Resolve a service name to it's full path */ char *rc_service_resolve (const char *service) { char buffer[PATH_MAX]; @@ -285,8 +285,8 @@ bool rc_service_exists (const char *service) /* .sh files are not init scripts */ if (len > 2 && service[len - 3] == '.' && - service[len - 2] == 's' && - service[len - 1] == 'h') + service[len - 2] == 's' && + service[len - 1] == 'h') return (false); if (! (file = rc_service_resolve (service))) @@ -367,7 +367,7 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel) return (false); file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service), - (char *) NULL); + (char *) NULL); retval = exists (file); free (file); @@ -396,7 +396,7 @@ bool rc_service_mark (const char *service, const rc_service_state_t state) } file = rc_strcatpaths (RC_SVCDIR, rc_parse_service_state (state), base, - (char *) NULL); + (char *) NULL); if (exists (file)) unlink (file); i = symlink (init, file); @@ -420,21 +420,21 @@ bool rc_service_mark (const char *service, const rc_service_state_t state) int s = rc_service_state_names[i].state; if ((s != skip_state && - s != RC_SERVICE_STOPPED && - s != RC_SERVICE_COLDPLUGGED && - s != RC_SERVICE_SCHEDULED) && - (! skip_wasinactive || s != RC_SERVICE_WASINACTIVE)) + s != RC_SERVICE_STOPPED && + s != RC_SERVICE_COLDPLUGGED && + s != RC_SERVICE_SCHEDULED) && + (! skip_wasinactive || s != RC_SERVICE_WASINACTIVE)) { file = rc_strcatpaths (RC_SVCDIR, rc_parse_service_state (s), base, - (char *) NULL); + (char *) NULL); if (exists (file)) { if ((state == RC_SERVICE_STARTING || - state == RC_SERVICE_STOPPING) && - s == RC_SERVICE_INACTIVE) + state == RC_SERVICE_STOPPING) && + s == RC_SERVICE_INACTIVE) { char *wasfile = rc_strcatpaths (RC_SVCDIR, - rc_parse_service_state (RC_SERVICE_WASINACTIVE), - base, (char *) NULL); + rc_parse_service_state (RC_SERVICE_WASINACTIVE), + base, (char *) NULL); symlink (init, wasfile); skip_wasinactive = true; @@ -448,8 +448,8 @@ bool rc_service_mark (const char *service, const rc_service_state_t state) /* Remove the exclusive state if we're inactive */ if (state == RC_SERVICE_STARTED || - state == RC_SERVICE_STOPPED || - state == RC_SERVICE_INACTIVE) + state == RC_SERVICE_STOPPED || + state == RC_SERVICE_INACTIVE) { file = rc_strcatpaths (RC_SVCDIR, "exclusive", base, (char *) NULL); unlink (file); @@ -504,7 +504,7 @@ rc_service_state_t rc_service_state (const char *service) for (i = 0; rc_service_state_names[i].name; i++) { char *file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[i].name, - basename_c (service), (char*) NULL); + basename_c (service), (char*) NULL); if (exists (file)) { if (rc_service_state_names[i].state <= 0x10) state = rc_service_state_names[i].state; @@ -531,7 +531,7 @@ char *rc_service_value_get (const char *service, const char *option) FILE *fp; char *line = NULL; char *file = rc_strcatpaths (RC_SVCDIR, "options", service, option, - (char *) NULL); + (char *) NULL); if ((fp = fopen (file, "r"))) { line = rc_getline (fp); @@ -544,7 +544,7 @@ char *rc_service_value_get (const char *service, const char *option) librc_hidden_def(rc_service_value_get) bool rc_service_value_set (const char *service, const char *option, - const char *value) + const char *value) { FILE *fp; char *path = rc_strcatpaths (RC_SVCDIR, "options", service, (char *) NULL); @@ -585,7 +585,7 @@ static pid_t _exec_service (const char *service, const char *arg) /* We create a fifo so that other services can wait until we complete */ fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename_c (service), - (char *) NULL); + (char *) NULL); if (mkfifo (fifo, 0600) != 0 && errno != EEXIST) { free (fifo); @@ -638,7 +638,7 @@ pid_t rc_service_start (const char *service) librc_hidden_def(rc_service_start) bool rc_service_schedule_start (const char *service, - const char *service_to_start) + const char *service_to_start) { char *dir; char *init; @@ -650,7 +650,7 @@ bool rc_service_schedule_start (const char *service, return (false); dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service), - (char *) NULL); + (char *) NULL); if (mkdir (dir, 0755) != 0 && errno != EEXIST) { free (dir); return (false); @@ -670,7 +670,7 @@ librc_hidden_def(rc_service_schedule_start) bool rc_service_schedule_clear (const char *service) { char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service), - (char *) NULL); + (char *) NULL); bool retval; if (! (retval = rm_dir (dir, true)) && errno == ENOENT) @@ -699,7 +699,7 @@ char **rc_services_in_runlevel (const char *runlevel) /* These special levels never contain any services */ if (strcmp (runlevel, RC_LEVEL_SYSINIT) == 0 || - strcmp (runlevel, RC_LEVEL_SINGLE) == 0) + strcmp (runlevel, RC_LEVEL_SINGLE) == 0) return (NULL); dir = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, (char *) NULL); @@ -712,7 +712,7 @@ librc_hidden_def(rc_services_in_runlevel) char **rc_services_in_state (rc_service_state_t state) { char *dir = rc_strcatpaths (RC_SVCDIR, rc_parse_service_state (state), - (char *) NULL); + (char *) NULL); char **list = NULL; if (state == RC_SERVICE_SCHEDULED) { @@ -776,7 +776,7 @@ bool rc_service_add (const char *runlevel, const char *service) } file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service), - (char *) NULL); + (char *) NULL); retval = (symlink (init, file) == 0); free (init); free (file); @@ -793,7 +793,7 @@ bool rc_service_delete (const char *runlevel, const char *service) return (false); file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service), - (char *) NULL); + (char *) NULL); if (unlink (file) == 0) retval = true; @@ -811,7 +811,7 @@ char **rc_services_scheduled_by (const char *service) STRLIST_FOREACH (dirs, dir, i) { char *file = rc_strcatpaths (RC_SVCDIR, "scheduled", dir, service, - (char *) NULL); + (char *) NULL); if (exists (file)) rc_strlist_add (&list, file); free (file); @@ -825,7 +825,7 @@ librc_hidden_def(rc_services_scheduled_by) char **rc_services_scheduled (const char *service) { char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename_c (service), - (char *) NULL); + (char *) NULL); char **list = NULL; list = ls_dir (dir, LS_INITD); diff --git a/src/rc/_usage.c b/src/rc/_usage.c index b079e320..32b4bbc1 100644 --- a/src/rc/_usage.c +++ b/src/rc/_usage.c @@ -37,7 +37,7 @@ static void usage (int exit_status) printf ("\n\nOptions: [" getoptstring "]\n"); for (i = 0; longopts[i].name; ++i) { int len = printf (" -%c, --%s %s", longopts[i].val, longopts[i].name, - has_arg[longopts[i].has_arg]); + has_arg[longopts[i].has_arg]); char *lo = xstrdup (longopts_help[i]); char *p = lo; diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c index 612a0769..db81a631 100644 --- a/src/rc/checkpath.c +++ b/src/rc/checkpath.c @@ -75,7 +75,7 @@ static int do_check (char *path, uid_t uid, gid_t gid, mode_t mode, int file) } } else { if ((file && S_ISDIR (st.st_mode)) || - (! file && ! S_ISDIR (st.st_mode))) + (! file && ! S_ISDIR (st.st_mode))) { if (file) eerror ("%s: is a directory", path); @@ -84,7 +84,7 @@ static int do_check (char *path, uid_t uid, gid_t gid, mode_t mode, int file) return (-1); } } - + if (mode && (st.st_mode & 0777) != mode) { einfo ("%s: correcting mode", applet); if (chmod (path, mode)) { @@ -126,7 +126,7 @@ static int parse_mode (mode_t *mode, char *text) } static int parse_owner (struct passwd **user, struct group **group, - const char *owner) + const char *owner) { char *u = xstrdup (owner); char *g = strchr (u, ':'); @@ -164,7 +164,7 @@ static int parse_owner (struct passwd **user, struct group **group, static struct option longopts[] = { { "directory", 0, NULL, 'd'}, { "file", 0, NULL, 'f'}, - { "mode", 1, NULL, 'm'}, + { "mode", 1, NULL, 'm'}, { "owner", 1, NULL, 'o'}, longopts_COMMON }; @@ -191,7 +191,7 @@ int checkpath (int argc, char **argv) applet = basename_c (argv[0]); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'd': @@ -202,11 +202,13 @@ int checkpath (int argc, char **argv) break; case 'm': if (parse_mode (&mode, optarg) != 0) - eerrorx ("%s: invalid mode `%s'", applet, optarg); + eerrorx ("%s: invalid mode `%s'", + applet, optarg); break; case 'o': if (parse_owner (&pw, &gr, optarg) != 0) - eerrorx ("%s: owner `%s' not found", applet, optarg); + eerrorx ("%s: owner `%s' not found", + applet, optarg); break; case_RC_COMMON_GETOPT diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c index 5f8e469a..e67d8313 100644 --- a/src/rc/fstabinfo.c +++ b/src/rc/fstabinfo.c @@ -81,7 +81,7 @@ static struct mntent *getmntfile (const char *file) if (strcmp (file, ent->mnt_dir) == 0) break; END_ENT; - + return (ent); } #endif @@ -134,7 +134,7 @@ int fstabinfo (int argc, char **argv) unsetenv ("EINFO_QUIET"); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'b': @@ -156,9 +156,9 @@ int fstabinfo (int argc, char **argv) START_ENT; while ((ent = GET_ENT)) { if (((optarg[0] == '=' && i == ENT_PASS (ent)) || - (optarg[0] == '<' && i > ENT_PASS (ent)) || - (optarg[0] == '>' && i < ENT_PASS (ent))) && - strcmp (ENT_FILE (ent), "none") != 0) + (optarg[0] == '<' && i > ENT_PASS (ent)) || + (optarg[0] == '>' && i < ENT_PASS (ent))) && + strcmp (ENT_FILE (ent), "none") != 0) rc_strlist_add (&files, ENT_FILE (ent)); } END_ENT; @@ -182,7 +182,7 @@ int fstabinfo (int argc, char **argv) } break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c index e7e29578..989dcbdc 100644 --- a/src/rc/mountinfo.c +++ b/src/rc/mountinfo.c @@ -86,8 +86,8 @@ struct args { }; static int process_mount (char ***list, struct args *args, - char *from, char *to, char *fstype, char *options, - int netdev) + char *from, char *to, char *fstype, char *options, + int netdev) { char *p; @@ -107,24 +107,24 @@ static int process_mount (char ***list, struct args *args, return (1); } else { if (args->node_regex && - regexec (args->node_regex, from, 0, NULL, 0) != 0) + regexec (args->node_regex, from, 0, NULL, 0) != 0) return (1); if (args->skip_node_regex && - regexec (args->skip_node_regex, from, 0, NULL, 0) == 0) + regexec (args->skip_node_regex, from, 0, NULL, 0) == 0) return (1); if (args->fstype_regex && - regexec (args->fstype_regex, fstype, 0, NULL, 0) != 0) + regexec (args->fstype_regex, fstype, 0, NULL, 0) != 0) return (-1); if (args->skip_fstype_regex && - regexec (args->skip_fstype_regex, fstype, 0, NULL, 0) == 0) + regexec (args->skip_fstype_regex, fstype, 0, NULL, 0) == 0) return (-1); if (args->options_regex && - regexec (args->options_regex, options, 0, NULL, 0) != 0) + regexec (args->options_regex, options, 0, NULL, 0) != 0) return (-1); if (args->skip_options_regex && - regexec (args->skip_options_regex, options, 0, NULL, 0) == 0) + regexec (args->skip_options_regex, options, 0, NULL, 0) == 0) return (-1); } @@ -247,11 +247,11 @@ static char **find_mounts (struct args *args) } process_mount (&list, args, - mnts[i].f_mntfromname, - mnts[i].f_mntonname, - mnts[i].f_fstypename, - options, - netdev); + mnts[i].f_mntfromname, + mnts[i].f_mntonname, + mnts[i].f_fstypename, + options, + netdev); free (options); options = NULL; @@ -271,7 +271,7 @@ static struct mntent *getmntfile (const char *file) if (strcmp (file, ent->mnt_dir) == 0) break; endmntent (fp); - + return (ent); } @@ -395,7 +395,7 @@ int mountinfo (int argc, char **argv) args.netdev = net_ignore; while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'e': @@ -456,7 +456,7 @@ int mountinfo (int argc, char **argv) REG_FREE (args.skip_node_regex); REG_FREE (args.options_regex); REG_FREE (args.skip_options_regex); - + rc_strlist_reverse (nodes); result = EXIT_FAILURE; diff --git a/src/rc/rc-depend.c b/src/rc/rc-depend.c index c5e9e662..4a5d64e1 100644 --- a/src/rc/rc-depend.c +++ b/src/rc/rc-depend.c @@ -99,7 +99,7 @@ int rc_depend (int argc, char **argv) applet = basename_c (argv[0]); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 's': @@ -116,7 +116,7 @@ int rc_depend (int argc, char **argv) options &= RC_DEP_TRACE; break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } @@ -140,7 +140,7 @@ int rc_depend (int argc, char **argv) rc_strlist_add (&list, argv[optind]); errno = 0; depends = rc_deptree_depends (deptree, NULL, (const char **) list, - runlevel, 0); + runlevel, 0); if (! depends && errno == ENOENT) eerror ("no dependency info for service `%s'", argv[optind]); else @@ -167,7 +167,7 @@ int rc_depend (int argc, char **argv) } depends = rc_deptree_depends (deptree, (const char **) types, - (const char **) services, runlevel, options); + (const char **) services, runlevel, options); if (depends) { STRLIST_FOREACH (depends, service, i) { diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c index 0c48e444..0d9c514c 100644 --- a/src/rc/rc-logger.c +++ b/src/rc/rc-logger.c @@ -96,7 +96,7 @@ static void write_log (int logfd, const char *buffer, size_t bytes) in_term = true; break; } - + if (! in_escape) { write (logfd, p++, 1); continue; @@ -159,7 +159,7 @@ void rc_logger_open (const char *level) eerrorx ("pipe: %s", strerror (errno)); for (i = 0; i < 2; i++) if ((s = fcntl (signal_pipe[i], F_GETFD, 0) == -1 || - fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1)) + fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1)) eerrorx ("fcntl: %s", strerror (errno)); tcgetattr (STDOUT_FILENO, &tt); @@ -213,7 +213,7 @@ void rc_logger_open (const char *level) if (logbuf_size - logbuf_len < bytes) { logbuf_size += BUFSIZ * 10; logbuf = xrealloc (logbuf, sizeof (char ) * - logbuf_size); + logbuf_size); } memcpy (logbuf + logbuf_len, buffer, bytes); @@ -242,7 +242,7 @@ void rc_logger_open (const char *level) /* Try and cat our new logfile to a more permament location and then * punt it */ system (MOVELOG); - + exit (0); default: setpgid (rc_logger_pid, 0); @@ -251,8 +251,8 @@ void rc_logger_open (const char *level) dup2 (slave_tty, STDOUT_FILENO); dup2 (slave_tty, STDERR_FILENO); if (slave_tty != STDIN_FILENO && - slave_tty != STDOUT_FILENO && - slave_tty != STDERR_FILENO) + slave_tty != STDOUT_FILENO && + slave_tty != STDERR_FILENO) close (slave_tty); close (signal_pipe[0]); signal_pipe[0] = -1; diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 3cfbe175..0d6be40d 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -186,7 +186,7 @@ char **env_filter (void) /* Ensure our PATH is prefixed with the system locations first for a little extra security */ if (strcmp (env_name, "PATH") == 0 && - strncmp (PATH_PREFIX, env_var, pplen) != 0) + strncmp (PATH_PREFIX, env_var, pplen) != 0) { got_path = true; env_len = strlen (env_name) + strlen (env_var) + pplen + 2; @@ -233,7 +233,7 @@ char **env_filter (void) return (env); } - /* Other systems may need this at some point, but for now it's Linux only */ +/* Other systems may need this at some point, but for now it's Linux only */ #ifdef __linux__ static bool file_regex (const char *file, const char *regex) { @@ -338,7 +338,7 @@ char **env_config (void) } else if (file_regex ("/proc/cpuinfo", "UML")) { snprintf (sys, sizeof (sys), "UML"); } else if (file_regex ("/proc/self/status", - "(s_context|VxID|envID):[[:space:]]*[1-9]")) + "(s_context|VxID|envID):[[:space:]]*[1-9]")) { snprintf (sys, sizeof (sys), "VPS"); } @@ -381,7 +381,7 @@ char **env_config (void) errno = 0; if ((! rc_conf_yesno ("rc_color") && errno == 0) || - rc_conf_yesno ("rc_nocolor")) + rc_conf_yesno ("rc_nocolor")) rc_strlist_add (&env, "EINFO_COLOR=no"); free (runlevel); diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c index 861f064d..f50b4343 100644 --- a/src/rc/rc-plugin.c +++ b/src/rc/rc-plugin.c @@ -167,7 +167,7 @@ void rc_plugin_run (rc_hook_t hook, const char *value) * plugin will probably hang when running in silent mode. */ for (i = 0; i < 2; i++) if ((flags = fcntl (pfd[i], F_GETFD, 0)) < 0 || - fcntl (pfd[i], F_SETFD, flags | FD_CLOEXEC) < 0) + fcntl (pfd[i], F_SETFD, flags | FD_CLOEXEC) < 0) eerror ("fcntl: %s", strerror (errno)); /* We run the plugin in a new process so we never crash @@ -214,7 +214,7 @@ void rc_plugin_run (rc_hook_t hook, const char *value) } } } - + free (buffer); close (pfd[0]); diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index 155192fa..f57584ab 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -48,9 +48,9 @@ static const char *types_nua[] = { "ineed", "iuse", "iafter", NULL }; static void print_level (char *level) { printf ("Runlevel: %s%s%s\n", - ecolor (ECOLOR_HILITE), - level, - ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_HILITE), + level, + ecolor (ECOLOR_NORMAL)); } static void print_service (char *service) @@ -121,7 +121,7 @@ int rc_status (int argc, char **argv) int depopts = RC_DEP_STRICT | RC_DEP_START | RC_DEP_TRACE; while ((opt = getopt_long (argc, argv, getoptstring, longopts, - (int *) 0)) != -1) + (int *) 0)) != -1) switch (opt) { case 'a': levels = rc_runlevel_list (); @@ -155,7 +155,7 @@ int rc_status (int argc, char **argv) rc_strlist_free (services); exit (EXIT_SUCCESS); - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } while (optind < argc) @@ -178,8 +178,8 @@ int rc_status (int argc, char **argv) services = rc_services_in_runlevel (level); if (deptree) { ordered = rc_deptree_depends (deptree, types_nua, - (const char **) services, - level, depopts); + (const char **) services, + level, depopts); rc_strlist_free (services); services = ordered; ordered = NULL; diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c index 4f07503f..463c0cfe 100644 --- a/src/rc/rc-update.c +++ b/src/rc/rc-update.c @@ -59,14 +59,14 @@ static int add (const char *runlevel, const char *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); } @@ -83,10 +83,10 @@ static int 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); } @@ -162,7 +162,7 @@ int rc_update (int argc, char **argv) applet = basename_c (argv[0]); while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'a': @@ -175,15 +175,15 @@ int rc_update (int argc, char **argv) action |= DOSHOW; break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } verbose = rc_yesno (getenv ("EINFO_VERBOSE")); if ((action & DOSHOW && action != DOSHOW) || - (action & DOADD && action != DOADD) || - (action & DODELETE && action != DODELETE)) + (action & DOADD && action != DOADD) || + (action & DODELETE && action != DODELETE)) eerrorx ("%s: cannot mix commands", applet); /* We need to be backwards compatible */ @@ -192,7 +192,7 @@ int 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; diff --git a/src/rc/rc.c b/src/rc/rc.c index 015dd86f..4bf6541e 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -123,8 +123,8 @@ static void clean_failed (void) if ((dp = opendir (RC_SVCDIR "/failed"))) { while ((d = readdir (dp))) { if (d->d_name[0] == '.' && - (d->d_name[1] == '\0' || - (d->d_name[1] == '.' && d->d_name[2] == '\0'))) + (d->d_name[1] == '\0' || + (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; i = strlen (RC_SVCDIR "/failed/") + strlen (d->d_name) + 1; @@ -133,7 +133,7 @@ static void clean_failed (void) if (path) { if (unlink (path)) eerror ("%s: unlink `%s': %s", applet, path, - strerror (errno)); + strerror (errno)); free (path); } } @@ -147,7 +147,7 @@ static void cleanup (void) pidlist_t *pl = service_pids; rc_plugin_unload (); - + if (! rc_in_plugin && termios_orig) { tcsetattr (fileno (stdin), TCSANOW, termios_orig); free (termios_orig); @@ -204,21 +204,21 @@ static int do_e (int argc, char **argv) if (strcmp (applet, "eval_ecolors") == 0) { printf ("GOOD='%s'\nWARN='%s'\nBAD='%s'\nHILITE='%s'\nBRACKET='%s'\nNORMAL='%s'\n", - ecolor (ECOLOR_GOOD), - ecolor (ECOLOR_WARN), - ecolor (ECOLOR_BAD), - ecolor (ECOLOR_HILITE), - ecolor (ECOLOR_BRACKET), - ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_GOOD), + ecolor (ECOLOR_WARN), + ecolor (ECOLOR_BAD), + ecolor (ECOLOR_HILITE), + ecolor (ECOLOR_BRACKET), + ecolor (ECOLOR_NORMAL)); exit (EXIT_SUCCESS); } if (argc > 0) { if (strcmp (applet, "eend") == 0 || - strcmp (applet, "ewend") == 0 || - strcmp (applet, "veend") == 0 || - strcmp (applet, "vweend") == 0) + strcmp (applet, "ewend") == 0 || + strcmp (applet, "veend") == 0 || + strcmp (applet, "vweend") == 0) { errno = 0; retval = strtol (argv[0], NULL, 0); @@ -229,7 +229,7 @@ static int do_e (int argc, char **argv) argv++; } } else if (strcmp (applet, "esyslog") == 0 || - strcmp (applet, "elog") == 0) { + strcmp (applet, "elog") == 0) { char *dot = strchr (argv[0], '.'); if ((level = syslog_decode (dot + 1, prioritynames)) == -1) eerrorx ("%s: invalid log level `%s'", applet, argv[0]); @@ -405,7 +405,7 @@ static int do_mark_service (int argc, char **argv) if (runscript_pid && sscanf (runscript_pid, "%d", &pid) == 1) if (kill (pid, SIGHUP) != 0) eerror ("%s: failed to signal parent %d: %s", - applet, pid, strerror (errno)); + applet, pid, strerror (errno)); /* Remove the exclusive time test. This ensures that it's not in control as well */ @@ -415,7 +415,7 @@ static int do_mark_service (int argc, char **argv) 4; mtime = xmalloc (l); snprintf (mtime, l, RC_SVCDIR "exclusive/%s.%s", - svcname, runscript_pid); + svcname, runscript_pid); if (exists (mtime) && unlink (mtime) != 0) eerror ("%s: unlink: %s", applet, strerror (errno)); free (mtime); @@ -436,7 +436,7 @@ static int do_value (int argc, char **argv) eerrorx ("%s: no option specified", applet); if (strcmp (applet, "service_get_value") == 0 || - strcmp (applet, "get_options") == 0) + strcmp (applet, "get_options") == 0) { char *option = rc_service_value_get (service, argv[0]); if (option) { @@ -445,7 +445,7 @@ static int do_value (int argc, char **argv) ok = true; } } else if (strcmp (applet, "service_set_value") == 0 || - strcmp (applet, "save_options") == 0) + strcmp (applet, "save_options") == 0) ok = rc_service_value_set (service, argv[0], argv[1]); else eerrorx ("%s: unknown applet", applet); @@ -493,7 +493,7 @@ static char *proc_getent (const char *ent) } if ((proc = rc_getline (fp)) && - (p = strstr (proc, ent))) + (p = strstr (proc, ent))) { i = p - proc; if (i == '\0' || proc[i - 1] == ' ') { @@ -554,9 +554,9 @@ static bool want_interactive (void) return (false); if (PREVLEVEL && - strcmp (PREVLEVEL, "N") != 0 && - strcmp (PREVLEVEL, "S") != 0 && - strcmp (PREVLEVEL, "1") != 0) + strcmp (PREVLEVEL, "N") != 0 && + strcmp (PREVLEVEL, "S") != 0 && + strcmp (PREVLEVEL, "1") != 0) return (false); if (! gotinteractive) { @@ -609,11 +609,11 @@ static void sulogin (bool cont) execle (SULOGIN, SULOGIN, (char *) NULL, newenv); eerror ("%s: unable to exec `%s': %s", applet, SULOGIN, - strerror (errno)); + strerror (errno)); #else execle ("/bin/sh", "/bin/sh", (char *) NULL, newenv); eerror ("%s: unable to exec `/bin/sh': %s", applet, - strerror (errno)); + strerror (errno)); #endif _exit (EXIT_FAILURE); } @@ -637,11 +637,11 @@ static void single_user (void) #ifdef __linux__ execl ("/sbin/telinit", "/sbin/telinit", "S", (char *) NULL); eerrorx ("%s: unable to exec `/sbin/telinit': %s", - applet, strerror (errno)); + applet, strerror (errno)); #else if (kill (1, SIGTERM) != 0) eerrorx ("%s: unable to send SIGTERM to init (pid 1): %s", - applet, strerror (errno)); + applet, strerror (errno)); exit (EXIT_SUCCESS); #endif } @@ -651,12 +651,12 @@ static bool set_ksoftlevel (const char *level) FILE *fp; if (! level || - strcmp (level, getenv ("RC_BOOTLEVEL")) == 0 || - strcmp (level, RC_LEVEL_SINGLE) == 0 || - strcmp (level, RC_LEVEL_SYSINIT) == 0) + strcmp (level, getenv ("RC_BOOTLEVEL")) == 0 || + strcmp (level, RC_LEVEL_SINGLE) == 0 || + strcmp (level, RC_LEVEL_SYSINIT) == 0) { if (exists (RC_KSOFTLEVEL) && - unlink (RC_KSOFTLEVEL) != 0) + unlink (RC_KSOFTLEVEL) != 0) eerror ("unlink `%s': %s", RC_KSOFTLEVEL, strerror (errno)); return (false); } @@ -786,11 +786,11 @@ static void handle_signal (int sig) /* Only drop into single user mode if we're booting */ if ((PREVLEVEL && - (strcmp (PREVLEVEL, "S") == 0 || - strcmp (PREVLEVEL, "1") == 0)) || - (RUNLEVEL && - (strcmp (RUNLEVEL, "S") == 0 || - strcmp (RUNLEVEL, "1") == 0))) + (strcmp (PREVLEVEL, "S") == 0 || + strcmp (PREVLEVEL, "1") == 0)) || + (RUNLEVEL && + (strcmp (RUNLEVEL, "S") == 0 || + strcmp (RUNLEVEL, "1") == 0))) single_user (); exit (EXIT_FAILURE); @@ -814,7 +814,7 @@ static void run_script (const char *script) else if (pid == 0) { execl (script, script, (char *) NULL); eerror ("%s: unable to exec `%s': %s", - script, applet, strerror (errno)); + script, applet, strerror (errno)); _exit (EXIT_FAILURE); } @@ -868,9 +868,9 @@ int main (int argc, char **argv) if (argc > 1 && (strcmp (argv[1], "--version") == 0)) { printf ("%s (OpenRC" #ifdef BRANDING - " " BRANDING + " " BRANDING #endif - ") version " VERSION "\n", applet); + ") version " VERSION "\n", applet); exit (EXIT_SUCCESS); } @@ -885,7 +885,7 @@ int main (int argc, char **argv) else if (strcmp (applet, "rc-status") == 0) exit (rc_status (argc, argv)); else if (strcmp (applet, "rc-update") == 0 || - strcmp (applet, "update-rc") == 0) + strcmp (applet, "update-rc") == 0) exit (rc_update (argc, argv)); else if (strcmp (applet, "runscript") == 0) exit (runscript (argc, argv)); @@ -902,9 +902,9 @@ int main (int argc, char **argv) exit (do_e (argc, argv)); if (strcmp (applet, "service_get_value") == 0 || - strcmp (applet, "service_set_value") == 0 || - strcmp (applet, "get_options") == 0 || - strcmp (applet, "save_options") == 0) + strcmp (applet, "service_set_value") == 0 || + strcmp (applet, "get_options") == 0 || + strcmp (applet, "save_options") == 0) exit (do_value (argc, argv)); if (strncmp (applet, "service_", strlen ("service_")) == 0) @@ -928,7 +928,7 @@ int main (int argc, char **argv) if (p && sscanf (p, "%d", &pid) == 1) { if (kill (pid, SIGUSR1) != 0) eerrorx ("rc-abort: failed to signal parent %d: %s", - pid, strerror (errno)); + pid, strerror (errno)); exit (EXIT_SUCCESS); } exit (EXIT_FAILURE); @@ -986,14 +986,14 @@ int main (int argc, char **argv) argc++; argv--; while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) { switch (opt) { case 'o': if (strlen (optarg) == 0) optarg = NULL; exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE); - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } } @@ -1035,9 +1035,9 @@ int main (int argc, char **argv) */ if (newlevel) { if (strcmp (newlevel, RC_LEVEL_SYSINIT) == 0 && - RUNLEVEL && - (strcmp (RUNLEVEL, "S") == 0 || - strcmp (RUNLEVEL, "1") == 0)) + RUNLEVEL && + (strcmp (RUNLEVEL, "S") == 0 || + strcmp (RUNLEVEL, "1") == 0)) { /* OK, we're either in runlevel 1 or single user mode */ struct utsname uts; @@ -1053,19 +1053,19 @@ int main (int argc, char **argv) uname (&uts); printf ("\n %sOpenRC %s" VERSION "%s is starting up %s%s%s\n\n", - ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE), - ecolor (ECOLOR_NORMAL), ecolor (ECOLOR_BRACKET), + ecolor (ECOLOR_GOOD), ecolor (ECOLOR_HILITE), + ecolor (ECOLOR_NORMAL), ecolor (ECOLOR_BRACKET), #ifdef BRANDING - BRANDING + BRANDING #else - "" + "" #endif - , ecolor (ECOLOR_NORMAL)); + , ecolor (ECOLOR_NORMAL)); if (! rc_yesno (getenv ("EINFO_QUIET")) && - rc_conf_yesno ("rc_interactive")) + rc_conf_yesno ("rc_interactive")) printf ("Press %sI%s to enter interactive boot mode\n\n", - ecolor (ECOLOR_GOOD), ecolor (ECOLOR_NORMAL)); + ecolor (ECOLOR_GOOD), ecolor (ECOLOR_NORMAL)); setenv ("RC_SOFTLEVEL", newlevel, 1); rc_plugin_run (RC_HOOK_RUNLEVEL_START_IN, newlevel); @@ -1088,8 +1088,8 @@ int main (int argc, char **argv) exit (EXIT_SUCCESS); } else if (strcmp (newlevel, RC_LEVEL_SINGLE) == 0) { if (! RUNLEVEL || - (strcmp (RUNLEVEL, "S") != 0 && - strcmp (RUNLEVEL, "1") != 0)) + (strcmp (RUNLEVEL, "S") != 0 && + strcmp (RUNLEVEL, "1") != 0)) { /* Remember the current runlevel for when we come back */ set_ksoftlevel (runlevel); @@ -1097,27 +1097,27 @@ int main (int argc, char **argv) } } else if (strcmp (newlevel, RC_LEVEL_REBOOT) == 0) { if (! RUNLEVEL || - strcmp (RUNLEVEL, "6") != 0) + strcmp (RUNLEVEL, "6") != 0) { rc_logger_close (); execl (SHUTDOWN, SHUTDOWN, "-r", "now", (char *) NULL); eerrorx ("%s: unable to exec `" SHUTDOWN "': %s", - applet, strerror (errno)); + applet, strerror (errno)); } } else if (strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0) { if (! RUNLEVEL || - strcmp (RUNLEVEL, "0") != 0) + strcmp (RUNLEVEL, "0") != 0) { rc_logger_close (); execl (SHUTDOWN, SHUTDOWN, #ifdef __linux__ - "-h", + "-h", #else - "-p", + "-p", #endif - "now", (char *) NULL); + "now", (char *) NULL); eerrorx ("%s: unable to exec `" SHUTDOWN "': %s", - applet, strerror (errno)); + applet, strerror (errno)); } } } @@ -1128,27 +1128,27 @@ int main (int argc, char **argv) /* We should only use ksoftlevel if we were in single user mode If not, we need to erase ksoftlevel now. */ if (PREVLEVEL && - (strcmp (PREVLEVEL, "1") == 0 || - strcmp (PREVLEVEL, "S") == 0 || - strcmp (PREVLEVEL, "N") == 0)) + (strcmp (PREVLEVEL, "1") == 0 || + strcmp (PREVLEVEL, "S") == 0 || + strcmp (PREVLEVEL, "N") == 0)) { /* Try not to join boot and ksoftlevels together */ if (! newlevel || - strcmp (newlevel, getenv ("RC_BOOTLEVEL")) != 0) + strcmp (newlevel, getenv ("RC_BOOTLEVEL")) != 0) if (get_ksoftlevel (ksoftbuffer, sizeof (ksoftbuffer))) newlevel = ksoftbuffer; } else if (! RUNLEVEL || - (strcmp (RUNLEVEL, "1") != 0 && - strcmp (RUNLEVEL, "S") != 0 && - strcmp (RUNLEVEL, "N") != 0)) + (strcmp (RUNLEVEL, "1") != 0 && + strcmp (RUNLEVEL, "S") != 0 && + strcmp (RUNLEVEL, "N") != 0)) { set_ksoftlevel (NULL); } if (newlevel && - (strcmp (newlevel, RC_LEVEL_REBOOT) == 0 || - strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (newlevel, RC_LEVEL_SINGLE) == 0)) + (strcmp (newlevel, RC_LEVEL_REBOOT) == 0 || + strcmp (newlevel, RC_LEVEL_SHUTDOWN) == 0 || + strcmp (newlevel, RC_LEVEL_SINGLE) == 0)) { going_down = true; rc_runlevel_set (newlevel); @@ -1190,12 +1190,12 @@ int main (int argc, char **argv) if ((dp = opendir (DEVBOOT))) { while ((d = readdir (dp))) { if (d->d_name[0] == '.' && - (d->d_name[1] == '\0' || - (d->d_name[1] == '.' && d->d_name[2] == '\0'))) + (d->d_name[1] == '\0' || + (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; if (rc_service_exists (d->d_name) && - rc_service_plugable (d->d_name)) + rc_service_plugable (d->d_name)) rc_service_mark (d->d_name, RC_SERVICE_COLDPLUGGED); i = strlen (DEVBOOT "/") + strlen (d->d_name) + 1; @@ -1204,7 +1204,7 @@ int main (int argc, char **argv) if (tmp) { if (unlink (tmp)) eerror ("%s: unlink `%s': %s", applet, tmp, - strerror (errno)); + strerror (errno)); free (tmp); } } @@ -1217,9 +1217,9 @@ int main (int argc, char **argv) the device node to the init script to simulate the coldplug into runlevel for our dependency tree to work. */ if (newlevel && strcmp (newlevel, bootlevel) == 0 && - (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || - strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) && - rc_conf_yesno ("rc_coldplug")) + (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || + strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) && + rc_conf_yesno ("rc_coldplug")) { #if defined(__DragonFly__) || defined(__FreeBSD__) /* The net interfaces are easy - they're all in net /dev/net :) */ @@ -1229,7 +1229,7 @@ int main (int argc, char **argv) tmp = xmalloc (sizeof (char) * i); snprintf (tmp, i, "net.%s", d->d_name); if (rc_service_exists (tmp) && - rc_service_plugable (tmp)) + rc_service_plugable (tmp)) rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED); CHAR_FREE (tmp); } @@ -1242,7 +1242,7 @@ int main (int argc, char **argv) if ((dp = opendir ("/dev"))) { while ((d = readdir (dp))) { if (strncmp (d->d_name, "psm", 3) == 0 || - strncmp (d->d_name, "ums", 3) == 0) + strncmp (d->d_name, "ums", 3) == 0) { char *p = d->d_name + 3; if (p && isdigit ((int) *p)) { @@ -1250,7 +1250,7 @@ int main (int argc, char **argv) tmp = xmalloc (sizeof (char) * i); snprintf (tmp, i, "moused.%s", d->d_name); if (rc_service_exists (tmp) && - rc_service_plugable (tmp)) + rc_service_plugable (tmp)) rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED); CHAR_FREE (tmp); } @@ -1274,8 +1274,8 @@ int main (int argc, char **argv) rc_strlist_free (tmplist); deporder = rc_deptree_depends (deptree, types_nua, - (const char **) stop_services, - runlevel, depoptions | RC_DEP_STOP); + (const char **) stop_services, + runlevel, depoptions | RC_DEP_STOP); rc_strlist_free (stop_services); stop_services = deporder; @@ -1310,8 +1310,8 @@ int main (int argc, char **argv) rc_strlist_join (&coldplugged_services, tmplist); rc_strlist_free (tmplist); if (strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 && - strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 && - strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0) + strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 && + strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0) { /* We need to include the boot runlevel services if we're not in it */ tmplist = rc_services_in_runlevel (bootlevel); @@ -1394,8 +1394,8 @@ int main (int argc, char **argv) going to be started depends on us */ rc_strlist_add (&stopdeps, service); deporder = rc_deptree_depends (deptree, types_n, - (const char **) stopdeps, - runlevel, RC_DEP_STRICT); + (const char **) stopdeps, + runlevel, RC_DEP_STRICT); rc_strlist_free (stopdeps); stopdeps = NULL; found = false; @@ -1444,12 +1444,12 @@ int main (int argc, char **argv) /* Run the halt script if needed */ if (strcmp (runlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (runlevel, RC_LEVEL_REBOOT) == 0) + strcmp (runlevel, RC_LEVEL_REBOOT) == 0) { rc_logger_close (); execl (HALTSH, HALTSH, runlevel, (char *) NULL); eerrorx ("%s: unable to exec `%s': %s", - applet, HALTSH, strerror (errno)); + applet, HALTSH, strerror (errno)); } /* Single user is done now */ @@ -1468,8 +1468,8 @@ int main (int argc, char **argv) /* Order the services to start */ deporder = rc_deptree_depends (deptree, types_nua, - (const char **) start_services, - runlevel, depoptions | RC_DEP_START); + (const char **) start_services, + runlevel, depoptions | RC_DEP_START); rc_strlist_free (start_services); start_services = deporder; deporder = NULL; diff --git a/src/rc/runscript.c b/src/rc/runscript.c index c688da43..1f3d6625 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -262,18 +262,18 @@ static void start_services (char **list) { return; if (state & RC_SERVICE_INACTIVE || - state & RC_SERVICE_WASINACTIVE || - state & RC_SERVICE_STARTING || - state & RC_SERVICE_STARTED) + state & RC_SERVICE_WASINACTIVE || + state & RC_SERVICE_STARTING || + state & RC_SERVICE_STARTED) { STRLIST_FOREACH (list, svc, i) { if (rc_service_state (svc) & RC_SERVICE_STOPPED) { if (state & RC_SERVICE_INACTIVE || - state & RC_SERVICE_WASINACTIVE) + state & RC_SERVICE_WASINACTIVE) { rc_service_schedule_start (service, svc); ewarn ("WARNING: %s is scheduled to started when %s has started", - svc, applet); + svc, applet); } else rc_service_start (svc); } @@ -404,7 +404,7 @@ static bool svc_exec (const char *arg1, const char *arg2) eerrorx ("%s: pipe: %s", service, applet); for (i = 0; i < 2; i++) if ((flags = fcntl (signal_pipe[i], F_GETFD, 0) == -1 || - fcntl (signal_pipe[i], F_SETFD, flags | FD_CLOEXEC) == -1)) + fcntl (signal_pipe[i], F_SETFD, flags | FD_CLOEXEC) == -1)) eerrorx ("%s: fcntl: %s", service, strerror (errno)); /* Open a pty for our prefixed output @@ -439,15 +439,15 @@ static bool svc_exec (const char *arg1, const char *arg2) if (exists (RC_SVCDIR "/runscript.sh")) { execl (RC_SVCDIR "/runscript.sh", RC_SVCDIR "/runscript.sh", - service, arg1, arg2, (char *) NULL); + service, arg1, arg2, (char *) NULL); eerror ("%s: exec `" RC_SVCDIR "/runscript.sh': %s", - service, strerror (errno)); + service, strerror (errno)); _exit (EXIT_FAILURE); } else { execl (RC_LIBDIR "/sh/runscript.sh", RC_LIBDIR "/sh/runscript.sh", - service, arg1, arg2, (char *) NULL); + service, arg1, arg2, (char *) NULL); eerror ("%s: exec `" RC_LIBDIR "/sh/runscript.sh': %s", - service, strerror (errno)); + service, strerror (errno)); _exit (EXIT_FAILURE); } } @@ -584,9 +584,9 @@ static void make_exclusive () exclusive = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL); if (mkfifo (exclusive, 0600) != 0 && errno != EEXIST && - (errno != EACCES || geteuid () == 0)) + (errno != EACCES || geteuid () == 0)) eerrorx ("%s: unable to create fifo `%s': %s", - applet, exclusive, strerror (errno)); + applet, exclusive, strerror (errno)); path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL); i = strlen (path) + 16; @@ -596,7 +596,7 @@ static void make_exclusive () if (exists (mtime_test) && unlink (mtime_test) != 0) { eerror ("%s: unlink `%s': %s", - applet, mtime_test, strerror (errno)); + applet, mtime_test, strerror (errno)); free (mtime_test); mtime_test = NULL; return; @@ -604,7 +604,7 @@ static void make_exclusive () if (symlink (service, mtime_test) != 0) { eerror ("%s: symlink `%s' to `%s': %s", - applet, service, mtime_test, strerror (errno)); + applet, service, mtime_test, strerror (errno)); free (mtime_test); mtime_test = NULL; } @@ -645,7 +645,7 @@ static void svc_start (bool deps) if (rc_yesno (getenv ("IN_HOTPLUG")) || in_background) { if (! state & RC_SERVICE_INACTIVE && - ! state & RC_SERVICE_STOPPED) + ! state & RC_SERVICE_STOPPED) exit (EXIT_FAILURE); background = true; } @@ -694,11 +694,11 @@ static void svc_start (bool deps) rc_strlist_free (need_services); need_services = rc_deptree_depends (deptree, types_n, svcl, - softlevel, depoptions); + softlevel, depoptions); rc_strlist_free (use_services); use_services = rc_deptree_depends (deptree, types_nu, svcl, - softlevel, depoptions); + softlevel, depoptions); if (! rc_runlevel_starting ()) { STRLIST_FOREACH (use_services, svc, i) @@ -711,7 +711,7 @@ static void svc_start (bool deps) /* Now wait for them to start */ services = rc_deptree_depends (deptree, types_nua, svcl, - softlevel, depoptions); + softlevel, depoptions); /* We use tmplist to hold our scheduled by list */ rc_strlist_free (tmplist); @@ -725,7 +725,7 @@ static void svc_start (bool deps) /* Don't wait for services which went inactive but are now in * starting state which we are after */ if (svcs & RC_SERVICE_STARTING && - svcs & RC_SERVICE_WASINACTIVE) { + svcs & RC_SERVICE_WASINACTIVE) { bool use = false; STRLIST_FOREACH (use_services, svc2, j) if (strcmp (svc, svc2) == 0) { @@ -744,11 +744,11 @@ static void svc_start (bool deps) STRLIST_FOREACH (need_services, svc2, j) if (strcmp (svc, svc2) == 0) { if (svcs & RC_SERVICE_INACTIVE || - svcs & RC_SERVICE_WASINACTIVE) + svcs & RC_SERVICE_WASINACTIVE) rc_strlist_add (&tmplist, svc); else eerrorx ("ERROR: cannot start %s as %s would not start", - applet, svc); + applet, svc); } } @@ -786,7 +786,7 @@ static void svc_start (bool deps) p += snprintf (p, len, "%s", svc); } ewarnx ("WARNING: %s is scheduled to start when %s has started", - applet, tmp); + applet, tmp); } rc_strlist_free (services); @@ -852,12 +852,12 @@ static void svc_stop (bool deps) rc_service_state_t state = rc_service_state (service); if (rc_runlevel_stopping () && - state & RC_SERVICE_FAILED) + state & RC_SERVICE_FAILED) exit (EXIT_FAILURE); if (rc_yesno (getenv ("IN_HOTPLUG")) || in_background) if (! (state & RC_SERVICE_STARTED) && - ! (state & RC_SERVICE_INACTIVE)) + ! (state & RC_SERVICE_INACTIVE)) exit (EXIT_FAILURE); if (state & RC_SERVICE_STOPPED) { @@ -875,7 +875,7 @@ static void svc_stop (bool deps) rc_plugin_run (RC_HOOK_SERVICE_STOP_IN, applet); if (! rc_runlevel_stopping () && - rc_service_in_runlevel (service, RC_LEVEL_BOOT)) + rc_service_in_runlevel (service, RC_LEVEL_BOOT)) ewarn ("WARNING: you are stopping a boot service"); if (deps && ! (state & RC_SERVICE_WASINACTIVE)) { @@ -896,17 +896,17 @@ static void svc_stop (bool deps) tmplist = NULL; rc_strlist_free (services); services = rc_deptree_depends (deptree, types_m, svcl, - softlevel, depoptions); + softlevel, depoptions); rc_strlist_reverse (services); STRLIST_FOREACH (services, svc, i) { rc_service_state_t svcs = rc_service_state (svc); if (svcs & RC_SERVICE_STARTED || - svcs & RC_SERVICE_INACTIVE) + svcs & RC_SERVICE_INACTIVE) { svc_wait (deptree, svc); svcs = rc_service_state (svc); if (svcs & RC_SERVICE_STARTED || - svcs & RC_SERVICE_INACTIVE) + svcs & RC_SERVICE_INACTIVE) { pid_t pid = rc_service_stop (svc); if (! rc_conf_yesno ("rc_parallel")) @@ -928,15 +928,15 @@ static void svc_stop (bool deps) if (rc_runlevel_stopping ()) { /* If shutting down, we should stop even if a dependant failed */ if (softlevel && - (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 || - strcmp (softlevel, RC_LEVEL_REBOOT) == 0 || - strcmp (softlevel, RC_LEVEL_SINGLE) == 0)) + (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 || + strcmp (softlevel, RC_LEVEL_REBOOT) == 0 || + strcmp (softlevel, RC_LEVEL_SINGLE) == 0)) continue; rc_service_mark (service, RC_SERVICE_FAILED); } eerrorx ("ERROR: cannot stop %s as %s is still up", - applet, svc); + applet, svc); } } rc_strlist_free (tmplist); @@ -945,7 +945,7 @@ static void svc_stop (bool deps) /* We now wait for other services that may use us and are stopping This is important when a runlevel stops */ services = rc_deptree_depends (deptree, types_mua, svcl, - softlevel, depoptions); + softlevel, depoptions); STRLIST_FOREACH (services, svc, i) { if (rc_service_state (svc) & RC_SERVICE_STOPPED) continue; @@ -1161,7 +1161,7 @@ int runscript (int argc, char **argv) /* Right then, parse any options there may be */ while ((opt = getopt_long (argc, argv, getoptstring, - longopts, (int *) 0)) != -1) + longopts, (int *) 0)) != -1) switch (opt) { case 'd': setenv ("RC_DEBUG", "yes", 1); @@ -1209,7 +1209,7 @@ int runscript (int argc, char **argv) exit (EXIT_FAILURE); if (strcmp (optarg, "status") != 0 && - strcmp (optarg, "help") != 0) { + strcmp (optarg, "help") != 0) { /* Only root should be able to run us */ } @@ -1223,7 +1223,7 @@ int runscript (int argc, char **argv) doneone = true; if (strcmp (optarg, "describe") == 0 || - strcmp (optarg, "help") == 0) + strcmp (optarg, "help") == 0) { char *save = prefix; @@ -1232,12 +1232,12 @@ int runscript (int argc, char **argv) svc_exec (optarg, NULL); eprefix (save); } else if (strcmp (optarg, "ineed") == 0 || - strcmp (optarg, "iuse") == 0 || - strcmp (optarg, "needsme") == 0 || - strcmp (optarg, "usesme") == 0 || - strcmp (optarg, "iafter") == 0 || - strcmp (optarg, "ibefore") == 0 || - strcmp (optarg, "iprovide") == 0) { + strcmp (optarg, "iuse") == 0 || + strcmp (optarg, "needsme") == 0 || + strcmp (optarg, "usesme") == 0 || + strcmp (optarg, "iafter") == 0 || + strcmp (optarg, "ibefore") == 0 || + strcmp (optarg, "iprovide") == 0) { int depoptions = RC_DEP_TRACE; const char *t[] = { optarg, NULL }; const char *s[] = { applet, NULL }; @@ -1264,7 +1264,7 @@ int runscript (int argc, char **argv) eerrorx ("%s: root access required", applet); if (strcmp (optarg, "conditionalrestart") == 0 || - strcmp (optarg, "condrestart") == 0) + strcmp (optarg, "condrestart") == 0) { if (rc_service_state (service) & RC_SERVICE_STARTED) svc_restart (deps); @@ -1280,12 +1280,12 @@ int runscript (int argc, char **argv) if (deps) { if (! in_background && - ! rc_runlevel_stopping () && - rc_service_state (service) & RC_SERVICE_STOPPED) + ! rc_runlevel_stopping () && + rc_service_state (service) & RC_SERVICE_STOPPED) uncoldplug (); if (in_background && - rc_service_state (service) & RC_SERVICE_INACTIVE) + rc_service_state (service) & RC_SERVICE_INACTIVE) { int j; STRLIST_FOREACH (restart_services, svc, j) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index e0c55386..901194e9 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -168,7 +168,7 @@ static int parse_signal (const char *sig) for (i = 0; i < sizeof (signallist) / sizeof (signallist[0]); i++) if (strcmp (sig, signallist[i].name) == 0 || - (s && strcmp (s, signallist[i].name) == 0)) + (s && strcmp (s, signallist[i].name) == 0)) return (signallist[i].signal); eerrorx ("%s: `%s' is not a valid signal", applet, sig); @@ -186,9 +186,9 @@ static void parse_schedule_item (schedulelist_t *item, const char *string) errno = 0; if (sscanf (string, "%d", &item->value) != 1) eerrorx ("%s: invalid timeout value in schedule `%s'", applet, - string); + string); } else if ((after_hyph = string + (string[0] == '-')) && - ((sig = parse_signal (after_hyph)) != -1)) + ((sig = parse_signal (after_hyph)) != -1)) { item->type = schedule_signal; item->value = (int) sig; @@ -253,7 +253,7 @@ static void parse_schedule (const char *string, int default_signal) if (next->type == schedule_forever) { if (repeatat) eerrorx ("%s: invalid schedule, `forever' appears more than once", - applet); + applet); repeatat = next; continue; @@ -305,8 +305,8 @@ static pid_t get_pid (const char *pidfile, bool quiet) /* return number of processed killed, -1 on error */ static int do_stop (const char *exec, const char *cmd, - const char *pidfile, uid_t uid,int sig, - bool quiet, bool verbose, bool test) + const char *pidfile, uid_t uid,int sig, + bool quiet, bool verbose, bool test) { pid_t *pids; bool killed; @@ -338,7 +338,7 @@ static int do_stop (const char *exec, const char *cmd, killed = (kill (pids[i], sig) == 0 || errno == ESRCH ? true : false); if (verbose) eend (killed ? 0 : 1, "%s: failed to send signal %d to PID %d: %s", - applet, sig, pids[i], strerror (errno)); + applet, sig, pids[i], strerror (errno)); if (! killed) { nkilled = -1; } else { @@ -352,8 +352,8 @@ static int do_stop (const char *exec, const char *cmd, } static int run_stop_schedule (const char *exec, const char *cmd, - const char *pidfile, uid_t uid, - bool quiet, bool verbose, bool test) + const char *pidfile, uid_t uid, + bool quiet, bool verbose, bool test) { schedulelist_t *item = schedule; int nkilled = 0; @@ -382,7 +382,7 @@ static int run_stop_schedule (const char *exec, const char *cmd, case schedule_signal: nrunning = 0; nkilled = do_stop (exec, cmd, pidfile, uid, item->value, - quiet, verbose, test); + quiet, verbose, test); if (nkilled == 0) { if (tkilled == 0) { if (! quiet) @@ -407,7 +407,7 @@ static int run_stop_schedule (const char *exec, const char *cmd, while (nloops) { if ((nrunning = do_stop (exec, cmd, pidfile, - uid, 0, true, false, true)) == 0) + uid, 0, true, false, true)) == 0) return (true); if (nanosleep (&ts, NULL) == -1) { @@ -584,7 +584,7 @@ int start_stop_daemon (int argc, char **argv) eerror ("%s: invalid nice level `%s' (SSD_NICELEVEL)", applet, env); while ((opt = getopt_long (argc, argv, getoptstring, longopts, - (int *) 0)) != -1) + (int *) 0)) != -1) switch (opt) { case 'K': /* --stop */ stop = true; @@ -702,7 +702,7 @@ int start_stop_daemon (int argc, char **argv) redirect_stderr = optarg; break; - case_RC_COMMON_GETOPT + case_RC_COMMON_GETOPT } quiet = rc_yesno (getenv ("EINFO_QUIET")); @@ -712,9 +712,9 @@ int start_stop_daemon (int argc, char **argv) * instead of forcing --stop --oknodo as well */ if (! start && ! stop) if (sig != SIGINT && - sig != SIGTERM && - sig != SIGQUIT && - sig != SIGKILL) + sig != SIGTERM && + sig != SIGQUIT && + sig != SIGKILL) { oknodo = true; stop = true; @@ -737,7 +737,7 @@ int start_stop_daemon (int argc, char **argv) if ((redirect_stdout || redirect_stderr) && ! background) eerrorx ("%s: --stdout and --stderr are only relevant with --background", - applet); + applet); argc -= optind; argv += optind; @@ -839,7 +839,7 @@ int start_stop_daemon (int argc, char **argv) if (nicelevel) { if (setpriority (PRIO_PROCESS, mypid, nicelevel) == -1) eerrorx ("%s: setpritory %d: %s", applet, nicelevel, - strerror(errno)); + strerror(errno)); } if (ch_root && chroot (ch_root) < 0) @@ -852,7 +852,7 @@ int start_stop_daemon (int argc, char **argv) FILE *fp = fopen (pidfile, "w"); if (! fp) eerrorx ("%s: fopen `%s': %s", applet, pidfile, strerror - (errno)); + (errno)); fprintf (fp, "%d\n", mypid); fclose (fp); } @@ -902,7 +902,7 @@ int start_stop_daemon (int argc, char **argv) /* Clean the environment of any RC_ variables */ STRLIST_FOREACH (environ, env, i) { if (strncmp (env, "RC_", 3) == 0 || - strncmp (env, "SSD_NICELEVEL=", strlen ("SSD_NICELEVEL=")) == 0) + strncmp (env, "SSD_NICELEVEL=", strlen ("SSD_NICELEVEL=")) == 0) continue; /* For the path, remove the rcscript bin dir from it */ @@ -918,9 +918,9 @@ int start_stop_daemon (int argc, char **argv) p += 5; while ((token = strsep (&p, ":"))) { if (strcmp (token, RC_LIBDIR "/bin") == 0 || - strcmp (token, RC_LIBDIR "/sbin") == 0) + strcmp (token, RC_LIBDIR "/sbin") == 0) continue; - + t = strlen (token); if (newpath) { l = strlen (newpath); @@ -949,15 +949,15 @@ int start_stop_daemon (int argc, char **argv) stderr_fd = devnull_fd; if (redirect_stdout) { if ((stdout_fd = open (redirect_stdout, O_WRONLY | O_CREAT | O_APPEND, - S_IRUSR | S_IWUSR)) == -1) + S_IRUSR | S_IWUSR)) == -1) eerrorx ("%s: unable to open the logfile for stdout `%s': %s", - applet, redirect_stdout, strerror (errno)); + applet, redirect_stdout, strerror (errno)); } if (redirect_stderr) { if ((stderr_fd = open (redirect_stderr, O_WRONLY | O_CREAT | O_APPEND, - S_IRUSR | S_IWUSR)) == -1) + S_IRUSR | S_IWUSR)) == -1) eerrorx ("%s: unable to open the logfile for stderr `%s': %s", - applet, redirect_stderr, strerror (errno)); + applet, redirect_stderr, strerror (errno)); } if (background) { @@ -1011,7 +1011,7 @@ int start_stop_daemon (int argc, char **argv) int nloops = START_WAIT / POLL_INTERVAL; int nloopsp = WAIT_PIDFILE / POLL_INTERVAL; bool alive = false; - + ts.tv_sec = 0; ts.tv_nsec = POLL_INTERVAL; @@ -1049,7 +1049,7 @@ int start_stop_daemon (int argc, char **argv) if (get_pid (pidfile, true) == -1) { if (! nloopsp) eerrorx ("%s: did not create a valid pid in `%s'", - applet, pidfile); + applet, pidfile); alive = true; } else nloopsp = 0; -- cgit v1.2.3