Add man pages for all librc functions.

This commit is contained in:
Roy Marples 2007-12-24 22:03:27 +00:00
parent 7de72229a5
commit 5741ad634d
10 changed files with 770 additions and 2 deletions

View File

@ -1,6 +1,10 @@
DIR = /usr/share/man
MAN3 = einfo.3
MAN8 = start-stop-daemon.8 rc.8 rc-update.8 runscript.8
_MAN3_SH = ls -1 *.3
_MAN3 != $(_MAN3_SH)
MAN3 = $(_MAN3)$(shell $(_MAN3_SH))
_MAN8_SH = ls -1 *.8
_MAN8 != $(_MAN8_SH)
MAN8 = $(_MAN8)$(shell $(_MAN8_SH))
TOPDIR = ..
include $(TOPDIR)/default.mk

72
man/rc_config.3 Normal file
View File

@ -0,0 +1,72 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_CONFIG 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_config_list , rc_config_load , rc_config_value , rc_yesno
.Nd functions to query OpenRC service configurations
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft "char **" Fn rc_config_list "const char *file"
.Ft "char **" Fn rc_config_load "const char *file"
.Ft "char *" Fn rc_config_value "const char *const *list" "const char *entry"
.Ft bool Fn rc_yesno "const char *value"
.Sh DESCRIPTION
These functions provide an easy means of querying OpenRC configuration files.
.Pp
.Fn rc_config_list
returns a list of non comment lines in
.Fa file .
.Fn rc_config_load
does the same, but attempts to parse the line as if it was
a shell assignment.
.Fn rc_config_value
returns the value of
.Fa entry
found in
.Fa list .
.Pp
Each list should be freed using
.Fn rc_strlist_free
when done.
.Pp
.Fn rc_yesno
returns if
.Fa value
is true, yes, on or 1 regardless of case, otherwise false.
If
.Fa value
is also not false, no, off or 0 regardless of case then
.Va errno
is set to
.Va EINVAL .
.Sh SEE ALSO
.Xr rc_strlist_free 3 ,
.Xr sh 1
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

114
man/rc_deptree.3 Normal file
View File

@ -0,0 +1,114 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_DEPTREE 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_deptree_update , rc_deptree_update_needed , rc_deptree_load ,
.Nm rc_deptree_depend , rc_deptree_depends , rc_deptree_order ,
.Nm rc_deptree_free
.Nd RC dependency tree functions
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft bool Fn rc_deptree_update void
.Ft bool Fn rc_deptree_update_needed void
.Ft rc_depinfo_t Fn rc_deptree_load void
.Ft "char **" Fo rc_deptree_depend
.Fa "const rc_depinfo_t *deptree"
.Fa "const char *type"
.Fa "const char *service"
.Fc
.Ft bool Fo rc_deptree_depends
.Fa "const rc_depinfo_t *deptree"
.Fa "const char *const *types"
.Fa "const char *const *services"
.Fa "const char *runlevel"
.Fa "int options"
.Fc
.Ft "char **" Fo rc_deptree_order
.Fa "const rc_depinfo_t *deptree"
.Fa "const char *runlevel"
.Fa "int options"
.Fc
.Ft void Fn rc_deptree_free "rc_depinfo_t *deptree"
.Sh DESCRIPTION
These functions provide a means of querying the dependencies of OpenRC
services.
.Pp
.Fn rc_deptree_update
updates the service dependency tree, normally
.Pa /lib/rc/init.d/deptree .
.Fn rc_deptree_update_needed
checks to see if the dependency tree needs updated based on the mtime of it
compared to
.Pa /etc/init.d ,
.Pa /etc/conf.d ,
.Pa /usr/local/etc/init.d ,
.Pa /usr/local/etc/conf.d ,
.Pa /etc/rc.conf
and any files specified by a service.
.Pp
.Fn rc_deptree_load
loads the deptree and returns a pointer to it which needs to be freed by
.Fn rc_deptree_free
when done.
.Pp
.Fn rc_deptree_depend ,
.Fn rc_deptree_depends
and
.Fn rc_deptree_order
return a list of services from the
.Fa deptree
based on the
.Fa type
or
.Fa types
of dependency.
.Fa options
can be a bitmask of
.Va RC_DEP_TRACE
and
.Va RC_DEP_STRICT .
.Va RC_DEP_TRACE
follows each services dependencies right down to the first service needed and
.Va RC_DEP_STRICT
only lists services actually needed or in the
.Va runlevel .
.Sh IMPLEMENTATION NOTES
Each function that returns
.Fr "char **"
returns a malloced NULL terminated array of malloced NULL terminated strings,
all of which need to be freed using
.Fn rc_strlist_free
when done.
.Sh SEE ALSO
.Xr malloc 3 ,
.Xr free 3 ,
.Xr rc_strlist_free 3 ,
.Xr runscript 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

