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