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>
17 /* tokenize the setup.ini files. We parse a string which we've
18 previously downloaded. The program must call ini_init() to specify
28 #define YY_INPUT(buf,result,max_size) { result = ini_getchar(buf, max_size); }
30 static int ini_getchar(char *buf, int max_size);
31 static void ignore_line (void);
38 %option never-interactive
44 [0123456789abcdef]{32,32} {
45 yylval = (char *) new unsigned char[16];
46 for (int i=0; i< 16; ++i)
47 ((unsigned char *) yylval) [i] = 0;
48 for (int i=0; i< 32; ++i)
50 unsigned char val = (unsigned char) yytext[i];
55 ((unsigned char *) yylval) [i / 2] += val << ((i % 2) ? 0 : 4);
60 \"[^"]*\" { yylval = new char [strlen (yytext+1) + 1];
61 strcpy (yylval, yytext+1);
62 yylval[strlen (yylval)-1] = 0;
65 "setup-timestamp:" return SETUP_TIMESTAMP;
66 "setup-version:" return SETUP_VERSION;
67 "version:" return PACKAGEVERSION;
68 "install:" return INSTALL;
69 "source:" return SOURCE;
70 "sdesc:" return SDESC;
71 "ldesc:" return LDESC;
73 "category:" return CATEGORY;
74 "requires:" return REQUIRES;
76 "apath:" return APATH;
77 "ppath:" return PPATH;
79 "include-setup:" return INCLUDE_SETUP;
81 "download-url:" return DOWNLOAD_URL;
83 ^{STR}":" ignore_line ();
85 "[curr]" return T_CURR;
86 "[test]" return T_TEST;
87 "[exp]" return T_TEST;
88 "[prev]" return T_PREV;
89 "["{STR}"]" return T_UNKNOWN;
91 {STR} { yylval = new char [strlen(yytext) + 1];
92 strcpy (yylval, yytext);
95 [ \t\r]+ /* do nothing */;
97 "#".*\n { return '\n'; }
99 \n { return *yytext; }
100 . { return *yytext; }
104 #include "io_stream.h"
106 static io_stream *input_stream = 0;
107 extern IniDBBuilder *iniBuilder;
110 ini_init(io_stream *stream, IniDBBuilder *aBuilder)
112 input_stream = stream;
113 iniBuilder = aBuilder;
119 ini_getchar(char *buf, int max_size)
123 ssize_t len = input_stream->read (buf, max_size);
138 while ((c = yyinput ()))
150 return !!YY_AT_BOL ();