]> cygwin.com Git - cygwin-apps/setup.git/blob - iniparse.y
* net.cc (do_net): Default to direct download.
[cygwin-apps/setup.git] / iniparse.y
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
19 #include <stdio.h>
20 #include <stdlib.h>
21
22 #include "ini.h"
23 #include "iniparse.h"
24
25 #include "port.h"
26
27 #define YYERROR_VERBOSE 1
28 /*#define YYDEBUG 1*/
29
30 static Package *cp;
31 static int trust;
32 extern unsigned int setup_timestamp;
33 extern char *setup_version;
34 extern int yylineno;
35
36 #define cpt (cp->info+trust)
37
38 %}
39
40 %token STRING
41 %token SETUP_TIMESTAMP SETUP_VERSION VERSION INSTALL SOURCE SDESC LDESC
42 %token T_PREV T_CURR T_TEST T_UNKNOWN
43
44 %%
45
46 whole_file
47 : setup_headers packages
48 ;
49
50 setup_headers
51 : setup_header setup_headers
52 | /* empty */
53 ;
54
55 setup_header
56 : SETUP_TIMESTAMP STRING '\n' { setup_timestamp = strtoul ($2, 0, 0); }
57 | SETUP_VERSION STRING '\n' { setup_version = _strdup ($2); }
58 | '\n'
59 | error { yyerror ("unrecognized line in setup.ini headers (do you have the latest setup?)"); } '\n'
60 ;
61
62 packages
63 : package packages
64 | /* empty */
65 ;
66
67 package
68 : '@' STRING '\n' { new_package($2); }
69 lines
70 ;
71
72 lines
73 : simple_line '\n' lines
74 | simple_line
75 ;
76
77 simple_line
78 : VERSION STRING { cpt->version = $2; }
79 | SDESC STRING { cp->sdesc = $2; }
80 | LDESC STRING { cp->ldesc = $2; }
81 | INSTALL STRING STRING { cpt->install = $2;
82 cpt->install_size = atoi($3); }
83 | SOURCE STRING STRING { cpt->source = $2;
84 cpt->source_size = atoi($3); }
85 | T_PREV { trust = TRUST_PREV; }
86 | T_CURR { trust = TRUST_CURR; }
87 | T_TEST { trust = TRUST_TEST; }
88 | T_UNKNOWN { trust = TRUST_UNKNOWN; }
89 | /* empty */
90 | error '\n' { yylineno --;
91 yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name);
92 yylineno ++;
93 }
94 ;
95
96 %%
97
98 Package *package = 0;
99 int npackages = 0;
100 static int maxpackages = 0;
101
102 Package *
103 new_package (char *name)
104 {
105 if (package == 0)
106 maxpackages = npackages = 0;
107 if (npackages >= maxpackages)
108 {
109 maxpackages += 10;
110 if (package)
111 package = (Package *) realloc (package, maxpackages * sizeof (Package));
112 else
113 package = (Package *) malloc (maxpackages * sizeof (Package));
114 }
115 cp = package + npackages;
116 npackages ++;
117
118 memset (cp, 0, sizeof (Package));
119 cp->name = name;
120
121 trust = TRUST_CURR;
122
123 return cp;
124 }
This page took 0.052994 seconds and 5 git commands to generate.