Escape the '.' in radius dictionary ATTRIBUTE names. This may fix the OSX-10.5 build...
[obnox/wireshark/wip.git] / epan / radius_dict.l
1 /*
2  * We don't use unput, so don't generate code for it.
3  */
4 %option nounput
5
6 /*
7  * We don't read from the terminal.
8  */
9 %option never-interactive
10
11 /*
12  * The language we're scanning is case-insensitive.
13  */
14 %option caseless
15
16 /*
17  * Prefix scanner routines with "Radius" rather than "yy", so this scanner
18  * can coexist with other scanners.
19  */
20 %option prefix="Radius"
21
22 %option outfile="radius_dict.c"
23
24 %{
25         /* radius_dict.l
26         *
27         * RADIUS dictionary parser
28         *
29         * $Id$
30         *
31         * Wireshark - Network traffic analyzer
32         * By Gerald Combs <gerald@wireshark.org>
33         * Copyright 1998 Gerald Combs
34         *
35         * This program is free software; you can redistribute it and/or
36         * modify it under the terms of the GNU General Public License
37         * as published by the Free Software Foundation; either version 2
38         * of the License, or (at your option) any later version.
39         *
40         * This program is distributed in the hope that it will be useful,
41         * but WITHOUT ANY WARRANTY; without even the implied warranty of
42         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43         * GNU General Public License for more details.
44         *
45         * You should have received a copy of the GNU General Public License
46         * along with this program; if not, write to the Free Software
47         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
48         */
49
50 #ifdef HAVE_CONFIG_H
51 #include "config.h"
52 #endif
53
54 #include <glib.h>
55 #include <stdio.h>
56 #include <stdlib.h>
57 #include <string.h>
58 #include <errno.h>
59 #include <epan/packet.h>
60 #include <epan/dissectors/packet-radius.h>
61 #include "radius_dict_lex.h"
62 #include <wsutil/file_util.h>
63
64 #ifdef _WIN32
65 /* disable Windows VC compiler warning "signed/unsigned mismatch" associated  */
66 /* with YY_INPUT code generated by flex versions such as 2.5.35.              */
67 #pragma warning (disable:4018)
68 #endif
69
70 #define ECHO
71 #define MAX_INCLUDE_DEPTH 10
72
73         void add_vendor(const gchar* name, guint32 vendor_id, guint vendor_type_octets, guint vendor_length_octets, gboolean vendor_has_flags);
74         void add_value(const gchar* attrib_name,const  gchar* value_repr, long value);
75         void add_tlv(const gchar* name, const  gchar* code, radius_attr_dissector_t type, const gchar* current_attr);
76         void add_attribute(const gchar*,const  gchar*, radius_attr_dissector_t,const  gchar*, gboolean, gboolean, const gchar*);
77
78         static YY_BUFFER_STATE include_stack[10];
79         static int include_stack_ptr = 0;
80
81         static radius_dictionary_t* dict = NULL;
82         static GHashTable* value_strings = NULL; /* GArray(value_string) by attribute name */
83
84         static gchar* attr_name = NULL;
85         static gchar* attr_id = NULL;
86         static radius_attr_dissector_t* attr_type = NULL;
87         static gchar* attr_vendor = NULL;
88         static gchar* vendor_name = NULL;
89         static guint32 vendor_id = 0;
90         static guint vendor_type_octets = 1;
91         static guint vendor_length_octets = 1;
92         static gboolean vendor_has_flags = FALSE;
93         static gchar* value_repr = NULL;
94         static gboolean encrypted = FALSE;
95         static gboolean has_tag = FALSE;
96         static gchar* current_vendor = NULL;
97         static gchar* current_attr = NULL;
98
99         static GString* error = NULL;
100         static gchar* directory = NULL;
101         static int linenums[] = {1,1,1,1,1,1,1,1,1,1};
102         static gchar* fullpaths[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
103
104 %}
105
106 /* Note: FreeRadius allows VENDOR, ATTRIBUTE and VALUE names to contain any non-blank character.
107  *       Using [^[:blank:]] below for those names fails for some reason so for now the patterns for each
108  *       include those characters found in the the corresponding names in the FreeRadius dictionaries.
109  */
110
111 %START WS_OUT VENDOR VENDOR_W_NAME ATTR ATTR_W_NAME ATTR_W_ID ATTR_W_TYPE ATTR_W_VENDOR VALUE VALUE_W_ATTR VALUE_W_NAME INCLUDE JUNK BEGIN_VENDOR END_VENDOR VENDOR_W_ID VENDOR_W_FORMAT VENDOR_W_TYPE_OCTETS VENDOR_W_LENGTH_OCTETS VENDOR_W_CONTINUATION BEGIN_TLV END_TLV
112 %%
113 [:blank:]   ;
114 #[^\n]*         ;
115
116 <JUNK>.*\qn             ;
117
118 <WS_OUT>VENDOR { BEGIN VENDOR; }
119 <WS_OUT>ATTRIBUTE { BEGIN ATTR; }
120 <WS_OUT>VALUE { BEGIN VALUE; }
121 <WS_OUT>\$INCLUDE { BEGIN INCLUDE; }
122 <WS_OUT>BEGIN-VENDOR { BEGIN BEGIN_VENDOR; }
123 <WS_OUT>END-VENDOR { BEGIN END_VENDOR; }
124 <WS_OUT>BEGIN-TLV { BEGIN BEGIN_TLV; }
125 <WS_OUT>END-TLV { BEGIN END_TLV; }
126
127 <BEGIN_VENDOR>[0-9a-z_-]+ {
128     if (current_vendor) {
129         g_free(current_vendor);
130     }
131     current_vendor = g_strdup(yytext);
132     BEGIN WS_OUT;
133 }
134 <END_VENDOR>[^\n]* {
135     if (current_vendor) {
136         g_free(current_vendor);
137         current_vendor = NULL;
138     }
139     BEGIN WS_OUT;
140 }
141
142 <BEGIN_TLV>[0-9a-z_-]+ {
143     if (current_attr) {
144         g_free(current_attr);
145     }
146     current_attr = g_strdup(yytext);
147     BEGIN WS_OUT;
148 }
149 <END_TLV>[^\n]* {
150     if (current_attr) {
151         g_free(current_attr);
152         current_attr = NULL;
153     }
154     BEGIN WS_OUT;
155 }
156
157 <VENDOR>[0-9a-z_-]+   {
158     vendor_name = g_strdup(yytext);
159     vendor_type_octets = 1;
160     vendor_length_octets = 1;
161     vendor_has_flags = FALSE;
162     BEGIN VENDOR_W_NAME;
163 }
164 <VENDOR_W_NAME>[0-9]+   {
165     vendor_id = strtol(yytext,NULL,10);
166     BEGIN VENDOR_W_ID;
167 }
168 <VENDOR_W_NAME>0x[0-9a-f]+   {
169     vendor_id = strtol(yytext,NULL,16);
170     BEGIN VENDOR_W_ID;
171 }
172 <VENDOR_W_ID>format= {
173     BEGIN VENDOR_W_FORMAT;
174 }
175 <VENDOR_W_FORMAT>[124] {
176     vendor_type_octets = strtol(yytext,NULL,10);
177     BEGIN VENDOR_W_TYPE_OCTETS;
178 }
179 <VENDOR_W_TYPE_OCTETS>,[012] {
180     vendor_length_octets = strtol(yytext+1,NULL,10);
181     BEGIN VENDOR_W_LENGTH_OCTETS;
182 }
183 <VENDOR_W_LENGTH_OCTETS>,c {
184     vendor_has_flags = TRUE;
185     BEGIN VENDOR_W_CONTINUATION;
186 }
187 <VENDOR_W_FORMAT>\n |
188 <VENDOR_W_TYPE_OCTETS>\n |
189 <VENDOR_W_LENGTH_OCTETS>\n |
190 <VENDOR_W_CONTINUATION>\n |
191 <VENDOR_W_ID>\n {
192     add_vendor(vendor_name, vendor_id, vendor_type_octets, vendor_length_octets, vendor_has_flags);
193     g_free(vendor_name);
194     BEGIN WS_OUT;
195 }
196
197 <ATTR>[0-9a-z_/\.-]+                    { attr_name = g_strdup(yytext); encrypted = FALSE; has_tag = FALSE; BEGIN ATTR_W_NAME; }
198 <ATTR_W_NAME>[0-9]+                     { attr_id = g_strdup(yytext);  BEGIN ATTR_W_ID;}
199 <ATTR_W_NAME>0x[0-9a-f]+                { attr_id = g_strdup_printf("%u",(int)strtoul(yytext,NULL,16)); BEGIN ATTR_W_ID;}
200 <ATTR_W_ID>integer                      { attr_type = radius_integer;  BEGIN ATTR_W_TYPE; }
201 <ATTR_W_ID>string                       { attr_type = radius_string;  BEGIN ATTR_W_TYPE; }
202 <ATTR_W_ID>octets                       { attr_type = radius_octets;  BEGIN ATTR_W_TYPE; }
203 <ATTR_W_ID>ipaddr                       { attr_type = radius_ipaddr;  BEGIN ATTR_W_TYPE; }
204 <ATTR_W_ID>ipv6addr                     { attr_type = radius_ipv6addr;  BEGIN ATTR_W_TYPE; }
205 <ATTR_W_ID>ipv6prefix                   { attr_type = radius_ipv6prefix;  BEGIN ATTR_W_TYPE; }
206 <ATTR_W_ID>ipxnet                       { attr_type = radius_ipxnet;  BEGIN ATTR_W_TYPE; }
207 <ATTR_W_ID>date                         { attr_type = radius_date;  BEGIN ATTR_W_TYPE; }
208 <ATTR_W_ID>abinary                      { attr_type = radius_abinary;  BEGIN ATTR_W_TYPE; }
209 <ATTR_W_ID>ether                        { attr_type = radius_ether;  BEGIN ATTR_W_TYPE; }
210 <ATTR_W_ID>ifid                         { attr_type = radius_ifid;  BEGIN ATTR_W_TYPE; }
211 <ATTR_W_ID>byte                         { attr_type = radius_integer;  BEGIN ATTR_W_TYPE; }
212 <ATTR_W_ID>short                        { attr_type = radius_integer;  BEGIN ATTR_W_TYPE; }
213 <ATTR_W_ID>signed                       { attr_type = radius_signed;  BEGIN ATTR_W_TYPE; }
214 <ATTR_W_ID>combo-ip                     { attr_type = radius_combo_ip;  BEGIN ATTR_W_TYPE; }
215 <ATTR_W_ID>tlv                          { attr_type = radius_tlv;  BEGIN ATTR_W_TYPE; }
216 <ATTR_W_ID>[0-9a-z_-]+                  { attr_type = radius_octets;  BEGIN ATTR_W_TYPE; }
217 <ATTR_W_TYPE>has_tag[,]?                { has_tag = TRUE; }
218 <ATTR_W_TYPE>encrypt=1[,]?              { encrypted=TRUE; }
219 <ATTR_W_TYPE>[0-9a-z_-]+=([^\n]*)       ;
220 <ATTR_W_TYPE>[0-9a-z_-]+                {
221     attr_vendor = g_strdup(yytext);
222     add_attribute(attr_name,attr_id,attr_type,attr_vendor,encrypted,has_tag,current_attr);
223     g_free(attr_id);
224     g_free(attr_vendor);
225     g_free(attr_name);
226     attr_id = NULL;
227     attr_vendor = NULL;
228     attr_name = NULL;
229     BEGIN WS_OUT;
230 }
231 <ATTR_W_TYPE>\n                                         {
232     add_attribute(attr_name,attr_id,attr_type,current_vendor,encrypted,has_tag,current_attr);
233     g_free(attr_id);
234     g_free(attr_name);
235     linenums[include_stack_ptr]++;
236     has_tag = FALSE;
237     encrypted=FALSE;
238     BEGIN WS_OUT;
239 }
240 <ATTR_W_VENDOR>\n                                       {
241     add_attribute(attr_name,attr_id,attr_type,attr_vendor,encrypted,has_tag,current_attr);
242     g_free(attr_id);
243     g_free(attr_vendor);
244     g_free(attr_name);
245     linenums[include_stack_ptr]++;
246     BEGIN WS_OUT;
247 };
248
249 <VALUE>[0-9a-z_/-]+                                     { attr_name = g_strdup(yytext); BEGIN VALUE_W_ATTR; }
250 <VALUE_W_ATTR>[^[:blank:]]+                     { value_repr = g_strdup(yytext); BEGIN VALUE_W_NAME; }
251 <VALUE_W_NAME>[0-9]+                            { add_value(attr_name,value_repr,strtol(yytext,NULL,10));  g_free(attr_name); g_free(value_repr); BEGIN WS_OUT;}
252 <VALUE_W_NAME>0x[0-9a-f]+                       { add_value(attr_name,value_repr,strtol(yytext,NULL,16));  g_free(attr_name); g_free(value_repr); BEGIN WS_OUT;}
253
254 <INCLUDE>[^[:blank:]\n]+   {
255         if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) {
256                 g_string_append_printf(error, "$INCLUDE files nested to deeply\n");
257                 yyterminate();
258         }
259
260         include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
261
262         fullpaths[include_stack_ptr] = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
263             directory,yytext);
264
265         yyin = ws_fopen( fullpaths[include_stack_ptr], "r" );
266
267         if (!yyin) {
268                 if (errno) {
269                         g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], strerror(errno) );
270                         yyterminate();
271                 }
272         } else {
273                 linenums[include_stack_ptr] = 1;
274                 yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) );
275         }
276
277
278         BEGIN WS_OUT;
279 }
280
281 <<EOF>> {
282
283         fclose(yyin);
284         yyin = NULL;
285
286         if ( --include_stack_ptr < 0 ) {
287                 yyterminate();
288         } else {
289                 g_free(fullpaths[include_stack_ptr+1]);
290                 fullpaths[include_stack_ptr+1] = NULL;
291
292                 yy_delete_buffer( YY_CURRENT_BUFFER );
293                 yy_switch_to_buffer(include_stack[include_stack_ptr]);
294         }
295
296         BEGIN WS_OUT;
297 }
298
299 \n      { linenums[include_stack_ptr]++; BEGIN WS_OUT; }
300
301
302 %%
303
304 void add_vendor(const gchar* name, guint32 vendor_id, guint vendor_type_octets, guint vendor_length_octets, gboolean vendor_has_flags) {
305         radius_vendor_info_t* v;
306
307         v = g_hash_table_lookup(dict->vendors_by_id, GUINT_TO_POINTER(vendor_id));
308
309         if (!v) {
310                 v = g_malloc(sizeof(radius_vendor_info_t));
311                 v->attrs_by_id = g_hash_table_new(g_direct_hash,g_direct_equal);
312                 v->code = vendor_id;
313                 v->ett = -1;
314                 v->name = NULL;
315         }
316         /* Assume that the dictionary knows the 'ground truth' about the
317          * type/length/has_flags information and thus allow the dictionary to
318          * overwrite these values even for vendors that have already been loaded.
319          */
320         v->type_octets = vendor_type_octets;
321         v->length_octets = vendor_length_octets;
322         v->has_flags = vendor_has_flags;
323
324         if (v->name)
325                 g_free((gpointer) v->name);
326         v->name = g_strdup(name);
327
328         g_hash_table_insert(dict->vendors_by_id,GUINT_TO_POINTER(v->code),v);
329         g_hash_table_insert(dict->vendors_by_name, (gpointer) v->name, v);
330 }
331
332 void add_attribute(const gchar* name, const  gchar* codestr, radius_attr_dissector_t type, const  gchar* vendor_name, gboolean crypt, gboolean tagged, const gchar* current_attr) {
333         radius_attr_info_t* a;
334         GHashTable* by_id;
335         guint32 code;
336
337
338         if (current_attr){
339                 add_tlv(name, codestr, type, current_attr);
340                 return;
341         }
342
343
344         if (vendor_name) {
345                 radius_vendor_info_t* v;
346                 v = g_hash_table_lookup(dict->vendors_by_name,vendor_name);
347
348                 if (! v) {
349                         g_string_append_printf(error, "Vendor: '%s', does not exist in %s:%i \n", vendor_name, fullpaths[include_stack_ptr], linenums[include_stack_ptr] );
350                         BEGIN JUNK;
351                         return;
352                 } else {
353                         by_id = v->attrs_by_id;
354                 }
355         } else {
356                 by_id = dict->attrs_by_id;
357         }
358
359         code=strtol(codestr, NULL, 10);
360
361         a=g_hash_table_lookup(by_id, GUINT_TO_POINTER(code));
362
363         if (!a) {
364                 a = g_malloc(sizeof(radius_attr_info_t));
365                 a->name = NULL;
366                 a->dissector = NULL;
367         }
368
369         a->code = code;
370         a->encrypt = crypt;
371         a->tagged =  tagged;
372         a->type = type;
373         a->vs = NULL;
374         a->hf = -1;
375         a->hf64 = -1;
376         a->hf_tag = -1;
377         a->hf_len = -1;
378         a->ett = -1;
379         a->tlvs_by_id = NULL;
380
381         if (a->name)
382                 g_free((gpointer) a->name);
383         a->name = g_strdup(name);
384
385         g_hash_table_insert(by_id, GUINT_TO_POINTER(code),a);
386         g_hash_table_insert(dict->attrs_by_name,(gpointer) (a->name),a);
387 }
388
389 void add_tlv(const gchar* name, const  gchar* codestr, radius_attr_dissector_t type, const gchar* current_attr) {
390         radius_attr_info_t* a;
391         radius_attr_info_t* s;
392         guint32 code;
393
394         a = g_hash_table_lookup(dict->attrs_by_name, current_attr);
395
396         if (! a) {
397                 g_string_sprintfa(error, "Attr: '%s', does not exist in %s:%i \n", current_attr, fullpaths[include_stack_ptr], linenums[include_stack_ptr]);
398                 BEGIN JUNK;
399                 return;
400         }
401
402         if (type == radius_tlv) {
403                 g_string_sprintfa(error, "sub-TLV: '%s', sub-TLV's type is specified as tlv in %s:%i \n", name, fullpaths[include_stack_ptr], linenums[include_stack_ptr]);
404                 BEGIN JUNK;
405                 return;
406         }
407
408
409         if (! a->tlvs_by_id) {
410                 a->tlvs_by_id = g_hash_table_new(g_direct_hash,g_direct_equal);
411         }
412
413         code=strtol(codestr, NULL, 10);
414
415         s = g_hash_table_lookup(a->tlvs_by_id, GUINT_TO_POINTER(code));
416
417         if (!s) {
418                 s = g_malloc(sizeof(radius_attr_info_t));
419                 s->name = NULL;
420                 s->dissector = NULL;
421         }
422
423         s->code = code;
424         s->type = type;
425         s->encrypt = FALSE;
426         s->tagged = FALSE;
427         s->dissector = NULL;
428         s->vs = NULL;
429         s->hf = -1;
430         s->hf64 = -1;
431         s->hf_tag = -1;
432         s->hf_len = -1;
433         s->ett = -1;
434         s->tlvs_by_id = NULL;
435
436         if (s->name)
437                 g_free((gpointer) s->name);
438         s->name = g_strdup(name);
439
440         g_hash_table_insert(a->tlvs_by_id,GUINT_TO_POINTER(s->code),s);
441         g_hash_table_insert(dict->tlvs_by_name,(gpointer) (s->name),s);
442 }
443
444 void add_value(const gchar* attrib_name, const gchar* value_repr, long value) {
445         value_string v;
446         GArray* a = g_hash_table_lookup(value_strings,attrib_name);
447
448         if (! a) {
449                 a = g_array_new(TRUE,TRUE,sizeof(value_string));
450                 g_hash_table_insert(value_strings,g_strdup(attrib_name),a);
451         }
452
453         v.value = value;
454         v.strptr = g_strdup(value_repr);
455
456         g_array_append_val(a,v);
457 }
458
459 static void setup_tlvs(gpointer k _U_, gpointer v, gpointer p _U_) {
460         radius_attr_info_t* s = v;
461         gpointer key;
462
463         union {
464                 GArray* a;
465                 gpointer p;
466         } vs;
467
468         if (g_hash_table_lookup_extended(value_strings, s->name, &key, &vs.p)) {
469                 s->vs = (value_string*)(void *)vs.a->data;
470                 g_array_free(vs.a, FALSE);
471                 g_hash_table_remove(value_strings, key);
472                 g_free(key);
473         }
474 }
475
476 static void setup_attrs(gpointer k _U_, gpointer v, gpointer p _U_) {
477         radius_attr_info_t* a = v;
478         gpointer key;
479
480         union {
481                 GArray* a;
482                 gpointer p;
483         } vs;
484
485         if (g_hash_table_lookup_extended(value_strings,a->name,&key,&vs.p) ) {
486                 a->vs = (value_string*)(void *)vs.a->data;
487                 g_array_free(vs.a,FALSE);
488                 g_hash_table_remove(value_strings,key);
489                 g_free(key);
490         }
491
492         if (a->tlvs_by_id) {
493                 g_hash_table_foreach(a->tlvs_by_id, setup_tlvs, p);
494         }
495 }
496
497 static void setup_vendors(gpointer k _U_, gpointer v, gpointer p) {
498         radius_vendor_info_t* vnd = v;
499
500         g_hash_table_foreach(vnd->attrs_by_id,setup_attrs,p);
501 }
502
503 static gboolean destroy_value_strings(gpointer k, gpointer v, gpointer p _U_) {
504         value_string* vs = (value_string*)(void *)(((GArray*)v)->data);
505
506         g_free(k);
507
508         for (;vs->strptr;vs++) {
509                 g_free((void*)vs->strptr);
510         }
511
512         g_array_free(v,TRUE);
513         return TRUE;
514 }
515
516 static gboolean destroy_tlvs(gpointer k _U_, gpointer v, gpointer p _U_) {
517         radius_attr_info_t* s = v;
518         int i;
519
520         g_free((gpointer) (s->name));
521
522         if (s->vs) {
523                 for(i=0; s->vs[i].strptr; i++) {
524                         g_free((void *)s->vs[i].strptr);
525                 }
526                 g_free((void *)s->vs);
527         }
528         g_free(s);
529         return TRUE;
530 }
531
532 static gboolean destroy_attrs(gpointer k _U_, gpointer v, gpointer p _U_) {
533         radius_attr_info_t* a = v;
534         int i;
535
536         g_free((gpointer) (a->name));
537         if (a->tlvs_by_id) {
538                 g_hash_table_foreach_remove(a->tlvs_by_id, destroy_tlvs, p);
539                 g_hash_table_destroy(a->tlvs_by_id);
540         }
541
542         if (a->vs) {
543                 for(i=0; a->vs[i].strptr; i++) {
544                         g_free((void *)a->vs[i].strptr);
545                 }
546                 g_free((void *)a->vs);
547         }
548         g_free(a);
549         return TRUE;
550 }
551
552 static gboolean destroy_vendors(gpointer k _U_, gpointer v, gpointer p) {
553         radius_vendor_info_t* vnd = v;
554         g_free( (gpointer) vnd->name);
555         g_hash_table_foreach_remove(vnd->attrs_by_id,destroy_attrs,p);
556         g_hash_table_destroy(vnd->attrs_by_id);
557         g_free(vnd);
558         return TRUE;
559 }
560
561 static void destroy_dict(radius_dictionary_t* d) {
562         g_hash_table_foreach_remove(d->attrs_by_id,destroy_attrs,NULL);
563         g_hash_table_foreach_remove(d->vendors_by_id,destroy_vendors,NULL);
564         g_hash_table_destroy(d->vendors_by_id);
565         g_hash_table_destroy(d->attrs_by_id);
566         g_hash_table_destroy(d->vendors_by_name);
567         g_hash_table_destroy(d->attrs_by_name);
568         g_free(d);
569 }
570
571 gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar* filename, gchar** err_str) {
572         int i;
573
574         dict = d;
575         directory = dir;
576
577         fullpaths[include_stack_ptr] = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
578             directory,filename);
579
580         error = g_string_new("");
581
582         yyin = ws_fopen(fullpaths[include_stack_ptr],"r");
583
584         if (!yyin) {
585                 g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], strerror(errno) );
586                 g_free(fullpaths[include_stack_ptr]);
587                 *err_str = error->str;
588                 g_string_free(error,FALSE);
589                 return FALSE;
590         }
591
592         value_strings = g_hash_table_new(g_str_hash,g_str_equal);
593
594         BEGIN WS_OUT;
595
596         yylex();
597
598         if (yyin != NULL) fclose(yyin);
599         yyin = NULL;
600
601         for (i=0; i < 10; i++) {
602                 if (fullpaths[i]) g_free(fullpaths[i]);
603         }
604
605         g_hash_table_foreach(dict->attrs_by_id,setup_attrs,NULL);
606         g_hash_table_foreach(dict->vendors_by_id,setup_vendors,NULL);
607         g_hash_table_foreach_remove(value_strings,destroy_value_strings,NULL);
608
609         if (error->len > 0) {
610                  *err_str = error->str;
611                 g_string_free(error,FALSE);
612                 destroy_dict(dict);
613                 return FALSE;
614         } else {
615                 *err_str = NULL;
616                 g_string_free(error,TRUE);
617                 return TRUE;
618         }
619 }
620
621 /*
622  * We want to stop processing when we get to the end of the input.
623  * (%option noyywrap is not used because if used then
624  * some flex versions (eg: 2.5.35) generate code which causes
625  * warnings by the Windows VC compiler).
626  */
627
628 int yywrap(void) {
629     return 1;
630 }