API change! rc_strlist_add and friends now take char *** instead of
char ** and return a pointer to the item added instead of the new list head. This is so we can easily tell if the item was successfully added or not instead of iterating through the list looking for it. list = rc_strlist_add (list, item); becomes rc_strlist_add (&list, item);
This commit is contained in:
parent
99eabdc3ba
commit
f1bba12892
11
ChangeLog
11
ChangeLog
@ -1,6 +1,17 @@
|
|||||||
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
||||||
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
||||||
|
|
||||||
|
18 Sep 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
|
API change! rc_strlist_add and friends now take char *** instead of
|
||||||
|
char ** and return a pointer to the item added instead of the new
|
||||||
|
list head. This is so we can easily tell if the item was successfully
|
||||||
|
added or not instead of iterating through the list looking for it.
|
||||||
|
|
||||||
|
list = rc_strlist_add (list, item);
|
||||||
|
becomes
|
||||||
|
rc_strlist_add (&list, item);
|
||||||
|
|
||||||
17 Sep 2007; Roy Marples <uberlord@gentoo.org>:
|
17 Sep 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
Document the preferance of wpa_supplicant, #192828.
|
Document the preferance of wpa_supplicant, #192828.
|
||||||
|
@ -102,6 +102,7 @@ int env_update (int argc, char **argv)
|
|||||||
int opt;
|
int opt;
|
||||||
bool ldconfig = true;
|
bool ldconfig = true;
|
||||||
bool fork_ldconfig = false;
|
bool fork_ldconfig = false;
|
||||||
|
int nents = 0;
|
||||||
|
|
||||||
applet = argv[0];
|
applet = argv[0];
|
||||||
|
|
||||||
@ -147,12 +148,12 @@ int env_update (int argc, char **argv)
|
|||||||
|
|
||||||
if (strcmp (var, "COLON_SEPARATED") == 0)
|
if (strcmp (var, "COLON_SEPARATED") == 0)
|
||||||
while ((var = strsep (&value, " ")))
|
while ((var = strsep (&value, " ")))
|
||||||
mycolons = rc_strlist_addu (mycolons, var);
|
rc_strlist_addu (&mycolons, var);
|
||||||
else if (strcmp (var, "SPACE_SEPARATED") == 0)
|
else if (strcmp (var, "SPACE_SEPARATED") == 0)
|
||||||
while ((var = strsep (&value, " ")))
|
while ((var = strsep (&value, " ")))
|
||||||
myspaces = rc_strlist_addu (myspaces, var);
|
rc_strlist_addu (&myspaces, var);
|
||||||
else
|
else
|
||||||
config = rc_strlist_add (config, entry);
|
rc_strlist_add (&config, entry);
|
||||||
free (tmpent);
|
free (tmpent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +228,7 @@ int env_update (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! replaced)
|
if (! replaced)
|
||||||
envs = rc_strlist_addsort (envs, entry);
|
rc_strlist_addsort (&envs, entry);
|
||||||
|
|
||||||
free (tmpent);
|
free (tmpent);
|
||||||
}
|
}
|
||||||
@ -285,7 +286,8 @@ int env_update (int argc, char **argv)
|
|||||||
if (strlen (file) == 0)
|
if (strlen (file) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ldents = rc_strlist_addu (ldents, file);
|
if (rc_strlist_addu (&ldents, file))
|
||||||
|
nents++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ldconfig) {
|
if (ldconfig) {
|
||||||
@ -293,12 +295,8 @@ int env_update (int argc, char **argv)
|
|||||||
if (rc_exists (LDSOCONF)) {
|
if (rc_exists (LDSOCONF)) {
|
||||||
char **lines = rc_get_list (NULL, LDSOCONF);
|
char **lines = rc_get_list (NULL, LDSOCONF);
|
||||||
char *line;
|
char *line;
|
||||||
int nents = 0;
|
|
||||||
ld = false;
|
ld = false;
|
||||||
|
|
||||||
STRLIST_FOREACH (ldents, line, i)
|
|
||||||
nents ++;
|
|
||||||
|
|
||||||
STRLIST_FOREACH (lines, line, i)
|
STRLIST_FOREACH (lines, line, i)
|
||||||
if (i > nents || strcmp (line, ldents[i - 1]) != 0)
|
if (i > nents || strcmp (line, ldents[i - 1]) != 0)
|
||||||
{
|
{
|
||||||
|
@ -144,7 +144,7 @@ rc_depinfo_t *rc_load_deptree (void)
|
|||||||
if (! deptype->type)
|
if (! deptype->type)
|
||||||
deptype->type = rc_xstrdup (type);
|
deptype->type = rc_xstrdup (type);
|
||||||
|
|
||||||
deptype->services = rc_strlist_addsort (deptype->services, e);
|
rc_strlist_addsort (&deptype->services, e);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ static bool get_provided1 (const char *runlevel, struct lhead *providers,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
retval = true;
|
retval = true;
|
||||||
providers->list = rc_strlist_add (providers->list, service);
|
rc_strlist_add (&providers->list, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (retval);
|
return (retval);
|
||||||
@ -271,7 +271,7 @@ static char **get_provided (rc_depinfo_t *deptree, rc_depinfo_t *depinfo,
|
|||||||
if (options & RC_DEP_STOP)
|
if (options & RC_DEP_STOP)
|
||||||
{
|
{
|
||||||
STRLIST_FOREACH (dt->services, service, i)
|
STRLIST_FOREACH (dt->services, service, i)
|
||||||
providers.list = rc_strlist_add (providers.list, service);
|
rc_strlist_add (&providers.list, service);
|
||||||
|
|
||||||
return (providers.list);
|
return (providers.list);
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ static char **get_provided (rc_depinfo_t *deptree, rc_depinfo_t *depinfo,
|
|||||||
STRLIST_FOREACH (dt->services, service, i)
|
STRLIST_FOREACH (dt->services, service, i)
|
||||||
if (rc_service_in_runlevel (service, runlevel) ||
|
if (rc_service_in_runlevel (service, runlevel) ||
|
||||||
rc_service_in_runlevel (service, bootlevel))
|
rc_service_in_runlevel (service, bootlevel))
|
||||||
providers.list = rc_strlist_add (providers.list, service);
|
rc_strlist_add (&providers.list, service);
|
||||||
|
|
||||||
if (providers.list)
|
if (providers.list)
|
||||||
return (providers.list);
|
return (providers.list);
|
||||||
@ -348,7 +348,7 @@ static char **get_provided (rc_depinfo_t *deptree, rc_depinfo_t *depinfo,
|
|||||||
|
|
||||||
/* Still nothing? OK, list all services */
|
/* Still nothing? OK, list all services */
|
||||||
STRLIST_FOREACH (dt->services, service, i)
|
STRLIST_FOREACH (dt->services, service, i)
|
||||||
providers.list = rc_strlist_add (providers.list, service);
|
rc_strlist_add (&providers.list, service);
|
||||||
|
|
||||||
return (providers.list);
|
return (providers.list);
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ static void visit_service (rc_depinfo_t *deptree, char **types,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Add ourselves as a visited service */
|
/* Add ourselves as a visited service */
|
||||||
visited->list = rc_strlist_add (visited->list, depinfo->service);
|
rc_strlist_add (&visited->list, depinfo->service);
|
||||||
|
|
||||||
STRLIST_FOREACH (types, item, i)
|
STRLIST_FOREACH (types, item, i)
|
||||||
{
|
{
|
||||||
@ -385,7 +385,7 @@ static void visit_service (rc_depinfo_t *deptree, char **types,
|
|||||||
{
|
{
|
||||||
if (! options & RC_DEP_TRACE || strcmp (item, "iprovide") == 0)
|
if (! options & RC_DEP_TRACE || strcmp (item, "iprovide") == 0)
|
||||||
{
|
{
|
||||||
sorted->list = rc_strlist_add (sorted->list, service);
|
rc_strlist_add (&sorted->list, service);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +438,7 @@ static void visit_service (rc_depinfo_t *deptree, char **types,
|
|||||||
svcname = getenv("SVCNAME");
|
svcname = getenv("SVCNAME");
|
||||||
if (! svcname || strcmp (svcname, depinfo->service) != 0)
|
if (! svcname || strcmp (svcname, depinfo->service) != 0)
|
||||||
if (! rc_get_deptype (depinfo, "providedby"))
|
if (! rc_get_deptype (depinfo, "providedby"))
|
||||||
sorted->list = rc_strlist_add (sorted->list, depinfo->service);
|
rc_strlist_add (&sorted->list, depinfo->service);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **rc_get_depends (rc_depinfo_t *deptree,
|
char **rc_get_depends (rc_depinfo_t *deptree,
|
||||||
@ -517,9 +517,9 @@ char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel,
|
|||||||
|
|
||||||
/* Now we have our lists, we need to pull in any dependencies
|
/* Now we have our lists, we need to pull in any dependencies
|
||||||
and order them */
|
and order them */
|
||||||
types = rc_strlist_add (NULL, "ineed");
|
rc_strlist_add (&types, "ineed");
|
||||||
types = rc_strlist_add (types, "iuse");
|
rc_strlist_add (&types, "iuse");
|
||||||
types = rc_strlist_add (types, "iafter");
|
rc_strlist_add (&types, "iafter");
|
||||||
services = rc_get_depends (deptree, types, list, runlevel,
|
services = rc_get_depends (deptree, types, list, runlevel,
|
||||||
RC_DEP_STRICT | RC_DEP_TRACE | options);
|
RC_DEP_STRICT | RC_DEP_TRACE | options);
|
||||||
rc_strlist_free (list);
|
rc_strlist_free (list);
|
||||||
@ -752,7 +752,7 @@ int rc_update_deptree (bool force)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp (type, "config") == 0) {
|
if (strcmp (type, "config") == 0) {
|
||||||
config = rc_strlist_addsort (config, depend);
|
rc_strlist_addsort (&config, depend);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ int rc_update_deptree (bool force)
|
|||||||
depend[len - 1] == 'h')
|
depend[len - 1] == 'h')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
deptype->services = rc_strlist_addsort (deptype->services, depend);
|
rc_strlist_addsort (&deptype->services, depend);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -848,8 +848,7 @@ int rc_update_deptree (bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! already_added)
|
if (! already_added)
|
||||||
dt->services = rc_strlist_addsort (dt->services,
|
rc_strlist_addsort (&dt->services, depinfo->service);
|
||||||
depinfo->service);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ char **rc_ls_dir (char **list, const char *dir, int options)
|
|||||||
d->d_name[l - 1] == 'h')
|
d->d_name[l - 1] == 'h')
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list = rc_strlist_addsort (list, d->d_name);
|
rc_strlist_addsort (&list, d->d_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir (dp);
|
closedir (dp);
|
||||||
@ -377,7 +377,7 @@ char **rc_get_config (char **list, const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! replaced) {
|
if (! replaced) {
|
||||||
list = rc_strlist_addsort (list, newline);
|
rc_strlist_addsort (&list, newline);
|
||||||
free (newline);
|
free (newline);
|
||||||
}
|
}
|
||||||
free (entry);
|
free (entry);
|
||||||
@ -430,7 +430,7 @@ char **rc_get_list (char **list, const char *file)
|
|||||||
if (token[strlen (token) - 1] == '\n')
|
if (token[strlen (token) - 1] == '\n')
|
||||||
token[strlen (token) - 1] = 0;
|
token[strlen (token) - 1] = 0;
|
||||||
|
|
||||||
list = rc_strlist_add (list, token);
|
rc_strlist_add (&list, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
@ -515,7 +515,7 @@ char **rc_filter_env (void)
|
|||||||
snprintf (e, env_len, "%s=%s", env_name, env_var);
|
snprintf (e, env_len, "%s=%s", env_name, env_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
env = rc_strlist_add (env, e);
|
rc_strlist_add (&env, e);
|
||||||
free (e);
|
free (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +525,7 @@ char **rc_filter_env (void)
|
|||||||
env_len = strlen ("PATH=") + strlen (PATH_PREFIX) + 2;
|
env_len = strlen ("PATH=") + strlen (PATH_PREFIX) + 2;
|
||||||
p = rc_xmalloc (sizeof (char *) * env_len);
|
p = rc_xmalloc (sizeof (char *) * env_len);
|
||||||
snprintf (p, env_len, "PATH=%s", PATH_PREFIX);
|
snprintf (p, env_len, "PATH=%s", PATH_PREFIX);
|
||||||
env = rc_strlist_add (env, p);
|
rc_strlist_add (&env, p);
|
||||||
free (p);
|
free (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,12 +606,12 @@ char **rc_config_env (char **env)
|
|||||||
e = getenv (line);
|
e = getenv (line);
|
||||||
if (! e) {
|
if (! e) {
|
||||||
*p = '=';
|
*p = '=';
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
} else {
|
} else {
|
||||||
int len = strlen (line) + strlen (e) + 2;
|
int len = strlen (line) + strlen (e) + 2;
|
||||||
char *new = rc_xmalloc (sizeof (char *) * len);
|
char *new = rc_xmalloc (sizeof (char *) * len);
|
||||||
snprintf (new, len, "%s=%s", line, e);
|
snprintf (new, len, "%s=%s", line, e);
|
||||||
env = rc_strlist_add (env, new);
|
rc_strlist_add (&env, new);
|
||||||
free (new);
|
free (new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -621,23 +621,23 @@ char **rc_config_env (char **env)
|
|||||||
i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
|
i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR);
|
snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
/* One char less to drop the trailing / */
|
/* One char less to drop the trailing / */
|
||||||
i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
|
i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR);
|
snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
env = rc_strlist_add (env, "RC_BOOTLEVEL=" RC_LEVEL_BOOT);
|
rc_strlist_add (&env, "RC_BOOTLEVEL=" RC_LEVEL_BOOT);
|
||||||
|
|
||||||
p = rc_get_runlevel ();
|
p = rc_get_runlevel ();
|
||||||
i = strlen ("RC_SOFTLEVEL=") + strlen (p) + 1;
|
i = strlen ("RC_SOFTLEVEL=") + strlen (p) + 1;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_SOFTLEVEL=%s", p);
|
snprintf (line, i, "RC_SOFTLEVEL=%s", p);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
if (rc_exists (RC_KSOFTLEVEL)) {
|
if (rc_exists (RC_KSOFTLEVEL)) {
|
||||||
@ -652,13 +652,13 @@ char **rc_config_env (char **env)
|
|||||||
i += strlen ("RC_DEFAULTLEVEL=") + 2;
|
i += strlen ("RC_DEFAULTLEVEL=") + 2;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_DEFAULTLEVEL=%s", buffer);
|
snprintf (line, i, "RC_DEFAULTLEVEL=%s", buffer);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
env = rc_strlist_add (env, "RC_DEFAULTLEVEL=" RC_LEVEL_DEFAULT);
|
rc_strlist_add (&env, "RC_DEFAULTLEVEL=" RC_LEVEL_DEFAULT);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -687,7 +687,7 @@ char **rc_config_env (char **env)
|
|||||||
i = strlen ("RC_SYS=") + strlen (sys) + 2;
|
i = strlen ("RC_SYS=") + strlen (sys) + 2;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_SYS=%s", sys);
|
snprintf (line, i, "RC_SYS=%s", sys);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +704,7 @@ char **rc_config_env (char **env)
|
|||||||
i = strlen ("RC_NET_FS_LIST=") + strlen (RC_NET_FS_LIST_DEFAULT) + 1;
|
i = strlen ("RC_NET_FS_LIST=") + strlen (RC_NET_FS_LIST_DEFAULT) + 1;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_NET_FS_LIST=%s", RC_NET_FS_LIST_DEFAULT);
|
snprintf (line, i, "RC_NET_FS_LIST=%s", RC_NET_FS_LIST_DEFAULT);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,7 +714,7 @@ char **rc_config_env (char **env)
|
|||||||
i = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
|
i = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
|
||||||
line = rc_xmalloc (sizeof (char *) * i);
|
line = rc_xmalloc (sizeof (char *) * i);
|
||||||
snprintf (line, i, "RC_UNAME=%s", uts.sysname);
|
snprintf (line, i, "RC_UNAME=%s", uts.sysname);
|
||||||
env = rc_strlist_add (env, line);
|
rc_strlist_add (&env, line);
|
||||||
free (line);
|
free (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,59 +9,67 @@
|
|||||||
|
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
|
|
||||||
static char **_rc_strlist_add (char **list, const char *item, bool uniq)
|
static char *_rc_strlist_add (char ***list, const char *item, bool uniq)
|
||||||
{
|
{
|
||||||
char **newlist;
|
char **newlist;
|
||||||
|
char **lst = *list;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (! item)
|
if (! item)
|
||||||
return (list);
|
return (NULL);
|
||||||
|
|
||||||
while (list && list[i]) {
|
while (lst && lst[i]) {
|
||||||
if (uniq && strcmp (list[i], item) == 0)
|
if (uniq && strcmp (lst[i], item) == 0) {
|
||||||
return (list);
|
errno = EEXIST;
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
newlist = rc_xrealloc (list, sizeof (char *) * (i + 2));
|
newlist = rc_xrealloc (lst, sizeof (char *) * (i + 2));
|
||||||
newlist[i] = rc_xstrdup (item);
|
newlist[i] = rc_xstrdup (item);
|
||||||
newlist[i + 1] = NULL;
|
newlist[i + 1] = NULL;
|
||||||
|
|
||||||
return (newlist);
|
*list = newlist;
|
||||||
|
return (newlist[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **rc_strlist_add (char **list, const char *item)
|
char *rc_strlist_add (char ***list, const char *item)
|
||||||
{
|
{
|
||||||
return (_rc_strlist_add (list, item, false));
|
return (_rc_strlist_add (list, item, false));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_add)
|
librc_hidden_def(rc_strlist_add)
|
||||||
|
|
||||||
char **rc_strlist_addu (char **list, const char *item)
|
char *rc_strlist_addu (char ***list, const char *item)
|
||||||
{
|
{
|
||||||
return (_rc_strlist_add (list, item, true));
|
return (_rc_strlist_add (list, item, true));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_addu)
|
librc_hidden_def(rc_strlist_addu)
|
||||||
|
|
||||||
static char **_rc_strlist_addsort (char **list, const char *item,
|
static char *_rc_strlist_addsort (char ***list, const char *item,
|
||||||
int (*sortfunc) (const char *s1,
|
int (*sortfunc) (const char *s1,
|
||||||
const char *s2),
|
const char *s2),
|
||||||
bool uniq)
|
bool uniq)
|
||||||
{
|
{
|
||||||
char **newlist;
|
char **newlist;
|
||||||
|
char **lst = *list;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char *tmp1;
|
char *tmp1;
|
||||||
char *tmp2;
|
char *tmp2;
|
||||||
|
char *retval;
|
||||||
|
|
||||||
if (! item)
|
if (! item)
|
||||||
return (list);
|
return (NULL);
|
||||||
|
|
||||||
while (list && list[i]) {
|
while (lst && lst[i]) {
|
||||||
if (uniq && strcmp (list[i], item) == 0)
|
if (uniq && strcmp (lst[i], item) == 0) {
|
||||||
return (list);
|
errno = EEXIST;
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
newlist = rc_xrealloc (list, sizeof (char *) * (i + 2));
|
newlist = rc_xrealloc (lst, sizeof (char *) * (i + 2));
|
||||||
|
|
||||||
if (! i)
|
if (! i)
|
||||||
newlist[i] = NULL;
|
newlist[i] = NULL;
|
||||||
@ -72,7 +80,7 @@ static char **_rc_strlist_addsort (char **list, const char *item,
|
|||||||
i++;
|
i++;
|
||||||
|
|
||||||
tmp1 = newlist[i];
|
tmp1 = newlist[i];
|
||||||
newlist[i] = rc_xstrdup (item);
|
retval = newlist[i] = rc_xstrdup (item);
|
||||||
do {
|
do {
|
||||||
i++;
|
i++;
|
||||||
tmp2 = newlist[i];
|
tmp2 = newlist[i];
|
||||||
@ -80,44 +88,50 @@ static char **_rc_strlist_addsort (char **list, const char *item,
|
|||||||
tmp1 = tmp2;
|
tmp1 = tmp2;
|
||||||
} while (tmp1);
|
} while (tmp1);
|
||||||
|
|
||||||
return (newlist);
|
*list = newlist;
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **rc_strlist_addsort (char **list, const char *item)
|
char *rc_strlist_addsort (char ***list, const char *item)
|
||||||
{
|
{
|
||||||
return (_rc_strlist_addsort (list, item, strcoll, false));
|
return (_rc_strlist_addsort (list, item, strcoll, false));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_addsort)
|
librc_hidden_def(rc_strlist_addsort)
|
||||||
|
|
||||||
char **rc_strlist_addsortc (char **list, const char *item)
|
char *rc_strlist_addsortc (char ***list, const char *item)
|
||||||
{
|
{
|
||||||
return (_rc_strlist_addsort (list, item, strcmp, false));
|
return (_rc_strlist_addsort (list, item, strcmp, false));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_addsortc)
|
librc_hidden_def(rc_strlist_addsortc)
|
||||||
|
|
||||||
char **rc_strlist_addsortu (char **list, const char *item)
|
char *rc_strlist_addsortu (char ***list, const char *item)
|
||||||
{
|
{
|
||||||
return (_rc_strlist_addsort (list, item, strcmp, true));
|
return (_rc_strlist_addsort (list, item, strcmp, true));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_addsortu)
|
librc_hidden_def(rc_strlist_addsortu)
|
||||||
|
|
||||||
char **rc_strlist_delete (char **list, const char *item)
|
int rc_strlist_delete (char ***list, const char *item)
|
||||||
{
|
{
|
||||||
|
char **lst = *list;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
if (!list || ! item)
|
if (!lst || ! item)
|
||||||
return (list);
|
return (-1);
|
||||||
|
|
||||||
while (list[i])
|
while (lst[i])
|
||||||
if (! strcmp (list[i], item)) {
|
if (! strcmp (lst[i], item)) {
|
||||||
free (list[i]);
|
free (lst[i]);
|
||||||
|
retval = 0;
|
||||||
do {
|
do {
|
||||||
list[i] = list[i + 1];
|
lst[i] = lst[i + 1];
|
||||||
i++;
|
i++;
|
||||||
} while (list[i]);
|
} while (lst[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (list);
|
if (retval)
|
||||||
|
errno = ENOENT;
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_strlist_delete)
|
librc_hidden_def(rc_strlist_delete)
|
||||||
|
|
||||||
@ -184,10 +198,8 @@ void rc_strlist_free (char **list)
|
|||||||
if (! list)
|
if (! list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (list[i]) {
|
while (list[i])
|
||||||
free (list[i]);
|
free (list[i++]);
|
||||||
list[i++] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free (list);
|
free (list);
|
||||||
}
|
}
|
||||||
|
10
src/librc.c
10
src/librc.c
@ -53,7 +53,7 @@ char **rc_get_runlevels (void)
|
|||||||
STRLIST_FOREACH (dirs, dir, i) {
|
STRLIST_FOREACH (dirs, dir, i) {
|
||||||
char *path = rc_strcatpaths (RC_RUNLEVELDIR, dir, (char *) NULL);
|
char *path = rc_strcatpaths (RC_RUNLEVELDIR, dir, (char *) NULL);
|
||||||
if (rc_is_dir (path))
|
if (rc_is_dir (path))
|
||||||
runlevels = rc_strlist_addsort (runlevels, dir);
|
rc_strlist_addsort (&runlevels, dir);
|
||||||
free (path);
|
free (path);
|
||||||
}
|
}
|
||||||
rc_strlist_free (dirs);
|
rc_strlist_free (dirs);
|
||||||
@ -65,7 +65,7 @@ librc_hidden_def(rc_get_runlevels)
|
|||||||
char *rc_get_runlevel (void)
|
char *rc_get_runlevel (void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
static char buffer [PATH_MAX];
|
static char buffer[PATH_MAX];
|
||||||
|
|
||||||
if (! (fp = fopen (SOFTLEVEL, "r"))) {
|
if (! (fp = fopen (SOFTLEVEL, "r"))) {
|
||||||
snprintf (buffer, sizeof (buffer), "sysinit");
|
snprintf (buffer, sizeof (buffer), "sysinit");
|
||||||
@ -198,7 +198,7 @@ char **rc_service_options (const char *service)
|
|||||||
if (buffer[strlen (buffer) - 1] == '\n')
|
if (buffer[strlen (buffer) - 1] == '\n')
|
||||||
buffer[strlen (buffer) - 1] = '\0';
|
buffer[strlen (buffer) - 1] = '\0';
|
||||||
while ((token = strsep (&p, " ")))
|
while ((token = strsep (&p, " ")))
|
||||||
opts = rc_strlist_addsort (opts, token);
|
rc_strlist_addsort (&opts, token);
|
||||||
}
|
}
|
||||||
pclose (fp);
|
pclose (fp);
|
||||||
return (opts);
|
return (opts);
|
||||||
@ -728,7 +728,7 @@ char **rc_services_in_state (rc_service_state_t state)
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
STRLIST_FOREACH (entries, e, j)
|
STRLIST_FOREACH (entries, e, j)
|
||||||
list = rc_strlist_addsortu (list, e);
|
rc_strlist_addsortu (&list, e);
|
||||||
|
|
||||||
if (entries)
|
if (entries)
|
||||||
free (entries);
|
free (entries);
|
||||||
@ -807,7 +807,7 @@ char **rc_services_scheduled_by (const char *service)
|
|||||||
char *file = rc_strcatpaths (RC_SVCDIR, "scheduled", dir, service,
|
char *file = rc_strcatpaths (RC_SVCDIR, "scheduled", dir, service,
|
||||||
(char *) NULL);
|
(char *) NULL);
|
||||||
if (rc_exists (file))
|
if (rc_exists (file))
|
||||||
list = rc_strlist_add (list, file);
|
rc_strlist_add (&list, file);
|
||||||
free (file);
|
free (file);
|
||||||
}
|
}
|
||||||
rc_strlist_free (dirs);
|
rc_strlist_free (dirs);
|
||||||
|
@ -117,7 +117,7 @@ static int process_mount (char ***list, struct args *args,
|
|||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
*list = rc_strlist_addsortc (*list, p);
|
rc_strlist_addsortc (list, p);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ int mountinfo (int argc, char **argv)
|
|||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
if (argv[optind][0] != '/')
|
if (argv[optind][0] != '/')
|
||||||
eerrorx ("%s: `%s' is not a mount point", argv[0], argv[optind]);
|
eerrorx ("%s: `%s' is not a mount point", argv[0], argv[optind]);
|
||||||
args.mounts = rc_strlist_add (args.mounts, argv[optind++]);
|
rc_strlist_add (&args.mounts, argv[optind++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes = find_mounts (&args);
|
nodes = find_mounts (&args);
|
||||||
|
@ -57,7 +57,7 @@ int rc_depend (int argc, char **argv)
|
|||||||
|
|
||||||
if (argv[i][0] == '-') {
|
if (argv[i][0] == '-') {
|
||||||
argv[i]++;
|
argv[i]++;
|
||||||
types = rc_strlist_add (types, argv[i]);
|
rc_strlist_add (&types, argv[i]);
|
||||||
} else {
|
} else {
|
||||||
if ((deptree = rc_load_deptree ()) == NULL)
|
if ((deptree = rc_load_deptree ()) == NULL)
|
||||||
eerrorx ("failed to load deptree");
|
eerrorx ("failed to load deptree");
|
||||||
@ -66,7 +66,7 @@ int rc_depend (int argc, char **argv)
|
|||||||
if (! di)
|
if (! di)
|
||||||
eerror ("no dependency info for service `%s'", argv[i]);
|
eerror ("no dependency info for service `%s'", argv[i]);
|
||||||
else
|
else
|
||||||
services = rc_strlist_add (services, argv[i]);
|
rc_strlist_add (&services, argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +80,8 @@ int rc_depend (int argc, char **argv)
|
|||||||
|
|
||||||
/* If we don't have any types, then supply some defaults */
|
/* If we don't have any types, then supply some defaults */
|
||||||
if (! types) {
|
if (! types) {
|
||||||
types = rc_strlist_add (NULL, "ineed");
|
rc_strlist_add (&types, "ineed");
|
||||||
rc_strlist_add (types, "iuse");
|
rc_strlist_add (&types, "iuse");
|
||||||
}
|
}
|
||||||
|
|
||||||
depends = rc_get_depends (deptree, types, services, runlevel, options);
|
depends = rc_get_depends (deptree, types, services, runlevel, options);
|
||||||
|
@ -114,10 +114,10 @@ int rc_status (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
levels = rc_strlist_add (levels, argv[optind++]);
|
rc_strlist_add (&levels, argv[optind++]);
|
||||||
|
|
||||||
if (! levels)
|
if (! levels)
|
||||||
levels = rc_strlist_add (NULL, rc_get_runlevel ());
|
rc_strlist_add (&levels, rc_get_runlevel ());
|
||||||
|
|
||||||
STRLIST_FOREACH (levels, level, i) {
|
STRLIST_FOREACH (levels, level, i) {
|
||||||
print_level (level);
|
print_level (level);
|
||||||
|
@ -80,13 +80,13 @@ static void show (char **runlevels, bool verbose)
|
|||||||
|
|
||||||
STRLIST_FOREACH (runlevels, runlevel, j) {
|
STRLIST_FOREACH (runlevels, runlevel, j) {
|
||||||
if (rc_service_in_runlevel (service, runlevel)) {
|
if (rc_service_in_runlevel (service, runlevel)) {
|
||||||
in = rc_strlist_add (in, runlevel);
|
rc_strlist_add (&in, runlevel);
|
||||||
inone = true;
|
inone = true;
|
||||||
} else {
|
} else {
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
memset (buffer, ' ', strlen (runlevel));
|
memset (buffer, ' ', strlen (runlevel));
|
||||||
buffer[strlen (runlevel)] = 0;
|
buffer[strlen (runlevel)] = 0;
|
||||||
in = rc_strlist_add (in, buffer);
|
rc_strlist_add (&in, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ int rc_update (int argc, char **argv)
|
|||||||
|
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
if (rc_runlevel_exists (argv[optind]))
|
if (rc_runlevel_exists (argv[optind]))
|
||||||
runlevels = rc_strlist_add (runlevels, argv[optind++]);
|
rc_strlist_add (&runlevels, argv[optind++]);
|
||||||
else {
|
else {
|
||||||
rc_strlist_free (runlevels);
|
rc_strlist_free (runlevels);
|
||||||
eerrorx ("%s: `%s' is not a valid runlevel", applet, argv[optind]);
|
eerrorx ("%s: `%s' is not a valid runlevel", applet, argv[optind]);
|
||||||
@ -195,7 +195,7 @@ int rc_update (int argc, char **argv)
|
|||||||
|
|
||||||
if (action & DOSHOW) {
|
if (action & DOSHOW) {
|
||||||
if (service)
|
if (service)
|
||||||
runlevels = rc_strlist_add (runlevels, service);
|
rc_strlist_add (&runlevels, service);
|
||||||
if (! runlevels)
|
if (! runlevels)
|
||||||
runlevels = rc_get_runlevels ();
|
runlevels = rc_get_runlevels ();
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ int rc_update (int argc, char **argv)
|
|||||||
else {
|
else {
|
||||||
retval = EXIT_SUCCESS;
|
retval = EXIT_SUCCESS;
|
||||||
if (! runlevels)
|
if (! runlevels)
|
||||||
runlevels = rc_strlist_add (runlevels, rc_get_runlevel ());
|
rc_strlist_add (&runlevels, rc_get_runlevel ());
|
||||||
STRLIST_FOREACH (runlevels, runlevel, i) {
|
STRLIST_FOREACH (runlevels, runlevel, i) {
|
||||||
if (action & DOADD) {
|
if (action & DOADD) {
|
||||||
if (! add (runlevel, service))
|
if (! add (runlevel, service))
|
||||||
|
24
src/rc.c
24
src/rc.c
@ -1092,16 +1092,17 @@ int main (int argc, char **argv)
|
|||||||
stop_services = rc_ls_dir (stop_services, RC_SVCDIR_INACTIVE, RC_LS_INITD);
|
stop_services = rc_ls_dir (stop_services, RC_SVCDIR_INACTIVE, RC_LS_INITD);
|
||||||
stop_services = rc_ls_dir (stop_services, RC_SVCDIR_STARTED, RC_LS_INITD);
|
stop_services = rc_ls_dir (stop_services, RC_SVCDIR_STARTED, RC_LS_INITD);
|
||||||
|
|
||||||
types = rc_strlist_add (NULL, "ineed");
|
types = NULL;
|
||||||
types = rc_strlist_add (types, "iuse");
|
rc_strlist_add (&types, "ineed");
|
||||||
types = rc_strlist_add (types, "iafter");
|
rc_strlist_add (&types, "iuse");
|
||||||
|
rc_strlist_add (&types, "iafter");
|
||||||
deporder = rc_get_depends (deptree, types, stop_services,
|
deporder = rc_get_depends (deptree, types, stop_services,
|
||||||
runlevel, depoptions | RC_DEP_STOP);
|
runlevel, depoptions | RC_DEP_STOP);
|
||||||
rc_strlist_free (stop_services);
|
rc_strlist_free (stop_services);
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
|
types = NULL;
|
||||||
stop_services = deporder;
|
stop_services = deporder;
|
||||||
deporder = NULL;
|
deporder = NULL;
|
||||||
types = NULL;
|
|
||||||
rc_strlist_reverse (stop_services);
|
rc_strlist_reverse (stop_services);
|
||||||
|
|
||||||
/* Load our list of coldplugged services */
|
/* Load our list of coldplugged services */
|
||||||
@ -1115,7 +1116,7 @@ int main (int argc, char **argv)
|
|||||||
einfon ("Device initiated services:");
|
einfon ("Device initiated services:");
|
||||||
STRLIST_FOREACH (coldplugged_services, service, i) {
|
STRLIST_FOREACH (coldplugged_services, service, i) {
|
||||||
printf (" %s", service);
|
printf (" %s", service);
|
||||||
start_services = rc_strlist_add (start_services, service);
|
rc_strlist_add (&start_services, service);
|
||||||
}
|
}
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
@ -1140,7 +1141,7 @@ int main (int argc, char **argv)
|
|||||||
services = NULL;
|
services = NULL;
|
||||||
|
|
||||||
STRLIST_FOREACH (coldplugged_services, service, i)
|
STRLIST_FOREACH (coldplugged_services, service, i)
|
||||||
start_services = rc_strlist_add (start_services, service);
|
rc_strlist_add (&start_services, service);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1149,7 +1150,8 @@ int main (int argc, char **argv)
|
|||||||
if (going_down)
|
if (going_down)
|
||||||
rc_set_runlevel (newlevel);
|
rc_set_runlevel (newlevel);
|
||||||
|
|
||||||
types = rc_strlist_add (NULL, "needsme");
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, "needsme");
|
||||||
/* Now stop the services that shouldn't be running */
|
/* Now stop the services that shouldn't be running */
|
||||||
STRLIST_FOREACH (stop_services, service, i) {
|
STRLIST_FOREACH (stop_services, service, i) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -1209,7 +1211,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
/* We got this far! Or last check is to see if any any service that
|
/* We got this far! Or last check is to see if any any service that
|
||||||
going to be started depends on us */
|
going to be started depends on us */
|
||||||
stopdeps = rc_strlist_add (stopdeps, service);
|
rc_strlist_add (&stopdeps, service);
|
||||||
deporder = rc_get_depends (deptree, types, stopdeps,
|
deporder = rc_get_depends (deptree, types, stopdeps,
|
||||||
runlevel, RC_DEP_STRICT);
|
runlevel, RC_DEP_STRICT);
|
||||||
rc_strlist_free (stopdeps);
|
rc_strlist_free (stopdeps);
|
||||||
@ -1276,9 +1278,9 @@ int main (int argc, char **argv)
|
|||||||
rc_mark_service (service, rc_service_coldplugged);
|
rc_mark_service (service, rc_service_coldplugged);
|
||||||
|
|
||||||
/* Order the services to start */
|
/* Order the services to start */
|
||||||
types = rc_strlist_add (NULL, "ineed");
|
rc_strlist_add (&types, "ineed");
|
||||||
types = rc_strlist_add (types, "iuse");
|
rc_strlist_add (&types, "iuse");
|
||||||
types = rc_strlist_add (types, "iafter");
|
rc_strlist_add (&types, "iafter");
|
||||||
deporder = rc_get_depends (deptree, types, start_services,
|
deporder = rc_get_depends (deptree, types, start_services,
|
||||||
runlevel, depoptions | RC_DEP_START);
|
runlevel, depoptions | RC_DEP_START);
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
|
12
src/rc.h
12
src/rc.h
@ -197,12 +197,12 @@ char **rc_filter_env (void);
|
|||||||
char **rc_config_env (char **env);
|
char **rc_config_env (char **env);
|
||||||
|
|
||||||
/* Handy functions for dealing with string arrays of char ** */
|
/* Handy functions for dealing with string arrays of char ** */
|
||||||
char **rc_strlist_add (char **list, const char *item);
|
char *rc_strlist_add (char ***list, const char *item);
|
||||||
char **rc_strlist_addu (char **list, const char *item);
|
char *rc_strlist_addu (char ***list, const char *item);
|
||||||
char **rc_strlist_addsort (char **list, const char *item);
|
char *rc_strlist_addsort (char ***list, const char *item);
|
||||||
char **rc_strlist_addsortc (char **list, const char *item);
|
char *rc_strlist_addsortc (char ***list, const char *item);
|
||||||
char **rc_strlist_addsortu (char **list, const char *item);
|
char *rc_strlist_addsortu (char ***list, const char *item);
|
||||||
char **rc_strlist_delete (char **list, const char *item);
|
int rc_strlist_delete (char ***list, const char *item);
|
||||||
char **rc_strlist_join (char **list1, char **list2);
|
char **rc_strlist_join (char **list1, char **list2);
|
||||||
void rc_strlist_reverse (char **list);
|
void rc_strlist_reverse (char **list);
|
||||||
void rc_strlist_free (char **list);
|
void rc_strlist_free (char **list);
|
||||||
|
@ -558,7 +558,7 @@ static void get_started_services ()
|
|||||||
restart_services = rc_services_in_state (rc_service_started);
|
restart_services = rc_services_in_state (rc_service_started);
|
||||||
|
|
||||||
STRLIST_FOREACH (tmplist, svc, i)
|
STRLIST_FOREACH (tmplist, svc, i)
|
||||||
restart_services = rc_strlist_addsort (restart_services, svc);
|
rc_strlist_addsort (&restart_services, svc);
|
||||||
|
|
||||||
rc_strlist_free (tmplist);
|
rc_strlist_free (tmplist);
|
||||||
tmplist = NULL;
|
tmplist = NULL;
|
||||||
@ -610,9 +610,11 @@ static void svc_start (bool deps)
|
|||||||
eerrorx ("failed to load deptree");
|
eerrorx ("failed to load deptree");
|
||||||
|
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
types = rc_strlist_add (NULL, "broken");
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, "broken");
|
||||||
rc_strlist_free (svclist);
|
rc_strlist_free (svclist);
|
||||||
svclist = rc_strlist_add (NULL, applet);
|
svclist = NULL;
|
||||||
|
rc_strlist_add (&svclist, applet);
|
||||||
rc_strlist_free (services);
|
rc_strlist_free (services);
|
||||||
services = rc_get_depends (deptree, types, svclist, softlevel, 0);
|
services = rc_get_depends (deptree, types, svclist, softlevel, 0);
|
||||||
if (services) {
|
if (services) {
|
||||||
@ -628,12 +630,13 @@ static void svc_start (bool deps)
|
|||||||
services = NULL;
|
services = NULL;
|
||||||
|
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
types = rc_strlist_add (NULL, "ineed");
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, "ineed");
|
||||||
rc_strlist_free (need_services);
|
rc_strlist_free (need_services);
|
||||||
need_services = rc_get_depends (deptree, types, svclist,
|
need_services = rc_get_depends (deptree, types, svclist,
|
||||||
softlevel, depoptions);
|
softlevel, depoptions);
|
||||||
|
|
||||||
types = rc_strlist_add (types, "iuse");
|
rc_strlist_add (&types, "iuse");
|
||||||
rc_strlist_free (use_services);
|
rc_strlist_free (use_services);
|
||||||
use_services = rc_get_depends (deptree, types, svclist,
|
use_services = rc_get_depends (deptree, types, svclist,
|
||||||
softlevel, depoptions);
|
softlevel, depoptions);
|
||||||
@ -648,7 +651,7 @@ static void svc_start (bool deps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now wait for them to start */
|
/* Now wait for them to start */
|
||||||
types = rc_strlist_add (types, "iafter");
|
rc_strlist_add (&types, "iafter");
|
||||||
services = rc_get_depends (deptree, types, svclist,
|
services = rc_get_depends (deptree, types, svclist,
|
||||||
softlevel, depoptions);
|
softlevel, depoptions);
|
||||||
|
|
||||||
@ -683,7 +686,7 @@ static void svc_start (bool deps)
|
|||||||
if (strcmp (svc, svc2) == 0) {
|
if (strcmp (svc, svc2) == 0) {
|
||||||
if (rc_service_state (svc, rc_service_inactive) ||
|
if (rc_service_state (svc, rc_service_inactive) ||
|
||||||
rc_service_state (svc, rc_service_wasinactive))
|
rc_service_state (svc, rc_service_wasinactive))
|
||||||
tmplist = rc_strlist_add (tmplist, svc);
|
rc_strlist_add (&tmplist, svc);
|
||||||
else
|
else
|
||||||
eerrorx ("ERROR: cannot start %s as %s would not start",
|
eerrorx ("ERROR: cannot start %s as %s would not start",
|
||||||
applet, svc);
|
applet, svc);
|
||||||
@ -701,12 +704,14 @@ static void svc_start (bool deps)
|
|||||||
unlink_mtime_test ();
|
unlink_mtime_test ();
|
||||||
|
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
types = rc_strlist_add (NULL, "iprovide");
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, "iprovide");
|
||||||
STRLIST_FOREACH (tmplist, svc, i) {
|
STRLIST_FOREACH (tmplist, svc, i) {
|
||||||
rc_schedule_start_service (svc, service);
|
rc_schedule_start_service (svc, service);
|
||||||
|
|
||||||
rc_strlist_free (svclist);
|
rc_strlist_free (svclist);
|
||||||
svclist = rc_strlist_add (NULL, svc);
|
svclist = NULL;
|
||||||
|
rc_strlist_add (&svclist, svc);
|
||||||
rc_strlist_free (providelist);
|
rc_strlist_free (providelist);
|
||||||
providelist = rc_get_depends (deptree, types, svclist,
|
providelist = rc_get_depends (deptree, types, svclist,
|
||||||
softlevel, depoptions);
|
softlevel, depoptions);
|
||||||
@ -782,9 +787,11 @@ static void svc_start (bool deps)
|
|||||||
|
|
||||||
/* Do the same for any services we provide */
|
/* Do the same for any services we provide */
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
types = rc_strlist_add (NULL, "iprovide");
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, "iprovide");
|
||||||
rc_strlist_free (svclist);
|
rc_strlist_free (svclist);
|
||||||
svclist = rc_strlist_add (NULL, applet);
|
svclist = NULL;
|
||||||
|
rc_strlist_add (&svclist, applet);
|
||||||
rc_strlist_free (tmplist);
|
rc_strlist_free (tmplist);
|
||||||
tmplist = rc_get_depends (deptree, types, svclist, softlevel, depoptions);
|
tmplist = rc_get_depends (deptree, types, svclist, softlevel, depoptions);
|
||||||
|
|
||||||
@ -845,9 +852,11 @@ static void svc_stop (bool deps)
|
|||||||
eerrorx ("failed to load deptree");
|
eerrorx ("failed to load deptree");
|
||||||
|
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
types = rc_strlist_add (NULL, "needsme");
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, "needsme");
|
||||||
rc_strlist_free (svclist);
|
rc_strlist_free (svclist);
|
||||||
svclist = rc_strlist_add (NULL, applet);
|
svclist = NULL;
|
||||||
|
rc_strlist_add (&svclist, applet);
|
||||||
rc_strlist_free (tmplist);
|
rc_strlist_free (tmplist);
|
||||||
tmplist = NULL;
|
tmplist = NULL;
|
||||||
rc_strlist_free (services);
|
rc_strlist_free (services);
|
||||||
@ -865,7 +874,7 @@ static void svc_stop (bool deps)
|
|||||||
pid_t pid = rc_stop_service (svc);
|
pid_t pid = rc_stop_service (svc);
|
||||||
if (! rc_is_env ("RC_PARALLEL", "yes"))
|
if (! rc_is_env ("RC_PARALLEL", "yes"))
|
||||||
rc_waitpid (pid);
|
rc_waitpid (pid);
|
||||||
tmplist = rc_strlist_add (tmplist, svc);
|
rc_strlist_add (&tmplist, svc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -899,8 +908,8 @@ static void svc_stop (bool deps)
|
|||||||
|
|
||||||
/* We now wait for other services that may use us and are stopping
|
/* We now wait for other services that may use us and are stopping
|
||||||
This is important when a runlevel stops */
|
This is important when a runlevel stops */
|
||||||
types = rc_strlist_add (types, "usesme");
|
rc_strlist_add (&types, "usesme");
|
||||||
types = rc_strlist_add (types, "ibefore");
|
rc_strlist_add (&types, "ibefore");
|
||||||
services = rc_get_depends (deptree, types, svclist,
|
services = rc_get_depends (deptree, types, svclist,
|
||||||
softlevel, depoptions);
|
softlevel, depoptions);
|
||||||
STRLIST_FOREACH (services, svc, i) {
|
STRLIST_FOREACH (services, svc, i) {
|
||||||
@ -1212,9 +1221,11 @@ int runscript (int argc, char **argv)
|
|||||||
eerrorx ("failed to load deptree");
|
eerrorx ("failed to load deptree");
|
||||||
|
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
types = rc_strlist_add (NULL, optarg);
|
types = NULL;
|
||||||
|
rc_strlist_add (&types, optarg);
|
||||||
rc_strlist_free (svclist);
|
rc_strlist_free (svclist);
|
||||||
svclist = rc_strlist_add (NULL, applet);
|
svclist = NULL;
|
||||||
|
rc_strlist_add (&svclist, applet);
|
||||||
rc_strlist_free (services);
|
rc_strlist_free (services);
|
||||||
services = rc_get_depends (deptree, types, svclist,
|
services = rc_get_depends (deptree, types, svclist,
|
||||||
softlevel, depoptions);
|
softlevel, depoptions);
|
||||||
|
@ -880,10 +880,10 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
len = sizeof (char *) * strlen (path) + 6;
|
len = sizeof (char *) * strlen (path) + 6;
|
||||||
newpath = rc_xmalloc (len);
|
newpath = rc_xmalloc (len);
|
||||||
snprintf (newpath, len, "PATH=%s", path);
|
snprintf (newpath, len, "PATH=%s", path);
|
||||||
newenv = rc_strlist_add (newenv, newpath);
|
rc_strlist_add (&newenv, newpath);
|
||||||
free (newpath);
|
free (newpath);
|
||||||
} else
|
} else
|
||||||
newenv = rc_strlist_add (newenv, env);
|
rc_strlist_add (&newenv, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
umask (022);
|
umask (022);
|
||||||
|
Loading…
Reference in New Issue
Block a user