66
man/rc_find_pids.3 Normal file
View File

@ -0,0 +1,66 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_FIND_PIDS 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_find_pids
.Nd finds the pids of processes that match the given criteria
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft "pid_t *" Fo rc_find_pids
.Fa "const char *exec"
.Fa "const char *cmd"
.Fa "uid_t uid"
.Fa "pid_t pid"
.Fc
.Sh DESCRIPTION
.Fn rc_find_pids
returns a NULL terminated list of pids for processes matching the given
criteria. If
.Fa pid
is given then only that pid is returned if it is running. Otherise we check
all instances of
.Fa exec
with a process name of
.Fa cmd
owned by
.Fa uid ,
all of which are optional.
.Pp
The retuned list should be freed when done.
.Sh IMPLEMENTATION NOTES
On BSD systems we use
.Lb libkvm
and on Linux systems we use the
.Pa /proc
filesystem to find our processes.
.Sh SEE ALSO
.Xr free 3 ,
.Xr malloc 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

51
man/rc_plugin_hook.3 Normal file
View File

@ -0,0 +1,51 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_PLUGIN_HOOK 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_plugin_hook
.Nd hooks plugins into OpenRC services
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft int Fn rc_plugin_hook "rc_hook_t hook" "const char *name"
.Sh DESCRIPTION
.Fn rc_plugin_hook
is called for each shareable object found in
.Pa /lib/rc/plugins .
.Fa hook
is set to the hook running, and
.Fa name
is set to the name of the runlevel or name of the service.
.Pp
Plugins can affect the parent environemnt by writing NULL separated strings to
.Va rc_environ_fd .
.Sh SEE ALSO
.Xr rc 8 ,
.Xr runscript 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

67
man/rc_runlevel.3 Normal file
View File

@ -0,0 +1,67 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_RUNLEVEL 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_runlevel_get , rc_runlevel_exists , rc_runlevel_list , rc_runlevel_set ,
.Nm rc_runlevel_starting , rc_runlevel_stopping
.Nd RC runlevel functions
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft "char *" Fn rc_runlevel_get void
.Ft bool Fn rc_runlevel_exists
.Ft "char **" Fn rc_runlevel_list void
.Ft bool Fn rc_runlevel_set "const char *runlevel"
.Ft bool Fn rc_runlevel_starting void
.Ft bool Fn rc_runlevel_stopping void
.Sh DESCRIPTION
These functions provide a means of querying OpenRC to find out which runlevel
we are in and what services are in which runlevel.
.Sh IMPLEMENTATION NOTES
Each function that returns
.Fr "char *"
returns a malloced NULL terminated string that should be freed when done.
.Pp
Each function that returns
.Fr "char **"
returns a malloced NULL terminated array of malloced NULL terminated strings,
all of which need to be freed using
.Fn rc_strlist_free
when done.
.Sh FILES
.Pa /etc/init.d/functions.sh
is provided by OpenRC, which allows shell scripts to use the above functions.
For historical reasons our verbose functions are prefixed with v instead of
suffixed. So einfov becomes veinfo, einfovn becomes veinfon.
Rinse and repeat for the other verbose functions.
.Sh SEE ALSO
.Xr malloc 3 ,
.Xr free 3
.Xr rc_strlist_free 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

244
man/rc_service.3 Normal file
View File

