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:
		
							
								
								
									
										11
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,6 +1,17 @@
 | 
			
		||||
# ChangeLog for Gentoo System Intialization ("rc") scripts
 | 
			
		||||
# 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>:
 | 
			
		||||
 | 
			
		||||
    Document the preferance of wpa_supplicant, #192828.
 | 
			
		||||
 
 | 
			
		||||
@@ -102,6 +102,7 @@ int env_update (int argc, char **argv)
 | 
			
		||||
	int opt;
 | 
			
		||||
	bool ldconfig = true;
 | 
			
		||||
	bool fork_ldconfig = false;
 | 
			
		||||
	int nents = 0;
 | 
			
		||||
	
 | 
			
		||||
	applet = argv[0];
 | 
			
		||||
 | 
			
		||||
@@ -147,12 +148,12 @@ int env_update (int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
			if (strcmp (var, "COLON_SEPARATED") == 0)
 | 
			
		||||
				while ((var = strsep (&value, " ")))
 | 
			
		||||
					mycolons = rc_strlist_addu (mycolons, var);
 | 
			
		||||
					rc_strlist_addu (&mycolons, var);
 | 
			
		||||
			else if (strcmp (var, "SPACE_SEPARATED") == 0)
 | 
			
		||||
				while ((var = strsep (&value, " ")))
 | 
			
		||||
					myspaces = rc_strlist_addu (myspaces, var);
 | 
			
		||||
					rc_strlist_addu (&myspaces, var);
 | 
			
		||||
			else 
 | 
			
		||||
				config = rc_strlist_add (config, entry);
 | 
			
		||||
				rc_strlist_add (&config, entry);
 | 
			
		||||
			free (tmpent);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -227,7 +228,7 @@ int env_update (int argc, char **argv)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (! replaced)
 | 
			
		||||
			envs = rc_strlist_addsort (envs, entry);
 | 
			
		||||
			rc_strlist_addsort (&envs, entry);
 | 
			
		||||
 | 
			
		||||
		free (tmpent);
 | 
			
		||||
	}
 | 
			
		||||
