xref: /illumos-gate/usr/src/cmd/fm/fmdump/common/fmdump.h (revision 93a18d6d401e844455263f926578e9d2aa6b47ec)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_FMDUMP_H
27 #define	_FMDUMP_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <stdarg.h>
34 #include <stdio.h>
35 
36 #include <sys/types.h>
37 #include <sys/fm/protocol.h>
38 
39 #include <fm/fmd_log.h>
40 #include <fm/fmd_msg.h>
41 #include <fm/libtopo.h>
42 
43 enum {
44 	FMDUMP_SHORT,
45 	FMDUMP_VERB1,
46 	FMDUMP_VERB2,
47 	FMDUMP_MSG,
48 	FMDUMP_NFMTS
49 };
50 
51 typedef struct fmdump_ops {
52 	const char *do_label;
53 	struct fmdump_fmt {
54 		const char *do_hdr;
55 		fmd_log_rec_f *do_func;
56 	} do_formats[FMDUMP_NFMTS];
57 } fmdump_ops_t;
58 
59 typedef struct fmdump_arg {
60 	const struct fmdump_fmt *da_fmt;
61 	fmd_log_filter_t *da_fv;
62 	uint_t da_fc;
63 	FILE *da_fp;
64 } fmdump_arg_t;
65 
66 typedef struct fmdump_lyr {
67 	fmd_log_rec_f *dy_func;
68 	void *dy_arg;
69 	FILE *dy_fp;
70 } fmdump_lyr_t;
71 
72 extern const fmdump_ops_t fmdump_err_ops;
73 extern const fmdump_ops_t fmdump_flt_ops;
74 extern const fmdump_ops_t fmdump_asru_ops;
75 
76 extern const char *g_pname;
77 extern ulong_t g_errs;
78 extern ulong_t g_recs;
79 extern char *g_root;
80 
81 extern struct topo_hdl *g_thp;
82 extern fmd_msg_hdl_t *g_msg;
83 
84 extern void fmdump_printf(FILE *, const char *, ...);
85 extern void fmdump_warn(const char *, ...);
86 extern void fmdump_vwarn(const char *, va_list);
87 
88 extern char *fmdump_date(char *, size_t, const fmd_log_record_t *);
89 extern char *fmdump_year(char *, size_t, const fmd_log_record_t *);
90 extern char *fmdump_nvl2str(nvlist_t *nvl);
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif	/* _FMDUMP_H */
97