@ -0,0 +1,244 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_SERVICE 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_service_add , rc_service_delete , rc_service_daemon_set ,
.Nm rc_service_description , rc_service_exists , rc_service_in_runlevel ,
.Nm rc_service_mark , rc_service_extra_commands , rc_service_plugable ,
.Nm rc_service_resolve , rc_service_schedule_start , rc_services_scheduled_by ,
.Nm rc_service_schedule_clear , rc_service_state ,
.Nm rc_service_start , rc_service_stop ,
.Nm rc_service_started_daemon , rc_service_value_get , rc_service_value_set ,
.Nm rc_services_in_runlevel , rc_services_in_state , rc_services_scheduled ,
.Nm rc_service_daemons_crashed
.Nd functions to start, stop and query OpenRC services
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft bool Fn rc_service_add "const char *runlevel" "const char *service"
.Ft bool Fn rc_service_delete "const char *runlevel" "const char *service"
.Ft bool Fo rc_service_daemon_set
.Fa "const char *service"
.Fa "const char *exec"
.Fa "const char *name"
.Fa "const char *pidfile"
.Fa "bool started"
.Fc
.Ft "char *" Fo rc_service_description
.Fa "const char *service"
.Fa "const char *option"
.Fc
.Ft bool Fn rc_service_exists "const char *service"
.Ft bool Fn rc_service_in_runlevel "const char *service" "const char *runlevel"
.Ft bool Fn rc_service_mark "const char *service" "rc_service_state_t state"
.Ft "char **" Fn rc_service_extra_commands "const char *service"
.Ft bool Fn rc_service_plugable "const char *service"
.Ft "char *" rc_service_resolve "const char *service"
.Ft bool Fo rc_service_schedule_start
.Fa "const char *service"
.Fa "const char *service_to_start"
.Fc
.Ft "char **" Fn rc_services_scheduled_by "const char *service"
.Ft bool Fn rc_service_schedule_clear "const char *service"
.Ft rc_service_state_t Fn rc_service_state "const char *service"
.Ft pid_t Fn rc_service_start "const char *service"
.Ft pid_t Fn rc_service_stop "const char *service"
.Ft bool Fo rc_service_started_daemon
.Fa "const char *service"
.Fa "const char *exec"
.Fa "int indx"
.Fc
.Ft "char *" Fn rc_service_value_get "const char *service" "const char *option"
.Ft bool Fo rc_service_value_set
.Fa "const char *service"
.Fa "const char *option"
.Fa "const char *value"
.Fc
.Ft "char **" Fn rc_services_in_runlevel "const char *runlevel"
.Ft "char **" Fn rc_services_in_state "rc_service_state_t state"
.Ft "char **" Fn rc_services_scheduled "const char *service"
.Ft bool Fn rc_service_daemons_crashed "const char *service"
.Sh DESCRIPTION
These functions provide a means of querying OpenRC services to find out the
state of each one, to start and stop it, and any other functions related
to it.
.Pp
Most functions should be self descriptive as to what they do and what they
return based on names and arguments.
.Pp
.Fn rc_service_add
adds the
.Fa service
to the
.Fa runlevel .
.Pp
.Fn rc_service_delete
deletes the
.Fa service
from the
.Fa runlevel .
.Pp
.Fn rc_service_daemon_set
saves the arguments in the
.Fa service
state data so that
.Fn rc_service_daemons_crashed
can check to see if they are still running or not.
.Pp
.Fn rc_service_description
returns the
.Va description
variable of the
.Fa service .
If
.Fa option
is not null then we return the
.Fa description_$option
variable instead.
.Pp
.Fn rc_service_exists
returns true if the
.Fa service
exists, otherwise false.
.Pp
.Fn rc_service_in_runlevel
returns true if the
.Fa service
is in the
.Fa runlevel ,
otherwise false.
.Pp
.Fn rc_service_mark
puts the
.Fa service
into the given
.Fa state .
If the state is RC_SERVICE_STOPPED then all data associated with the
.Fa service
is lost.
.Fn rc_service_extra_commands
returns a list of extra commands the
.Fa service
supports beyond the default ones. See
.Nm runscript
for default commands.
.Pp
.Fn rc_service_plugable
returns true if the service is allowed to be plugged by
.Pa rc.conf .
Default is true.
.Pp
.Fn rc_service_resolve
resolves
.Fa service
to the full path of service that was started, or would be started.
.Pp
When
.Fa service
starts, it starts
.Fa service_to_start
afterswards as directed by
.Fn rc_service_schedule_start .
.Fn rc_services_scheduled
returns a list of services that will be started when
.Fa service
starts.
.Fn rc_service_schedule_clear
clears these scheduled services for
.Fa service .
.Pp
.Fn rc_service_state returns the state of
.Fa service .
The return value is a bitmask, where more than one state can apply.
.Pp
.Fn rc_service_start
starts
.Fa service ,
returning the pid of new process.
.Pp
.Fn rc_service_stop
stops
.Fa service ,
returning the pid of new process.
.Pp
.Fn rc_service_started_daemon
checks to see if
.Fa service
started
.Fa exec
using
.Nm start-stop-daemon .
If
.Fa indx
is greater than zero, then it must also be the nth daemon started by
.Fa service .
.Fn rc_service_value_set
saves the
.Fa value
under the name
.Fa option .
.Fn rc_service_value_get
returns the value of the saved
.Fa option .
.Pp
.Fn rc_services_in_runlevel
returns a list of services in
.Fa runlevel .
If
.Fa runlevel
is not specified, then it returns a list of all available services.
.Pp
.Fn rc_services_in_state
returns a list of all the services in
.Fa state .
.Sh IMPLEMENTATION NOTES
Each function that returns
.Fr "char *"
returns a malloced NULL terminated string that should be freed when done.
.Pp
Each function that returns
.Fr "char **"
returns a malloced NULL terminated array of malloced NULL terminated strings,
all of which need to be freed using
.Fn rc_strlist_free
when done.
.Pp
When a function fails it should either return false or NULL and set
.Va errno
unless specified otherwise as above.
.Sh FILES
.Pa /lib/rc/init.d
normally holds the volatile state data for services on a RAM backed disk.
.Sh SEE ALSO
.Xr errno 3 ,
.Xr malloc 3 ,
.Xr free 3
.Xr rc_strlist_free 3 ,
.Xr start-stop-daemon 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