@@ -285,7 +286,8 @@ int env_update (int argc, char **argv)
 | 
			
		||||
		if (strlen (file) == 0)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		ldents = rc_strlist_addu (ldents, file);
 | 
			
		||||
		if (rc_strlist_addu (&ldents, file))
 | 
			
		||||
			nents++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (ldconfig) {
 | 
			
		||||
@@ -293,12 +295,8 @@ int env_update (int argc, char **argv)
 | 
			
		||||
		if (rc_exists (LDSOCONF)) {
 | 
			
		||||
			char **lines = rc_get_list (NULL, LDSOCONF);
 | 
			
		||||
			char *line;
 | 
			
		||||
			int nents = 0;
 | 
			
		||||
			ld = false;
 | 
			
		||||
 | 
			
		||||
			STRLIST_FOREACH (ldents, line, i)
 | 
			
		||||
				nents ++;
 | 
			
		||||
 | 
			
		||||
			STRLIST_FOREACH (lines, line, i)
 | 
			
		||||
				if (i > nents || strcmp (line, ldents[i - 1]) != 0)
 | 
			
		||||
				{
 | 
			
		||||
 
 | 
			
		||||
@@ -144,7 +144,7 @@ rc_depinfo_t *rc_load_deptree (void)
 | 
			
		||||
		if (! deptype->type)
 | 
			
		||||
			deptype->type = rc_xstrdup (type);
 | 
			
		||||
 | 
			
		||||
		deptype->services = rc_strlist_addsort (deptype->services, e);
 | 
			
		||||
		rc_strlist_addsort (&deptype->services, e);
 | 
			
		||||
	}
 | 
			
		||||
	fclose (fp);
 | 
			
		||||
 | 
			
		||||
@@ -232,7 +232,7 @@ static bool get_provided1 (const char *runlevel, struct lhead *providers,
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		retval = true;
 | 
			
		||||
		providers->list = rc_strlist_add (providers->list, service);
 | 
			
		||||
		rc_strlist_add (&providers->list, service);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return (retval);
 | 
			
		||||
@@ -271,7 +271,7 @@ static char **get_provided (rc_depinfo_t *deptree, rc_depinfo_t *depinfo,
 | 
			
		||||
	if (options & RC_DEP_STOP)
 | 
			
		||||
	{
 | 
			
		||||
		STRLIST_FOREACH (dt->services, service, i)
 | 
			
		||||
			providers.list = rc_strlist_add (providers.list, service);
 | 
			
		||||
			rc_strlist_add (&providers.list, service);
 | 
			
		||||
 | 
			
		||||
		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)
 | 
			
		||||
			if (rc_service_in_runlevel (service, runlevel) ||
 | 
			
		||||
				rc_service_in_runlevel (service, bootlevel))
 | 
			
		||||
				providers.list = rc_strlist_add (providers.list, service);
 | 
			
		||||
				rc_strlist_add (&providers.list, service);
 | 
			
		||||
 | 
			
		||||
		if (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 */
 | 
			
		||||
	STRLIST_FOREACH (dt->services, service, i)
 | 
			
		||||
		providers.list = rc_strlist_add (providers.list, service);
 | 
			
		||||
		rc_strlist_add (&providers.list, service);
 | 
			
		||||
 | 
			
		||||
	return (providers.list);
 | 
			
		||||
}
 | 
			
		||||
@@ -375,7 +375,7 @@ static void visit_service (rc_depinfo_t *deptree, char **types,
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
	/* 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)
 | 
			
		||||
	{
 | 
			
		||||
@@ -385,7 +385,7 @@ static void visit_service (rc_depinfo_t *deptree, char **types,
 | 
			
		||||
			{
 | 
			
		||||
				if (! options & RC_DEP_TRACE || strcmp (item, "iprovide") == 0)
 | 
			
		||||
				{
 | 
			
		||||
					sorted->list = rc_strlist_add (sorted->list, service);
 | 
			
		||||
					rc_strlist_add (&sorted->list, service);
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@@ -438,7 +438,7 @@ static void visit_service (rc_depinfo_t *deptree, char **types,
 | 
			
		||||
	svcname = getenv("SVCNAME");
 | 
			
		||||
	if (! svcname || strcmp (svcname, depinfo->service) != 0)
 | 
			
		||||
		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,
 | 
			
		||||
@@ -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
 | 
			
		||||
	   and order them */
 | 
			
		||||
	types = rc_strlist_add (NULL, "ineed");
 | 
			
		||||
	types = rc_strlist_add (types, "iuse");
 | 
			
		||||
	types = rc_strlist_add (types, "iafter");
 | 
			
		||||
	rc_strlist_add (&types, "ineed");
 | 
			
		||||
	rc_strlist_add (&types, "iuse");
 | 
			
		||||
	rc_strlist_add (&types, "iafter");
 | 
			
		||||
	services = rc_get_depends (deptree, types, list, runlevel,
 | 
			
		||||
							   RC_DEP_STRICT | RC_DEP_TRACE | options);
 | 
			
		||||
	rc_strlist_free (list);
 | 
			
		||||
@@ -752,7 +752,7 @@ int rc_update_deptree (bool force)
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			if (strcmp (type, "config") == 0) {
 | 
			
		||||
				config = rc_strlist_addsort (config, depend);
 | 
			
		||||
				rc_strlist_addsort (&config, depend);
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -764,7 +764,7 @@ int rc_update_deptree (bool force)
 | 
			
		||||
				depend[len - 1] == 'h')
 | 
			
		||||
				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)
 | 
			
		||||
					dt->services = rc_strlist_addsort (dt->services,
 | 
			
		||||
													   depinfo->service);
 | 
			
		||||
					rc_strlist_addsort (&dt->services, depinfo->service);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -240,7 +240,7 @@ char **rc_ls_dir (char **list, const char *dir, int options)
 | 
			
		||||
					d->d_name[l - 1] == 'h')
 | 
			
		||||
					continue;
 | 
			
		||||
			}
 | 
			
		||||
			list = rc_strlist_addsort (list, d->d_name);
 | 
			
		||||
			rc_strlist_addsort (&list, d->d_name);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	closedir (dp);
 | 
			
		||||
@@ -377,7 +377,7 @@ char **rc_get_config (char **list, const char *file)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (! replaced) {
 | 
			
		||||
			list = rc_strlist_addsort (list, newline);
 | 
			
		||||
			rc_strlist_addsort (&list, newline);
 | 
			
		||||
			free (newline);
 | 
			
		||||
		}
 | 
			
		||||
		free (entry);
 | 
			
		||||
@@ -430,7 +430,7 @@ char **rc_get_list (char **list, const char *file)
 | 
			
		||||
			if (token[strlen (token) - 1] == '\n')
 | 
			
		||||
				token[strlen (token) - 1] = 0;
 | 
			
		||||
 | 
			
		||||
			list = rc_strlist_add (list, token);
 | 
			
		||||
			rc_strlist_add (&list, token);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	fclose (fp);
 | 
			
		||||
@@ -515,7 +515,7 @@ char **rc_filter_env (void)
 | 
			
		||||
			snprintf (e, env_len, "%s=%s", env_name, env_var);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		env = rc_strlist_add (env, e);
 | 
			
		||||
		rc_strlist_add (&env, e);
 | 
			
		||||
		free (e);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -525,7 +525,7 @@ char **rc_filter_env (void)
 | 
			
		||||
		env_len = strlen ("PATH=") + strlen (PATH_PREFIX) + 2;
 | 
			
		||||
		p = rc_xmalloc (sizeof (char *) * env_len);
 | 
			
		||||
		snprintf (p, env_len, "PATH=%s", PATH_PREFIX);
 | 
			
		||||
		env = rc_strlist_add (env, p);
 | 
			
		||||
		 rc_strlist_add (&env, p);
 | 
			
		||||
		free (p);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -606,12 +606,12 @@ char **rc_config_env (char **env)
 | 
			
		||||
		e = getenv (line);
 | 
			
		||||
		if (! e) {
 | 
			
		||||
			*p = '=';
 | 
			
		||||
			env = rc_strlist_add (env, line);
 | 
			
		||||
			rc_strlist_add (&env, line);
 | 
			
		||||
		} else {
 | 
			
		||||
			int len = strlen (line) + strlen (e) + 2;
 | 
			
		||||
			char *new = rc_xmalloc (sizeof (char *) * len);
 | 
			
		||||
			snprintf (new, len, "%s=%s", line, e);
 | 
			
		||||
			env = rc_strlist_add (env, new);
 | 
			
		||||
			rc_strlist_add (&env, new);
 | 
			
		||||
			free (new);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -621,23 +621,23 @@ char **rc_config_env (char **env)
 | 
			
		||||
	i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1;
 | 
			
		||||
	line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
	snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR);
 | 
			
		||||
	env = rc_strlist_add (env, line);
 | 
			
		||||
	rc_strlist_add (&env, line);
 | 
			
		||||
	free (line);
 | 
			
		||||
 | 
			
		||||
	/* One char less to drop the trailing / */
 | 
			
		||||
	i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1;
 | 
			
		||||
	line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
	snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR);
 | 
			
		||||
	env = rc_strlist_add (env, line);
 | 
			
		||||
	rc_strlist_add (&env, 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 ();
 | 
			
		||||
	i = strlen ("RC_SOFTLEVEL=") + strlen (p) + 1;
 | 
			
		||||
	line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
	snprintf (line, i, "RC_SOFTLEVEL=%s", p);
 | 
			
		||||
	env = rc_strlist_add (env, line);
 | 
			
		||||
	rc_strlist_add (&env, line);
 | 
			
		||||
	free (line);
 | 
			
		||||
 | 
			
		||||
	if (rc_exists (RC_KSOFTLEVEL)) {
 | 
			
		||||
@@ -652,13 +652,13 @@ char **rc_config_env (char **env)
 | 
			
		||||
				i += strlen ("RC_DEFAULTLEVEL=") + 2;
 | 
			
		||||
				line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
				snprintf (line, i, "RC_DEFAULTLEVEL=%s", buffer);
 | 
			
		||||
				env = rc_strlist_add (env, line);
 | 
			
		||||
				rc_strlist_add (&env, line);
 | 
			
		||||
				free (line);
 | 
			
		||||
			}
 | 
			
		||||
			fclose (fp);
 | 
			
		||||
		}
 | 
			
		||||
	} else
 | 
			
		||||
		env = rc_strlist_add (env, "RC_DEFAULTLEVEL=" RC_LEVEL_DEFAULT);
 | 
			
		||||
		rc_strlist_add (&env, "RC_DEFAULTLEVEL=" RC_LEVEL_DEFAULT);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
