9804 hal-set-property should support --direct option
[unleashed.git] / usr / src / cmd / syseventadm / syseventadm.h
blobe6766552701faf13076b11c342d83b200e535725
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYSEVENTADM_H
27 #define _SYSEVENTADM_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
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
51 #define CMD_LIST 0
52 #define CMD_REMOVE 1
55 * Exit codes
57 #define EXIT_OK 0
58 #define EXIT_NO_MATCH 1
59 #define EXIT_USAGE 2
60 #define EXIT_PERM 3
61 #define EXIT_CMD_FAILED 4
62 #define EXIT_NO_MEM 5
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 */
77 } serecord_t;
81 * Structures for building arbitarily long strings and argument lists
83 typedef struct str {
84 char *s_str;
85 int s_len;
86 int s_alloc;
87 int s_hint;
88 } str_t;
92 * Prototypes
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);
131 #ifdef __cplusplus
133 #endif
135 #endif /* _SYSEVENTADM_H */