]> cygwin.com Git - cygwin-apps/setup.git/blame - iniparse.y
* (all): add cvsid tags
[cygwin-apps/setup.git] / iniparse.y
CommitLineData
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
28static Package *cp;
29static int trust;
30extern unsigned int setup_timestamp;
b11b49f3 31extern 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
43whole_file
44 : setup_headers packages
45 ;
46
47setup_headers
48 : setup_header setup_headers
49 | /* empty */
50 ;
51
52setup_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
57packages
58 : package packages
59 | /* empty */
60 ;
61
62package
63 : '@' STRING '\n' { new_package($2); }
64 lines
65 | '\n'
66 ;
67
68lines
69 : simple_line '\n' lines
70 | simple_line
71 ;
72
73simple_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
94Package *package = 0;
95int npackages = 0;
96static int maxpackages = 0;
97
98Package *
99new_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}
This page took 0.044372 seconds and 5 git commands to generate.