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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYSEVENTADM_H
27 #define _SYSEVENTADM_H
34 * Directory where sysevent.conf files reside
36 #define SYSEVENT_CONFIG_DIR "/etc/sysevent/config"
39 * Lock file name to serialize registry updates
41 #define LOCK_FILENAME "/var/run/syseventconf.lock"
44 * Required suffix for all sysevent.conf files
46 #define SYSEVENT_CONF_SUFFIX ",sysevent.conf"
49 * cmd types for list/remove
58 #define EXIT_NO_MATCH 1
61 #define EXIT_CMD_FAILED 4
65 * sysevent.conf record
67 typedef struct serecord
{
68 char *se_vendor
; /* vendor */
69 char *se_publisher
; /* publisher */
70 char *se_class
; /* event class */
71 char *se_subclass
; /* event subclass */
72 char *se_user
; /* user */
73 char *se_reserved1
; /* reserved1 */
74 char *se_reserved2
; /* reserved2 */
75 char *se_path
; /* event path */
76 char *se_args
; /* optional args */
81 * Structures for building arbitarily long strings and argument lists
94 int main(int argc
, char **argv
);
95 static void enter_lock(char *root_dir
);
96 static void exit_lock(void);
97 static void set_root_dir(char *dir
);
98 static int usage(void);
99 static int add_cmd(void);
100 static int list_remove_cmd(int cmd
);
101 static int list_file(char *fname
);
102 static int remove_file(char *fname
);
103 static int check_for_removes(FILE *fp
);
104 static int restart_cmd(void);
106 static str_t
*read_next_line(FILE *fp
);
107 static serecord_t
*parse_line(str_t
*line
);
109 static int matches_serecord(serecord_t
*sep
);
110 static void print_serecord(FILE *fp
, serecord_t
*sep
);
111 static void free_serecord(serecord_t
*sep
);
113 static char *skip_spaces(char **cpp
);
114 static char *next_field(char **cpp
);
115 static void *sc_malloc(size_t n
);
116 static void *sc_realloc(void *p
, size_t current
, size_t n
);
117 static void sc_free(void *p
, size_t n
);
118 static char *sc_strdup(char *cp
);
119 static void sc_strfree(char *s
);
121 static str_t
*initstr(int hint
);
122 static void freestr(str_t
*str
);
123 static void resetstr(str_t
*str
);
124 static void strcats(str_t
*str
, char *s
);
125 static void strcatc(str_t
*str
, int c
);
126 static char *fstrgets(str_t
*str
, FILE *fp
);
127 static char **build_strlist(char **, int *, int *, char *);
129 static void no_mem_err(void);
135 #endif /* _SYSEVENTADM_H */