3 * Copyright (c) 2000, Red Hat, Inc.
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.
10 * A copy of the GNU General Public License can be found at
13 * Written by DJ Delorie <dj@cygnus.com>
14 * Maintained by Robert Collins <rbtcollins@hotmail.com>
18 /* tokenize the setup.ini files. We parse a string which we've
19 previously downloaded. The program must call ini_init() to specify
28 #include "IniParseFeedback.h"
30 #define YY_INPUT(buf,result,max_size) { result = ini_getchar(buf, max_size); }
32 static int ini_getchar(char *buf, int max_size);
33 static void ignore_line (void);
40 %option never-interactive
45 STR [!a-zA-Z0-9_./:\+-]+
49 [0123456789abcdef]{32,32} {
50 yylval = (char *) new unsigned char[16];
51 for (int i=0; i< 16; ++i)
52 ((unsigned char *) yylval) [i] = 0;
53 for (int i=0; i< 32; ++i)
55 unsigned char val = (unsigned char) yytext[i];
60 ((unsigned char *) yylval) [i / 2] += val << ((i % 2) ? 0 : 4);
65 \"[^"]*\" { yylval = new char [strlen (yytext+1) + 1];
66 strcpy (yylval, yytext+1);
67 yylval[strlen (yylval)-1] = 0;
70 "setup-timestamp:" return SETUP_TIMESTAMP;
71 "setup-version:" return SETUP_VERSION;
72 "Package:" return PACKAGENAME;
73 [vV]"ersion:" return PACKAGEVERSION;
74 "install:"|"Filename:" return INSTALL;
75 "source:" return SOURCE;
76 "sdesc:" return SDESC;
77 "ldesc:" return LDESC;
78 "Description:" BEGIN (descriptionstate); return DESCTAG;
79 "Size:" return FILESIZE;
80 "MD5sum:" return MD5LINE;
81 "Installed-Size:" return INSTALLEDSIZE;
82 "Maintainer:" BEGIN (eolstate); return MAINTAINER;
83 "Architecture:" return ARCHITECTURE;
84 "Source:" return SOURCEPACKAGE;
85 "Binary:" return BINARYPACKAGE;
86 "Build-Depends:" return BUILDDEPENDS;
87 "Build-Depends-Indep:" return BUILDDEPENDS; /* technicallyincorrect :[ */
88 "Standards-Version:" return STANDARDSVERSION;
89 "Format:" return FORMAT;
90 "Directory:" return DIRECTORY;
91 "Files:" return FILES;
93 "category:"|"Section:" return CATEGORY;
94 "Priority:" return PRIORITY;
95 "requires:" return REQUIRES;
96 "Depends:" return DEPENDS;
97 "Pre-Depends:" return PREDEPENDS;
98 "Recommends:" return RECOMMENDS;
99 "Suggests:" return SUGGESTS;
100 "Conflicts:" return CONFLICTS;
101 "Replaces:" return REPLACES;
102 "Provides:" return PROVIDES;
104 "apath:" return APATH;
105 "ppath:" return PPATH;
107 "include-setup:" return INCLUDE_SETUP;
109 "download-url:" return DOWNLOAD_URL;
111 ^{STR}":" ignore_line ();
113 "[curr]" return T_CURR;
114 "[test]" return T_TEST;
115 "[exp]" return T_TEST;
116 "[prev]" return T_PREV;
118 "(" return OPENBRACE;
119 ")" return CLOSEBRACE;
120 "[" return OPENSQUARE;
121 "]" return CLOSESQUARE;
133 {STR}"@"{STR} { yylval = new char [strlen(yytext) + 1];
134 strcpy (yylval, yytext);
136 {STR} { yylval = new char [strlen(yytext) + 1];
137 strcpy (yylval, yytext);
140 [ \t\r]+ /* do nothing */;
142 ^"#".*\n /* do nothing */;
143 <descriptionstate>[^\n]+ { yylval = new char [strlen(yytext) + 1];
144 strcpy (yylval, yytext);
146 <descriptionstate>\n { return NL; }
147 <descriptionstate>"\n"+ {BEGIN(INITIAL); return PARAGRAPH;}
148 <eolstate>[^\n]+ {return STRING; }
149 <eolstate>\n {BEGIN(INITIAL); return NL; }
156 #include "io_stream.h"
158 static io_stream *input_stream = 0;
159 extern IniDBBuilder *iniBuilder;
160 static IniParseFeedback *iniFeedback;
163 ini_init(io_stream *stream, IniDBBuilder *aBuilder, IniParseFeedback &aFeedback)
165 input_stream = stream;
166 iniBuilder = aBuilder;
167 iniFeedback = &aFeedback;
173 ini_getchar(char *buf, int max_size)
177 ssize_t len = input_stream->read (buf, max_size);
184 iniFeedback->progress (input_stream->tell(), input_stream->get_size());
194 while ((c = yyinput ()))
206 return !!YY_AT_BOL ();