rc_service_option_set -> rc_service_value_set, rc_service_option_get -> rc_service_value_get
This commit is contained in:
parent
563c6f46c0
commit
4b7efeafa6
14
src/librc.c
14
src/librc.c
@ -131,7 +131,7 @@ bool rc_runlevel_exists (const char *runlevel)
|
||||
}
|
||||
librc_hidden_def(rc_runlevel_exists)
|
||||
|
||||
/* Resolve a service name to it's full path */
|
||||
/* Resolve a service name to it's full path */
|
||||
char *rc_service_resolve (const char *service)
|
||||
{
|
||||
char buffer[PATH_MAX];
|
||||
@ -441,7 +441,7 @@ rc_service_state_t rc_service_state (const char *service)
|
||||
}
|
||||
librc_hidden_def(rc_service_state)
|
||||
|
||||
char *rc_service_option_get (const char *service, const char *option)
|
||||
char *rc_service_value_get (const char *service, const char *option)
|
||||
{
|
||||
FILE *fp;
|
||||
char buffer[RC_LINEBUFFER];
|
||||
@ -459,10 +459,10 @@ char *rc_service_option_get (const char *service, const char *option)
|
||||
|
||||
return (value);
|
||||
}
|
||||
librc_hidden_def(rc_service_option_get)
|
||||
librc_hidden_def(rc_service_value_get)
|
||||
|
||||
bool rc_service_option_set (const char *service, const char *option,
|
||||
const char *value)
|
||||
bool rc_service_value_set (const char *service, const char *option,
|
||||
const char *value)
|
||||
{
|
||||
FILE *fp;
|
||||
char *path = rc_strcatpaths (RC_SVCDIR, "options", service, (char *) NULL);
|
||||
@ -488,7 +488,7 @@ bool rc_service_option_set (const char *service, const char *option,
|
||||
free (file);
|
||||
return (retval);
|
||||
}
|
||||
librc_hidden_def(rc_service_option_set)
|
||||
librc_hidden_def(rc_service_value_set)
|
||||
|
||||
static pid_t _exec_service (const char *service, const char *arg)
|
||||
{
|
||||
@ -528,7 +528,7 @@ static pid_t _exec_service (const char *service, const char *arg)
|
||||
|
||||
if (pid == -1)
|
||||
fprintf (stderr, "vfork: %s\n", strerror (errno));
|
||||
|
||||
|
||||
return (pid);
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,6 @@ librc_hidden_proto(rc_service_description)
|
||||
librc_hidden_proto(rc_service_exists)
|
||||
librc_hidden_proto(rc_service_in_runlevel)
|
||||
librc_hidden_proto(rc_service_mark)
|
||||
librc_hidden_proto(rc_service_option_get)
|
||||
librc_hidden_proto(rc_service_option_set)
|
||||
librc_hidden_proto(rc_service_options)
|
||||
librc_hidden_proto(rc_service_plugable)
|
||||
librc_hidden_proto(rc_service_resolve)
|
||||
@ -103,6 +101,8 @@ librc_hidden_proto(rc_services_scheduled)
|
||||
librc_hidden_proto(rc_services_scheduled_by)
|
||||
librc_hidden_proto(rc_service_started_daemon)
|
||||
librc_hidden_proto(rc_service_state)
|
||||
librc_hidden_proto(rc_service_value_get)
|
||||
librc_hidden_proto(rc_service_value_set)
|
||||
librc_hidden_proto(rc_strcatpaths)
|
||||
librc_hidden_proto(rc_strlist_add)
|
||||
librc_hidden_proto(rc_strlist_addu)
|
||||
|
4
src/rc.c
4
src/rc.c
@ -362,14 +362,14 @@ static int do_options (int argc, char **argv)
|
||||
eerrorx ("%s: no option specified", applet);
|
||||
|
||||
if (strcmp (applet, "get_options") == 0) {
|
||||
char *option = rc_service_option_get (service, argv[0]);
|
||||
char *option = rc_service_value_get (service, argv[0]);
|
||||
if (option) {
|
||||
printf ("%s", option);
|
||||
free (option);
|
||||
ok = true;
|
||||
}
|
||||
} else if (strcmp (applet, "save_options") == 0)
|
||||
ok = rc_service_option_set (service, argv[0], argv[1]);
|
||||
ok = rc_service_value_set (service, argv[0], argv[1]);
|
||||
else
|
||||
eerrorx ("%s: unknown applet", applet);
|
||||
|
||||
|
56
src/rc.h
56
src/rc.h
@ -87,26 +87,25 @@ bool rc_service_mark (const char *service, rc_service_state_t state);
|
||||
* @return NULL terminated string list of options */
|
||||
char **rc_service_options (const char *service);
|
||||
|
||||
/*! Return a saved value for a service
|
||||
* @param service to check
|
||||
* @param option to load
|
||||
* @return saved value */
|
||||
char *rc_service_value_get (const char *service, const char *option);
|
||||
|
||||
/*! Save a persistent value for a service
|
||||
* @param service to save for
|
||||
* @param option to save
|
||||
* @param value of the option
|
||||
* @return true if saved, otherwise false */
|
||||
bool rc_service_value_set (const char *service, const char *option,
|
||||
const char *value);
|
||||
|
||||
/*! Resolves a service name to its full path.
|
||||
* @param service to check
|
||||
* @return pointer to full path of service */
|
||||
char *rc_service_resolve (const char *service);
|
||||
|
||||
/*! Checks if a service in in a state
|
||||
* @param service to check
|
||||
* @return state of the service */
|
||||
rc_service_state_t rc_service_state (const char *service);
|
||||
|
||||
/*! Start a service
|
||||
* @param service to start
|
||||
* @return pid of the service starting process */
|
||||
pid_t rc_service_start (const char *service);
|
||||
|
||||
/*! Stop a service
|
||||
* @param service to stop
|
||||
* @return pid of service stopping process */
|
||||
pid_t rc_service_stop (const char *service);
|
||||
|
||||
/*! Schedule a service to be started when another service starts
|
||||
* @param service that starts the scheduled service when started
|
||||
* @param service_to_start service that will be started */
|
||||
@ -122,23 +121,26 @@ char **rc_services_scheduled_by (const char *service);
|
||||
* @param service to clear */
|
||||
void rc_service_schedule_clear (const char *service);
|
||||
|
||||
/*! Checks if a service in in a state
|
||||
* @param service to check
|
||||
* @return state of the service */
|
||||
rc_service_state_t rc_service_state (const char *service);
|
||||
|
||||
/*! Start a service
|
||||
* @param service to start
|
||||
* @return pid of the service starting process */
|
||||
pid_t rc_service_start (const char *service);
|
||||
|
||||
/*! Stop a service
|
||||
* @param service to stop
|
||||
* @return pid of service stopping process */
|
||||
pid_t rc_service_stop (const char *service);
|
||||
|
||||
/*! Wait for a service to finish
|
||||
* @param service to wait for
|
||||
* @return true if service finished before timeout, otherwise false */
|
||||
bool rc_service_wait (const char *service);
|
||||
|
||||
/*! Return a saved value for a service
|
||||
* @param service to check
|
||||
* @param option to load
|
||||
* @return saved value */
|
||||
char *rc_service_option_get (const char *service, const char *option);
|
||||
/*! Save a persistent value for a service
|
||||
* @param service to save for
|
||||
* @param option to save
|
||||
* @param value of the option
|
||||
* @return true if saved, otherwise false */
|
||||
bool rc_service_option_set (const char *service, const char *option,
|
||||
const char *value);
|
||||
/*! Save the arguments to find a running daemon
|
||||
* @param service to save arguments for
|
||||
* @param exec that we started
|
||||
|
Loading…
Reference in New Issue
Block a user