/[CvsGraph]/cvsgraph/confy.y
ViewVC logotype

Annotate of /cvsgraph/confy.y

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations)
Mon Feb 26 00:09:20 2001 UTC (16 years, 7 months ago) by bertho
Branch: MAIN
Changes since 1.3: +7 -0 lines
- Fixed the recursion problem so that branches of branches are properly placed.
- Fixed a lonely '+' in an expression.
- Started to make an imagemap functionality (not very functional yet)
1 bertho 1.1 /*
2     * CvsGraph graphical representation generator of brances and revisions
3     * of a file in cvs/rcs.
4     *
5     * Copyright (C) 2001 B. Stultiens
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20     */
21    
22     %{
23     #include <stdio.h>
24     #include <stdlib.h>
25 bertho 1.2 #include <string.h>
26 bertho 1.1
27     #include <gd.h>
28     #include <gdfontt.h>
29     #include <gdfonts.h>
30     #include <gdfontmb.h>
31     #include <gdfontl.h>
32     #include <gdfontg.h>
33    
34     #include "cvsgraph.h"
35     #include "utils.h"
36     #include "readconf.h"
37    
38    
39     static void assign_num(int key, int val);
40     static void assign_str(int key, char *str);
41     static void assign_color(int key, char *str);
42    
43     %}
44    
45     %union{
46     char *str;
47     int num;
48     }
49    
50     %token tBRANCH_BGCOLOR tBRANCH_BSPACE tBRANCH_COLOR tBRANCH_FONT tBRANCH_LSPACE tBRANCH_RSPACE tBRANCH_TSPACE tBRANCH_SEPARATOR
51     %token tCMD_RLOG tCOLOR_BG tCVSMODULE tCVSROOT
52     %token tREV_COLOR tREV_FONT tREV_SEPARATOR tREV_MINLINE tREV_MAXLINE tREV_LSPACE tREV_RSPACE tREV_TSPACE tREV_BSPACE
53     %token tTAG_COLOR tTAG_FONT
54     %token tTITLE tTITLE_X tTITLE_Y tTITLE_FONT tTITLE_ALIGN tTITLE_COLOR
55     %token tMARGIN_TOP tMARGIN_BOTTOM tMARGIN_LEFT tMARGIN_RIGHT
56 bertho 1.3 %token tIMAGE_TYPE tIMAGE_QUALITY
57 bertho 1.4 %token tMAP_NAME tMAP_BRANCH tMAP_REV
58 bertho 1.1 %token <str> tSTRING
59     %token <num> tNUMBER
60    
61     %type <num> ikey skey ckey
62    
63     %%
64     conffile: /* Empty */
65     | lines
66     ;
67    
68     lines : line
69     | lines line
70     ;
71    
72     line : ikey '=' tNUMBER ';' {
73     assign_num($1, $3);
74     }
75     | ikey '=' tNUMBER error { yyerror("Missing ';'"); }
76     | ikey '=' error { yyerror("Number expected"); }
77     | ikey error { yyerror("Missing '='"); }
78     | skey '=' tSTRING ';' {
79     assign_str($1, $3);
80     }
81     | skey '=' tSTRING error { yyerror("Missing ';'"); }
82     | skey '=' error { yyerror("String expected"); }
83     | skey error { yyerror("Missing '='"); }
84     | ckey '=' tSTRING ';' {
85     assign_color($1, $3);
86     }
87     | ckey '=' tSTRING error { yyerror("Missing ';'"); }
88     | ckey '=' error { yyerror("Color-string expected"); }
89     | ckey error { yyerror("Missing '='"); }
90     | error { yyerror("Keyword expected"); }
91     ;
92    
93     ikey : tBRANCH_FONT { $$ = tBRANCH_FONT; }
94     | tBRANCH_LSPACE { $$ = tBRANCH_LSPACE; }
95     | tBRANCH_RSPACE { $$ = tBRANCH_RSPACE; }
96     | tBRANCH_TSPACE { $$ = tBRANCH_TSPACE; }
97     | tBRANCH_BSPACE { $$ = tBRANCH_BSPACE; }
98     | tBRANCH_SEPARATOR { $$ = tBRANCH_SEPARATOR; }
99     | tREV_FONT { $$ = tREV_FONT; }
100     | tREV_SEPARATOR { $$ = tREV_SEPARATOR; }
101     | tREV_MINLINE { $$ = tREV_MINLINE; }
102     | tREV_MAXLINE { $$ = tREV_MAXLINE; }
103     | tREV_LSPACE { $$ = tREV_LSPACE; }
104     | tREV_RSPACE { $$ = tREV_RSPACE; }
105     | tREV_TSPACE { $$ = tREV_TSPACE; }
106     | tREV_BSPACE { $$ = tREV_BSPACE; }
107     | tTAG_FONT { $$ = tTAG_FONT; }
108     | tTITLE_X { $$ = tTITLE_X; }
109     | tTITLE_Y { $$ = tTITLE_Y; }
110     | tTITLE_FONT { $$ = tTITLE_FONT; }
111     | tTITLE_ALIGN { $$ = tTITLE_ALIGN; }
112     | tMARGIN_TOP { $$ = tMARGIN_TOP; }
113     | tMARGIN_BOTTOM { $$ = tMARGIN_BOTTOM; }
114     | tMARGIN_LEFT { $$ = tMARGIN_LEFT; }
115     | tMARGIN_RIGHT { $$ = tMARGIN_RIGHT; }
116 bertho 1.3 | tIMAGE_TYPE { $$ = tIMAGE_TYPE; }
117     | tIMAGE_QUALITY { $$ = tIMAGE_QUALITY; }
118 bertho 1.1 ;
119    
120     skey : tCMD_RLOG { $$ = tCMD_RLOG; }
121     | tCVSMODULE { $$ = tCVSMODULE; }
122     | tCVSROOT { $$ = tCVSROOT; }
123     | tTITLE { $$ = tTITLE; }
124 bertho 1.4 | tMAP_NAME { $$ = tMAP_NAME; }
125     | tMAP_BRANCH { $$ = tMAP_BRANCH; }
126     | tMAP_REV { $$ = tMAP_REV; }
127 bertho 1.1 ;
128    
129     ckey : tCOLOR_BG { $$ = tCOLOR_BG; }
130     | tBRANCH_BGCOLOR { $$ = tBRANCH_BGCOLOR; }
131     | tBRANCH_COLOR { $$ = tBRANCH_COLOR; }
132     | tREV_COLOR { $$ = tREV_COLOR; }
133     | tTAG_COLOR { $$ = tTAG_COLOR; }
134     | tTITLE_COLOR { $$ = tTITLE_COLOR; }
135     ;
136    
137     %%
138    
139     static gdFontPtr get_font(int id)
140     {
141     switch(id)
142     {
143     case 0: return gdFontTiny;
144     case 1: return gdFontSmall;
145     default:
146     case 2: return gdFontMediumBold;
147     case 3: return gdFontLarge;
148     case 4: return gdFontGiant;
149     }
150     }
151    
152 bertho 1.3 static int bounds(int val, int mini, int maxi)
153     {
154     if(val < mini || val > maxi)
155     {
156     yywarning("Parameter must be between %d and %d", mini, maxi);
157     val = val < mini ? mini : maxi;
158     }
159     return val;
160     }
161    
162 bertho 1.1 static void assign_num(int key, int val)
163     {
164     switch(key)
165     {
166     case tBRANCH_FONT: conf.branch_font = get_font(val); break;
167     case tBRANCH_LSPACE: conf.branch_lspace = val; break;
168     case tBRANCH_RSPACE: conf.branch_rspace = val; break;
169     case tBRANCH_TSPACE: conf.branch_tspace = val; break;
170     case tBRANCH_BSPACE: conf.branch_bspace = val; break;
171     case tBRANCH_SEPARATOR: conf.branch_separator = val; break;
172     case tREV_FONT: conf.rev_font = get_font(val); break;
173     case tREV_SEPARATOR: conf.rev_separator = val; break;
174     case tREV_MINLINE: conf.rev_minline = val; break;
175     case tREV_MAXLINE: conf.rev_maxline = val; break;
176     case tREV_LSPACE: conf.rev_lspace = val; break;
177     case tREV_RSPACE: conf.rev_rspace = val; break;
178     case tREV_TSPACE: conf.rev_tspace = val; break;
179     case tREV_BSPACE: conf.rev_bspace = val; break;
180     case tTAG_FONT: conf.tag_font = get_font(val); break;
181     case tTITLE_X: conf.title_x = val; break;
182     case tTITLE_Y: conf.title_y = val; break;
183     case tTITLE_FONT: conf.title_font = get_font(val); break;
184     case tTITLE_ALIGN: conf.title_align = val; break;
185     case tMARGIN_TOP: conf.margin_top = val; break;
186     case tMARGIN_BOTTOM: conf.margin_bottom = val; break;
187     case tMARGIN_LEFT: conf.margin_left = val; break;
188     case tMARGIN_RIGHT: conf.margin_right = val; break;
189 bertho 1.3 case tIMAGE_TYPE: conf.image_type = val; break;
190     case tIMAGE_QUALITY: conf.image_quality = bounds(val, 1, 100); break;
191 bertho 1.1 default:
192     yyerror("internal: Invalid num key %d -> %d", key, val);
193     }
194     }
195    
196     static void assign_str(int key, char *str)
197     {
198     switch(key)
199     {
200     case tCMD_RLOG: conf.cmd_rlog = str; break;
201     case tCVSMODULE: conf.cvsmodule = str; break;
202     case tCVSROOT: conf.cvsroot = str; break;
203     case tTITLE: conf.title = str; break;
204 bertho 1.4 case tMAP_NAME: conf.map_name = str; break;
205     case tMAP_BRANCH: conf.map_branch = str; break;
206     case tMAP_REV: conf.map_rev = str; break;
207 bertho 1.1 default:
208     yyerror("internal: Invalid string key %d -> '%s'", key, str);
209     }
210     }
211    
212     static void set_color(color_t *c, char *s)
213     {
214     char *cptr;
215     if(*s != '#' || strlen(s) != 7)
216     {
217     colorerror:
218     yyerror("Invalid color value");
219     }
220     c->b = strtol(s+5, &cptr, 16);
221     if(*cptr)
222     goto colorerror;
223     s[5] = '\0';
224     c->g = strtol(s+3, &cptr, 16);
225     if(*cptr)
226     goto colorerror;
227     s[3] = '\0';
228     c->r = strtol(s+1, &cptr, 16);
229     if(*cptr)
230     goto colorerror;
231     }
232    
233     static void assign_color(int key, char *str)
234     {
235     switch(key)
236     {
237     case tCOLOR_BG: set_color(&conf.color_bg, str); break;
238     case tBRANCH_BGCOLOR: set_color(&conf.branch_bgcolor, str); break;
239     case tBRANCH_COLOR: set_color(&conf.branch_color, str); break;
240     case tREV_COLOR: set_color(&conf.rev_color, str); break;
241     case tTAG_COLOR: set_color(&conf.tag_color, str); break;
242     case tTITLE_COLOR: set_color(&conf.title_color, str); break;
243     default:
244     yyerror("internal: Invalid color key %d -> '%s'", key, str);
245     }
246     xfree(str);
247     }
248    

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0