]>
Commit | Line | Data |
---|---|---|
23c9e63c DD |
1 | %{ |
2 | /* | |
3 | * Copyright (c) 2000, Red Hat, Inc. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * A copy of the GNU General Public License can be found at | |
11 | * http://www.gnu.org/ | |
12 | * | |
13 | * Written by DJ Delorie <dj@cygnus.com> | |
14 | * | |
15 | */ | |
16 | ||
17 | /* Parse the setup.ini files. inilex.l provides the tokens for this. */ | |
18 | ||
b11b49f3 | 19 | #include <stdio.h> |
23c9e63c DD |
20 | #include <stdlib.h> |
21 | ||
22 | #include "ini.h" | |
23 | #include "iniparse.h" | |
24 | ||
b11b49f3 DD |
25 | #define YYERROR_VERBOSE 1 |
26 | /*#define YYDEBUG 1*/ | |
27 | ||
23c9e63c DD |
28 | static Package *cp; |
29 | static int trust; | |
30 | extern unsigned int setup_timestamp; | |
b11b49f3 | 31 | extern int yylineno; |
23c9e63c DD |
32 | |
33 | #define cpt (cp->info+trust) | |
34 | ||
35 | %} | |
36 | ||
37 | %token STRING | |
38 | %token SETUP_TIMESTAMP VERSION INSTALL SOURCE SDESC LDESC | |
b11b49f3 | 39 | %token T_PREV T_CURR T_TEST T_UNKNOWN |
23c9e63c DD |
40 | |
41 | %% | |
42 | ||
43 | whole_file | |
44 | : setup_headers packages | |
45 | ; | |
46 | ||
47 | setup_headers | |
48 | : setup_header setup_headers | |
49 | | /* empty */ | |
50 | ; | |
51 | ||
52 | setup_header | |
53 | : SETUP_TIMESTAMP STRING '\n' { setup_timestamp = strtoul ($2, 0, 0); } | |
b11b49f3 | 54 | | error { yyerror ("unrecognized line in setup.ini headers"); } '\n' |
23c9e63c DD |
55 | ; |
56 | ||
57 | packages | |
58 | : package packages | |
59 | | /* empty */ | |
60 | ; | |
61 | ||
62 | package | |
63 | : '@' STRING '\n' { new_package($2); } | |
64 | lines | |
65 | | '\n' | |
66 | ; | |
67 | ||
68 | lines | |
69 | : simple_line '\n' lines | |
70 | | simple_line | |
71 | ; | |
72 | ||
73 | simple_line | |
74 | : VERSION STRING { cpt->version = $2; } | |
75 | | SDESC STRING { cp->sdesc = $2; } | |
76 | | LDESC STRING { cp->ldesc = $2; } | |
77 | | INSTALL STRING STRING { cpt->install = $2; | |
78 | cpt->install_size = atoi($3); } | |
79 | | SOURCE STRING STRING { cpt->source = $2; | |
80 | cpt->source_size = atoi($3); } | |
81 | | T_PREV { trust = TRUST_PREV; } | |
82 | | T_CURR { trust = TRUST_CURR; } | |
83 | | T_TEST { trust = TRUST_TEST; } | |
b11b49f3 | 84 | | T_UNKNOWN { trust = TRUST_UNKNOWN; } |
23c9e63c | 85 | | /* empty */ |
b11b49f3 DD |
86 | | error '\n' { yylineno --; |
87 | yyerror ("unrecognized line in package %s", cp->name); | |
88 | yylineno ++; | |
89 | } | |
23c9e63c DD |
90 | ; |
91 | ||
92 | %% | |
93 | ||
94 | Package *package = 0; | |
95 | int npackages = 0; | |
96 | static int maxpackages = 0; | |
97 | ||
98 | Package * | |
99 | new_package (char *name) | |
100 | { | |
101 | if (npackages >= maxpackages) | |
102 | { | |
103 | maxpackages += 10; | |
104 | if (package) | |
105 | package = (Package *) realloc (package, maxpackages * sizeof (Package)); | |
106 | else | |
107 | package = (Package *) malloc (maxpackages * sizeof (Package)); | |
108 | } | |
109 | cp = package + npackages; | |
110 | npackages ++; | |
111 | ||
112 | memset (cp, 0, sizeof (Package)); | |
113 | cp->name = name; | |
114 | ||
115 | trust = TRUST_CURR; | |
116 | ||
117 | return cp; | |
118 | } |