Add casts to get rid of compiler warning about signed/unsigned issues.
[sysvinit.git] / src / init.h
CommitLineData
a74aeac6
PR
1/*
2 * init.h Several defines and declarations to be
3 * included by all modules of the init program.
4 *
5 * Version: @(#)init.h 2.85-5 02-Jul-2003 miquels@cistron.nl
6 *
7 * Copyright (C) 1998-2003 Miquel van Smoorenburg.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 */
24
25/* Standard configuration */
26#define CHANGE_WAIT 0 /* Change runlevel while
27 waiting for a process to exit? */
28/* Debug and test modes */
29#define DEBUG 0 /* Debug code off */
30#define INITDEBUG 0 /* Fork at startup to debug init. */
31
32/* Some constants */
33#define INITPID 1 /* pid of first process */
34#define PIPE_FD 10 /* Fileno of initfifo. */
35#define STATE_PIPE 11 /* used to pass state through exec */
36
37/* Failsafe configuration */
38#define MAXSPAWN 10 /* Max times respawned in.. */
39#define TESTTIME 120 /* this much seconds */
40#define SLEEPTIME 300 /* Disable time */
41
42/* Default path inherited by every child. */
43#define PATH_DEFAULT "/sbin:/usr/sbin:/bin:/usr/bin"
44
45
46/* Prototypes. */
47void write_utmp_wtmp(char *user, char *id, int pid, int type, char *line);
48void write_wtmp(char *user, char *id, int pid, int type, char *line);
49#ifdef __GNUC__
50__attribute__ ((format (printf, 2, 3)))
51#endif
52void initlog(int loglevel, char *fmt, ...);
53void set_term(int how);
54void print(char *fmt);
55
56#if DEBUG
57# define INITDBG(level, fmt, args...) initlog(level, fmt, ##args)
58#else
59# define INITDBG(level, fmt, args...)
60#endif
61
62/* Actions to be taken by init */
63#define RESPAWN 1
64#define WAIT 2
65#define ONCE 3
66#define BOOT 4
67#define BOOTWAIT 5
68#define POWERFAIL 6
69#define POWERWAIT 7
70#define POWEROKWAIT 8
71#define CTRLALTDEL 9
72#define OFF 10
73#define ONDEMAND 11
74#define INITDEFAULT 12
75#define SYSINIT 13
76#define POWERFAILNOW 14
77#define KBREQUEST 15
78
79/* Information about a process in the in-core inittab */
80typedef struct _child_ {
81 int flags; /* Status of this entry */
82 int exstat; /* Exit status of process */
83 int pid; /* Pid of this process */
84 time_t tm; /* When respawned last */
85 int count; /* Times respawned in the last 2 minutes */
86 char id[8]; /* Inittab id (must be unique) */
87 char rlevel[12]; /* run levels */
88 int action; /* what to do (see list below) */
89 char process[128]; /* The command line */
90 struct _child_ *new; /* New entry (after inittab re-read) */
91 struct _child_ *next; /* For the linked list */
92} CHILD;
93
94/* Values for the 'flags' field */
95#define RUNNING 2 /* Process is still running */
96#define KILLME 4 /* Kill this process */
97#define DEMAND 8 /* "runlevels" a b c */
98#define FAILING 16 /* process respawns rapidly */
99#define WAITING 32 /* We're waiting for this process */
100#define ZOMBIE 64 /* This process is already dead */
101#define XECUTED 128 /* Set if spawned once or more times */
102
103/* Log levels. */
104#define L_CO 1 /* Log on the console. */
105#define L_SY 2 /* Log with syslog() */
106#define L_VB (L_CO|L_SY) /* Log with both. */
107
108#ifndef NO_PROCESS
109# define NO_PROCESS 0
110#endif
111
112/*
113 * Global variables.
114 */
115extern CHILD *family;
116extern int wrote_wtmp_reboot;
117extern int wrote_utmp_reboot;
118
119/* Tokens in state parser */
120#define C_VER 1
121#define C_END 2
122#define C_REC 3
123#define C_EOR 4
124#define C_LEV 5
125#define C_FLAG 6
126#define C_ACTION 7
127#define C_PROCESS 8
128#define C_PID 9
129#define C_EXS 10
130#define C_EOF -1
131#define D_RUNLEVEL -2
132#define D_THISLEVEL -3
133#define D_PREVLEVEL -4
134#define D_GOTSIGN -5
135#define D_WROTE_WTMP_REBOOT -6
136#define D_WROTE_UTMP_REBOOT -7
137#define D_SLTIME -8
138#define D_DIDBOOT -9
139