reorg our header a little

This commit is contained in:
Roy Marples 2007-10-03 14:31:16 +00:00
parent 4b7efeafa6
commit fc3980b2e2

View File

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