diff options
| -rw-r--r-- | src/librc.c | 32 | ||||
| -rw-r--r-- | src/librc.h | 8 | ||||
| -rw-r--r-- | src/rc.c | 30 | ||||
| -rw-r--r-- | src/rc.h | 8 | ||||
| -rw-r--r-- | src/runscript.c | 42 | 
5 files changed, 60 insertions, 60 deletions
| diff --git a/src/librc.c b/src/librc.c index 83eca265..e295fb63 100644 --- a/src/librc.c +++ b/src/librc.c @@ -132,7 +132,7 @@ bool rc_runlevel_exists (const char *runlevel)  librc_hidden_def(rc_runlevel_exists)  /* Resolve a service name to it's full path */ -char *rc_resolve_service (const char *service) +char *rc_service_resolve (const char *service)  {  	char buffer[PATH_MAX];  	char *file; @@ -165,7 +165,7 @@ char *rc_resolve_service (const char *service)  	snprintf (buffer, sizeof (buffer), RC_INITDIR "/%s", service);  	return (rc_xstrdup (buffer));  } -librc_hidden_def(rc_resolve_service) +librc_hidden_def(rc_service_resolve)  bool rc_service_exists (const char *service)  { @@ -184,7 +184,7 @@ bool rc_service_exists (const char *service)  		service[len - 1] == 'h')  		return (false); -	file = rc_resolve_service (service);  +	file = rc_service_resolve (service);   	if (rc_exists (file))  		retval = rc_is_exec (file);  	free (file); @@ -202,7 +202,7 @@ char **rc_service_options (const char *service)  	char *p = buffer;  	FILE *fp; -	if (! (svc = rc_resolve_service (service))) +	if (! (svc = rc_service_resolve (service)))  		return (NULL);  	snprintf (cmd, sizeof (cmd), ". '%s'; echo \"${opts}\"",  svc); @@ -230,7 +230,7 @@ char *rc_service_description (const char *service, const char *option)  	FILE *fp;  	int i; -	if (! (svc = rc_resolve_service (service))) +	if (! (svc = rc_service_resolve (service)))  		return (NULL);  	if (! option) @@ -279,14 +279,14 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel)  }  librc_hidden_def(rc_service_in_runlevel) -bool rc_mark_service (const char *service, const rc_service_state_t state) +bool rc_service_mark (const char *service, const rc_service_state_t state)  {  	char *file;  	int i = 0;  	int skip_state = -1;  	char *base;  	char *svc; -	char *init = rc_resolve_service (service); +	char *init = rc_service_resolve (service);  	bool skip_wasinactive = false;  	if (! service) @@ -408,7 +408,7 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)  	free (init);  	return (true);  } -librc_hidden_def(rc_mark_service) +librc_hidden_def(rc_service_mark)  rc_service_state_t rc_service_state (const char *service)  { @@ -497,9 +497,9 @@ static pid_t _exec_service (const char *service, const char *arg)  	pid_t pid = -1;  	char *svc; -	file = rc_resolve_service (service); +	file = rc_service_resolve (service);  	if (! rc_is_file (file)) { -		rc_mark_service (service, RC_SERVICE_STOPPED); +		rc_service_mark (service, RC_SERVICE_STOPPED);  		free (file);  		return (0);  	} @@ -548,23 +548,23 @@ int rc_waitpid (pid_t pid)  }  librc_hidden_def(rc_waitpid) -pid_t rc_stop_service (const char *service) +pid_t rc_service_stop (const char *service)  {  	if (rc_service_state (service) & RC_SERVICE_STOPPED)  		return (0);  	return (_exec_service (service, "stop"));  } -librc_hidden_def(rc_stop_service) +librc_hidden_def(rc_service_stop) -pid_t rc_start_service (const char *service) +pid_t rc_service_start (const char *service)  {  	if (! rc_service_state (service) & RC_SERVICE_STOPPED)  		return (0);  	return (_exec_service (service, "start"));  } -librc_hidden_def(rc_start_service) +librc_hidden_def(rc_service_start)  bool rc_schedule_start_service (const char *service,  								const char *service_to_start) @@ -589,7 +589,7 @@ bool rc_schedule_start_service (const char *service,  			return (false);  		} -	init = rc_resolve_service (service_to_start); +	init = rc_service_resolve (service_to_start);  	svc = rc_xstrdup (service_to_start);  	file = rc_strcatpaths (dir, basename (svc), (char *) NULL);  	free (svc); @@ -733,7 +733,7 @@ bool rc_service_add (const char *runlevel, const char *service)  		return (false);  	} -	init = rc_resolve_service (service); +	init = rc_service_resolve (service);  	svc = rc_xstrdup (service);  	file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (svc),  						   (char *) NULL); diff --git a/src/librc.h b/src/librc.h index 4fd444d3..b5ef1fce 100644 --- a/src/librc.h +++ b/src/librc.h @@ -76,8 +76,6 @@ librc_hidden_proto(rc_is_file)  librc_hidden_proto(rc_is_link)  librc_hidden_proto(rc_ls_dir)  librc_hidden_proto(rc_make_env) -librc_hidden_proto(rc_mark_service) -librc_hidden_proto(rc_resolve_service)  librc_hidden_proto(rc_rm_dir)  librc_hidden_proto(rc_runlevel_exists)  librc_hidden_proto(rc_runlevel_starting) @@ -91,6 +89,10 @@ librc_hidden_proto(rc_service_description)  librc_hidden_proto(rc_service_exists)  librc_hidden_proto(rc_service_in_runlevel)  librc_hidden_proto(rc_service_options) +librc_hidden_proto(rc_service_mark) +librc_hidden_proto(rc_service_resolve) +librc_hidden_proto(rc_service_start) +librc_hidden_proto(rc_service_stop)  librc_hidden_proto(rc_services_in_runlevel)  librc_hidden_proto(rc_services_in_state)  librc_hidden_proto(rc_services_scheduled) @@ -100,8 +102,6 @@ librc_hidden_proto(rc_service_state)  librc_hidden_proto(rc_set_runlevel)  librc_hidden_proto(rc_set_service_daemon)  librc_hidden_proto(rc_set_service_option) -librc_hidden_proto(rc_start_service) -librc_hidden_proto(rc_stop_service)  librc_hidden_proto(rc_strcatpaths)  librc_hidden_proto(rc_strlist_add)  librc_hidden_proto(rc_strlist_addu) @@ -303,17 +303,17 @@ static int do_mark_service (int argc, char **argv)  		eerrorx ("%s: no service specified", applet);  	if (strcmp (applet, "mark_service_started") == 0) -		ok = rc_mark_service (argv[0], RC_SERVICE_STARTED); +		ok = rc_service_mark (argv[0], RC_SERVICE_STARTED);  	else if (strcmp (applet, "mark_service_stopped") == 0) -		ok = rc_mark_service (argv[0], RC_SERVICE_STOPPED); +		ok = rc_service_mark (argv[0], RC_SERVICE_STOPPED);  	else if (strcmp (applet, "mark_service_inactive") == 0) -		ok = rc_mark_service (argv[0], RC_SERVICE_INACTIVE); +		ok = rc_service_mark (argv[0], RC_SERVICE_INACTIVE);  	else if (strcmp (applet, "mark_service_starting") == 0) -		ok = rc_mark_service (argv[0], RC_SERVICE_STOPPING); +		ok = rc_service_mark (argv[0], RC_SERVICE_STOPPING);  	else if (strcmp (applet, "mark_service_stopping") == 0) -		ok = rc_mark_service (argv[0], RC_SERVICE_STOPPING); +		ok = rc_service_mark (argv[0], RC_SERVICE_STOPPING);  	else if (strcmp (applet, "mark_service_coldplugged") == 0) -		ok = rc_mark_service (argv[0], RC_SERVICE_COLDPLUGGED); +		ok = rc_service_mark (argv[0], RC_SERVICE_COLDPLUGGED);  	else  		eerrorx ("%s: unknown applet", applet); @@ -1041,7 +1041,7 @@ int main (int argc, char **argv)  		STRLIST_FOREACH (start_services, service, i)  			if (rc_allow_plug (service)) -				rc_mark_service (service, RC_SERVICE_COLDPLUGGED); +				rc_service_mark (service, RC_SERVICE_COLDPLUGGED);  		/* We need to dump this list now.  		   This may seem redunant, but only Linux needs this and saves on  		   code bloat. */ @@ -1066,7 +1066,7 @@ int main (int argc, char **argv)  			tmp = rc_xmalloc (sizeof (char *) * j);  			snprintf (tmp, j, "net.%s", service);  			if (rc_service_exists (tmp) && rc_allow_plug (tmp)) -				rc_mark_service (tmp, RC_SERVICE_COLDPLUGGED); +				rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);  			CHAR_FREE (tmp);  		}  		rc_strlist_free (start_services); @@ -1085,7 +1085,7 @@ int main (int argc, char **argv)  					tmp = rc_xmalloc (sizeof (char *) * j);  					snprintf (tmp, j, "moused.%s", service);  					if (rc_service_exists (tmp) && rc_allow_plug (tmp)) -						rc_mark_service (tmp, RC_SERVICE_COLDPLUGGED); +						rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);  					CHAR_FREE (tmp);  				}  			} @@ -1185,7 +1185,7 @@ int main (int argc, char **argv)  		/* We always stop the service when in these runlevels */  		if (going_down) { -			pid_t pid = rc_stop_service (service); +			pid_t pid = rc_service_stop (service);  			if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))  				rc_waitpid (pid);  			continue; @@ -1250,7 +1250,7 @@ int main (int argc, char **argv)  		/* After all that we can finally stop the blighter! */  		if (! found) { -			pid_t pid = rc_stop_service (service); +			pid_t pid = rc_service_stop (service);  			if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))  				rc_waitpid (pid);  		} @@ -1294,7 +1294,7 @@ int main (int argc, char **argv)  	/* Re-add our coldplugged services if they stopped */  	STRLIST_FOREACH (coldplugged_services, service, i) -		rc_mark_service (service, RC_SERVICE_COLDPLUGGED); +		rc_service_mark (service, RC_SERVICE_COLDPLUGGED);  	/* Order the services to start */  	rc_strlist_add (&types, "ineed"); @@ -1316,7 +1316,7 @@ int main (int argc, char **argv)  			char *token;  			while ((token = strsep (&p, ","))) -				rc_mark_service (token, RC_SERVICE_STARTED); +				rc_service_mark (token, RC_SERVICE_STARTED);  			free (service);  		}  	} @@ -1349,7 +1349,7 @@ interactive_option:  			}  			/* Remember the pid if we're running in parallel */ -			if ((pid = rc_start_service (service))) +			if ((pid = rc_service_start (service)))  				add_pid (pid);  			if (! rc_env_bool ("RC_PARALLEL")) { @@ -1372,7 +1372,7 @@ interactive_option:  			char *token;  			while ((token = strsep (&p, ","))) -				rc_mark_service (token, RC_SERVICE_STOPPED); +				rc_service_mark (token, RC_SERVICE_STOPPED);  			free (service);  		}  	} @@ -62,7 +62,7 @@ typedef enum  /*! Resolves a service name to its full path.   * @param service to check   * @return pointer to full path of service */ -char *rc_resolve_service (const char *service); +char *rc_service_resolve (const char *service);  /*! Checks if a service exists or not.   * @param service to check   * @return true if service exists, otherwise false */ @@ -94,17 +94,17 @@ rc_service_state_t rc_service_state (const char *service);   * @param service to mark   * @param state service should be in   * @return true if service state change was successful, otherwise false */ -bool rc_mark_service (const char *service, rc_service_state_t state); +bool rc_service_mark (const char *service, rc_service_state_t state);  /*! Stop a service   * @param service to stop   * @return pid of service stopping process */ -pid_t rc_stop_service (const char *service); +pid_t rc_service_stop (const char *service);  /*! Start a service   * @param service to start   * @return pid of the service starting process */ -pid_t rc_start_service (const char *service); +pid_t rc_service_start (const char *service);  /*! Wait for a process to finish   * @param pid to wait for diff --git a/src/runscript.c b/src/runscript.c index f35b7137..9f6c41be 100644 --- a/src/runscript.c +++ b/src/runscript.c @@ -241,7 +241,7 @@ static void start_services (char **list) {  					ewarn ("WARNING: %s is scheduled to started when %s has started",  						   svc, applet);  				} else -					rc_start_service (svc); +					rc_service_start (svc);  			}  		}  	} @@ -278,11 +278,11 @@ static void cleanup (void)  				 rc_runlevel_stopping () &&  				 (strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 ||  				  strcmp (softlevel, RC_LEVEL_REBOOT) == 0))) -				rc_mark_service (applet, RC_SERVICE_STOPPED); +				rc_service_mark (applet, RC_SERVICE_STOPPED);  			else if (state & RC_SERVICE_WASINACTIVE) -				rc_mark_service (applet, RC_SERVICE_INACTIVE); +				rc_service_mark (applet, RC_SERVICE_INACTIVE);  			else -				rc_mark_service (applet, RC_SERVICE_STARTED); +				rc_service_mark (applet, RC_SERVICE_STARTED);  		}  		if (exclusive && rc_exists (exclusive))  			unlink (exclusive); @@ -566,7 +566,7 @@ static void svc_start (bool deps)  	else if (state & RC_SERVICE_INACTIVE && ! background)  		ewarnx ("WARNING: %s has already started, but is inactive", applet); -	if (! rc_mark_service (service, RC_SERVICE_STOPPING)) +	if (! rc_service_mark (service, RC_SERVICE_STOPPING))  		eerrorx ("ERROR: %s has been started by something else", applet);  	make_exclusive (service); @@ -616,7 +616,7 @@ static void svc_start (bool deps)  		if (! rc_runlevel_starting ()) {  			STRLIST_FOREACH (use_services, svc, i)  				if (rc_service_state (svc) & RC_SERVICE_STOPPED) { -					pid_t pid = rc_start_service (svc); +					pid_t pid = rc_service_start (svc);  					if (! rc_env_bool ("RC_PARALLEL"))  						rc_waitpid (pid);  				} @@ -673,7 +673,7 @@ static void svc_start (bool deps)  			/* Set the state now, then unlink our exclusive so that  			   our scheduled list is preserved */ -			rc_mark_service (service, RC_SERVICE_STOPPED); +			rc_service_mark (service, RC_SERVICE_STOPPED);  			unlink_mtime_test ();  			rc_strlist_free (types); @@ -729,16 +729,16 @@ static void svc_start (bool deps)  	if (in_control ()) {  		if (! started) {  			if (rc_service_state (service) & RC_SERVICE_WASINACTIVE) -				rc_mark_service (service, RC_SERVICE_INACTIVE); +				rc_service_mark (service, RC_SERVICE_INACTIVE);  			else { -				rc_mark_service (service, RC_SERVICE_STOPPED); +				rc_service_mark (service, RC_SERVICE_STOPPED);  				if (rc_runlevel_starting ()) -					rc_mark_service (service, RC_SERVICE_FAILED); +					rc_service_mark (service, RC_SERVICE_FAILED);  			}  			rc_plugin_run (RC_HOOK_SERVICE_START_DONE, applet);  			eerrorx ("ERROR: %s failed to start", applet);  		} -		rc_mark_service (service, RC_SERVICE_STARTED); +		rc_service_mark (service, RC_SERVICE_STARTED);  		unlink_mtime_test ();  		rc_plugin_run (RC_HOOK_SERVICE_START_DONE, applet);  	} else { @@ -754,7 +754,7 @@ static void svc_start (bool deps)  	services = rc_services_scheduled (service);  	STRLIST_FOREACH (services, svc, i)  		if (rc_service_state (svc) & RC_SERVICE_STOPPED) -			rc_start_service (svc); +			rc_service_start (svc);  	rc_strlist_free (services);  	services = NULL; @@ -773,7 +773,7 @@ static void svc_start (bool deps)  		services = rc_services_scheduled (svc2);  		STRLIST_FOREACH (services, svc, i)  			if (rc_service_state (svc) & RC_SERVICE_STOPPED) -				rc_start_service (svc); +				rc_service_start (svc);  	}  	hook_out = 0; @@ -802,7 +802,7 @@ static void svc_stop (bool deps)  	} else if (state & RC_SERVICE_STOPPING)  		ewarnx ("WARNING: %s is already stopping", applet); -	if (! rc_mark_service (service, RC_SERVICE_STOPPING)) +	if (! rc_service_mark (service, RC_SERVICE_STOPPING))  		eerrorx ("ERROR: %s has been stopped by something else", applet);  	make_exclusive (service); @@ -847,7 +847,7 @@ static void svc_stop (bool deps)  				if (svcs & RC_SERVICE_STARTED ||   					svcs & RC_SERVICE_INACTIVE)  				{ -					pid_t pid = rc_stop_service (svc); +					pid_t pid = rc_service_stop (svc);  					if (! rc_env_bool ("RC_PARALLEL"))  						rc_waitpid (pid);  					rc_strlist_add (&tmplist, svc); @@ -871,7 +871,7 @@ static void svc_stop (bool deps)  						 strcmp (softlevel, RC_LEVEL_REBOOT) == 0 ||  						 strcmp (softlevel, RC_LEVEL_SINGLE) == 0))  						continue; -					rc_mark_service (service, RC_SERVICE_FAILED); +					rc_service_mark (service, RC_SERVICE_FAILED);  				}  				eerrorx ("ERROR:  cannot stop %s as %s is still up", @@ -913,17 +913,17 @@ static void svc_stop (bool deps)  	if (! stopped) {  		if (rc_service_state (service) &  RC_SERVICE_WASINACTIVE) -			rc_mark_service (service, RC_SERVICE_INACTIVE); +			rc_service_mark (service, RC_SERVICE_INACTIVE);  		else -			rc_mark_service (service, RC_SERVICE_STARTED); +			rc_service_mark (service, RC_SERVICE_STARTED);  		rc_plugin_run (RC_HOOK_SERVICE_STOP_DONE, applet);  		eerrorx ("ERROR: %s failed to stop", applet);  	}  	if (in_background) -		rc_mark_service (service, RC_SERVICE_INACTIVE); +		rc_service_mark (service, RC_SERVICE_INACTIVE);  	else -		rc_mark_service (service, RC_SERVICE_STOPPED); +		rc_service_mark (service, RC_SERVICE_STOPPED);  	unlink_mtime_test ();  	rc_plugin_run (RC_HOOK_SERVICE_STOP_DONE, applet); @@ -1249,7 +1249,7 @@ int runscript (int argc, char **argv)  				}  			} else if (strcmp (optarg, "zap") == 0) {  				einfo ("Manually resetting %s to stopped state", applet); -				rc_mark_service (applet, RC_SERVICE_STOPPED); +				rc_service_mark (applet, RC_SERVICE_STOPPED);  				uncoldplug ();  			} else  				svc_exec (optarg, NULL); | 
