xref: /illumos-gate/usr/src/lib/fm/libdiagcode/common/diagcode.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_FM_DIAGCODE_H
28 #define	_FM_DIAGCODE_H
29 
30 #include <sys/types.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * The following interfaces are private to Sun and should
38  * not be used by applications developed outside of Sun.
39  * They may change incompatibly or go away without notice.
40  */
41 
42 #define	FM_DC_VERSION   1	/* pass to fm_dc_opendict() */
43 
44 typedef struct fm_dc_handle fm_dc_handle_t;
45 
46 /* open a dictionary, return opaque handle */
47 fm_dc_handle_t *fm_dc_opendict(int version, const char *dirpath,
48     const char *dictname);
49 
50 /* close a dictionary */
51 void fm_dc_closedict(fm_dc_handle_t *dhp);
52 
53 /* return maximum length (in bytes) of diagcodes for a given dictionary */
54 size_t fm_dc_codelen(fm_dc_handle_t *dhp);
55 
56 /* return number of strings in key for a given dictionary, plus 1 for null */
57 int fm_dc_maxkey(fm_dc_handle_t *dhp);
58 
59 /* given a key, construct a diagcode */
60 int fm_dc_key2code(fm_dc_handle_t *dhp,
61     const char *key[], char *code, size_t maxcode);
62 
63 /* given a diagcode, return the key (array of strings) */
64 int fm_dc_code2key(fm_dc_handle_t *dhp, const char *code,
65     char *key[], int maxkey);
66 
67 /* return the right-hand side of a names property from the dict header */
68 const char *fm_dc_getprop(fm_dc_handle_t *dhp, const char *name);
69 
70 #ifdef	__cplusplus
71 }
72 #endif
73 
74 #endif	/* _FM_DIAGCODE_H */
75