/[baselayout]/trunk/src/rc.h
Gentoo

Diff of /trunk/src/rc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2576 Revision 2577
23#define RC_LEVEL_REBOOT "reboot" 23#define RC_LEVEL_REBOOT "reboot"
24#define RC_LEVEL_DEFAULT "default" 24#define RC_LEVEL_DEFAULT "default"
25 25
26typedef enum 26typedef enum
27{ 27{
28 rc_service_started, 28 rc_service_started,
29 rc_service_stopped, 29 rc_service_stopped,
30 rc_service_starting, 30 rc_service_starting,
31 rc_service_stopping, 31 rc_service_stopping,
32 rc_service_inactive, 32 rc_service_inactive,
33 rc_service_wasinactive, 33 rc_service_wasinactive,
34 rc_service_coldplugged, 34 rc_service_coldplugged,
35 rc_service_failed, 35 rc_service_failed,
36 rc_service_scheduled, 36 rc_service_scheduled,
37 rc_service_crashed 37 rc_service_crashed
38} rc_service_state_t; 38} rc_service_state_t;
39 39
40char *rc_resolve_service (const char *service); 40char *rc_resolve_service (const char *service);
41bool rc_service_exists (const char *service); 41bool rc_service_exists (const char *service);
42bool rc_service_in_runlevel (const char *service, const char *runlevel); 42bool rc_service_in_runlevel (const char *service, const char *runlevel);
43bool rc_service_state (const char *service, rc_service_state_t state); 43bool rc_service_state (const char *service, rc_service_state_t state);
44bool rc_mark_service (const char *service, rc_service_state_t state); 44bool rc_mark_service (const char *service, rc_service_state_t state);
45pid_t rc_stop_service (const char *service); 45pid_t rc_stop_service (const char *service);
46pid_t rc_start_service (const char *service); 46pid_t rc_start_service (const char *service);
47void rc_schedule_start_service (const char *service, 47void rc_schedule_start_service (const char *service,
48 const char *service_to_start); 48 const char *service_to_start);
49char **rc_services_scheduled_by (const char *service); 49char **rc_services_scheduled_by (const char *service);
50void rc_schedule_clear (const char *service); 50void rc_schedule_clear (const char *service);
51bool rc_wait_service (const char *service); 51bool rc_wait_service (const char *service);
52bool rc_get_service_option (const char *service, const char *option, 52bool rc_get_service_option (const char *service, const char *option,
53 char *value); 53 char *value);
54bool rc_set_service_option (const char *service, const char *option, 54bool rc_set_service_option (const char *service, const char *option,
55 const char *value); 55 const char *value);
56void rc_set_service_daemon (const char *service, const char *exec, 56void rc_set_service_daemon (const char *service, const char *exec,
57 const char *name, const char *pidfile, 57 const char *name, const char *pidfile,
58 bool started); 58 bool started);
59bool rc_service_started_daemon (const char *service, const char *exec, 59bool rc_service_started_daemon (const char *service, const char *exec,
60 int indx); 60 int indx);
61 61
62bool rc_allow_plug (char *service); 62bool rc_allow_plug (char *service);
63 63
64char *rc_get_runlevel (void); 64char *rc_get_runlevel (void);
65void rc_set_runlevel (const char *runlevel); 65void rc_set_runlevel (const char *runlevel);
73char **rc_services_in_state (rc_service_state_t state); 73char **rc_services_in_state (rc_service_state_t state);
74char **rc_services_scheduled (const char *service); 74char **rc_services_scheduled (const char *service);
75 75
76/* Find pids based on criteria - free the pointer returned after use */ 76/* Find pids based on criteria - free the pointer returned after use */
77pid_t *rc_find_pids (const char *exec, const char *cmd, 77pid_t *rc_find_pids (const char *exec, const char *cmd,
78 uid_t uid, pid_t pid); 78 uid_t uid, pid_t pid);
79/* Checks that all daemons started with start-stop-daemon by the service 79/* Checks that all daemons started with start-stop-daemon by the service
80 are still running. If so, return false otherwise true. 80 are still running. If so, return false otherwise true.
81 You should check that the service has been started before calling this. */ 81 You should check that the service has been started before calling this. */
82bool rc_service_daemons_crashed (const char *service); 82bool rc_service_daemons_crashed (const char *service);
83 83
84/* Dependency tree structs and functions. */ 84/* Dependency tree structs and functions. */
85typedef struct rc_deptype 85typedef struct rc_deptype
86{ 86{
87 char *type; 87 char *type;
88 char **services; 88 char **services;
89 struct rc_deptype *next; 89 struct rc_deptype *next;
90} rc_deptype_t; 90} rc_deptype_t;
91 91
92typedef struct rc_depinfo 92typedef struct rc_depinfo
93{ 93{
94 char *service; 94 char *service;
95 rc_deptype_t *depends; 95 rc_deptype_t *depends;
96 struct rc_depinfo *next; 96 struct rc_depinfo *next;
97} rc_depinfo_t; 97} rc_depinfo_t;
98 98
99 99
100/* Options for rc_dep_depends and rc_order_services. 100/* Options for rc_dep_depends and rc_order_services.
101 When changing runlevels, you should use RC_DEP_START and RC_DEP_STOP for 101 When changing runlevels, you should use RC_DEP_START and RC_DEP_STOP for
108int rc_update_deptree (bool force); 108int rc_update_deptree (bool force);
109rc_depinfo_t *rc_load_deptree (void); 109rc_depinfo_t *rc_load_deptree (void);
110rc_depinfo_t *rc_get_depinfo (rc_depinfo_t *deptree, const char *service); 110rc_depinfo_t *rc_get_depinfo (rc_depinfo_t *deptree, const char *service);
111rc_deptype_t *rc_get_deptype (rc_depinfo_t *depinfo, const char *type); 111rc_deptype_t *rc_get_deptype (rc_depinfo_t *depinfo, const char *type);
112char **rc_get_depends (rc_depinfo_t *deptree, char **types, 112char **rc_get_depends (rc_depinfo_t *deptree, char **types,
113 char **services, const char *runlevel, int options); 113 char **services, const char *runlevel, int options);
114/* List all the services that should be started, in order, the the 114/* List all the services that should be started, in order, the the
115 given runlevel, including sysinit and boot services where 115 given runlevel, including sysinit and boot services where
116 approriate. 116 approriate.
117 If reboot, shutdown or single are given then we list all the services 117 If reboot, shutdown or single are given then we list all the services
118 we that we need to shutdown in order. */ 118 we that we need to shutdown in order. */
119char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel, 119char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel,
120 int options); 120 int options);
121 121
122void rc_free_deptree (rc_depinfo_t *deptree); 122void rc_free_deptree (rc_depinfo_t *deptree);
123 123
124/* Plugin handler 124/* Plugin handler
125 For each plugin loaded we will call it's _name_hook with the below 125 For each plugin loaded we will call it's _name_hook with the below
132 start_in we may start other services before we start the service in 132 start_in we may start other services before we start the service in
133 question. now shows we really will start the service now and done shows 133 question. now shows we really will start the service now and done shows
134 when we have done it as may start scheduled services at this point. */ 134 when we have done it as may start scheduled services at this point. */
135typedef enum 135typedef enum
136{ 136{
137 rc_hook_runlevel_stop_in = 1, 137 rc_hook_runlevel_stop_in = 1,
138 rc_hook_runlevel_stop_out = 4, 138 rc_hook_runlevel_stop_out = 4,
139 rc_hook_runlevel_start_in = 5, 139 rc_hook_runlevel_start_in = 5,
140 rc_hook_runlevel_start_out = 8, 140 rc_hook_runlevel_start_out = 8,
141 /* We reserved a few numbers if we need rc_runlevel_stop_now and done */ 141 /* We reserved a few numbers if we need rc_runlevel_stop_now and done */
142 rc_hook_service_stop_in = 101, 142 rc_hook_service_stop_in = 101,
143 rc_hook_service_stop_now, 143 rc_hook_service_stop_now,
144 rc_hook_service_stop_done, 144 rc_hook_service_stop_done,
145 rc_hook_service_stop_out, 145 rc_hook_service_stop_out,
146 rc_hook_service_start_in, 146 rc_hook_service_start_in,
147 rc_hook_service_start_now, 147 rc_hook_service_start_now,
148 rc_hook_service_start_done, 148 rc_hook_service_start_done,
149 rc_hook_service_start_out 149 rc_hook_service_start_out
150} rc_hook_t; 150} rc_hook_t;
151 151
152/* RC utility functions. 152/* RC utility functions.
153 Although not directly related to RC in general, they are used by RC 153 Although not directly related to RC in general, they are used by RC
154 itself and the supporting applications. */ 154 itself and the supporting applications. */

Legend:
Removed from v.2576  
changed lines
  Added in v.2577

  ViewVC Help
Powered by ViewVC 1.1.20