dtudcfonted: Resolve CID 86280
[oweals/cde.git] / cde / config / makedepend / ifparser.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  * $XConsortium: ifparser.h /main/4 1996/09/28 16:15:24 rws $
25  *
26  * Copyright 1992 Network Computing Devices, Inc.
27  * 
28  * Permission to use, copy, modify, and distribute this software and its
29  * documentation for any purpose and without fee is hereby granted, provided
30  * that the above copyright notice appear in all copies and that both that
31  * copyright notice and this permission notice appear in supporting
32  * documentation, and that the name of Network Computing Devices may not be
33  * used in advertising or publicity pertaining to distribution of the software
34  * without specific, written prior permission.  Network Computing Devices makes
35  * no representations about the suitability of this software for any purpose.
36  * It is provided ``as is'' without express or implied warranty.
37  * 
38  * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
39  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
40  * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
41  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
42  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
43  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
44  * PERFORMANCE OF THIS SOFTWARE.
45  * 
46  * Author:  Jim Fulton
47  *          Network Computing Devices, Inc.
48  * 
49  * Simple if statement processor
50  *
51  * This module can be used to evaluate string representations of C language
52  * if constructs.  It accepts the following grammar:
53  * 
54  *     EXPRESSION       :=      VALUE
55  *                       |      VALUE  BINOP    EXPRESSION
56  * 
57  *     VALUE            :=      '('  EXPRESSION  ')'
58  *                       |      '!'  VALUE
59  *                       |      '-'  VALUE
60  *                       |      'defined'  '('  variable  ')'
61  *                       |      variable
62  *                       |      number
63  * 
64  *     BINOP            :=      '*'     |  '/'  |  '%'
65  *                       |      '+'     |  '-'
66  *                       |      '<<'    |  '>>'
67  *                       |      '<'     |  '>'  |  '<='  |  '>='
68  *                       |      '=='    |  '!='
69  *                       |      '&'     |  '|'
70  *                       |      '&&'    |  '||'
71  * 
72  * The normal C order of precidence is supported.
73  * 
74  * 
75  * External Entry Points:
76  * 
77  *     ParseIfExpression                parse a string for #if
78  */
79
80 #include <stdlib.h>
81 #include <stdio.h>
82
83 #define const /**/
84 typedef int Bool;
85 #define False 0
86 #define True 1
87
88 typedef struct _if_parser {
89     struct {                            /* functions */
90         char *(*handle_error) (/* struct _if_parser *, const char *,
91                                  const char * */);
92         long (*eval_variable) (/* struct _if_parser *, const char *, int */);
93         int (*eval_defined) (/* struct _if_parser *, const char *, int */);
94     } funcs;
95     char *data;
96 } IfParser;
97
98 char *ParseIfExpression (
99 #ifdef __STDC__
100     IfParser *, 
101     const char *, 
102     long *
103 #endif
104 );
105