xref: /illumos-gate/usr/src/cmd/fm/fmdump/common/fmdump.h (revision 2db6d663)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5b6955755SRobert Johnston  * Common Development and Distribution License (the "License").
6b6955755SRobert Johnston  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22f6e214c7SGavin Maltby  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23*2db6d663SJoshua M. Clulow  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_FMDUMP_H
277c478bd9Sstevel@tonic-gate #define	_FMDUMP_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
33f6e214c7SGavin Maltby #include <assert.h>
347c478bd9Sstevel@tonic-gate #include <stdarg.h>
357c478bd9Sstevel@tonic-gate #include <stdio.h>
36f6e214c7SGavin Maltby #include <synch.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
40b6955755SRobert Johnston 
417c478bd9Sstevel@tonic-gate #include <fm/fmd_log.h>
42b6955755SRobert Johnston #include <fm/fmd_msg.h>
437aec1d6eScindi #include <fm/libtopo.h>
447c478bd9Sstevel@tonic-gate 
45f6e214c7SGavin Maltby #ifdef DEBUG
46f6e214c7SGavin Maltby #define	ASSERT(x) (assert(x))
47f6e214c7SGavin Maltby #else
48f6e214c7SGavin Maltby #define	ASSERT(x)
49f6e214c7SGavin Maltby #endif
50f6e214c7SGavin Maltby 
517c478bd9Sstevel@tonic-gate enum {
527c478bd9Sstevel@tonic-gate 	FMDUMP_SHORT,
537c478bd9Sstevel@tonic-gate 	FMDUMP_VERB1,
547c478bd9Sstevel@tonic-gate 	FMDUMP_VERB2,
55f6e214c7SGavin Maltby 	FMDUMP_PRETTY,
56b6955755SRobert Johnston 	FMDUMP_MSG,
57*2db6d663SJoshua M. Clulow 	FMDUMP_JSON,
587c478bd9Sstevel@tonic-gate 	FMDUMP_NFMTS
597c478bd9Sstevel@tonic-gate };
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate typedef struct fmdump_ops {
627c478bd9Sstevel@tonic-gate 	const char *do_label;
637c478bd9Sstevel@tonic-gate 	struct fmdump_fmt {
647c478bd9Sstevel@tonic-gate 		const char *do_hdr;
657c478bd9Sstevel@tonic-gate 		fmd_log_rec_f *do_func;
667c478bd9Sstevel@tonic-gate 	} do_formats[FMDUMP_NFMTS];
677c478bd9Sstevel@tonic-gate } fmdump_ops_t;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef struct fmdump_arg {
707c478bd9Sstevel@tonic-gate 	const struct fmdump_fmt *da_fmt;
717c478bd9Sstevel@tonic-gate 	fmd_log_filter_t *da_fv;
727c478bd9Sstevel@tonic-gate 	uint_t da_fc;
737c478bd9Sstevel@tonic-gate 	FILE *da_fp;
747c478bd9Sstevel@tonic-gate } fmdump_arg_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate typedef struct fmdump_lyr {
777c478bd9Sstevel@tonic-gate 	fmd_log_rec_f *dy_func;
787c478bd9Sstevel@tonic-gate 	void *dy_arg;
797c478bd9Sstevel@tonic-gate 	FILE *dy_fp;
807c478bd9Sstevel@tonic-gate } fmdump_lyr_t;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate extern const fmdump_ops_t fmdump_err_ops;
837c478bd9Sstevel@tonic-gate extern const fmdump_ops_t fmdump_flt_ops;
847c478bd9Sstevel@tonic-gate extern const fmdump_ops_t fmdump_asru_ops;
85f6e214c7SGavin Maltby extern const fmdump_ops_t fmdump_info_ops;
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate extern const char *g_pname;
887c478bd9Sstevel@tonic-gate extern ulong_t g_errs;
897c478bd9Sstevel@tonic-gate extern ulong_t g_recs;
907c478bd9Sstevel@tonic-gate extern char *g_root;
91b6955755SRobert Johnston 
927aec1d6eScindi extern struct topo_hdl *g_thp;
93b6955755SRobert Johnston extern fmd_msg_hdl_t *g_msg;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate extern void fmdump_printf(FILE *, const char *, ...);
967c478bd9Sstevel@tonic-gate extern void fmdump_warn(const char *, ...);
977c478bd9Sstevel@tonic-gate extern void fmdump_vwarn(const char *, va_list);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate extern char *fmdump_date(char *, size_t, const fmd_log_record_t *);
1007c478bd9Sstevel@tonic-gate extern char *fmdump_year(char *, size_t, const fmd_log_record_t *);
1017c478bd9Sstevel@tonic-gate extern char *fmdump_nvl2str(nvlist_t *nvl);
1027c478bd9Sstevel@tonic-gate 
103f6e214c7SGavin Maltby extern int fmdump_render_nvlist(nvlist_prtctl_t, void *, nvlist_t *,
104f6e214c7SGavin Maltby     const char *, nvlist_t *);
105f6e214c7SGavin Maltby 
106*2db6d663SJoshua M. Clulow extern int fmdump_print_json(fmd_log_t *, const fmd_log_record_t *, FILE *);
107*2db6d663SJoshua M. Clulow 
1087c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate #endif
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #endif	/* _FMDUMP_H */
113