@@ -687,7 +687,7 @@ char **rc_config_env (char **env)
 | 
			
		||||
		i = strlen ("RC_SYS=") + strlen (sys) + 2;
 | 
			
		||||
		line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
		snprintf (line, i, "RC_SYS=%s", sys);
 | 
			
		||||
		env = rc_strlist_add (env, line);
 | 
			
		||||
		rc_strlist_add (&env, 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;
 | 
			
		||||
		line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
		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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -714,7 +714,7 @@ char **rc_config_env (char **env)
 | 
			
		||||
		i = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2;
 | 
			
		||||
		line = rc_xmalloc (sizeof (char *) * i);
 | 
			
		||||
		snprintf (line, i, "RC_UNAME=%s", uts.sysname);
 | 
			
		||||
		env = rc_strlist_add (env, line);
 | 
			
		||||
		rc_strlist_add (&env, line);
 | 
			
		||||
		free (line);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,59 +9,67 @@
 | 
			
		||||
 | 
			
		||||
#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 **lst = *list;
 | 
			
		||||
	int i = 0;
 | 
			
		||||
 | 
			
		||||
	if (! item)
 | 
			
		||||
		return (list);
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	while (list && list[i]) {
 | 
			
		||||
		if (uniq && strcmp (list[i], item) == 0)
 | 
			
		||||
			return (list);
 | 
			
		||||
	while (lst && lst[i]) {
 | 
			
		||||
		if (uniq && strcmp (lst[i], item) == 0) {
 | 
			
		||||
			errno = EEXIST;
 | 
			
		||||
			return (NULL);
 | 
			
		||||
		}
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	newlist = rc_xrealloc (list, sizeof (char *) * (i + 2));
 | 
			
		||||
	newlist = rc_xrealloc (lst, sizeof (char *) * (i + 2));
 | 
			
		||||
	newlist[i] = rc_xstrdup (item);
 | 
			
		||||
	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));
 | 
			
		||||
}
 | 
			
		||||
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));
 | 
			
		||||
}
 | 
			
		||||
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)
 | 
			
		||||
