xref: /onnv-gate/usr/src/cmd/syseventadm/syseventadm.h (revision 8397:f04a527d794d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*8397SEric.Schrock@Sun.COM  * Common Development and Distribution License (the "License").
6*8397SEric.Schrock@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*8397SEric.Schrock@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYSEVENTADM_H
270Sstevel@tonic-gate #define	_SYSEVENTADM_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Directory where sysevent.conf files reside
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate #define	SYSEVENT_CONFIG_DIR		"/etc/sysevent/config"
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * Lock file name to serialize registry updates
400Sstevel@tonic-gate  */
41*8397SEric.Schrock@Sun.COM #define	LOCK_FILENAME	"/var/run/syseventconf.lock"
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * Required suffix for all sysevent.conf files
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate #define	SYSEVENT_CONF_SUFFIX		",sysevent.conf"
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * cmd types for list/remove
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate #define	CMD_LIST	0
520Sstevel@tonic-gate #define	CMD_REMOVE	1
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  * Exit codes
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate #define	EXIT_OK			0
580Sstevel@tonic-gate #define	EXIT_NO_MATCH		1
590Sstevel@tonic-gate #define	EXIT_USAGE		2
600Sstevel@tonic-gate #define	EXIT_PERM		3
610Sstevel@tonic-gate #define	EXIT_CMD_FAILED		4
620Sstevel@tonic-gate #define	EXIT_NO_MEM		5
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * sysevent.conf record
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate typedef struct serecord {
680Sstevel@tonic-gate 	char	*se_vendor;			/* vendor */
690Sstevel@tonic-gate 	char	*se_publisher;			/* publisher */
700Sstevel@tonic-gate 	char	*se_class;			/* event class */
710Sstevel@tonic-gate 	char	*se_subclass;			/* event subclass */
720Sstevel@tonic-gate 	char	*se_user;			/* user */
730Sstevel@tonic-gate 	char	*se_reserved1;			/* reserved1 */
740Sstevel@tonic-gate 	char	*se_reserved2;			/* reserved2 */
750Sstevel@tonic-gate 	char	*se_path;			/* event path */
760Sstevel@tonic-gate 	char	*se_args;			/* optional args */
770Sstevel@tonic-gate } serecord_t;
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * Structures for building arbitarily long strings and argument lists
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate typedef struct str {
840Sstevel@tonic-gate 	char	*s_str;
850Sstevel@tonic-gate 	int	s_len;
860Sstevel@tonic-gate 	int	s_alloc;
870Sstevel@tonic-gate 	int	s_hint;
880Sstevel@tonic-gate } str_t;
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * Prototypes
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate int main(int argc, char **argv);
950Sstevel@tonic-gate static void enter_lock(char *root_dir);
960Sstevel@tonic-gate static void exit_lock(void);
970Sstevel@tonic-gate static void set_root_dir(char *dir);
980Sstevel@tonic-gate static int usage(void);
990Sstevel@tonic-gate static int add_cmd(void);
1000Sstevel@tonic-gate static int list_remove_cmd(int cmd);
1010Sstevel@tonic-gate static int list_file(char *fname);
1020Sstevel@tonic-gate static int remove_file(char *fname);
1030Sstevel@tonic-gate static int check_for_removes(FILE *fp);
1040Sstevel@tonic-gate static int restart_cmd(void);
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate static str_t *read_next_line(FILE *fp);
1070Sstevel@tonic-gate static serecord_t *parse_line(str_t *line);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate static int matches_serecord(serecord_t *sep);
1100Sstevel@tonic-gate static void print_serecord(FILE *fp, serecord_t *sep);
1110Sstevel@tonic-gate static void free_serecord(serecord_t *sep);
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate static char *skip_spaces(char **cpp);
1140Sstevel@tonic-gate static char *next_field(char **cpp);
1150Sstevel@tonic-gate static void *sc_malloc(size_t n);
1160Sstevel@tonic-gate static void *sc_realloc(void *p, size_t current, size_t n);
1170Sstevel@tonic-gate static void sc_free(void *p, size_t n);
1180Sstevel@tonic-gate static char *sc_strdup(char *cp);
1190Sstevel@tonic-gate static void sc_strfree(char *s);
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate static str_t *initstr(int hint);
1220Sstevel@tonic-gate static void freestr(str_t *str);
1230Sstevel@tonic-gate static void resetstr(str_t *str);
1240Sstevel@tonic-gate static void strcats(str_t *str, char *s);
1250Sstevel@tonic-gate static void strcatc(str_t *str, int c);
1260Sstevel@tonic-gate static char *fstrgets(str_t *str, FILE *fp);
1270Sstevel@tonic-gate static char **build_strlist(char **, int *, int *, char *);
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate static void no_mem_err(void);
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate #ifdef	__cplusplus
1320Sstevel@tonic-gate }
1330Sstevel@tonic-gate #endif
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate #endif	/* _SYSEVENTADM_H */
136