aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rc.h54
1 files changed, 43 insertions, 11 deletions
diff --git a/src/rc.h b/src/rc.h
index 11b7e582..24bd4746 100644
--- a/src/rc.h
+++ b/src/rc.h
@@ -59,6 +59,16 @@ typedef enum
RC_SERVICE_WASINACTIVE = 0x0800,
} rc_service_state_t;
+/*! Save the arguments to find a running daemon
+ * @param service to save arguments for
+ * @param exec that we started
+ * @param name of the process (optional)
+ * @param pidfile of the process (optional)
+ * @param started if true, add the arguments otherwise remove existing matching arguments */
+void rc_service_daemon_set (const char *service, const char *exec,
+ const char *name, const char *pidfile,
+ bool started);
+
/*! Returns a description of what the service and/or option does.
* @param service to check
* @param option to check (if NULL, service description)
@@ -141,15 +151,6 @@ pid_t rc_service_stop (const char *service);
* @return true if service finished before timeout, otherwise false */
bool rc_service_wait (const char *service);
-/*! Save the arguments to find a running daemon
- * @param service to save arguments for
- * @param exec that we started
- * @param name of the process (optional)
- * @param pidfile of the process (optional)
- * @param started if true, add the arguments otherwise remove existing matching arguments */
-void rc_service_daemon_set (const char *service, const char *exec,
- const char *name, const char *pidfile,
- bool started);
/*! Check if the service started the daemon
* @param service to check
* @param exec to check
@@ -166,6 +167,7 @@ bool rc_service_plugable (char *service);
/*! Return the current runlevel.
* @return the current runlevel */
char *rc_runlevel_get (void);
+
/*! Set the runlevel.
* This just changes the stored runlevel and does not start or stop any services.
* @param runlevel to store */
@@ -192,19 +194,23 @@ bool rc_runlevel_stopping (void);
* @param service to add
* @return true if successful, otherwise false */
bool rc_service_add (const char *runlevel, const char *service);
+
/*! Remove the service from the runlevel
* @param runlevel to remove from
* @param service to remove
* @return true if sucessful, otherwise false */
bool rc_service_delete (const char *runlevel, const char *service);
+
/*! List the services in a runlevel
* @param runlevel to list
* @return NULL terminated list of services */
char **rc_services_in_runlevel (const char *runlevel);
+
/*! List the services in a state
* @param state to list
* @return NULL terminated list of services */
char **rc_services_in_state (rc_service_state_t state);
+
/*! List the services shceduled to start when this one does
* @param service to check
* @return NULL terminated list of services */
@@ -216,13 +222,11 @@ char **rc_services_scheduled (const char *service);
* @return true if all daemons started are still running, otherwise false */
bool rc_service_daemons_crashed (const char *service);
-
/*! Wait for a process to finish
* @param pid to wait for
* @return exit status of the process */
int rc_waitpid (pid_t pid);
-
/*! Find processes based on criteria.
* All of these are optional.
* pid overrides anything else.
@@ -262,27 +266,33 @@ typedef void *rc_depinfo_t;
* has specified.
* @return 0 if successful, otherwise -1 */
int rc_deptree_update (void);
+
/*! Check if the cached dependency tree is older than any init script,
* its configuration file or an external configuration file the init script
* has specified.
* @return true if it needs updating, otherwise false */
bool rc_deptree_update_needed (void);
+
/*! Load the cached dependency tree and return a pointer to it.
* This pointer should be freed with rc_deptree_free when done.
* @return pointer to the dependency tree */
rc_depinfo_t *rc_deptree_load (void);
+
/*! Get a services depedency information from a loaded tree
* @param deptree to search
* @param service to find
* @return service dependency information */
rc_depinfo_t *rc_deptree_depinfo (rc_depinfo_t *deptree, const char *service);
+
/*! Get a depenency type from the service dependency information
* @param depinfo service dependency to search
* @param type to find
* @return service dependency type information */
rc_deptype_t *rc_deptree_deptype (rc_depinfo_t *depinfo, const char *type);
+
char **rc_deptree_depends (rc_depinfo_t *deptree, char **types,
char **services, const char *runlevel, int options);
+
/*! List all the services that should be stoppned and then started, in order,
* for the given runlevel, including sysinit and boot services where
* approriate.
@@ -341,15 +351,18 @@ extern FILE *rc_environ_fd;
/*! @name Memory Allocation
* Ensure that if we cannot allocate the memory then we exit */
/*@{*/
+
/*! Allocate a block of memory
* @param size of memory to allocate
* @return pointer to memory */
void *rc_xmalloc (size_t size);
+
/*! Re-size a block of memory
* @param ptr to the block of memory to re-size
* @param size memory should be
* @return pointer to memory block */
void *rc_xrealloc (void *ptr, size_t size);
+
/*! Duplicate a NULL terminated string
* @param str to duplicate
* @return pointer to the new string */
@@ -359,34 +372,41 @@ char *rc_xstrdup (const char *str);
/*! @name Utility
* Although not RC specific functions, they are used by the supporting
* applications */
+
/*! Concatenate paths adding '/' if needed. The resultant pointer should be
* freed when finished with.
* @param path1 starting path
* @param paths NULL terminated list of paths to add
* @return pointer to the new path */
char *rc_strcatpaths (const char *path1, const char *paths, ...) SENTINEL;
+
/*! Check if an environment variable is a boolean and return it's value.
* If variable is not a boolean then we set errno to be ENOENT when it does
* not exist or EINVAL if it's not a boolean.
* @param variable to check
* @return true if it matches true, yes or 1, false if otherwise. */
bool rc_env_bool (const char *variable);
+
/*! Check if the file exists or not
* @param pathname to check
* @return true if it exists, otherwise false */
bool rc_exists (const char *pathname);
+
/*! Check if the file is a real file
* @param pathname to check
* @return true if it's a real file, otherwise false */
bool rc_is_file (const char *pathname);
+
/*! Check if the file is a symbolic link or not
* @param pathname to check
* @return true if it's a symbolic link, otherwise false */
bool rc_is_link (const char *pathname);
+
/*! Check if the file is a directory or not
* @param pathname to check
* @return true if it's a directory, otherwise false */
bool rc_is_dir (const char *pathname);
+
/*! Check if the file is marked executable or not
* @param pathname to check
* @return true if it's marked executable, otherwise false */
@@ -407,14 +427,17 @@ bool rc_rm_dir (const char *pathname, bool top);
/*! @name Configuration */
/*! Return a NULL terminated list of non comment lines from a file. */
char **rc_get_list (const char *file);
+
/*! Return a NULL terminated list of key=value lines from a file. */
char **rc_get_config (const char *file);
+
/*! Return the value of the entry from a key=value list. */
char *rc_get_config_entry (char **list, const char *entry);
/*! Return a NULL terminated string list of variables allowed through
* from the current environemnt. */
char **rc_filter_env (void);
+
/*! Return a NULL terminated string list of enviroment variables made from
* our configuration files. */
char **rc_make_env (void);
@@ -424,49 +447,58 @@ char **rc_make_env (void);
* It's safe to assume that any function here that uses char ** is a string
* list that can be manipulated with the below functions. Every string list
* should be released with a call to rc_strlist_free.*/
+
/*! Duplicate the item, add it to end of the list and return a pointer to it.
* @param list to add the item too
* @param item to add.
* @return pointer to newly added item */
char *rc_strlist_add (char ***list, const char *item);
+
/*! If the item does not exist in the list, duplicate it, add it to the
* list and then return a pointer to it.
* @param list to add the item too
* @param item to add.
* @return pointer to newly added item */
char *rc_strlist_addu (char ***list, const char *item);
+
/*! Duplicate the item, add it to the list at the point based on locale and
* then return a pointer to it.
* @param list to add the item too
* @param item to add.
* @return pointer to newly added item */
char *rc_strlist_addsort (char ***list, const char *item);
+
/*! Duplicate the item, add it to the list at the point based on C locale and
* then return a pointer to it.
* @param list to add the item too
* @param item to add.
* @return pointer to newly added item */
char *rc_strlist_addsortc (char ***list, const char *item);
+
/*! If the item does not exist in the list, duplicate it, add it to the
* list based on locale and then return a pointer to it.
* @param list to add the item too
* @param item to add.
* @return pointer to newly added item */
char *rc_strlist_addsortu (char ***list, const char *item);
+
/*! Free the item and remove it from the list. Return 0 on success otherwise -1.
* @param list to add the item too
* @param item to add.
* @return true on success, otherwise false */
bool rc_strlist_delete (char ***list, const char *item);
+
/*! Moves the contents of list2 onto list1, so list2 is effectively emptied.
* Returns a pointer to the last item on the new list.
* @param list1 to append to
* @param list2 to move from
* @return pointer to the last item on the list */
char *rc_strlist_join (char ***list1, char **list2);
+
/*! Reverses the contents of the list.
* @param list to reverse */
void rc_strlist_reverse (char **list);
+
/*! Frees each item on the list and the list itself.
* @param list to free */
void rc_strlist_free (char **list);