2001-02-01 20:31:21 +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
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
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,
|
2016-09-19 01:48:50 +00:00
|
|
|
STTYPE_CHARCONST,
|
2001-02-01 20:21:25 +00:00
|
|
|
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,
|
2015-08-19 03:03:41 +00:00
|
|
|
STTYPE_SET,
|
2021-03-21 10:06:17 +00:00
|
|
|
STTYPE_PCRE,
|
2001-02-01 20:21:25 +00:00
|
|
|
STTYPE_NUM_TYPES
|
|
|
|
} sttype_id_t;
|
|
|
|
|
|
|
|
typedef gpointer (*STTypeNewFunc)(gpointer);
|
2012-06-19 12:12:41 +00:00
|
|
|
typedef gpointer (*STTypeDupFunc)(gconstpointer);
|
2001-02-01 20:21:25 +00:00
|
|
|
typedef void (*STTypeFreeFunc)(gpointer);
|
|
|
|
|
|
|
|
|
|
|
|
/* Type information */
|
|
|
|
typedef struct {
|
|
|
|
sttype_id_t id;
|
|
|
|
const char *name;
|
|
|
|
STTypeNewFunc func_new;
|
|
|
|
STTypeFreeFunc func_free;
|
2012-06-19 12:12:41 +00:00
|
|
|
STTypeDupFunc func_dup;
|
2001-02-01 20:21:25 +00:00
|
|
|
} 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;
|
2013-12-13 00:08:16 +00:00
|
|
|
gboolean inside_brackets;
|
|
|
|
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);
|
2015-08-19 03:03:41 +00:00
|
|
|
void sttype_register_set(void);
|
2005-07-23 06:49:07 +00:00
|
|
|
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);
|
|
|
|
|
2013-08-10 17:49:28 +00:00
|
|
|
void
|
|
|
|
stnode_set_bracket(stnode_t *node, gboolean bracket);
|
|
|
|
|
2012-06-19 12:12:41 +00:00
|
|
|
stnode_t*
|
|
|
|
stnode_dup(const stnode_t *org);
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
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);
|
|
|
|
|
2019-01-27 17:02:03 +00:00
|
|
|
gpointer
|
|
|
|
stnode_steal_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) \
|
2013-12-13 00:08:16 +00:00
|
|
|
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)); \
|
|
|
|
}
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
#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; \
|
2013-03-19 19:02:25 +00:00
|
|
|
value = (CONCAT(type,_t) *)stnode_data(node);\
|
2001-02-01 20:21:25 +00:00
|
|
|
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
|