xref: /onnv-gate/usr/src/cmd/fm/fmdump/common/fmdump.h (revision 12967:ab9ae749152f)
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
59501SRobert.Johnston@Sun.COM  * Common Development and Distribution License (the "License").
69501SRobert.Johnston@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*12967Sgavin.maltby@oracle.com  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_FMDUMP_H
260Sstevel@tonic-gate #define	_FMDUMP_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifdef	__cplusplus
290Sstevel@tonic-gate extern "C" {
300Sstevel@tonic-gate #endif
310Sstevel@tonic-gate 
32*12967Sgavin.maltby@oracle.com #include <assert.h>
330Sstevel@tonic-gate #include <stdarg.h>
340Sstevel@tonic-gate #include <stdio.h>
35*12967Sgavin.maltby@oracle.com #include <synch.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <sys/types.h>
380Sstevel@tonic-gate #include <sys/fm/protocol.h>
399501SRobert.Johnston@Sun.COM 
400Sstevel@tonic-gate #include <fm/fmd_log.h>
419501SRobert.Johnston@Sun.COM #include <fm/fmd_msg.h>
421414Scindi #include <fm/libtopo.h>
430Sstevel@tonic-gate 
44*12967Sgavin.maltby@oracle.com #ifdef DEBUG
45*12967Sgavin.maltby@oracle.com #define	ASSERT(x) (assert(x))
46*12967Sgavin.maltby@oracle.com #else
47*12967Sgavin.maltby@oracle.com #define	ASSERT(x)
48*12967Sgavin.maltby@oracle.com #endif
49*12967Sgavin.maltby@oracle.com 
500Sstevel@tonic-gate enum {
510Sstevel@tonic-gate 	FMDUMP_SHORT,
520Sstevel@tonic-gate 	FMDUMP_VERB1,
530Sstevel@tonic-gate 	FMDUMP_VERB2,
54*12967Sgavin.maltby@oracle.com 	FMDUMP_PRETTY,
559501SRobert.Johnston@Sun.COM 	FMDUMP_MSG,
560Sstevel@tonic-gate 	FMDUMP_NFMTS
570Sstevel@tonic-gate };
580Sstevel@tonic-gate 
590Sstevel@tonic-gate typedef struct fmdump_ops {
600Sstevel@tonic-gate 	const char *do_label;
610Sstevel@tonic-gate 	struct fmdump_fmt {
620Sstevel@tonic-gate 		const char *do_hdr;
630Sstevel@tonic-gate 		fmd_log_rec_f *do_func;
640Sstevel@tonic-gate 	} do_formats[FMDUMP_NFMTS];
650Sstevel@tonic-gate } fmdump_ops_t;
660Sstevel@tonic-gate 
670Sstevel@tonic-gate typedef struct fmdump_arg {
680Sstevel@tonic-gate 	const struct fmdump_fmt *da_fmt;
690Sstevel@tonic-gate 	fmd_log_filter_t *da_fv;
700Sstevel@tonic-gate 	uint_t da_fc;
710Sstevel@tonic-gate 	FILE *da_fp;
720Sstevel@tonic-gate } fmdump_arg_t;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate typedef struct fmdump_lyr {
750Sstevel@tonic-gate 	fmd_log_rec_f *dy_func;
760Sstevel@tonic-gate 	void *dy_arg;
770Sstevel@tonic-gate 	FILE *dy_fp;
780Sstevel@tonic-gate } fmdump_lyr_t;
790Sstevel@tonic-gate 
800Sstevel@tonic-gate extern const fmdump_ops_t fmdump_err_ops;
810Sstevel@tonic-gate extern const fmdump_ops_t fmdump_flt_ops;
820Sstevel@tonic-gate extern const fmdump_ops_t fmdump_asru_ops;
83*12967Sgavin.maltby@oracle.com extern const fmdump_ops_t fmdump_info_ops;
840Sstevel@tonic-gate 
850Sstevel@tonic-gate extern const char *g_pname;
860Sstevel@tonic-gate extern ulong_t g_errs;
870Sstevel@tonic-gate extern ulong_t g_recs;
880Sstevel@tonic-gate extern char *g_root;
899501SRobert.Johnston@Sun.COM 
901414Scindi extern struct topo_hdl *g_thp;
919501SRobert.Johnston@Sun.COM extern fmd_msg_hdl_t *g_msg;
920Sstevel@tonic-gate 
930Sstevel@tonic-gate extern void fmdump_printf(FILE *, const char *, ...);
940Sstevel@tonic-gate extern void fmdump_warn(const char *, ...);
950Sstevel@tonic-gate extern void fmdump_vwarn(const char *, va_list);
960Sstevel@tonic-gate 
970Sstevel@tonic-gate extern char *fmdump_date(char *, size_t, const fmd_log_record_t *);
980Sstevel@tonic-gate extern char *fmdump_year(char *, size_t, const fmd_log_record_t *);
990Sstevel@tonic-gate extern char *fmdump_nvl2str(nvlist_t *nvl);
1000Sstevel@tonic-gate 
101*12967Sgavin.maltby@oracle.com extern int fmdump_render_nvlist(nvlist_prtctl_t, void *, nvlist_t *,
102*12967Sgavin.maltby@oracle.com     const char *, nvlist_t *);
103*12967Sgavin.maltby@oracle.com 
1040Sstevel@tonic-gate #ifdef	__cplusplus
1050Sstevel@tonic-gate }
1060Sstevel@tonic-gate #endif
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate #endif	/* _FMDUMP_H */
109