1 /*
2 **
3 ** Aaa_intern.h
4 **
5 ** Copyright (C) 1995, 1996, 1997 Johannes Plass
6 ** Copyright (C) 2004 Jose E. Marchesi
7 **
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 3 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with GNU gv; see the file COPYING.  If not, write to
20 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ** Boston, MA 02111-1307, USA.
22 **
23 ** Authors:   Johannes Plass (plass@thep.physik.uni-mainz.de)
24 **            Department of Physics
25 **            Johannes Gutenberg-University
26 **            Mainz, Germany
27 **
28 **            Jose E. Marchesi (jemarch@gnu.org)
29 **            GNU Project
30 **
31 */
32 
33 #ifndef	_AAA_INTERN_H_
34 #define	_AAA_INTERN_H_
35 
36 /*
37 #define MESSAGES
38 #define MEMDEBUG
39 */
40 
41 /*---------------------------------------------------------*/
42 /* Include */
43 /*---------------------------------------------------------*/
44 
45 #include    <stdio.h>
46 #include    <stdlib.h>
47 
48 #include    "paths.h"
49 #include    INC_X11(Xlib.h)
50 #include    INC_X11(Xresource.h)
51 #include    INC_X11(IntrinsicP.h)
52 #include    INC_X11(cursorfont.h)
53 #include    INC_X11(StringDefs.h)
54 
55 #include    INC_XMU(Misc.h)
56 #include    INC_XMU(Converters.h)
57 #define DESTROY_EXPLICITLY
58 #include    "AaaP.h"
59 
60 #ifdef MEMDEBUG
61 #   define MESSAGES
62 #endif
63 
64 #include    "message.h"
65 
66 #ifdef MEMDEBUG
67 #   define MEMMESSAGE(sss)      INFMESSAGE(sss)
68 #   define MEMBEGINMESSAGE(sss) BEGINMESSAGE(sss)
69 #   define MEMENDMESSAGE(sss)   ENDMESSAGE(sss)
70 #else
71 #   define MEMMESSAGE(sss)
72 #   define MEMBEGINMESSAGE(sss)
73 #   define MEMENDMESSAGE(sss)
74 #endif
75 
76 /*---------------------------------------------------------*/
77 /* Bison Configuration */
78 /*---------------------------------------------------------*/
79 
80 typedef union {
81     int		    ival;
82     XrmQuark	    qval;
83     BoxPtr	    bval;
84     BoxParamsPtr    pval;
85     GlueRec	    gval;
86     LayoutDirection lval;
87     ExprPtr	    eval;
88     Operator	    oval;
89 } YYSTYPE;
90 
91 typedef struct _LayoutConverterStruct {
92    String    base;
93    String    oldfrom;
94    String    from;
95    LayoutPtr *to;
96 }  LayoutConverterStruct, *LayoutConverterArg;
97 
98 #define YYPARSE_PARAM  layoutConverterArg
99 #define YYLEX_PARAM    layoutConverterArg
100 
101 /* ###todo###
102    Currently I have no time to take care of alloca used in the dynamic stack
103    extension, therefore we just show a polite message and exit in case a stack
104    overflow occurs ###jp###.
105    By the way, YYINITDEPTH=200 is already pretty much, I never got a stack size
106    larger than 40 with the layouts I use. ###jp###
107 */
108 #define YYINITDEPTH 200
109 #define yyoverflow(a1,a2,a3,a4,a5,a6)				\
110 {								\
111    fprintf(stderr,"yyoverflow: stack overflow\n");		\
112    fprintf(stderr,"   maximal stacksize: %d\n",yystacksize);	\
113    fprintf(stderr,"   used             : %d\n",size);		\
114    fprintf(stderr,"Overflow forces image exit, bye bye.\n");	\
115    exit(0);						        \
116 }
117 
118 extern int layout_parse (void *);
119 extern void layout_scan_error (char *, void *);
120 extern int layout_lex (YYSTYPE *, void *);
121 
122 #define layout_error(sss)       layout_scan_error(sss,YYLEX_PARAM)
123 
124 /*---------------------------------------------------------*/
125 /* Macros */
126 /*---------------------------------------------------------*/
127 
128 #define New(ttt)      (ttt *) XtMalloc(sizeof(ttt))
129 #define Dispose(xxx)  XtFree((XtPointer)xxx)
130 #define Some(ttt,nnn) (ttt *) XtMalloc(sizeof(ttt)*nnn)
131 #define More(xxx,ttt,nnn)   (			\
132  (xxx) ?					\
133  (ttt *) XtRealloc(xxx,sizeof(ttt)*nnn) :	\
134  (ttt *) XtMalloc(sizeof(ttt)*nnn)		\
135 )
136 
137 #define GlueEqual(a,b)			\
138  ( (a).order == (b).order && (a).value == (b).value )
139 
140 #define AddGlue(r,a,b)			\
141    if (a.order == b.order) {		\
142       r.order = a.order;		\
143       r.value = a.value + b.value;	\
144    } else {				\
145       if (a.order > b.order) r = a;	\
146       else                   r = b;	\
147    }
148 
149 #define MinGlue(r,b)				\
150    if (r.order == b.order) {			\
151       if (r.value > b.value) r.value = b.value;	\
152    } else {					\
153       if (r.order > b.order) r = b;		\
154    }
155 
156 #define SubGlue(r,a,b)			\
157    if (a.order == b.order) {		\
158       r.order = a.order;		\
159       r.value = a.value - b.value;	\
160    } else {				\
161       if (a.order > b.order)		\
162          r = a;				\
163       else {				\
164          r.order = b.order;		\
165          r.value = -b.value;		\
166       }					\
167    }
168 
169 #define ZeroGlue(g)	((g).value = 0, (g).order = 0, (g).expr = 0)
170 #define IsZeroGlue(g)	((g).value == 0)
171 
172 #define QuarkToWidget(l,q)  XtNameToWidget((Widget) l, (char *) XrmQuarkToString(q))
173 
174 #endif /* _AAA_INTERN_H_ */
175