xref: /titanic_41/usr/src/cmd/fm/fmdump/common/fmdump.h (revision b6805bf78d2bbbeeaea8909a05623587b42d58b3)
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 (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_FMDUMP_H
26 #define	_FMDUMP_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <assert.h>
33 #include <stdarg.h>
34 #include <stdio.h>
35 #include <synch.h>
36 
37 #include <sys/types.h>
38 #include <sys/fm/protocol.h>
39 
40 #include <fm/fmd_log.h>
41 #include <fm/fmd_msg.h>
42 #include <fm/libtopo.h>
43 
44 #ifdef DEBUG
45 #define	ASSERT(x) (assert(x))
46 #else
47 #define	ASSERT(x)
48 #endif
49 
50 enum {
51 	FMDUMP_SHORT,
52 	FMDUMP_VERB1,
53 	FMDUMP_VERB2,
54 	FMDUMP_PRETTY,
55 	FMDUMP_MSG,
56 	FMDUMP_NFMTS
57 };
58 
59 typedef struct fmdump_ops {
60 	const char *do_label;
61 	struct fmdump_fmt {
62 		const char *do_hdr;
63 		fmd_log_rec_f *do_func;
64 	} do_formats[FMDUMP_NFMTS];
65 } fmdump_ops_t;
66 
67 typedef struct fmdump_arg {
68 	const struct fmdump_fmt *da_fmt;
69 	fmd_log_filter_t *da_fv;
70 	uint_t da_fc;
71 	FILE *da_fp;
72 } fmdump_arg_t;
73 
74 typedef struct fmdump_lyr {
75 	fmd_log_rec_f *dy_func;
76 	void *dy_arg;
77 	FILE *dy_fp;
78 } fmdump_lyr_t;
79 
80 extern const fmdump_ops_t fmdump_err_ops;
81 extern const fmdump_ops_t fmdump_flt_ops;
82 extern const fmdump_ops_t fmdump_asru_ops;
83 extern const fmdump_ops_t fmdump_info_ops;
84 
85 extern const char *g_pname;
86 extern ulong_t g_errs;
87 extern ulong_t g_recs;
88 extern char *g_root;
89 
90 extern struct topo_hdl *g_thp;
91 extern fmd_msg_hdl_t *g_msg;
92 
93 extern void fmdump_printf(FILE *, const char *, ...);
94 extern void fmdump_warn(const char *, ...);
95 extern void fmdump_vwarn(const char *, va_list);
96 
97 extern char *fmdump_date(char *, size_t, const fmd_log_record_t *);
98 extern char *fmdump_year(char *, size_t, const fmd_log_record_t *);
99 extern char *fmdump_nvl2str(nvlist_t *nvl);
100 
101 extern int fmdump_render_nvlist(nvlist_prtctl_t, void *, nvlist_t *,
102     const char *, nvlist_t *);
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _FMDUMP_H */
109