static char *_rc_strlist_addsort (char ***list, const char *item,
 | 
			
		||||
								  int (*sortfunc) (const char *s1,
 | 
			
		||||
												   const char *s2),
 | 
			
		||||
								  bool uniq)
 | 
			
		||||
{
 | 
			
		||||
	char **newlist;
 | 
			
		||||
	char **lst = *list;
 | 
			
		||||
	int i = 0;
 | 
			
		||||
	char *tmp1;
 | 
			
		||||
	char *tmp2;
 | 
			
		||||
	char *retval;
 | 
			
		||||
 | 
			
		||||
	if (! item)
 | 
			
		||||
		return (list);
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	while (list && list[i])	{
 | 
			
		||||
		if (uniq && strcmp (list[i], item) == 0)
 | 
			
		||||
			return (list);
 | 
			
		||||
	while (lst && lst[i])	{
 | 
			
		||||
		if (uniq && strcmp (lst[i], item) == 0) {
 | 
			
		||||
			errno = EEXIST;
 | 
			
		||||
			return (NULL);
 | 
			
		||||
		}
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	newlist = rc_xrealloc (list, sizeof (char *) * (i + 2));
 | 
			
		||||
	newlist = rc_xrealloc (lst, sizeof (char *) * (i + 2));
 | 
			
		||||
 | 
			
		||||
	if (! i)
 | 
			
		||||
		newlist[i] = NULL;
 | 
			
		||||
@@ -72,7 +80,7 @@ static char **_rc_strlist_addsort (char **list, const char *item,
 | 
			
		||||
		i++;
 | 
			
		||||
 | 
			
		||||
	tmp1 = newlist[i];
 | 
			
		||||
	newlist[i] = rc_xstrdup (item);
 | 
			
		||||
	retval = newlist[i] = rc_xstrdup (item);
 | 
			
		||||
	do {
 | 
			
		||||
		i++;
 | 
			
		||||
		tmp2 = newlist[i];
 | 
			
		||||
@@ -80,44 +88,50 @@ static char **_rc_strlist_addsort (char **list, const char *item,
 | 
			
		||||
		tmp1 = tmp2;
 | 
			
		||||
	} 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));
 | 
			
		||||
}
 | 
			
		||||
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));
 | 
			
		||||
}
 | 
			
		||||
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));
 | 
			
		||||
}
 | 
			
		||||
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 retval = -1;
 | 
			
		||||
 | 
			
		||||
	if (!list || ! item)
 | 
			
		||||
		return (list);
 | 
			
		||||
	if (!lst || ! item)
 | 
			
		||||
		return (-1);
 | 
			
		||||
 | 
			
		||||
	while (list[i])
 | 
			
		||||
		if (! strcmp (list[i], item)) {
 | 
			
		||||
			free (list[i]);
 | 
			
		||||
	while (lst[i])
 | 
			
		||||
		if (! strcmp (lst[i], item)) {
 | 
			
		||||
			free (lst[i]);
 | 
			
		||||
			retval = 0;
 | 
			
		||||
			do {
 | 
			
		||||
				list[i] = list[i + 1];
 | 
			
		||||
				lst[i] = lst[i + 1];
 | 
			
		||||
				i++;
 | 
			
		||||
			} while (list[i]);
 | 
			
		||||
			} while (lst[i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	return (list);
 | 
			
		||||
	if (retval)
 | 
			
		||||
		errno = ENOENT;
 | 
			
		||||
	return (retval);
 | 
			
		||||
}
 | 
			
		||||
librc_hidden_def(rc_strlist_delete)
 | 
			
		||||
 | 
			
		||||
@@ -184,10 +198,8 @@ void rc_strlist_free (char **list)
 | 
			
		||||
	if (! list)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	while (list[i]) {
 | 
			
		||||
		free (list[i]);
 | 
			
		||||
		list[i++] = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	while (list[i])
 | 
			
		||||
		free (list[i++]);
 | 
			
		||||
 | 
			
		||||
	free (list);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								src/librc.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/librc.c
									
									
									
									
									
								
							@@ -53,7 +53,7 @@ char **rc_get_runlevels (void)
 | 
			
		||||
	STRLIST_FOREACH (dirs, dir, i) {
 | 
			
		||||
		char *path = rc_strcatpaths (RC_RUNLEVELDIR, dir, (char *) NULL);
 | 
			
		||||
		if (rc_is_dir (path))
 | 
			
		||||
			runlevels = rc_strlist_addsort (runlevels, dir);
 | 
			
		||||
			rc_strlist_addsort (&runlevels, dir);
 | 
			
		||||
		free (path);
 | 
			
		||||
	}
 | 
			
		||||
	rc_strlist_free (dirs);
 | 
			
		||||
@@ -65,7 +65,7 @@ librc_hidden_def(rc_get_runlevels)
 | 
			
		||||
char *rc_get_runlevel (void)
 | 
			
		||||
{
 | 
			
		||||
	FILE *fp;
 | 
			
		||||
	static char buffer [PATH_MAX];
 | 
			
		||||
	static char buffer[PATH_MAX];
 | 
			
		||||
 | 
			
		||||
	if (! (fp = fopen (SOFTLEVEL, "r"))) {
 | 
			
		||||
		snprintf (buffer, sizeof (buffer), "sysinit");
 | 
			
		||||
@@ -198,7 +198,7 @@ char **rc_service_options (const char *service)
 | 
			
		||||
		if (buffer[strlen (buffer) - 1] == '\n')
 | 
			
		||||
			buffer[strlen (buffer) - 1] = '\0';
 | 
			
		||||
		while ((token = strsep (&p, " ")))
 | 
			
		||||
			opts = rc_strlist_addsort (opts, token);
 | 
			
		||||
			rc_strlist_addsort (&opts, token);
 | 
			
		||||
	}
 | 
			
		||||
	pclose (fp);
 | 
			
		||||
	return (opts);
 | 
			
		||||
@@ -728,7 +728,7 @@ char **rc_services_in_state (rc_service_state_t state)
 | 
			
		||||
			int j;
 | 
			
		||||
 | 
			
		||||
			STRLIST_FOREACH (entries, e, j)
 | 
			
		||||
				list = rc_strlist_addsortu (list, e);
 | 
			
		||||
				rc_strlist_addsortu (&list, e);
 | 
			
		||||
 | 
			
		||||
			if (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 *) NULL);
 | 
			
		||||
		if (rc_exists (file))
 | 
			
		||||
			list = rc_strlist_add (list, file);
 | 
			
		||||
			rc_strlist_add (&list, file);
 | 
			
		||||
		free (file);
 | 
			
		||||
	}
 | 
			
		||||
	rc_strlist_free (dirs);
 | 
			
		||||
 
 | 
			
		||||
@@ -117,7 +117,7 @@ static int process_mount (char ***list, struct args *args,
 | 
			
		||||
 | 
			
		||||
	if (p) {
 | 
			
		||||
		errno = 0;
 | 
			
		||||
		*list = rc_strlist_addsortc (*list, p);
 | 
			
		||||
		rc_strlist_addsortc (list, p);
 | 
			
		||||
		return (0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -332,7 +332,7 @@ int mountinfo (int argc, char **argv)
 | 
			
		||||
	while (optind < argc) {
 | 
			
		||||
		if (argv[optind][0] != '/')
 | 
			
		||||
			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);
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,7 @@ int rc_depend (int argc, char **argv)
 | 
			
		||||
 | 
			
		||||
		if (argv[i][0] == '-') {
 | 
			
		||||
			argv[i]++;
 | 
			
		||||
			types = rc_strlist_add (types, argv[i]);
 | 
			
		||||
			rc_strlist_add (&types, argv[i]);
 | 
			
		||||
		} else {
 | 
			
		||||
			if ((deptree = rc_load_deptree ()) == NULL)
 | 
			
		||||
				eerrorx ("failed to load deptree");
 | 
			
		||||
@@ -66,7 +66,7 @@ int rc_depend (int argc, char **argv)
 | 
			
		||||
			if (! di)
 | 
			
		||||
				eerror ("no dependency info for service `%s'", argv[i]);
 | 
			
		||||
			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 (! types) {
 | 
			
		||||
		types = rc_strlist_add (NULL, "ineed");
 | 
			
		||||
		rc_strlist_add (types, "iuse");
 | 
			
		||||
		rc_strlist_add (&types, "ineed");
 | 
			
		||||
		rc_strlist_add (&types, "iuse");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	depends = rc_get_depends (deptree, types, services, runlevel, options);
 | 
			
		||||
 
 | 
			
		||||
@@ -114,10 +114,10 @@ int rc_status (int argc, char **argv)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	while (optind < argc)
 | 
			
		||||
		levels = rc_strlist_add (levels, argv[optind++]);
 | 
			
		||||
		rc_strlist_add (&levels, argv[optind++]);
 | 
			
		||||
 | 
			
		||||
	if (! levels)
 | 
			
		||||
		levels = rc_strlist_add (NULL, rc_get_runlevel ());
 | 
			
		||||
		rc_strlist_add (&levels, rc_get_runlevel ());
 | 
			
		||||
 | 
			
		||||
	STRLIST_FOREACH (levels, level, i) {
 | 
			
		||||
		print_level (level);
 | 
			
		||||
 
 | 
			
		||||
@@ -80,13 +80,13 @@ static void show (char **runlevels, bool verbose)
 | 
			
		||||
 | 
			
		||||
		STRLIST_FOREACH (runlevels, runlevel, j) {
 | 
			
		||||
			if (rc_service_in_runlevel (service, runlevel)) {
 | 
			
		||||
				in = rc_strlist_add (in, runlevel);
 | 
			
		||||
				rc_strlist_add (&in, runlevel);
 | 
			
		||||
				inone = true;
 | 
			
		||||
			} else {
 | 
			
		||||
				char buffer[PATH_MAX];
 | 
			
		||||
				memset (buffer, ' ', strlen (runlevel));
 | 
			
		||||
				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)
 | 
			
		||||
			if (rc_runlevel_exists (argv[optind]))
 | 
			
		||||
				runlevels = rc_strlist_add (runlevels, argv[optind++]);
 | 
			
		||||
				rc_strlist_add (&runlevels, argv[optind++]);
 | 
			
		||||
			else {
 | 
			
		||||
				rc_strlist_free (runlevels);
 | 
			
		||||
				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 (service)
 | 
			
		||||
			runlevels = rc_strlist_add (runlevels, service);
 | 
			
		||||
			rc_strlist_add (&runlevels, service);
 | 
			
		||||
		if (! runlevels)
 | 
			
		||||
			runlevels = rc_get_runlevels ();
 | 
			
		||||
 | 
			
		||||
@@ -209,7 +209,7 @@ int rc_update (int argc, char **argv)
 | 
			
		||||
		else {
 | 
			
		||||
			retval = EXIT_SUCCESS;
 | 
			
		||||
			if (! runlevels)
 | 
			
		||||
				runlevels = rc_strlist_add (runlevels, rc_get_runlevel ());	
 | 
			
		||||
				rc_strlist_add (&runlevels, rc_get_runlevel ());	
 | 
			
		||||
			STRLIST_FOREACH (runlevels, runlevel, i) {
 | 
			
		||||
				if (action & DOADD) {
 | 
			
		||||
					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_STARTED, RC_LS_INITD);
 | 
			
		||||
 | 
			
		||||
	types = rc_strlist_add (NULL, "ineed");
 | 
			
		||||
	types = rc_strlist_add (types, "iuse");
 | 
			
		||||
	types = rc_strlist_add (types, "iafter");
 | 
			
		||||
	types = NULL;
 | 
			
		||||
	rc_strlist_add (&types, "ineed");
 | 
			
		||||
	rc_strlist_add (&types, "iuse");
 | 
			
		||||
	rc_strlist_add (&types, "iafter");
 | 
			
		||||
	deporder = rc_get_depends (deptree, types, stop_services,
 | 
			
		||||
							   runlevel, depoptions | RC_DEP_STOP);
 | 
			
		||||
	rc_strlist_free (stop_services);
 | 
			
		||||
	rc_strlist_free (types);
 | 
			
		||||
	types = NULL;
 | 
			
		||||
	stop_services = deporder;
 | 
			
		||||
	deporder = NULL;
 | 
			
		||||
	types = NULL;
 | 
			
		||||
	rc_strlist_reverse (stop_services);
 | 
			
		||||
 | 
			
		||||
	/* Load our list of coldplugged services */
 | 
			
		||||
@@ -1115,7 +1116,7 @@ int main (int argc, char **argv)
 | 
			
		||||
			einfon ("Device initiated services:");
 | 
			
		||||
			STRLIST_FOREACH (coldplugged_services, service, i) {
 | 
			
		||||
				printf (" %s", service);
 | 
			
		||||
				start_services = rc_strlist_add (start_services, service);
 | 
			
		||||
				rc_strlist_add (&start_services, service);
 | 
			
		||||
			}
 | 
			
		||||
			printf ("\n");
 | 
			
		||||
		}
 | 
			
		||||
@@ -1140,7 +1141,7 @@ int main (int argc, char **argv)
 | 
			
		||||
			services = NULL;
 | 
			
		||||
 | 
			
		||||
			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)
 | 
			
		||||
		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 */
 | 
			
		||||
	STRLIST_FOREACH (stop_services, service, i) {
 | 
			
		||||
		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
 | 
			
		||||
		   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,
 | 
			
		||||
								   runlevel, RC_DEP_STRICT);
 | 
			
		||||
		rc_strlist_free (stopdeps);
 | 
			
		||||
@@ -1276,9 +1278,9 @@ int main (int argc, char **argv)
 | 
			
		||||
		rc_mark_service (service, rc_service_coldplugged);
 | 
			
		||||
 | 
			
		||||
	/* Order the services to start */
 | 
			
		||||
	types = rc_strlist_add (NULL, "ineed");
 | 
			
		||||
	types = rc_strlist_add (types, "iuse");
 | 
			
		||||
	types = rc_strlist_add (types, "iafter");
 | 
			
		||||
	rc_strlist_add (&types, "ineed");
 | 
			
		||||
	rc_strlist_add (&types, "iuse");
 | 
			
		||||
	rc_strlist_add (&types, "iafter");
 | 
			
		||||
	deporder = rc_get_depends (deptree, types, start_services,
 | 
			
		||||
							   runlevel, depoptions | RC_DEP_START);
 | 
			
		||||
	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);
 | 
			
		||||
 | 
			
		||||
/* Handy functions for dealing with string arrays of char ** */
 | 
			
		||||
char **rc_strlist_add (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_addsortc (char **list, const char *item);
 | 
			
		||||
char **rc_strlist_addsortu (char **list, const char *item);
 | 
			
		||||
char **rc_strlist_delete (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_addsort (char ***list, const char *item);
 | 
			
		||||
char *rc_strlist_addsortc (char ***list, const char *item);
 | 
			
		||||
char *rc_strlist_addsortu (char ***list, const char *item);
 | 
			
		||||
int rc_strlist_delete (char ***list, const char *item);
 | 
			
		||||
char **rc_strlist_join (char **list1, char **list2);
 | 
			
		||||
void rc_strlist_reverse (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);
 | 
			
		||||
 | 
			
		||||
	STRLIST_FOREACH (tmplist, svc, i)
 | 
			
		||||
		restart_services = rc_strlist_addsort (restart_services, svc);
 | 
			
		||||
		rc_strlist_addsort (&restart_services, svc);
 | 
			
		||||
 | 
			
		||||
	rc_strlist_free (tmplist);
 | 
			
		||||
	tmplist = NULL;
 | 
			
		||||
@@ -610,9 +610,11 @@ static void svc_start (bool deps)
 | 
			
		||||
			eerrorx ("failed to load deptree");
 | 
			
		||||
 | 
			
		||||
		rc_strlist_free (types);
 | 
			
		||||
		types = rc_strlist_add (NULL, "broken");
 | 
			
		||||
		types = NULL;
 | 
			
		||||
		rc_strlist_add (&types, "broken");
 | 
			
		||||
		rc_strlist_free (svclist);
 | 
			
		||||
		svclist = rc_strlist_add (NULL, applet);
 | 
			
		||||
		svclist = NULL;
 | 
			
		||||
		rc_strlist_add (&svclist, applet);
 | 
			
		||||
		rc_strlist_free (services);
 | 
			
		||||
		services = rc_get_depends (deptree, types, svclist, softlevel, 0);
 | 
			
		||||
		if (services) {
 | 
			
		||||
@@ -628,12 +630,13 @@ static void svc_start (bool deps)
 | 
			
		||||
		services = NULL;
 | 
			
		||||
 | 
			
		||||
		rc_strlist_free (types);
 | 
			
		||||
		types = rc_strlist_add (NULL, "ineed");
 | 
			
		||||
		types = NULL;
 | 
			
		||||
		rc_strlist_add (&types, "ineed");
 | 
			
		||||
		rc_strlist_free (need_services);
 | 
			
		||||
		need_services = rc_get_depends (deptree, types, svclist,
 | 
			
		||||
										softlevel, depoptions);
 | 
			
		||||
 | 
			
		||||
		types = rc_strlist_add (types, "iuse");
 | 
			
		||||
		rc_strlist_add (&types, "iuse");
 | 
			
		||||
		rc_strlist_free (use_services);
 | 
			
		||||
		use_services = rc_get_depends (deptree, types, svclist,
 | 
			
		||||
									   softlevel, depoptions);
 | 
			
		||||
@@ -648,7 +651,7 @@ static void svc_start (bool deps)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* Now wait for them to start */
 | 
			
		||||
		types = rc_strlist_add (types, "iafter");
 | 
			
		||||
		rc_strlist_add (&types, "iafter");
 | 
			
		||||
		services = rc_get_depends (deptree, types, svclist,
 | 
			
		||||
								   softlevel, depoptions);
 | 
			
		||||
 | 
			
		||||
@@ -683,7 +686,7 @@ static void svc_start (bool deps)
 | 
			
		||||
				if (strcmp (svc, svc2) == 0) {
 | 
			
		||||
					if (rc_service_state (svc, rc_service_inactive) ||
 | 
			
		||||
						rc_service_state (svc, rc_service_wasinactive))
 | 
			
		||||
						tmplist = rc_strlist_add (tmplist, svc);
 | 
			
		||||
						rc_strlist_add (&tmplist, svc);
 | 
			
		||||
					else
 | 
			
		||||
						eerrorx ("ERROR: cannot start %s as %s would not start",
 | 
			
		||||
								 applet, svc);
 | 
			
		||||
@@ -701,12 +704,14 @@ static void svc_start (bool deps)
 | 
			
		||||
			unlink_mtime_test ();
 | 
			
		||||
 | 
			
		||||
			rc_strlist_free (types);
 | 
			
		||||
			types = rc_strlist_add (NULL, "iprovide");
 | 
			
		||||
			types = NULL;
 | 
			
		||||
			rc_strlist_add (&types, "iprovide");
 | 
			
		||||
			STRLIST_FOREACH (tmplist, svc, i) {
 | 
			
		||||
				rc_schedule_start_service (svc, service);
 | 
			
		||||
 | 
			
		||||
				rc_strlist_free (svclist);
 | 
			
		||||
				svclist = rc_strlist_add (NULL, svc);
 | 
			
		||||
				svclist = NULL;
 | 
			
		||||
				rc_strlist_add (&svclist, svc);
 | 
			
		||||
				rc_strlist_free (providelist);
 | 
			
		||||
				providelist = rc_get_depends (deptree, types, svclist,
 | 
			
		||||
											  softlevel, depoptions);
 | 
			
		||||
@@ -782,9 +787,11 @@ static void svc_start (bool deps)
 | 
			
		||||
 | 
			
		||||
	/* Do the same for any services we provide */
 | 
			
		||||
	rc_strlist_free (types);
 | 
			
		||||
	types = rc_strlist_add (NULL, "iprovide");
 | 
			
		||||
	types = NULL;
 | 
			
		||||
	rc_strlist_add (&types, "iprovide");
 | 
			
		||||
	rc_strlist_free (svclist);
 | 
			
		||||
	svclist = rc_strlist_add (NULL, applet);
 | 
			
		||||
	svclist = NULL;
 | 
			
		||||
	rc_strlist_add (&svclist, applet);
 | 
			
		||||
	rc_strlist_free (tmplist);
 | 
			
		||||
	tmplist = rc_get_depends (deptree, types, svclist, softlevel, depoptions);
 | 
			
		||||
 | 
			
		||||
@@ -845,9 +852,11 @@ static void svc_stop (bool deps)
 | 
			
		||||
			eerrorx ("failed to load deptree");
 | 
			
		||||
 | 
			
		||||
		rc_strlist_free (types);
 | 
			
		||||
		types = rc_strlist_add (NULL, "needsme");
 | 
			
		||||
		types = NULL;
 | 
			
		||||
		rc_strlist_add (&types, "needsme");
 | 
			
		||||
		rc_strlist_free (svclist);
 | 
			
		||||
		svclist = rc_strlist_add (NULL, applet);
 | 
			
		||||
		svclist = NULL;
 | 
			
		||||
		rc_strlist_add (&svclist, applet);
 | 
			
		||||
		rc_strlist_free (tmplist);
 | 
			
		||||
		tmplist = NULL;
 | 
			
		||||
		rc_strlist_free (services);
 | 
			
		||||
@@ -865,7 +874,7 @@ static void svc_stop (bool deps)
 | 
			
		||||
					pid_t pid = rc_stop_service (svc);
 | 
			
		||||
					if (! rc_is_env ("RC_PARALLEL", "yes"))
 | 
			
		||||
						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
 | 
			
		||||
		   This is important when a runlevel stops */
 | 
			
		||||
		types = rc_strlist_add (types, "usesme");
 | 
			
		||||
		types = rc_strlist_add (types, "ibefore");
 | 
			
		||||
		rc_strlist_add (&types, "usesme");
 | 
			
		||||
		rc_strlist_add (&types, "ibefore");
 | 
			
		||||
		services = rc_get_depends (deptree, types, svclist,
 | 
			
		||||
								   softlevel, depoptions);
 | 
			
		||||
		STRLIST_FOREACH (services, svc, i) {
 | 
			
		||||
@@ -1212,9 +1221,11 @@ int runscript (int argc, char **argv)
 | 
			
		||||
				eerrorx ("failed to load deptree");
 | 
			
		||||
 | 
			
		||||
			rc_strlist_free (types);
 | 
			
		||||
			types = rc_strlist_add (NULL, optarg);
 | 
			
		||||
			types = NULL;
 | 
			
		||||
			rc_strlist_add (&types, optarg);
 | 
			
		||||
			rc_strlist_free (svclist);
 | 
			
		||||
			svclist = rc_strlist_add (NULL, applet);
 | 
			
		||||
			svclist = NULL;
 | 
			
		||||
			rc_strlist_add (&svclist, applet);
 | 
			
		||||
			rc_strlist_free (services);
 | 
			
		||||
			services = rc_get_depends (deptree, types, svclist,
 | 
			
		||||
									   softlevel, depoptions);
 | 
			
		||||
 
 | 
			
		||||
@@ -880,10 +880,10 @@ int start_stop_daemon (int argc, char **argv)
 | 
			
		||||
					len = sizeof (char *) * strlen (path) + 6;
 | 
			
		||||
					newpath = rc_xmalloc (len);
 | 
			
		||||
					snprintf (newpath, len, "PATH=%s", path);
 | 
			
		||||
					newenv = rc_strlist_add (newenv, newpath);
 | 
			
		||||
					rc_strlist_add (&newenv, newpath);
 | 
			
		||||
					free (newpath);
 | 
			
		||||
				} else
 | 
			
		||||
					newenv = rc_strlist_add (newenv, env);
 | 
			
		||||
					rc_strlist_add (&newenv, env);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		umask (022);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user