2001-02-01 20:31:21 +00:00
|
|
|
/*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2001-02-01 20:21:25 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-02-01 20:31:21 +00:00
|
|
|
* Copyright 2001 Gerald Combs
|
2001-02-01 20:21:25 +00:00
|
|
|
*
|
2001-02-01 20:31:21 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-02-01 20:31:21 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-02-01 20:31:21 +00:00
|
|
|
* 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.
|
2001-02-01 20:21:25 +00:00
|
|
|
*/
|
2001-02-01 20:31:21 +00:00
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef SYNTAX_TREE_H
|
|
|
|
#define SYNTAX_TREE_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
2009-08-29 07:53:48 +00:00
|
|
|
#include "cppmagic.h"
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2010-08-29 10:47:38 +00:00
|
|
|
/** @file
|
|
|
|
*/
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
typedef enum {
|
|
|
|
STTYPE_UNINITIALIZED,
|
|
|
|
STTYPE_TEST,
|
2003-07-25 03:44:05 +00:00
|
|
|
STTYPE_UNPARSED,
|
2001-02-01 20:21:25 +00:00
|
|
|
STTYPE_STRING,
|
|
|
|
STTYPE_FIELD,
|
|
|
|
STTYPE_FVALUE,
|
2001-02-27 19:23:30 +00:00
|
|
|
STTYPE_INTEGER,
|
2001-02-01 20:21:25 +00:00
|
|
|
STTYPE_RANGE,
|
2006-05-02 14:26:17 +00:00
|
|
|
STTYPE_FUNCTION,
|
2001-02-01 20:21:25 +00:00
|
|
|
STTYPE_NUM_TYPES
|
|
|
|
} sttype_id_t;
|
|
|
|
|
|
|
|
typedef gpointer (*STTypeNewFunc)(gpointer);
|
|
|
|
typedef void (*STTypeFreeFunc)(gpointer);
|
|
|
|
|
|
|
|
|
|
|
|
/* Type information */
|
|
|
|
typedef struct {
|
|
|
|
sttype_id_t id;
|
|
|
|
const char *name;
|
|
|
|
STTypeNewFunc func_new;
|
|
|
|
STTypeFreeFunc func_free;
|
|
|
|
} sttype_t;
|
|
|
|
|
2010-08-29 10:47:38 +00:00
|
|
|
/** Node (type instance) information */
|
2001-02-01 20:21:25 +00:00
|
|
|
typedef struct {
|
|
|
|
guint32 magic;
|
|
|
|
sttype_t *type;
|
|
|
|
|
2001-02-27 19:23:30 +00:00
|
|
|
/* This could be made an enum, but I haven't
|
|
|
|
* set aside to time to do so. */
|
|
|
|
gpointer data;
|
2004-06-03 07:36:25 +00:00
|
|
|
gint32 value;
|
2008-01-31 23:10:09 +00:00
|
|
|
const char *deprecated_token;
|
2001-02-01 20:21:25 +00:00
|
|
|
} stnode_t;
|
|
|
|
|
2005-07-23 06:49:07 +00:00
|
|
|
/* These are the sttype_t registration function prototypes. */
|
2006-05-02 14:26:17 +00:00
|
|
|
void sttype_register_function(void);
|
2005-07-23 06:49:07 +00:00
|
|
|
void sttype_register_integer(void);
|
|
|
|
void sttype_register_pointer(void);
|
|
|
|
void sttype_register_range(void);
|
|
|
|
void sttype_register_string(void);
|
|
|
|
void sttype_register_test(void);
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
void
|
|
|
|
sttype_init(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
sttype_cleanup(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
sttype_register(sttype_t *type);
|
|
|
|
|
|
|
|
stnode_t*
|
|
|
|
stnode_new(sttype_id_t type_id, gpointer data);
|
|
|
|
|
|
|
|
void
|
|
|
|
stnode_init(stnode_t *node, sttype_id_t type_id, gpointer data);
|
|
|
|
|
2001-02-27 19:23:30 +00:00
|
|
|
void
|
2004-06-03 07:36:25 +00:00
|
|
|
stnode_init_int(stnode_t *node, sttype_id_t type_id, gint32 value);
|
2001-02-27 19:23:30 +00:00
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
void
|
|
|
|
stnode_free(stnode_t *node);
|
|
|
|
|
|
|
|
const char*
|
|
|
|
stnode_type_name(stnode_t *node);
|
|
|
|
|
|
|
|
sttype_id_t
|
|
|
|
stnode_type_id(stnode_t *node);
|
|
|
|
|
|
|
|
gpointer
|
|
|
|
stnode_data(stnode_t *node);
|
|
|
|
|
2004-06-03 07:36:25 +00:00
|
|
|
gint32
|
2001-02-27 19:23:30 +00:00
|
|
|
stnode_value(stnode_t *node);
|
|
|
|
|
2008-01-31 23:10:09 +00:00
|
|
|
const char *
|
2008-01-31 19:50:38 +00:00
|
|
|
stnode_deprecated(stnode_t *node);
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#define assert_magic(obj, mnum) \
|
|
|
|
g_assert((obj)); \
|
|
|
|
if ((obj)->magic != (mnum)) { \
|
|
|
|
g_print("\nMagic num is 0x%08x, but should be 0x%08x", \
|
|
|
|
(obj)->magic, (mnum)); \
|
|
|
|
g_assert((obj)->magic == (mnum)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define STTYPE_ACCESSOR(ret,type,attr,magicnum) \
|
|
|
|
ret \
|
2009-08-29 07:53:48 +00:00
|
|
|
CONCAT(CONCAT(CONCAT(sttype_,type),_),attr) (stnode_t *node) \
|
2001-02-01 20:21:25 +00:00
|
|
|
{\
|
2009-08-29 07:53:48 +00:00
|
|
|
CONCAT(type,_t) *value; \
|
2001-02-01 20:21:25 +00:00
|
|
|
value = stnode_data(node);\
|
|
|
|
assert_magic(value, magicnum); \
|
|
|
|
return value->attr; \
|
|
|
|
}
|
2002-08-28 20:41:00 +00:00
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#define STTYPE_ACCESSOR_PROTOTYPE(ret,type,attr) \
|
|
|
|
ret \
|
2009-08-29 07:53:48 +00:00
|
|
|
CONCAT(CONCAT(CONCAT(sttype_,type),_),attr) (stnode_t *node);
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|