45
man/rc_strcatpaths.3 Normal file
View File

@ -0,0 +1,45 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_STRCATPATHS 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_strcatpaths
.Nd concatenates each elements, seperating each with / as necessary
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft "char *" Fn rc_strcatpaths "const char *path" ...
.Sh DESCRIPTION
.Fn rc_strcatpaths concatenates each
.Fa path ,
seperating each with / as necessary and returns a malloced pointer
to the result. This should be freed when done.
.Sh SEE ALSO
.Xr free 3 ,
.Xr malloc 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

104
man/rc_strlist.3 Normal file
View File

@ -0,0 +1,104 @@
.\" Copyright 2007 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Dec 24, 2007
.Dt RC_STRLIST 3 SMM
.Os OpenRC
.Sh NAME
.Nm rc_strlist_add , rc_strlist_addu , rc_strlist_addsort ,
.Nm rc_strlist_addsortc , rc_strlist_addsortu , rc_strlist_delete ,
.Nm rc_strlist_join , rc_strlist_reverse , rc_strlist_free
.Nd RC string list functions
.Sh LIBRARY
Run Command library (librc, -lrc)
.Sh SYNOPSIS
.In rc.h
.Ft "char *" Fn rc_strlist_add "char ***list" "const char *item"
.Ft "char *" Fn rc_strlist_addu "char ***list" "const char *item"
.Ft "char *" Fn rc_strlist_addsort "char ***list" "const char *item"
.Ft "char *" Fn rc_strlist_addsortc "char ***list" "const char *item"
.Ft "char *" Fn rc_strlist_addsortu "char ***list" "const char *item"
.Ft bool Fn rc_strlist_delete "char ***list" "const char *item"
.Ft "char *" Fn rc_strlist_join "char ***list1" "const char **list2"
.Ft void Fn rc_strlist_reverse "char **list"
.Ft void Fn rc_strlist_free "char **list"
.Sh DESCRIPTION
These functions provide an easy means of manipulating string lists without
the need for custom structures or non standard macros.
.Pp
.Fn rc_strlist_add
adds a malloced copy of
.Fa item
to
.Fa list ,
realloced to accomodate the new item. It returns a pointer to the new item on
success, or NULL on failure and sets
.Va errno
accordingly.
.Fn rc_strlist_addu
and
.Fn rc_strlist_addsortu
only work if
.Fa list
does not already contain
.Fa item .
.Fn rc_strlist_addsort
adds the item to the list in a lexically sorted position, using
.Nm strcoll ,
whereas
.Fn rc_strlist_addsortc
uses
.Nm strcmp .
.Pp
.Fn rc_strlist_delete
removes and frees
.Fa item
from
.Fa list ,
retuning true on success, otherwise false.
.Pp
.Fn rc_strlist_join
appends
.Fa list2
to the end of
.Fa list1
and returns a pointer to the last item on the new list.
.Pp
.Fn rc_strlist_reverse
reverses the items on
.Fa list .
.Pp
.Fn rc_strlist_free
frees each item on
.Fa list
and the
.Fa list
itself.
.Sh SEE ALSO
.Xr malloc 3 ,
.Xr free 3 ,
.Xr strcmp 3 ,
.Xr strcoll 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name

View File

@ -367,6 +367,7 @@ show() {
.Xr rc 8 ,
.Xr rc-status 8 ,
.Xr rc-update 8 ,
.Xr rc_plugin_hook 3 ,
.Xr sh 1p ,
.Xr start-stop-daemon 8 ,
.Xr uname 1