summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/lib_init_d.h
diff options
context:
space:
mode:
Diffstat (limited to 'urunlevel/my_linux/lib_init_d.h')
-rw-r--r--urunlevel/my_linux/lib_init_d.h183
1 files changed, 183 insertions, 0 deletions
diff --git a/urunlevel/my_linux/lib_init_d.h b/urunlevel/my_linux/lib_init_d.h
new file mode 100644
index 0000000..13253e9
--- /dev/null
+++ b/urunlevel/my_linux/lib_init_d.h
@@ -0,0 +1,183 @@
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
50typedef 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
71typedef struct init_d_handle_s {
72 int (*start)(struct init_d_handle_s *);
73 int (*stop)(struct init_d_handle_s *);
74 int (*restart)(struct init_d_handle_s *);
75 int (*try_restart)(struct init_d_handle_s *);
76 int (*reload)(struct init_d_handle_s *);
77 int (*force_reload)(struct init_d_handle_s *);
78 int (*status)(struct init_d_handle_s *, int);
79 int (*show_info)(struct init_d_handle_s *);
80 char *basename;
81 char *pathname;
82 char *args;
83 char *pidfile;
84 char *info;
85} init_d_handle_t;
86
87
88int do_init_from_main(int argc, char **argv, struct init_d_handle_s *init_d);
89int do_init(struct init_d_handle_s *init_d, const char *command);
90
91int default_start(struct init_d_handle_s *);
92int default_stop(struct init_d_handle_s *);
93int default_restart(struct init_d_handle_s *);
94int default_try_restart(struct init_d_handle_s *);
95int default_reload(struct init_d_handle_s *);
96int default_force_reload(struct init_d_handle_s *);
97int default_status(struct init_d_handle_s *, int);
98int default_show_info(struct init_d_handle_s *);
99
100int no_stop(struct init_d_handle_s *);
101int no_reload(struct init_d_handle_s *);
102int no_status(struct init_d_handle_s *, int);
103
104/*
105 * error codes
106 */
107
108#define INIT_D_OK 0
109#define INIT_D_ERROR_GENERIC 1
110#define INIT_D_ERROR_ARGS 2
111#define INIT_D_ERROR_NOT_IMPLEMENTED 3
112#define INIT_D_ERROR_SECURITY 4
113#define INIT_D_ERROR_NOT_INSTALLED 5
114#define INIT_D_ERROR_NOT_CONFIGURED 6
115#define INIT_D_ERROR_NOT_RUNNING 7
116
117
118/*
119 * status codes
120 */
121
122#define INIT_D_STATUS_OK 0
123#define INIT_D_STATUS_DEAD_PID 1
124#define INIT_D_STATUS_DEAD_LOCK 2
125#define INIT_D_STATUS_NOT_RUNNING 3
126#define INIT_D_STATUS_UNKNOWN 4
127
128
129/*
130 * /lib/lsb/init-functions
131 */
132int start_daemon(int force, int nice_level, char *pidfile, char *pathname, char *args);
133int killproc(char *pidfile, char *pathname, int my_signal);
134int checkpid(char *pid);
135int pidofproc(char *pidfile, char *pathname, char **pids);
136void log_success_msg(char *message);
137void log_failure_msg(char *message);
138void log_warning_msg(char *message);
139
140
141#define REDIR 1
142#define QUIET 2
143#define ERRONLY 4
144#define FORK 8
145#define NOFORK 16
146#define DAEMON 32
147
148extern struct stat path_stat;
149
150typedef struct nodes_s
151{
152 const char *name;
153 mode_t mode;
154 int major;
155 int minor;
156 int count;
157} nodes_t;
158
159
160char *argv_cat(int argc, char **argv);
161char *big_chomp(char *s);
162int checkpid(char *pid);
163char *doit(int mode, char *command, ...);
164
165#ifndef CONFIG_IFUPDOWN
166#define RUNLEVEL_LIST 1
167#endif
168#ifdef RUNLEVEL_LIST
169// From ifupdown, so it should probably be in libbb.
170llist_t *llist_add_to_end(llist_t *list_head, char *data);
171#else
172extern llist_t *llist_add_to_end(llist_t *list_head, char *data);
173#endif
174
175llist_t *llist_delete(llist_t **unsorted, llist_t *previous, llist_t *current);
176void make_disk(char *token, const nodes_t *nodes);
177void make_ram_disk(int size, int number, char *place, int TMPFS);
178void quick_mount(char *type, char *device, char *path, char *data, ...);
179char *quick_read(char *filename);
180void quick_write(const char *filename, const char *data, ...);
181
182
183#endif