xref: /titanic_52/usr/src/cmd/syseventd/daemons/syseventconfd/syseventconfd.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYSEVENTCONFD_H
28 #define	_SYSEVENTCONFD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 
37 /*
38  * debug levels
39  */
40 #define	DBG_EXEC	1	/* path and args for each fork/exec */
41 #define	DBG_EVENTS	2	/* received events */
42 #define	DBG_CHILD	3	/* child exit status */
43 #define	DBG_EXEC_ARGS	4	/* more detail on exec args */
44 
45 
46 /*
47  * list of cmds received from syseventd/sysevent_conf_mod
48  */
49 struct cmd {
50 	nvlist_t	*cmd_nvlist;
51 	struct cmd	*cmd_next;
52 	struct cmd	*cmd_taiL;
53 };
54 
55 
56 /*
57  * Structures for building arbitarily long strings and argument lists
58  */
59 typedef struct arg {
60 	char	**arg_args;
61 	int	arg_nargs;
62 	int	arg_alloc;
63 	int	arg_hint;
64 } arg_t;
65 
66 typedef struct str {
67 	char	*s_str;
68 	int	s_len;
69 	int	s_alloc;
70 	int	s_hint;
71 } str_t;
72 
73 
74 /*
75  * Prototypes
76  */
77 void main(int argc, char **argv);
78 static void event_handler(sysevent_t *event);
79 static void exec_cmd(struct cmd *cmd);
80 static void sigwait_thr(void);
81 static void reapchild(int sig);
82 static void flt_handler(int sig);
83 static void syserrmsg(char *message, ...);
84 static void printmsg(int level, char *message, ...);
85 static void set_root_dir(char *dir);
86 static void usage(void);
87 static arg_t *init_arglist(int hint);
88 static void free_arglist(arg_t *arglist);
89 static int add_arg(arg_t *arglist, char *arg);
90 static char *next_arg(char **cpp);
91 static struct cmd *alloc_cmd(nvlist_t *nvlist);
92 static void free_cmd(struct cmd *cmd);
93 static void *sc_malloc(size_t n);
94 static void *sc_realloc(void *p, size_t n);
95 static sysevent_handle_t *open_channel(void);
96 
97 
98 #ifdef	__cplusplus
99 }
100 #endif
101 
102 #endif	/* _SYSEVENTCONFD_H */
103