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