]> cygwin.com Git - cygwin-apps/setup.git/blame - inilex.ll
Added dpiAwareness element to manifest
[cygwin-apps/setup.git] / inilex.ll
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>
aa1e3b4d 14 * Maintained by Robert Collins <rbtcollins@hotmail.com>
23c9e63c
DD
15 *
16 */
17
18/* tokenize the setup.ini files. We parse a string which we've
19 previously downloaded. The program must call ini_init() to specify
20 that string. */
21
b11b49f3 22#include "win32.h"
23c9e63c
DD
23#include <string.h>
24
25#include "ini.h"
443b9db6 26#include "iniparse.hh"
3c054baf 27#include "String++.h"
aa1e3b4d 28#include "IniParseFeedback.h"
be13ef43 29#include "sha2.h"
23c9e63c 30
b3c035ce 31#define YY_READ_BUF_SIZE 65536
23c9e63c
DD
32#define YY_INPUT(buf,result,max_size) { result = ini_getchar(buf, max_size); }
33
34static int ini_getchar(char *buf, int max_size);
b24c88b3 35static void ignore_line (void);
23c9e63c
DD
36
37%}
38
b11b49f3 39/*%option debug */
c63e8b4a 40%option nounput
23c9e63c 41%option noyywrap
b11b49f3
DD
42%option yylineno
43%option never-interactive
44
b06628c5 45STR [!a-zA-Z0-9_./:\+~-]+
b53880ee
AG
46HEX [0-9a-f]
47B64 [a-zA-Z0-9_-]
23c9e63c
DD
48
49%%
50
b53880ee 51{HEX}{32} {
58ee6135 52 yylval = (char *) new unsigned char[16];
be13ef43 53 memset (yylval, 0, 16);
3ce2ac31
AG
54 int i, j;
55 unsigned char v1, v2;
56 for (i = 0, j = 0; i < 32; i += 2, ++j)
58ee6135 57 {
3ce2ac31
AG
58 v1 = hexnibble((unsigned char) yytext[i+0]);
59 v2 = hexnibble((unsigned char) yytext[i+1]);
60 ((unsigned char *) yylval) [j] = nibbled1(v1, v2);
58ee6135
RC
61 }
62 return MD5;
63}
64
b53880ee 65{HEX}{128} {
99f33a3b
CV
66 yylval = (char *) new unsigned char[SHA512_DIGEST_LENGTH];
67 memset (yylval, 0, SHA512_DIGEST_LENGTH);
3ce2ac31
AG
68 int i, j;
69 unsigned char v1, v2;
70 for (i = 0, j = 0; i < SHA512_BLOCK_LENGTH; i += 2, ++j)
be13ef43 71 {
3ce2ac31
AG
72 v1 = hexnibble((unsigned char) yytext[i+0]);
73 v2 = hexnibble((unsigned char) yytext[i+1]);
74 ((unsigned char *) yylval) [j] = nibbled1(v1, v2);
be13ef43 75 }
99f33a3b 76 return SHA512;
be13ef43
CV
77}
78
b53880ee 79{B64}{86} {
3ce2ac31
AG
80 /* base64url as defined in RFC4648 */
81 yylval = (char *) new unsigned char[SHA512_DIGEST_LENGTH];
82 memset (yylval, 0, SHA512_DIGEST_LENGTH);
83 int i, j;
84 unsigned char v1, v2, v3, v4;
85 for (i = 0, j = 0; i < 4*(SHA512_DIGEST_LENGTH/3); i += 4, j += 3)
86 {
87 v1 = b64url(((unsigned char) yytext[i+0]));
88 v2 = b64url(((unsigned char) yytext[i+1]));
89 v3 = b64url(((unsigned char) yytext[i+2]));
90 v4 = b64url(((unsigned char) yytext[i+3]));
91 ((unsigned char *) yylval) [j+0] = b64d1(v1, v2, v3, v4);
92 ((unsigned char *) yylval) [j+1] = b64d2(v1, v2, v3, v4);
93 ((unsigned char *) yylval) [j+2] = b64d3(v1, v2, v3, v4);
94 }
95 v1 = b64url((unsigned char) yytext[i+0]);
96 v2 = b64url((unsigned char) yytext[i+1]);
97 v3 = 0;
98 v4 = 0;
99 ((unsigned char *) yylval) [j+0] = b64d1(v1, v2, v3, v4);
b53880ee 100 return SHA512;
3ce2ac31
AG
101}
102
5e0464a1
RC
103\"[^"]*\" { yylval = new char [strlen (yytext+1) + 1];
104 strcpy (yylval, yytext+1);
23c9e63c
DD
105 yylval[strlen (yylval)-1] = 0;
106 return STRING; }
107
108"setup-timestamp:" return SETUP_TIMESTAMP;
13d27274 109"setup-version:" return SETUP_VERSION;
ec599284 110"setup-minimum-version:" return SETUP_MINIMUM_VERSION;
dd15057d 111"arch:" return ARCH;
ec599284 112
dd15057d 113"release:" return RELEASE;
aa1e3b4d
RC
114"Package:" return PACKAGENAME;
115[vV]"ersion:" return PACKAGEVERSION;
116"install:"|"Filename:" return INSTALL;
23c9e63c
DD
117"source:" return SOURCE;
118"sdesc:" return SDESC;
119"ldesc:" return LDESC;
f38044ff 120"message:" return MESSAGE;
aa1e3b4d 121"Source:" return SOURCEPACKAGE;
06eaabde 122[bB]"uild-"[dD]"epends:" return BUILDDEPENDS;
d2e0c29e 123"replace-versions:" return REPLACE_VERSIONS;
aa1e3b4d
RC
124
125"category:"|"Section:" return CATEGORY;
38c97581 126"requires:" return REQUIRES;
b7579b94 127[dD]"epends:" return DEPENDS;
f68a5e31 128[dD]"epends2:" return DEPENDS;
20b98f20 129[oO]"bsoletes:" return OBSOLETES;
9c3e3256 130[pP]"rovides:" return PROVIDES;
e6433da6 131[cC]"onflicts:" return CONFLICTS;
38c97581 132
b11b49f3
DD
133^{STR}":" ignore_line ();
134
23c9e63c
DD
135"[curr]" return T_CURR;
136"[test]" return T_TEST;
13d27274 137"[exp]" return T_TEST;
23c9e63c 138"[prev]" return T_PREV;
20cf793b 139"["{STR}"]" return T_OTHER;
23c9e63c 140
aa1e3b4d
RC
141"(" return OPENBRACE;
142")" return CLOSEBRACE;
143"<<" return LT;
144">>" return GT;
145">=" return GTEQUAL;
146"<=" return LTEQUAL;
b1ff53ed
RC
147">" return GT;
148"<" return LT;
aa1e3b4d
RC
149"=" return EQUAL;
150\, return COMMA;
aa1e3b4d
RC
151"@" return AT;
152
5e0464a1
RC
153{STR} { yylval = new char [strlen(yytext) + 1];
154 strcpy (yylval, yytext);
23c9e63c
DD
155 return STRING; }
156
fb2cd8f6 157[ \t\r]+ /* do nothing */;
b11b49f3 158
aa1e3b4d 159^"#".*\n /* do nothing */;
23c9e63c 160
aa1e3b4d
RC
161\n { return NL; }
162. { return *yytext;}
23c9e63c
DD
163
164%%
165
341988b9
RC
166#include "io_stream.h"
167
168static io_stream *input_stream = 0;
605034ca 169extern IniDBBuilder *iniBuilder;
aa1e3b4d 170static IniParseFeedback *iniFeedback;
341988b9 171
23c9e63c 172void
605034ca 173ini_init(io_stream *stream, IniDBBuilder *aBuilder, IniParseFeedback &aFeedback)
23c9e63c 174{
341988b9 175 input_stream = stream;
076654e7 176 iniBuilder = aBuilder;
aa1e3b4d 177 iniFeedback = &aFeedback;
0d4e0aad
CF
178 YY_FLUSH_BUFFER;
179 yylineno = 1;
23c9e63c
DD
180}
181
182static int
183ini_getchar(char *buf, int max_size)
184{
341988b9 185 if (input_stream)
23c9e63c 186 {
341988b9
RC
187 ssize_t len = input_stream->read (buf, max_size);
188 if (len < 1)
189 {
190 len = 0;
191 input_stream = 0;
23c9e63c 192 }
aa1e3b4d
RC
193 else
194 iniFeedback->progress (input_stream->tell(), input_stream->get_size());
341988b9 195 return len;
23c9e63c 196 }
341988b9 197 return 0;
23c9e63c 198}
b11b49f3
DD
199
200static void
201ignore_line ()
202{
203 char c;
341988b9 204 while ((c = yyinput ()))
b11b49f3
DD
205 {
206 if (c == EOF)
207 return;
208 if (c == '\n')
209 return;
210 }
211}
0d4e0aad 212
80811841 213void
eb20d728 214yyerror (const std::string& s)
0d4e0aad 215{
80811841 216 iniFeedback->note_error(yylineno - (!!YY_AT_BOL ()), s);
0d4e0aad 217}
This page took 0.175724 seconds and 6 git commands to generate.