/[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.2 - (show annotations)
Fri Feb 23 00:16:25 2001 UTC (16 years, 7 months ago) by bertho
Branch: MAIN
Changes since 1.1: +1 -0 lines
Fix warning about strlen() becuase of missing include.
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 #include <string.h>
26
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 %token <str> tSTRING
57 %token <num> tNUMBER
58
59 %type <num> ikey skey ckey
60
61 %%
62 conffile: /* Empty */
63 | lines
64 ;
65
66 lines : line
67 | lines line
68 ;
69
70 line : ikey '=' tNUMBER ';' {
71 assign_num($1, $3);
72 }
73 | ikey '=' tNUMBER error { yyerror("Missing ';'"); }
74 | ikey '=' error { yyerror("Number expected"); }
75 | ikey error { yyerror("Missing '='"); }
76 | skey '=' tSTRING ';' {
77 assign_str($1, $3);
78 }
79 | skey '=' tSTRING error { yyerror("Missing ';'"); }
80 | skey '=' error { yyerror("String expected"); }
81 | skey error { yyerror("Missing '='"); }
82 | ckey '=' tSTRING ';' {
83 assign_color($1, $3);
84 }
85 | ckey '=' tSTRING error { yyerror("Missing ';'"); }
86 | ckey '=' error { yyerror("Color-string expected"); }
87 | ckey error { yyerror("Missing '='"); }
88 | error { yyerror("Keyword expected"); }
89 ;
90
91 ikey : tBRANCH_FONT { $$ = tBRANCH_FONT; }
92 | tBRANCH_LSPACE { $$ = tBRANCH_LSPACE; }
93 | tBRANCH_RSPACE { $$ = tBRANCH_RSPACE; }
94 | tBRANCH_TSPACE { $$ = tBRANCH_TSPACE; }
95 | tBRANCH_BSPACE { $$ = tBRANCH_BSPACE; }
96 | tBRANCH_SEPARATOR { $$ = tBRANCH_SEPARATOR; }
97 | tREV_FONT { $$ = tREV_FONT; }
98 | tREV_SEPARATOR { $$ = tREV_SEPARATOR; }
99 | tREV_MINLINE { $$ = tREV_MINLINE; }
100 | tREV_MAXLINE { $$ = tREV_MAXLINE; }
101 | tREV_LSPACE { $$ = tREV_LSPACE; }
102 | tREV_RSPACE { $$ = tREV_RSPACE; }
103 | tREV_TSPACE { $$ = tREV_TSPACE; }
104 | tREV_BSPACE { $$ = tREV_BSPACE; }
105 | tTAG_FONT { $$ = tTAG_FONT; }
106 | tTITLE_X { $$ = tTITLE_X; }
107 | tTITLE_Y { $$ = tTITLE_Y; }
108 | tTITLE_FONT { $$ = tTITLE_FONT; }
109 | tTITLE_ALIGN { $$ = tTITLE_ALIGN; }
110 | tMARGIN_TOP { $$ = tMARGIN_TOP; }
111 | tMARGIN_BOTTOM { $$ = tMARGIN_BOTTOM; }
112 | tMARGIN_LEFT { $$ = tMARGIN_LEFT; }
113 | tMARGIN_RIGHT { $$ = tMARGIN_RIGHT; }
114 ;
115
116 skey : tCMD_RLOG { $$ = tCMD_RLOG; }
117 | tCVSMODULE { $$ = tCVSMODULE; }
118 | tCVSROOT { $$ = tCVSROOT; }
119 | tTITLE { $$ = tTITLE; }
120 ;
121
122 ckey : tCOLOR_BG { $$ = tCOLOR_BG; }
123 | tBRANCH_BGCOLOR { $$ = tBRANCH_BGCOLOR; }
124 | tBRANCH_COLOR { $$ = tBRANCH_COLOR; }
125 | tREV_COLOR { $$ = tREV_COLOR; }
126 | tTAG_COLOR { $$ = tTAG_COLOR; }
127 | tTITLE_COLOR { $$ = tTITLE_COLOR; }
128 ;
129
130 %%
131
132 static gdFontPtr get_font(int id)
133 {
134 switch(id)
135 {
136 case 0: return gdFontTiny;
137 case 1: return gdFontSmall;
138 default:
139 case 2: return gdFontMediumBold;
140 case 3: return gdFontLarge;
141 case 4: return gdFontGiant;
142 }
143 }
144
145 static void assign_num(int key, int val)
146 {
147 switch(key)
148 {
149 case tBRANCH_FONT: conf.branch_font = get_font(val); break;
150 case tBRANCH_LSPACE: conf.branch_lspace = val; break;
151 case tBRANCH_RSPACE: conf.branch_rspace = val; break;
152 case tBRANCH_TSPACE: conf.branch_tspace = val; break;
153 case tBRANCH_BSPACE: conf.branch_bspace = val; break;
154 case tBRANCH_SEPARATOR: conf.branch_separator = val; break;
155 case tREV_FONT: conf.rev_font = get_font(val); break;
156 case tREV_SEPARATOR: conf.rev_separator = val; break;
157 case tREV_MINLINE: conf.rev_minline = val; break;
158 case tREV_MAXLINE: conf.rev_maxline = val; break;
159 case tREV_LSPACE: conf.rev_lspace = val; break;
160 case tREV_RSPACE: conf.rev_rspace = val; break;
161 case tREV_TSPACE: conf.rev_tspace = val; break;
162 case tREV_BSPACE: conf.rev_bspace = val; break;
163 case tTAG_FONT: conf.tag_font = get_font(val); break;
164 case tTITLE_X: conf.title_x = val; break;
165 case tTITLE_Y: conf.title_y = val; break;
166 case tTITLE_FONT: conf.title_font = get_font(val); break;
167 case tTITLE_ALIGN: conf.title_align = val; break;
168 case tMARGIN_TOP: conf.margin_top = val; break;
169 case tMARGIN_BOTTOM: conf.margin_bottom = val; break;
170 case tMARGIN_LEFT: conf.margin_left = val; break;
171 case tMARGIN_RIGHT: conf.margin_right = val; break;
172 default:
173 yyerror("internal: Invalid num key %d -> %d", key, val);
174 }
175 }
176
177 static void assign_str(int key, char *str)
178 {
179 switch(key)
180 {
181 case tCMD_RLOG: conf.cmd_rlog = str; break;
182 case tCVSMODULE: conf.cvsmodule = str; break;
183 case tCVSROOT: conf.cvsroot = str; break;
184 case tTITLE: conf.title = str; break;
185 default:
186 yyerror("internal: Invalid string key %d -> '%s'", key, str);
187 }
188 }
189
190 static void set_color(color_t *c, char *s)
191 {
192 char *cptr;
193 if(*s != '#' || strlen(s) != 7)
194 {
195 colorerror:
196 yyerror("Invalid color value");
197 }
198 c->b = strtol(s+5, &cptr, 16);
199 if(*cptr)
200 goto colorerror;
201 s[5] = '\0';
202 c->g = strtol(s+3, &cptr, 16);
203 if(*cptr)
204 goto colorerror;
205 s[3] = '\0';
206 c->r = strtol(s+1, &cptr, 16);
207 if(*cptr)
208 goto colorerror;
209 }
210
211 static void assign_color(int key, char *str)
212 {
213 switch(key)
214 {
215 case tCOLOR_BG: set_color(&conf.color_bg, str); break;
216 case tBRANCH_BGCOLOR: set_color(&conf.branch_bgcolor, str); break;
217 case tBRANCH_COLOR: set_color(&conf.branch_color, str); break;
218 case tREV_COLOR: set_color(&conf.rev_color, str); break;
219 case tTAG_COLOR: set_color(&conf.tag_color, str); break;
220 case tTITLE_COLOR: set_color(&conf.title_color, str); break;
221 default:
222 yyerror("internal: Invalid color key %d -> '%s'", key, str);
223 }
224 xfree(str);
225 }
226

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0