1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _PARSER_H
28*7c478bd9Sstevel@tonic-gate #define	_PARSER_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate typedef struct metainfo {
37*7c478bd9Sstevel@tonic-gate 	char mi_filename[MAXPATHLEN];
38*7c478bd9Sstevel@tonic-gate 	int mi_line_number;
39*7c478bd9Sstevel@tonic-gate 	int mi_nlines;
40*7c478bd9Sstevel@tonic-gate 	int mi_ext_cnt;
41*7c478bd9Sstevel@tonic-gate 	int mi_flags;
42*7c478bd9Sstevel@tonic-gate 	int mi_extended;
43*7c478bd9Sstevel@tonic-gate } Meta_info;
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate typedef struct translator_info {
46*7c478bd9Sstevel@tonic-gate 	char	*ti_liblist;
47*7c478bd9Sstevel@tonic-gate 	char	*ti_dash_I;
48*7c478bd9Sstevel@tonic-gate 	char	*ti_output_file;
49*7c478bd9Sstevel@tonic-gate 	int	ti_nfiles;
50*7c478bd9Sstevel@tonic-gate 	int	ti_verbosity;
51*7c478bd9Sstevel@tonic-gate 	int	ti_flags;
52*7c478bd9Sstevel@tonic-gate 	char    *ti_versfile;
53*7c478bd9Sstevel@tonic-gate 	char	*ti_arch;
54*7c478bd9Sstevel@tonic-gate 	int	ti_archtoken;
55*7c478bd9Sstevel@tonic-gate 	int	ti_libtype;	/* set to FILTERLIB if processing filter lib */
56*7c478bd9Sstevel@tonic-gate } Translator_info;
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate typedef struct {
59*7c478bd9Sstevel@tonic-gate 	char *key;
60*7c478bd9Sstevel@tonic-gate 	int  token;
61*7c478bd9Sstevel@tonic-gate } xlator_keyword_t;
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * Translator Flags
65*7c478bd9Sstevel@tonic-gate  * These are values for the ti_flags member of the Translator_info
66*7c478bd9Sstevel@tonic-gate  * structure. Each bit of ti_flags represents a flag.
67*7c478bd9Sstevel@tonic-gate  * first bit = picky flag; translator runs in picky mode
68*7c478bd9Sstevel@tonic-gate  *             picky mode means complain about interfaces with no versions
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate #define	XLATOR_PICKY_FLAG	0x01
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /* Return Codes from xlator_* functions */
73*7c478bd9Sstevel@tonic-gate #define	XLATOR_FATAL	-2
74*7c478bd9Sstevel@tonic-gate #define	XLATOR_NONFATAL	-1
75*7c478bd9Sstevel@tonic-gate #define	XLATOR_SUCCESS	0
76*7c478bd9Sstevel@tonic-gate #define	XLATOR_SKIP	1
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /* Misc Return Codes from Utility Functions */
79*7c478bd9Sstevel@tonic-gate enum {
80*7c478bd9Sstevel@tonic-gate 	XLATOR_KW_NOTFOUND,
81*7c478bd9Sstevel@tonic-gate 	XLATOR_KW_FUNC,
82*7c478bd9Sstevel@tonic-gate 	XLATOR_KW_DATA,
83*7c478bd9Sstevel@tonic-gate 	XLATOR_KW_END
84*7c478bd9Sstevel@tonic-gate };
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate /* Library Type */
87*7c478bd9Sstevel@tonic-gate #define	NORMALLIB 0
88*7c478bd9Sstevel@tonic-gate #define	FILTERLIB 1
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /* Maxmimum levels of extends */
91*7c478bd9Sstevel@tonic-gate #define	MAX_EXTENDS 16
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /* Architecture Bitmap */
94*7c478bd9Sstevel@tonic-gate #define	XLATOR_SPARC	0x01
95*7c478bd9Sstevel@tonic-gate #define	XLATOR_SPARCV9	0x02
96*7c478bd9Sstevel@tonic-gate #define	XLATOR_I386	0x04
97*7c478bd9Sstevel@tonic-gate #define	XLATOR_IA64	0x08
98*7c478bd9Sstevel@tonic-gate #define	XLATOR_AMD64	0x10
99*7c478bd9Sstevel@tonic-gate #define	XLATOR_ALLARCH	0xFF
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate extern xlator_keyword_t *keywordlist;
102*7c478bd9Sstevel@tonic-gate extern char **filelist;
103*7c478bd9Sstevel@tonic-gate extern int verbosity;
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate extern int frontend(const Translator_info *);
106*7c478bd9Sstevel@tonic-gate extern int do_extends(const Meta_info, const Translator_info *, char *);
107*7c478bd9Sstevel@tonic-gate extern void split(const char *, char *, char *);
108*7c478bd9Sstevel@tonic-gate extern void remcomment(char const *);
109*7c478bd9Sstevel@tonic-gate extern void getlinecont(char *, char *, int, FILE *, Meta_info *);
110*7c478bd9Sstevel@tonic-gate extern char *line_to_buf(char *, const char *);
111*7c478bd9Sstevel@tonic-gate extern int non_empty(const char *);
112*7c478bd9Sstevel@tonic-gate extern int check4extends(const char *, const char *, int, FILE *);
113*7c478bd9Sstevel@tonic-gate extern int interesting_keyword(xlator_keyword_t *, const char *);
114*7c478bd9Sstevel@tonic-gate extern int arch_strtoi(const char *);
115*7c478bd9Sstevel@tonic-gate extern int readline(char **, FILE *);
116*7c478bd9Sstevel@tonic-gate extern int arch_match(FILE *, int);
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /* xlator_ functions */
119*7c478bd9Sstevel@tonic-gate extern xlator_keyword_t *xlator_init(const Translator_info *);
120*7c478bd9Sstevel@tonic-gate extern int xlator_startlib(char const *libname);
121*7c478bd9Sstevel@tonic-gate extern int xlator_startfile(char const *filename);
122*7c478bd9Sstevel@tonic-gate extern int xlator_start_if(const Meta_info meta_info, const int token,
123*7c478bd9Sstevel@tonic-gate     char *value);
124*7c478bd9Sstevel@tonic-gate extern int xlator_take_kvpair(const Meta_info, const int token, char *value);
125*7c478bd9Sstevel@tonic-gate extern int xlator_end_if(const Meta_info, const char *value);
126*7c478bd9Sstevel@tonic-gate extern int xlator_endfile(void);
127*7c478bd9Sstevel@tonic-gate extern int xlator_endlib(void);
128*7c478bd9Sstevel@tonic-gate extern int xlator_end(void);
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
131*7c478bd9Sstevel@tonic-gate }
132*7c478bd9Sstevel@tonic-gate #endif
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate #endif	/* _PARSER_H */
135