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

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0