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 ();
38 %option never-interactive
44 \"[^"]*\" { yylval = strdup (yytext+1);
45 yylval[strlen (yylval)-1] = 0;
48 "setup-timestamp:" return SETUP_TIMESTAMP;
49 "setup-version:" return SETUP_VERSION;
50 "version:" return VERSION;
51 "install:" return INSTALL;
53 "source:" return SOURCE;
54 "sdesc:" return SDESC;
55 "ldesc:" return LDESC;
57 ^{STR}":" ignore_line ();
59 "[curr]" return T_CURR;
60 "[test]" return T_TEST;
61 "[exp]" return T_TEST;
62 "[prev]" return T_PREV;
63 "["{STR}"]" return T_UNKNOWN;
65 {STR} { yylval = strdup (yytext);
68 [ \t\r]+ /* do nothing */
70 "#".*\n /* ignore comments */
72 \n { return yytext[0]; }
73 . { return yytext[0]; }
77 static char *input_string = 0;
78 static char *end_input_string;
81 ini_init(char *string)
83 input_string = string;
84 end_input_string = input_string + strlen(input_string);
88 ini_getchar(char *buf, int max_size)
92 int avail = end_input_string - input_string;
95 input_string = end_input_string = 0;
100 memcpy(buf, input_string, avail);
101 input_string += avail;