From Jakub Zawadzki via bug #4289: (Fix for) Frame arrival times (pcap)
[obnox/wireshark/wip.git] / epan / dtd_parse.l
index d57ae355f2bbaea4c4c93ae909bfe592cabc17ab..4d84b1259079a45b8887b9772e412414d85d7b6e 100644 (file)
@@ -1,16 +1,28 @@
-%option noyywrap
+/*
+ * We don't use unput, so don't generate code for it.
+ */
 %option nounput 
-%option outfile="dtd_parse.c"
-%option prefix="Dtd_Parse_"
+
+/*
+ * We don't read from the terminal.
+ */
 %option never-interactive
 
+/*
+ * Prefix scanner routines with "Dtd_Parse_" rather than "yy", so this scanner
+ * can coexist with other scanners.
+ */
+%option prefix="Dtd_Parse_"
+
+%option outfile="dtd_parse.c"
+
 %{
 
        /* dtd_parse.l
        * an XML dissector for Wireshark 
        * lexical analyzer for DTDs
        *
-       * Copyright 2004, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
+       * Copyright 2004, Luis E. Garcia Ontanon <luis@ontanon.org>
        *
        * $Id$
        *
@@ -30,7 +42,7 @@
        * 
        * You should have received a copy of the GNU General Public License
        * along with this program; if not, write to the Free Software
-       * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+       * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
        */
        
 #include <glib.h>
@@ -39,6 +51,7 @@
 #include "dtd.h"
 #include "dtd_grammar.h"
 #include "dtd_parse.h"
+#include "dtd_parse_lex.h"
        
        struct _proto_xmlpi_attr {
                gchar* name;
@@ -62,7 +75,7 @@
        static void set_media_type (gchar* val) { if(build_data->media_type) g_free(build_data->media_type); build_data->media_type = g_strdup(val); }
        static void set_proto_root (gchar* val) { if(build_data->proto_root) g_free(build_data->proto_root); build_data->proto_root = g_strdup(val); }
        static void set_description (gchar* val) { if(build_data->description) g_free(build_data->description); build_data->description = g_strdup(val); }
-       static void set_recursive (gchar* val) { build_data->recursion = ( g_strcasecmp(val,"yes") == 0 ) ? TRUE : FALSE; }
+       static void set_recursive (gchar* val) { build_data->recursion = ( g_ascii_strcasecmp(val,"yes") == 0 ) ? TRUE : FALSE; }
 
        static struct _proto_xmlpi_attr proto_attrs[] =
        {
 
 #define YY_INPUT(buff,result,max_size) ( (result) = my_yyinput((buff),(max_size)) )
 
+/*
+ * Flex (v 2.5.35) uses this symbol to "exclude" unistd.h
+ */
+#ifdef _WIN32
+#define YY_NO_UNISTD_H
+#endif
+
 %}
 
 comment_start "<!--"
@@ -198,7 +218,7 @@ squoted        ['][^\']*[']
 <GET_ATTR_QUOTE>{get_attr_quote} { BEGIN GET_ATTR_VAL; }
 
 <GET_ATTR_QUOTE>. {
-       g_string_sprintfa(build_data->error,
+       g_string_append_printf(build_data->error,
                                        "error in wireshark:protocol xmpli at %s : could not find attribute value!",
                                        location);
        yyterminate();
@@ -210,7 +230,7 @@ squoted        ['][^\']*[']
        gboolean got_it = FALSE;
        
        for(pa = proto_attrs; pa->name; pa++) {
-               if (g_strcasecmp(attr_name,pa->name) == 0) {
+               if (g_ascii_strcasecmp(attr_name,pa->name) == 0) {
                        pa->act(yytext);
                        got_it = TRUE;
                        break;
@@ -218,7 +238,7 @@ squoted        ['][^\']*[']
        }
        
        if (! got_it) {
-               g_string_sprintfa(build_data->error,
+               g_string_append_printf(build_data->error,
                                                "error in wireshark:protocol xmpli at %s : no such parameter %s!",
                                                location, attr_name);
                g_free(attr_name);
@@ -306,7 +326,7 @@ extern dtd_build_data_t* dtd_parse(GString* s) {
 
        input_string = s;
        offset = 0;
-       len = input_string->len;
+       len = (guint) input_string->len;
        
        pParser = DtdParseAlloc(g_malloc);
 
@@ -345,3 +365,14 @@ extern dtd_build_data_t* dtd_parse(GString* s) {
        
        return build_data;
 }
+
+/*
+ * We want to stop processing when we get to the end of the input.
+ * (%option noyywrap is not used because if used then 
+ * some flex versions (eg: 2.5.35) generate code which causes
+ * warnings by the Windows VC compiler).
+ */
+
+int yywrap(void) {
+    return 1;
+}