diff options
Diffstat (limited to 'urunlevel/runlevel/lib_init_d.h')
-rw-r--r-- | urunlevel/runlevel/lib_init_d.h | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/urunlevel/runlevel/lib_init_d.h b/urunlevel/runlevel/lib_init_d.h new file mode 100644 index 0000000..a9179d5 --- /dev/null +++ b/urunlevel/runlevel/lib_init_d.h | |||
@@ -0,0 +1,202 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 by David Seikel won_fang@yahoo.com.au | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
17 | * 02111-1307 USA | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #ifndef _INIT_D_H | ||
22 | #define _INIT_D_H | ||
23 | |||
24 | |||
25 | /* | ||
26 | * init script defines | ||
27 | */ | ||
28 | |||
29 | #define INIT_D_COMMENT "\n#// " | ||
30 | #define INIT_D_BEGIN "\n### BEGIN INIT INFO " | ||
31 | #define INIT_D_PROV "\n# Provides: " | ||
32 | #define INIT_D_RSTART "\n# Required-Start: " | ||
33 | #define INIT_D_RSTOP "\n# Required-Stop: " | ||
34 | #define INIT_D_SSTART "\n# Should-Start: " | ||
35 | #define INIT_D_SSTOP "\n# Should-Stop: " | ||
36 | #define INIT_D_DSTART "\n# Default-Start: " | ||
37 | #define INIT_D_DSTOP "\n# Default-Stop: " | ||
38 | #define INIT_D_SDESC "\n# Short-Description: " | ||
39 | #define INIT_D_DESC "\n# Description: " | ||
40 | #define INIT_D_CONT "\n#\t" | ||
41 | #define INIT_D_CONT2 "\n# " | ||
42 | #define INIT_D_END "\n### END INIT INFO\n" | ||
43 | #define INIT_D_CUSTOM "\n# X-" | ||
44 | |||
45 | |||
46 | /* | ||
47 | * init info | ||
48 | */ | ||
49 | |||
50 | typedef struct init_d_info_s { | ||
51 | char **provides; | ||
52 | char **reqstart; | ||
53 | char **reqstop; | ||
54 | char **shouldstart; | ||
55 | char **shouldstop; | ||
56 | int *defstart; | ||
57 | int *defstop; | ||
58 | char *shortdesc; | ||
59 | char *desc; | ||
60 | char *comment; | ||
61 | int sizes[11]; | ||
62 | char *path; | ||
63 | llist_t *start; | ||
64 | } init_d_info_t; | ||
65 | |||
66 | |||
67 | /* | ||
68 | * init commands | ||
69 | */ | ||
70 | |||
71 | typedef struct init_d_handle_s { | ||
72 | int (*start)(struct init_d_handle_s *, int); | ||
73 | int (*stop)(struct init_d_handle_s *, int); | ||
74 | int (*restart)(struct init_d_handle_s *, int); | ||
75 | int (*try_restart)(struct init_d_handle_s *, int); | ||
76 | int (*reload)(struct init_d_handle_s *, int); | ||
77 | int (*force_reload)(struct init_d_handle_s *, int); | ||
78 | int (*status)(struct init_d_handle_s *, int); | ||
79 | int (*show_info)(struct init_d_handle_s *, int); | ||
80 | char *basename; | ||
81 | char *pathname; | ||
82 | char *args; | ||
83 | char *pidfile; | ||
84 | char *info; | ||
85 | } init_d_handle_t; | ||
86 | |||
87 | |||
88 | int do_init_from_main(int argc, char **argv, struct init_d_handle_s *init_d); | ||
89 | int do_init(struct init_d_handle_s *init_d, const char *command); | ||
90 | |||
91 | int default_start(struct init_d_handle_s *, int); | ||
92 | int default_stop(struct init_d_handle_s *, int); | ||
93 | int default_restart(struct init_d_handle_s *, int); | ||
94 | int default_try_restart(struct init_d_handle_s *, int); | ||
95 | int default_reload(struct init_d_handle_s *, int); | ||
96 | int default_force_reload(struct init_d_handle_s *, int); | ||
97 | int default_status(struct init_d_handle_s *, int); | ||
98 | int default_show_info(struct init_d_handle_s *, int); | ||
99 | |||
100 | int no_stop(struct init_d_handle_s *, int); | ||
101 | int no_reload(struct init_d_handle_s *, int); | ||
102 | int no_status(struct init_d_handle_s *, int); | ||
103 | |||
104 | int sighup_reload(struct init_d_handle_s *, int); | ||
105 | int print_status(struct init_d_handle_s *init_d, int quiet, int status); | ||
106 | |||
107 | /* | ||
108 | * error codes | ||
109 | */ | ||
110 | |||
111 | #define INIT_D_OK 0 | ||
112 | #define INIT_D_ERROR_GENERIC 1 | ||
113 | #define INIT_D_ERROR_ARGS 2 | ||
114 | #define INIT_D_ERROR_NOT_IMPLEMENTED 3 | ||
115 | #define INIT_D_ERROR_SECURITY 4 | ||
116 | #define INIT_D_ERROR_NOT_INSTALLED 5 | ||
117 | #define INIT_D_ERROR_NOT_CONFIGURED 6 | ||
118 | #define INIT_D_ERROR_NOT_RUNNING 7 | ||
119 | |||
120 | |||
121 | /* | ||
122 | * internal error codes | ||
123 | * | ||
124 | * Only used internally to support just_checking. | ||
125 | */ | ||
126 | |||
127 | #define INIT_D_ERROR_JUST_RUNNING 150 | ||
128 | #define INIT_D_ERROR_JUST_NOT_RUNNING 151 | ||
129 | |||
130 | |||
131 | /* | ||
132 | * status codes | ||
133 | */ | ||
134 | |||
135 | #define INIT_D_STATUS_OK 0 | ||
136 | #define INIT_D_STATUS_DEAD_PID 1 | ||
137 | #define INIT_D_STATUS_DEAD_LOCK 2 | ||
138 | #define INIT_D_STATUS_NOT_RUNNING 3 | ||
139 | #define INIT_D_STATUS_UNKNOWN 4 | ||
140 | |||
141 | |||
142 | /* | ||
143 | * /lib/lsb/init-functions | ||
144 | */ | ||
145 | int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args); | ||
146 | int killproc(char *pidfile, char *pathname, int my_signal); | ||
147 | int checkpid(char *pid); | ||
148 | int pidofproc(char *pidfile, char *pathname, char **pids); | ||
149 | void log_success_msg(char *message); | ||
150 | void log_failure_msg(char *message); | ||
151 | void log_warning_msg(char *message); | ||
152 | |||
153 | |||
154 | init_d_info_t *parse_init_info(char *info_text, char *name); | ||
155 | char *get_init_info(char *pathname); | ||
156 | llist_t *get_scripts(void); | ||
157 | llist_t *sort_scripts(llist_t *unsorted); | ||
158 | |||
159 | |||
160 | #define REDIR 1 | ||
161 | #define QUIET 2 | ||
162 | #define ERRONLY 4 | ||
163 | #define FORK 8 | ||
164 | #define NOFORK 16 | ||
165 | #define DAEMON 32 | ||
166 | |||
167 | extern struct stat path_stat; | ||
168 | |||
169 | typedef struct nodes_s | ||
170 | { | ||
171 | const char *name; | ||
172 | mode_t mode; | ||
173 | int major; | ||
174 | int minor; | ||
175 | int count; | ||
176 | } nodes_t; | ||
177 | |||
178 | |||
179 | char *argv_cat(int argc, char **argv); | ||
180 | char *big_chomp(char *s); | ||
181 | int checkpid(char *pid); | ||
182 | char *doit(int mode, char *command, ...); | ||
183 | |||
184 | #ifndef CONFIG_IFUPDOWN | ||
185 | #define RUNLEVEL_LIST 1 | ||
186 | #endif | ||
187 | #ifdef RUNLEVEL_LIST | ||
188 | // From ifupdown, so it should probably be in libbb. | ||
189 | llist_t *llist_add_to_end(llist_t *list_head, char *data); | ||
190 | #else | ||
191 | extern llist_t *llist_add_to_end(llist_t *list_head, char *data); | ||
192 | #endif | ||
193 | |||
194 | llist_t *llist_delete(llist_t **unsorted, llist_t *previous, llist_t *current); | ||
195 | void make_disk(char *token, const nodes_t *nodes); | ||
196 | void make_ram_disk(int size, int number, char *place, int TMPFS); | ||
197 | void quick_mount(char *type, char *device, char *path, char *data, ...); | ||
198 | char *quick_read(char *filename); | ||
199 | void quick_write(const char *filename, const char *data, ...); | ||
200 | |||
201 | |||
202 | #endif | ||