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