xref: /illumos-gate/usr/src/lib/cfgadm_plugins/ib/common/cfga_conf.h (revision dd51520e127b452179a2ce4ea3bd8dee949f9afe)
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 _CFGA_CONF_H
28 #define	_CFGA_CONF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /* for ib.conf file support */
37 
38 #define	IBCONF_FILE		"/kernel/drv/ib.conf"
39 
40 /* type of variable entries read */
41 typedef struct ibcfg_var {
42 	char			*name;		/* service name */
43 	ib_service_type_t	type;		/* service type */
44 } ibcfg_var_t;
45 
46 /* values returned during parsing */
47 typedef enum ib_parse_state_e {
48 	IB_NEWVAR,				/* new token seen */
49 	IB_CONFIG_VAR,				/* "name" token seen */
50 	IB_VAR_EQUAL,				/* "=" token seen */
51 	IB_VAR_VALUE,				/* "value" token seen */
52 	IB_ERROR				/* error seen */
53 } ib_parse_state_t;
54 
55 /* service record for each entry read */
56 typedef struct ib_svc_rec_s {
57 	char			*name;		/* service name */
58 	ib_service_type_t	type;		/* service type */
59 	struct ib_svc_rec_s	*next;		/* next link */
60 } ib_svc_rec_t;
61 
62 
63 #define	isunary(ch)		((ch) == '~' || (ch) == '-')
64 #define	iswhite(ch)		((ch) == ' ' || (ch) == '\t')
65 #define	isnewline(ch)		((ch) == '\n' || (ch) == '\r' || (ch) == '\f')
66 #define	isalphanum(ch)		(isalpha(ch) || isdigit(ch))
67 #define	isnamechar(ch)		(isalphanum(ch) || (ch) == '_' || (ch) == '-')
68 
69 #define	GETC(a, cntr)		a[cntr++]
70 #define	UNGETC(cntr)		cntr--
71 #define	MAXLINESIZE		132
72 
73 /* string defines for conf file usage */
74 #define	IBCONF_PORT_SERVICE_HDR	"PORT communication services:\n"
75 #define	IBCONF_VPPA_SERVICE_HDR	"VPPA communication services:\n"
76 #define	IBCONF_HCA_SERVICE_HDR	"HCA communication services:\n"
77 #define	IBCONF_SERVICE_HDR_LEN	32
78 
79 /* tokens as read from IBCONF_FILE */
80 typedef enum ib_token_e {
81 	EQUALS,
82 	AMPERSAND,
83 	BIT_OR,
84 	STAR,
85 	POUND,
86 	COLON,
87 	SEMICOLON,
88 	COMMA,
89 	SLASH,
90 	WHITE_SPACE,
91 	NEWLINE,
92 	E_O_F,
93 	STRING,			/* c */
94 	HEXVAL,
95 	DECVAL,
96 	NAME			/* f */
97 } ib_token_t;
98 
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* _CFGA_CONF_H */
105