/[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.7 - (hide annotations)
Sat Mar 10 02:54:39 2001 UTC (16 years, 7 months ago) by bertho
Branch: MAIN
CVS Tags: REL_1_1_1, REL_1_1_3, REL_1_1_2
Changes since 1.6: +20 -3 lines
- Fixed path problems. Cvsroot and module will always have a
  trailing '/' if they are not empty so that simple files
  can be addressed directly from the commandline. This also
  eases expansions.
- Implemented new features:
	* revisions can have custom text
	* background colors of boxes working
	* boxes can have shadow (looks nice)
	* imagemaps generate diff areas between revisions
- Several new config parameters to support above functionality.
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 bertho 1.5 static const char err_semicolon[] = "Missing ';'";
44     static const char err_assign[] = "Missing '='";
45    
46 bertho 1.1 %}
47    
48     %union{
49     char *str;
50     int num;
51     }
52    
53 bertho 1.5 %token tBRANCH_BGCOLOR tBRANCH_BSPACE tBRANCH_COLOR tBRANCH_FONT tBRANCH_LSPACE tBRANCH_RSPACE tBRANCH_TSPACE
54     %token tBRANCH_CONNECT tBRANCH_MARGIN
55 bertho 1.7 %token tCOLOR_BG tCVSMODULE tCVSROOT tDATE_FORMAT tBOX_SHADOW
56     %token tREV_COLOR tREV_BGCOLOR tREV_FONT tREV_SEPARATOR tREV_MINLINE tREV_MAXLINE tREV_LSPACE
57     %token tREV_RSPACE tREV_TSPACE tREV_BSPACE tREV_TEXT tREV_TEXT_COLOR tREV_TEXT_FONT
58 bertho 1.1 %token tTAG_COLOR tTAG_FONT
59     %token tTITLE tTITLE_X tTITLE_Y tTITLE_FONT tTITLE_ALIGN tTITLE_COLOR
60     %token tMARGIN_TOP tMARGIN_BOTTOM tMARGIN_LEFT tMARGIN_RIGHT
61 bertho 1.3 %token tIMAGE_TYPE tIMAGE_QUALITY
62 bertho 1.7 %token tMAP_NAME tMAP_BRANCH_HREF tMAP_BRANCH_ALT tMAP_REV_HREF tMAP_REV_ALT tMAP_DIFF_HREF tMAP_DIFF_ALT
63 bertho 1.5 %token <str> tUNKNOWN
64 bertho 1.1 %token <str> tSTRING
65     %token <num> tNUMBER
66    
67     %type <num> ikey skey ckey
68    
69     %%
70     conffile: /* Empty */
71     | lines
72     ;
73    
74     lines : line
75     | lines line
76     ;
77    
78 bertho 1.5 line : ikey '=' tNUMBER ';' { assign_num($1, $3); }
79     | ikey '=' tNUMBER error { yyerror(err_semicolon); }
80 bertho 1.1 | ikey '=' error { yyerror("Number expected"); }
81 bertho 1.5 | ikey error { yyerror(err_assign); }
82     | skey '=' tSTRING ';' { assign_str($1, $3); }
83     | skey '=' tSTRING error { yyerror(err_semicolon); }
84 bertho 1.1 | skey '=' error { yyerror("String expected"); }
85 bertho 1.5 | skey error { yyerror(err_assign); }
86     | ckey '=' tSTRING ';' { assign_color($1, $3); }
87     | ckey '=' tSTRING error { yyerror(err_semicolon); }
88 bertho 1.1 | ckey '=' error { yyerror("Color-string expected"); }
89 bertho 1.5 | ckey error { yyerror(err_assign); }
90     | tUNKNOWN '=' notsc ';' { yywarning("Unknown config parameter '%s' ignored", $1); xfree($1); }
91     | tUNKNOWN '=' notsc error { yyerror(err_semicolon); }
92     | tUNKNOWN '=' error { yyerror("String or number expected"); }
93     | tUNKNOWN error { yyerror(err_assign); }
94 bertho 1.1 | error { yyerror("Keyword expected"); }
95     ;
96    
97 bertho 1.5 notsc : tSTRING { xfree($1); }
98     | tNUMBER {}
99     ;
100    
101 bertho 1.1 ikey : tBRANCH_FONT { $$ = tBRANCH_FONT; }
102     | tBRANCH_LSPACE { $$ = tBRANCH_LSPACE; }
103     | tBRANCH_RSPACE { $$ = tBRANCH_RSPACE; }
104     | tBRANCH_TSPACE { $$ = tBRANCH_TSPACE; }
105     | tBRANCH_BSPACE { $$ = tBRANCH_BSPACE; }
106 bertho 1.5 | tBRANCH_CONNECT { $$ = tBRANCH_CONNECT; }
107     | tBRANCH_MARGIN { $$ = tBRANCH_MARGIN; }
108 bertho 1.1 | tREV_FONT { $$ = tREV_FONT; }
109     | tREV_SEPARATOR { $$ = tREV_SEPARATOR; }
110     | tREV_MINLINE { $$ = tREV_MINLINE; }
111     | tREV_MAXLINE { $$ = tREV_MAXLINE; }
112     | tREV_LSPACE { $$ = tREV_LSPACE; }
113     | tREV_RSPACE { $$ = tREV_RSPACE; }
114     | tREV_TSPACE { $$ = tREV_TSPACE; }
115     | tREV_BSPACE { $$ = tREV_BSPACE; }
116 bertho 1.7 | tREV_TEXT_FONT { $$ = tREV_TEXT_FONT; }
117 bertho 1.1 | tTAG_FONT { $$ = tTAG_FONT; }
118     | tTITLE_X { $$ = tTITLE_X; }
119     | tTITLE_Y { $$ = tTITLE_Y; }
120     | tTITLE_FONT { $$ = tTITLE_FONT; }
121     | tTITLE_ALIGN { $$ = tTITLE_ALIGN; }
122     | tMARGIN_TOP { $$ = tMARGIN_TOP; }
123     | tMARGIN_BOTTOM { $$ = tMARGIN_BOTTOM; }
124     | tMARGIN_LEFT { $$ = tMARGIN_LEFT; }
125     | tMARGIN_RIGHT { $$ = tMARGIN_RIGHT; }
126 bertho 1.3 | tIMAGE_TYPE { $$ = tIMAGE_TYPE; }
127     | tIMAGE_QUALITY { $$ = tIMAGE_QUALITY; }
128 bertho 1.7 | tBOX_SHADOW { $$ = tBOX_SHADOW; }
129 bertho 1.1 ;
130    
131 bertho 1.5 skey : tCVSMODULE { $$ = tCVSMODULE; }
132 bertho 1.1 | tCVSROOT { $$ = tCVSROOT; }
133     | tTITLE { $$ = tTITLE; }
134 bertho 1.7 | tDATE_FORMAT { $$ = tDATE_FORMAT; }
135 bertho 1.4 | tMAP_NAME { $$ = tMAP_NAME; }
136 bertho 1.6 | tMAP_BRANCH_HREF { $$ = tMAP_BRANCH_HREF; }
137     | tMAP_BRANCH_ALT { $$ = tMAP_BRANCH_ALT; }
138     | tMAP_REV_HREF { $$ = tMAP_REV_HREF; }
139     | tMAP_REV_ALT { $$ = tMAP_REV_ALT; }
140 bertho 1.7 | tMAP_DIFF_HREF { $$ = tMAP_DIFF_HREF; }
141     | tMAP_DIFF_ALT { $$ = tMAP_DIFF_ALT; }
142     | tREV_TEXT { $$ = tREV_TEXT; }
143 bertho 1.1 ;
144    
145     ckey : tCOLOR_BG { $$ = tCOLOR_BG; }
146     | tBRANCH_BGCOLOR { $$ = tBRANCH_BGCOLOR; }
147     | tBRANCH_COLOR { $$ = tBRANCH_COLOR; }
148     | tREV_COLOR { $$ = tREV_COLOR; }
149 bertho 1.7 | tREV_BGCOLOR { $$ = tREV_BGCOLOR; }
150     | tREV_TEXT_COLOR { $$ = tREV_TEXT_COLOR; }
151 bertho 1.1 | tTAG_COLOR { $$ = tTAG_COLOR; }
152     | tTITLE_COLOR { $$ = tTITLE_COLOR; }
153     ;
154    
155     %%
156    
157     static gdFontPtr get_font(int id)
158     {
159     switch(id)
160     {
161     case 0: return gdFontTiny;
162     case 1: return gdFontSmall;
163     default:
164     case 2: return gdFontMediumBold;
165     case 3: return gdFontLarge;
166     case 4: return gdFontGiant;
167     }
168     }
169    
170 bertho 1.3 static int bounds(int val, int mini, int maxi)
171     {
172     if(val < mini || val > maxi)
173     {
174     yywarning("Parameter must be between %d and %d", mini, maxi);
175     val = val < mini ? mini : maxi;
176     }
177     return val;
178     }
179    
180 bertho 1.1 static void assign_num(int key, int val)
181     {
182     switch(key)
183     {
184     case tBRANCH_FONT: conf.branch_font = get_font(val); break;
185     case tBRANCH_LSPACE: conf.branch_lspace = val; break;
186     case tBRANCH_RSPACE: conf.branch_rspace = val; break;
187     case tBRANCH_TSPACE: conf.branch_tspace = val; break;
188     case tBRANCH_BSPACE: conf.branch_bspace = val; break;
189 bertho 1.5 case tBRANCH_CONNECT: conf.branch_connect = val; break;
190     case tBRANCH_MARGIN: conf.branch_margin = val; break;
191 bertho 1.1 case tREV_FONT: conf.rev_font = get_font(val); break;
192     case tREV_SEPARATOR: conf.rev_separator = val; break;
193     case tREV_MINLINE: conf.rev_minline = val; break;
194     case tREV_MAXLINE: conf.rev_maxline = val; break;
195     case tREV_LSPACE: conf.rev_lspace = val; break;
196     case tREV_RSPACE: conf.rev_rspace = val; break;
197     case tREV_TSPACE: conf.rev_tspace = val; break;
198     case tREV_BSPACE: conf.rev_bspace = val; break;
199 bertho 1.7 case tREV_TEXT_FONT: conf.rev_text_font = get_font(val); break;
200 bertho 1.1 case tTAG_FONT: conf.tag_font = get_font(val); break;
201     case tTITLE_X: conf.title_x = val; break;
202     case tTITLE_Y: conf.title_y = val; break;
203     case tTITLE_FONT: conf.title_font = get_font(val); break;
204     case tTITLE_ALIGN: conf.title_align = val; break;
205     case tMARGIN_TOP: conf.margin_top = val; break;
206     case tMARGIN_BOTTOM: conf.margin_bottom = val; break;
207     case tMARGIN_LEFT: conf.margin_left = val; break;
208     case tMARGIN_RIGHT: conf.margin_right = val; break;
209 bertho 1.3 case tIMAGE_TYPE: conf.image_type = val; break;
210     case tIMAGE_QUALITY: conf.image_quality = bounds(val, 1, 100); break;
211 bertho 1.7 case tBOX_SHADOW: conf.box_shadow = val; break;
212 bertho 1.1 default:
213     yyerror("internal: Invalid num key %d -> %d", key, val);
214     }
215     }
216    
217     static void assign_str(int key, char *str)
218     {
219     switch(key)
220     {
221     case tCVSMODULE: conf.cvsmodule = str; break;
222     case tCVSROOT: conf.cvsroot = str; break;
223     case tTITLE: conf.title = str; break;
224 bertho 1.7 case tDATE_FORMAT: conf.date_format = str; break;
225 bertho 1.4 case tMAP_NAME: conf.map_name = str; break;
226 bertho 1.6 case tMAP_BRANCH_HREF: conf.map_branch_href = str; break;
227     case tMAP_BRANCH_ALT: conf.map_branch_alt = str; break;
228     case tMAP_REV_HREF: conf.map_rev_href = str; break;
229     case tMAP_REV_ALT: conf.map_rev_alt = str; break;
230 bertho 1.7 case tMAP_DIFF_HREF: conf.map_diff_href = str; break;
231     case tMAP_DIFF_ALT: conf.map_diff_alt = str; break;
232     case tREV_TEXT: conf.rev_text = str; break;
233 bertho 1.1 default:
234     yyerror("internal: Invalid string key %d -> '%s'", key, str);
235     }
236     }
237    
238     static void set_color(color_t *c, char *s)
239     {
240     char *cptr;
241     if(*s != '#' || strlen(s) != 7)
242     {
243     colorerror:
244     yyerror("Invalid color value");
245     }
246     c->b = strtol(s+5, &cptr, 16);
247     if(*cptr)
248     goto colorerror;
249     s[5] = '\0';
250     c->g = strtol(s+3, &cptr, 16);
251     if(*cptr)
252     goto colorerror;
253     s[3] = '\0';
254     c->r = strtol(s+1, &cptr, 16);
255     if(*cptr)
256     goto colorerror;
257     }
258    
259     static void assign_color(int key, char *str)
260     {
261     switch(key)
262     {
263     case tCOLOR_BG: set_color(&conf.color_bg, str); break;
264     case tBRANCH_BGCOLOR: set_color(&conf.branch_bgcolor, str); break;
265     case tBRANCH_COLOR: set_color(&conf.branch_color, str); break;
266     case tREV_COLOR: set_color(&conf.rev_color, str); break;
267 bertho 1.7 case tREV_BGCOLOR: set_color(&conf.rev_bgcolor, str); break;
268     case tREV_TEXT_COLOR: set_color(&conf.rev_text_color, str); break;
269 bertho 1.1 case tTAG_COLOR: set_color(&conf.tag_color, str); break;
270     case tTITLE_COLOR: set_color(&conf.title_color, str); break;
271     default:
272     yyerror("internal: Invalid color key %d -> '%s'", key, str);
273     }
274     xfree(str);
275     }
276    

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0