opts -> extra_commands. This is much more descriptive.

This commit is contained in:
Roy Marples 2007-11-20 18:19:48 +00:00
parent 6a6ef66d15
commit a76f2c20e4
7 changed files with 20 additions and 20 deletions

View File

@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
opts="save" extra_commands="save"
description="Sets the local clock to UTC or Local Time." description="Sets the local clock to UTC or Local Time."
description_save="Saves the current time in the BIOS." description_save="Saves the current time in the BIOS."

View File

@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
opts="save show" extra_commands="save show"
description="Sets the local clock to UTC or Local Time." description="Sets the local clock to UTC or Local Time."
description_save="Saves the current time in the BIOS." description_save="Saves the current time in the BIOS."

View File

@ -54,12 +54,12 @@ else
NL= NL=
fi fi
default_opts="describe help start status stop restart zap" default_commands="describe help start status stop restart zap"
extra_opts="$(. "${myscript}" 2>/dev/null ; echo "${opts}")" extra_commands="$(. "${myscript}" 2>/dev/null ; echo "${extra_commands:-${opts}}")"
printf "Usage: ${CYAN}${SERVICE}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} > printf "Usage: ${CYAN}${SERVICE}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} >
${CYAN}Normal Options:${OFF}" ${CYAN}Normal Commands:${OFF}"
if [ "${BE_VERBOSE}" = "yes" ] ; then if [ "${BE_VERBOSE}" = "yes" ] ; then
printf " printf "
@ -115,16 +115,16 @@ printf "
else else
printf " ${GREEN}${default_opts}${OFF} printf " ${GREEN}${default_commands}${OFF}
Default init.d options. Default init.d options.
" "
fi fi
if [ -n "${extra_opts}" ] ; then if [ -n "${extra_commands}" ] ; then
printf " printf "
${CYAN}Additional Options:${OFF}${NL} ${CYAN}Additional Options:${OFF}${NL}
${GREEN}${extra_opts}${OFF} ${GREEN}${extra_commands}${OFF}
Extra options supported by this init.d script. Extra options supported by this init.d script.
" "
fi fi

View File

@ -49,7 +49,7 @@ describe() {
fi fi
local svc= desc= local svc= desc=
for svc in ${opts}; do for svc in ${extra_commands:-${opts}}; do
eval desc=\$description_${svc} eval desc=\$description_${svc}
if [ -n "${desc}" ]; then if [ -n "${desc}" ]; then
einfo "${HILITE}${svc}${NORMAL}: ${desc}" einfo "${HILITE}${svc}${NORMAL}: ${desc}"
@ -128,7 +128,7 @@ fi
while [ -n "$1" ]; do while [ -n "$1" ]; do
# See if we have the required function and run it # See if we have the required function and run it
for rc_x in describe start stop ${opts}; do for rc_x in describe start stop ${extra_commands:-${opts}}; do
if [ "${rc_x}" = "$1" ]; then if [ "${rc_x}" = "$1" ]; then
if type "$1" >/dev/null 2>&1; then if type "$1" >/dev/null 2>&1; then
unset rc_x unset rc_x

View File

@ -300,12 +300,12 @@ bool rc_service_exists (const char *service)
librc_hidden_def(rc_service_exists) librc_hidden_def(rc_service_exists)
#define OPTSTR ". '%s'; echo \"${opts}\"" #define OPTSTR ". '%s'; echo \"${opts}\""
char **rc_service_options (const char *service) char **rc_service_extra_commands (const char *service)
{ {
char *svc; char *svc;
char *cmd = NULL; char *cmd = NULL;
char *buffer = NULL; char *buffer = NULL;
char **opts = NULL; char **commands = NULL;
char *token; char *token;
char *p = buffer; char *p = buffer;
FILE *fp; FILE *fp;
@ -324,15 +324,15 @@ 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, " ")))
rc_strlist_addsort (&opts, token); rc_strlist_addsort (&commands, token);
} }
pclose (fp); pclose (fp);
free (buffer); free (buffer);
} }
free (cmd); free (cmd);
return (opts); return (commands);
} }
librc_hidden_def(rc_service_options) librc_hidden_def(rc_service_extra_commands)
#define DESCSTR ". '%s'; echo \"${description%s%s}\"" #define DESCSTR ". '%s'; echo \"${description%s%s}\""
char *rc_service_description (const char *service, const char *option) char *rc_service_description (const char *service, const char *option)

View File

@ -95,9 +95,9 @@ librc_hidden_proto(rc_service_daemon_set)
librc_hidden_proto(rc_service_delete) librc_hidden_proto(rc_service_delete)
librc_hidden_proto(rc_service_description) librc_hidden_proto(rc_service_description)
librc_hidden_proto(rc_service_exists) librc_hidden_proto(rc_service_exists)
librc_hidden_proto(rc_service_extra_commands)
librc_hidden_proto(rc_service_in_runlevel) librc_hidden_proto(rc_service_in_runlevel)
librc_hidden_proto(rc_service_mark) librc_hidden_proto(rc_service_mark)
librc_hidden_proto(rc_service_options)
librc_hidden_proto(rc_service_plugable) librc_hidden_proto(rc_service_plugable)
librc_hidden_proto(rc_service_resolve) librc_hidden_proto(rc_service_resolve)
librc_hidden_proto(rc_service_schedule_clear) librc_hidden_proto(rc_service_schedule_clear)

View File

@ -143,10 +143,10 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel);
* @return true if service state change was successful, otherwise false */ * @return true if service state change was successful, otherwise false */
bool rc_service_mark (const char *service, rc_service_state_t state); bool rc_service_mark (const char *service, rc_service_state_t state);
/*! Lists the extra options a service has /*! Lists the extra commands a service has
* @param service to load the options from * @param service to load the commands from
* @return NULL terminated string list of options */ * @return NULL terminated string list of commands */
char **rc_service_options (const char *service); char **rc_service_extra_commands (const char *service);
/*! Check if the service is allowed to be hot/cold plugged /*! Check if the service is allowed to be hot/cold plugged
* @param service to check * @param service to check