xref: /illumos-gate/usr/src/cmd/abi/spectrans/parser/parser.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
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 _PARSER_H
28 #define	_PARSER_H
29 
30 #include <sys/param.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 typedef struct metainfo {
37 	char mi_filename[MAXPATHLEN];
38 	int mi_line_number;
39 	int mi_nlines;
40 	int mi_ext_cnt;
41 	int mi_flags;
42 	int mi_extended;
43 } Meta_info;
44 
45 typedef struct translator_info {
46 	char	*ti_liblist;
47 	char	*ti_dash_I;
48 	char	*ti_output_file;
49 	int	ti_nfiles;
50 	int	ti_verbosity;
51 	int	ti_flags;
52 	char    *ti_versfile;
53 	char	*ti_arch;
54 	int	ti_archtoken;
55 	int	ti_libtype;	/* set to FILTERLIB if processing filter lib */
56 } Translator_info;
57 
58 typedef struct {
59 	char *key;
60 	int  token;
61 } xlator_keyword_t;
62 
63 /*
64  * Translator Flags
65  * These are values for the ti_flags member of the Translator_info
66  * structure. Each bit of ti_flags represents a flag.
67  * first bit = picky flag; translator runs in picky mode
68  *             picky mode means complain about interfaces with no versions
69  */
70 #define	XLATOR_PICKY_FLAG	0x01
71 
72 /* Return Codes from xlator_* functions */
73 #define	XLATOR_FATAL	-2
74 #define	XLATOR_NONFATAL	-1
75 #define	XLATOR_SUCCESS	0
76 #define	XLATOR_SKIP	1
77 
78 /* Misc Return Codes from Utility Functions */
79 enum {
80 	XLATOR_KW_NOTFOUND,
81 	XLATOR_KW_FUNC,
82 	XLATOR_KW_DATA,
83 	XLATOR_KW_END
84 };
85 
86 /* Library Type */
87 #define	NORMALLIB 0
88 #define	FILTERLIB 1
89 
90 /* Maxmimum levels of extends */
91 #define	MAX_EXTENDS 16
92 
93 /* Architecture Bitmap */
94 #define	XLATOR_SPARC	0x01
95 #define	XLATOR_SPARCV9	0x02
96 #define	XLATOR_I386	0x04
97 #define	XLATOR_IA64	0x08
98 #define	XLATOR_AMD64	0x10
99 #define	XLATOR_ALLARCH	0xFF
100 
101 extern xlator_keyword_t *keywordlist;
102 extern char **filelist;
103 extern int verbosity;
104 
105 extern int frontend(const Translator_info *);
106 extern int do_extends(const Meta_info, const Translator_info *, char *);
107 extern void split(const char *, char *, char *);
108 extern void remcomment(char const *);
109 extern void getlinecont(char *, char *, int, FILE *, Meta_info *);
110 extern char *line_to_buf(char *, const char *);
111 extern int non_empty(const char *);
112 extern int check4extends(const char *, const char *, int, FILE *);
113 extern int interesting_keyword(xlator_keyword_t *, const char *);
114 extern int arch_strtoi(const char *);
115 extern int readline(char **, FILE *);
116 extern int arch_match(FILE *, int);
117 
118 /* xlator_ functions */
119 extern xlator_keyword_t *xlator_init(const Translator_info *);
120 extern int xlator_startlib(char const *libname);
121 extern int xlator_startfile(char const *filename);
122 extern int xlator_start_if(const Meta_info meta_info, const int token,
123     char *value);
124 extern int xlator_take_kvpair(const Meta_info, const int token, char *value);
125 extern int xlator_end_if(const Meta_info, const char *value);
126 extern int xlator_endfile(void);
127 extern int xlator_endlib(void);
128 extern int xlator_end(void);
129 
130 #ifdef	__cplusplus
131 }
132 #endif
133 
134 #endif	/* _PARSER_H */
135