unaligned access for you, and will, on at least some platforms, cause
the program to be terminated.
-Wireshark supports platforms with GLib 2.4[.x]/GTK+ 2.4[.x] or newer.
-If a Glib/GTK+ mechanism is available only in Glib/GTK+ versions
-newer than 2.4/2.4 then use "#if GTK_CHECK_VERSION(...)" to conditionally
-compile code using that mechanism.
+Wireshark supports platforms with GLib 2.14[.x]/GTK+ 2.12[.x] or newer.
+If a Glib/GTK+ mechanism is available only in Glib/GTK+ versions newer
+than 2.14/2.12 then use "#if GLIB_CHECK_VERSION(...)" or "#if
+GTK_CHECK_VERSION(...)" to conditionally compile code using that
+mechanism.
When different code must be used on UN*X and Win32, use a #if or #ifdef
that tests _WIN32, not WIN32. Try to write code portably whenever
gcp.h \
geoip_db.h \
golay.h \
- g_gnuc.h \
greproto.h \
guid-utils.h \
h225-persistentdata.h \
check_relation("contains", TRUE, ftype_can_contains, st_node, st_arg1, st_arg2);
break;
case TEST_OP_MATCHES:
-#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0)
- check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2);
-#else
- dfilter_fail("This Wireshark version does not support the \"matches\" operation.");
- THROW(TypeError);
-#endif
- break;
+ check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2); break;
default:
g_assert_not_reached();
case HDR_CONTENT_LENGTH:
errno = 0;
-#if GLIB_CHECK_VERSION(2,12,0)
eh_ptr->content_length = g_ascii_strtoll(value, &p, 10);
-#elif defined(HAVE_STRTOLL)
- eh_ptr->content_length = strtoll(value, &p, 10);
-#else
- /* Punt and grab a 32-bit value */
- eh_ptr->content_length = strtol(value, &p, 10);
-#endif
-
up = (guchar *)p;
if (eh_ptr->content_length < 0 ||
p == value ||
} decrypt_data_t;
static GHashTable *isakmp_hash = NULL;
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
-static GMemChunk *isakmp_key_data = NULL;
-static GMemChunk *isakmp_decrypt_data = NULL;
-#endif
static ikev1_uat_data_key_t* ikev1_uat_data = NULL;
static uat_t * ikev1_uat = NULL;
decr = (decrypt_data_t*) g_hash_table_lookup(isakmp_hash, i_cookie);
if (! decr) {
-#if GLIB_CHECK_VERSION(2,10,0)
ic_key = g_slice_alloc(COOKIE_SIZE);
decr = g_slice_alloc(sizeof(decrypt_data_t));
-#else
- ic_key = g_mem_chunk_alloc(isakmp_key_data);
- decr = g_mem_chunk_alloc(isakmp_decrypt_data);
-#endif
memcpy(ic_key, i_cookie, COOKIE_SIZE);
memset(decr, 0, sizeof(decrypt_data_t));
SET_ADDRESS(&decr->initiator, AT_NONE, 0, NULL);
#endif /* HAVE_LIBGCRYPT */
#ifdef HAVE_LIBGCRYPT
-#if GLIB_CHECK_VERSION(2,10,0)
static gboolean
free_cookie(gpointer key_arg, gpointer value, gpointer user_data _U_)
{
return TRUE;
}
#endif
-#endif
static void
isakmp_init_protocol(void) {
#ifdef HAVE_LIBGCRYPT
if (isakmp_hash) {
-#if GLIB_CHECK_VERSION(2,10,0)
g_hash_table_foreach_remove(isakmp_hash, free_cookie, NULL);
-#endif
g_hash_table_destroy(isakmp_hash);
}
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
- if (isakmp_key_data)
- g_mem_chunk_destroy(isakmp_key_data);
- if (isakmp_decrypt_data)
- g_mem_chunk_destroy(isakmp_decrypt_data);
-
- isakmp_key_data = g_mem_chunk_new("isakmp_key_data",
- COOKIE_SIZE, 5 * COOKIE_SIZE,
- G_ALLOC_AND_FREE);
- isakmp_decrypt_data = g_mem_chunk_new("isakmp_decrypt_data",
- sizeof(decrypt_data_t), 5 * sizeof(decrypt_data_t),
- G_ALLOC_AND_FREE);
-#endif
isakmp_hash = g_hash_table_new(isakmp_hash_func, isakmp_equal_func);
for (i = 0; i < num_ikev1_uat_data; i++) {
-#if GLIB_CHECK_VERSION(2,10,0)
ic_key = g_slice_alloc(COOKIE_SIZE);
decr = g_slice_alloc(sizeof(decrypt_data_t));
-#else
- ic_key = g_mem_chunk_alloc(isakmp_key_data);
- decr = g_mem_chunk_alloc(isakmp_decrypt_data);
-#endif
memcpy(ic_key, ikev1_uat_data[i].icookie, COOKIE_SIZE);
memset(decr, 0, sizeof(decrypt_data_t));
static int proto_synphasor = -1;
static GSList *config_frame_list = NULL;
-#if ! GLIB_CHECK_VERSION(2,10,0)
-static GMemChunk *frame_chunks = NULL;
-#endif
-
/* user preferences */
static guint global_pref_tcp_port = 4712;
static guint global_pref_udp_port = 4713;
config_frame *frame;
/* get a new frame and initialize it */
-#if GLIB_CHECK_VERSION(2,10,0)
frame = g_slice_new(config_frame);
-#else
- frame = g_mem_chunk_alloc(frame_chunks);
-#endif
frame->config_blocks = g_array_new(FALSE, TRUE, sizeof(config_block));
g_array_free(frame->config_blocks, TRUE);
/* and the config_frame */
-#if GLIB_CHECK_VERSION(2,10,0)
g_slice_free1(sizeof(config_frame), frame);
-#else
- g_mem_chunk_free(frame_chunks, frame);
-#endif
}
/* called every time the user loads a capture file or starts to capture */
config_frame_list = NULL;
}
-#if ! GLIB_CHECK_VERSION(2,10,0)
- if (frame_chunks != NULL) {
- g_mem_chunk_destroy(frame_chunks);
- }
- frame_chunks = g_mem_chunk_new("Frame_Chunks",
- sizeof(config_frame),
- 10*(sizeof(config_frame)),
- G_ALLOC_AND_FREE);
-#endif
}
/* the main dissection routine */
dissector_add_uint("udp.port", current_udp_port, synphasor_udp_handle);
dissector_add_uint("tcp.port", current_tcp_port, synphasor_tcp_handle);
} /* proto_reg_handoff_synphasor() */
-
#ifndef __EMEM_H__
#define __EMEM_H__
-#include "g_gnuc.h"
-
/** @file
*/
/** Initialize all the memory allocation pools described below.
#elif defined(HAVE_LIBGCRYPT)
gcry_check_version(NULL);
#endif
- tvbuff_init();
tap_init();
prefs_init();
proto_init(register_all_protocols_func, register_all_handoffs_func,
prefs_cleanup();
packet_cleanup();
oid_resolv_cleanup();
- tvbuff_cleanup();
#ifdef HAVE_LIBGNUTLS
gnutls_global_deinit();
#endif
#include <setjmp.h>
#include <stdlib.h>
#include <assert.h>
-#include <epan/g_gnuc.h>
#define XCEPT_GROUP_ANY 0
#define XCEPT_CODE_ANY 0
return create_persconffile_profile(persconfprofile, pf_dir_path_return);
}
-#if ! GLIB_CHECK_VERSION(2,14,0)
-static void
-hash_table_get_keys(gpointer key, gpointer value _U_, gpointer user_data)
-{
- GList **files = ((GList **)user_data);
- *files = g_list_append (*files, key);
-}
-#endif
-
int
copy_persconffile_profile(const char *toname, const char *fromname, gboolean from_global,
char **pf_filename_return, char **pf_to_dir_path_return, char **pf_from_dir_path_return)
from_dir = g_strdup (get_persconffile_dir(fromname));
}
-#if GLIB_CHECK_VERSION(2,14,0)
files = g_hash_table_get_keys(profile_files);
-#else
- files = NULL;
- g_hash_table_foreach(profile_files, hash_table_get_keys, &files);
-#endif
-
file = g_list_first(files);
while (file) {
filename = (gchar *)file->data;
#include <epan/strutil.h>
#include <epan/oids.h>
-#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0)
-# ifdef HAVE_LIBPCRE
+#ifdef HAVE_LIBPCRE
# include <pcre.h>
-# endif
-#define CMP_MATCHES cmp_matches
-#else
-#define CMP_MATCHES NULL
#endif
+#define CMP_MATCHES cmp_matches
static void
bytes_fvalue_new(fvalue_t *fv)
}
return FALSE;
}
-#elif GLIB_CHECK_VERSION(2,14,0) /* GRegex */
+#else /* GRegex */
static gboolean
cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b)
{
#include <pcre.h>
-/* Create a pcre_tuple_t object based on the given string pattern */
+/* Create a pcre_tuple_t object based on the given string pattern */
static pcre_tuple_t *
pcre_tuple_new(const char *value)
{
ftype_register(FT_PCRE, &pcre_type);
}
-#elif GLIB_CHECK_VERSION(2,14,0) /* No HAVE_LIBPCRE. Try falling back to GRegex. */
+#else /* No HAVE_LIBPCRE. Try falling back to GRegex. */
#include <glib.h>
ftype_register(FT_PCRE, &pcre_type);
}
-#else /* No HAVE_LIBPCRE or GRegex */
-
-void
-ftype_register_pcre(void)
-{
- static ftype_t pcre_type = {
- FT_PCRE, /* ftype */
- "FT_PCRE", /* name */
- "Compiled Perl-Compatible Regular Expression object", /* pretty_name */
- 0, /* wire_size */
- NULL, /* new_value */
- NULL, /* free_value */
- NULL, /* val_from_unparsed */
- NULL, /* val_from_string */
- NULL, /* val_to_string_repr */
- NULL, /* len_string_repr */
-
- NULL, /* set_value */
- NULL, /* set_value_uinteger */
- NULL, /* set_value_sinteger */
- NULL, /* set_value_integer64 */
- NULL, /* set_value_floating */
-
- NULL, /* get_value */
- NULL, /* get_value_uinteger */
- NULL, /* get_value_sinteger */
- NULL, /* get_value_integer64 */
- NULL, /* get_value_floating */
-
- NULL, /* cmp_eq */
- NULL, /* cmp_ne */
- NULL, /* cmp_gt */
- NULL, /* cmp_ge */
- NULL, /* cmp_lt */
- NULL, /* cmp_le */
- NULL, /* cmp_bitwise_and */
- NULL, /* cmp_contains */
- NULL, /* cmp_matches */
-
- NULL, /* len */
- NULL, /* slice */
- };
- ftype_register(FT_PCRE, &pcre_type);
-}
-
#endif /* HAVE_LIBPCRE */
-
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* vi: set shiftwidth=4 tabstop=4 noexpandtab
* :indentSize=4:tabSize=4:noTabs=false:
*/
-
#include <ftypes-int.h>
#include <string.h>
-#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0)
-# ifdef HAVE_LIBPCRE
+#ifdef HAVE_LIBPCRE
# include <pcre.h>
-# endif
-#define CMP_MATCHES cmp_matches
-#else
-#define CMP_MATCHES NULL
#endif
+#define CMP_MATCHES cmp_matches
#include <ctype.h>
}
return FALSE;
}
-#elif GLIB_CHECK_VERSION(2,14,0) /* GRegex */
+#else /* GRegex */
static gboolean
cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b)
{
#include <ftypes-int.h>
#include <string.h>
-#if defined(HAVE_LIBPCRE) || GLIB_CHECK_VERSION(2,14,0)
-# ifdef HAVE_LIBPCRE
+#ifdef HAVE_LIBPCRE
# include <pcre.h>
-# endif
-#define CMP_MATCHES cmp_matches
-#else
-#define CMP_MATCHES NULL
#endif
+#define CMP_MATCHES cmp_matches
#define tvb_is_private fvalue_gboolean1
TRY {
guint a_len = tvb_length(a);
-
+
if (a_len != tvb_length(b)) {
return TRUE;
}
TRY {
guint a_len = tvb_length(a);
guint b_len = tvb_length(b);
-
+
if (a_len > b_len) {
return TRUE;
}
{
tvbuff_t *a = fv_a->value.tvb;
tvbuff_t *b = fv_b->value.tvb;
-
+
TRY {
guint a_len = tvb_length(a);
guint b_len = tvb_length(b);
TRY {
guint a_len = tvb_length(a);
guint b_len = tvb_length(b);
-
+
if (a_len < b_len) {
return TRUE;
}
}
return FALSE;
}
-#elif GLIB_CHECK_VERSION(2,14,0) /* GRegex */
+#else /* GRegex */
static gboolean
cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b)
{
pcre_extra *ex;
char *error;
};
-#elif GLIB_CHECK_VERSION(2,14,0) /* No HAVE_LIBPCRE. Try falling back to GRegex. */
-
#endif /* HAVE_LIBPCRE */
void
FT_PCRE, /* a compiled Perl-Compatible Regular Expression object */
FT_GUID, /* GUID, UUID */
FT_OID, /* OBJECT IDENTIFIER */
- FT_EUI64,
+ FT_EUI64,
FT_NUM_TYPES /* last item number plus one */
};
tvbuff_t *tvb;
#ifdef HAVE_LIBPCRE
pcre_tuple_t *re;
-#elif GLIB_CHECK_VERSION(2,14,0) /* Try falling back to GRegex. */
+#else /* Try falling back to GRegex. */
GRegex *re;
#endif /* HAVE_LIBPCRE */
} value;
+++ /dev/null
-/* g_gnuc.h
- * Definitions of macros to conditionally do GCC optimization or code checks
- *
- * $Id$
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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.
- *
- * 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.
- *
- * 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.
- */
-
-#ifndef __G_GNUC_H__
-#define __G_GNUC_H__
-
-/**
- * GLib 2.6 has the ability to enable better optimization of malloc functions.
- * Hide the differences between different glib versions in this G_GNUC_MALLOC macro.
- */
-#if ! GLIB_CHECK_VERSION(2,6,0)
- #define G_GNUC_MALLOC
-#endif
-
-/* Glib 2.8 and later has this. */
-#if ! GLIB_CHECK_VERSION(2,8,0)
- #define G_GNUC_NULL_TERMINATED
-#endif
-
-#if ! GLIB_CHECK_VERSION(2,10,0)
- #define G_GNUC_WARN_UNUSED_RESULT
-#endif
-
-#endif /* g_gnuc.h */
/* Initialize protocol-specific variables. */
g_slist_foreach(init_routines, &call_init_routine, NULL);
- /* Initialize the common data structures for fragment reassembly.
- Must be done *after* calling init routines, as those routines
- may free up space for fragments, which they find by using the
- data structures that "reassemble_cleanup()" frees. */
- reassemble_init();
-
/* Initialize the stream-handling tables */
stream_init();
/* Cleanup protocol-specific variables. */
g_slist_foreach(init_routines, &call_init_routine, NULL);
- /* Cleanup the common data structures for fragment reassembly.
- Must be done *after* calling init routines, as those routines
- may free up space for fragments, which they find by using the
- data structures that "reassemble_cleanup()" frees. */
- reassemble_cleanup();
-
/* Cleanup the stream-handling tables */
stream_cleanup();
#include "tvbuff.h"
#include "ftypes/ftypes.h"
#include "register.h"
-#include "g_gnuc.h"
#ifdef __cplusplus
extern "C" {
e_uuid_t act_id;
} dcerpc_fragment_key;
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
-static GMemChunk *fragment_key_chunk = NULL;
-static GMemChunk *fragment_data_chunk = NULL;
-static GMemChunk *dcerpc_fragment_key_chunk = NULL;
-static int fragment_init_count = 200;
-#endif
-
static void LINK_FRAG(fragment_data *fd_head,fragment_data *fd)
{
fragment_data *fd_i;
static void *fragment_key_copy(const void *k)
{
const fragment_key* key = (const fragment_key*) k;
-#if GLIB_CHECK_VERSION(2,10,0)
fragment_key *new_key = g_slice_new(fragment_key);
-#else
- fragment_key *new_key = g_mem_chunk_alloc(fragment_key_chunk);
-#endif
COPY_ADDRESS(&new_key->src, &key->src);
COPY_ADDRESS(&new_key->dst, &key->dst);
{
const dcerpc_fragment_key* key = (const dcerpc_fragment_key*) k;
-#if GLIB_CHECK_VERSION(2,10,0)
dcerpc_fragment_key *new_key = g_slice_new(dcerpc_fragment_key);
-#else
- dcerpc_fragment_key *new_key = g_mem_chunk_alloc(dcerpc_fragment_key_chunk);
-#endif
COPY_ADDRESS(&new_key->src, &key->src);
COPY_ADDRESS(&new_key->dst, &key->dst);
* [or dcerpc_fragment_free_key()] is called (as a consequence of
* returning TRUE from this function).
* If mem_chunks are used, free the address data to which the key
- * refers; the the actual key and value structures get freed
- * by "reassemble_cleanup()").
+ * refers.
*/
static gboolean
free_all_fragments(gpointer key_arg _U_, gpointer value, gpointer user_data _U_)
{
fragment_data *fd_head, *tmp_fd;
-#if GLIB_CHECK_VERSION(2,10,0)
/* If Glib version => 2.10 we do g_hash_table_new_full() and supply a function
* to free the key and the addresses.
*/
-#else
- fragment_key *key = key_arg;
- /*
- * Grr. I guess the theory here is that freeing
- * something sure as heck modifies it, so you
- * want to ban attempts to free it, but, alas,
- * if we make the "data" field of an "address"
- * structure not a "const", the compiler whines if
- * we try to make it point into the data for a packet,
- * as that's a "const" array (and should be, as dissectors
- * shouldn't trash it).
- *
- * So we cast the complaint into oblivion, and rely on
- * the fact that these addresses are known to have had
- * their data mallocated, i.e. they don't point into,
- * say, the middle of the data for a packet.
- */
- g_free((gpointer)key->src.data);
- g_free((gpointer)key->dst.data);
-#endif
for (fd_head = value; fd_head != NULL; fd_head = tmp_fd) {
tmp_fd=fd_head->next;
if(fd_head->data && !(fd_head->flags&FD_NOT_MALLOCED))
g_free(fd_head->data);
-#if GLIB_CHECK_VERSION(2,10,0)
g_slice_free(fragment_data, fd_head);
-#endif
}
return TRUE;
* 'datalen' then we don't have to change the head of the list
* even if we want to keep it sorted
*/
-#if GLIB_CHECK_VERSION(2,10,0)
fd_head=g_slice_new0(fragment_data);
-#else
- fd_head=g_mem_chunk_alloc0(fragment_data_chunk);
-#endif
fd_head->flags=flags;
return fd_head;
/*
* For a reassembled-packet hash table entry, free the fragment data
* to which the value refers.
- * (The actual value structures get freed by "reassemble_cleanup()".)
*/
static gboolean
free_all_reassembled_fragments(gpointer key_arg _U_, gpointer value,
return TRUE;
}
-#if GLIB_CHECK_VERSION(2,10,0)
static void
fragment_free_key(void *ptr)
{
g_slice_free(dcerpc_fragment_key, key);
}
}
-#endif
+
/*
* Initialize a fragment table.
*/
* the keys are freed by calling fragment_free_key()
* and the values are freed in free_all_fragments().
*
- * If mem_chunks are used, the key and value data
- * are freed by "reassemble_cleanup()". free_all_fragments()
+ * free_all_fragments()
* will free the adrress data associated with the key
*/
g_hash_table_foreach_remove(*fragment_table,
free_all_fragments, NULL);
} else {
-#if GLIB_CHECK_VERSION(2,10,0)
/* The fragment table does not exist. Create it */
*fragment_table = g_hash_table_new_full(fragment_hash,
fragment_equal, fragment_free_key, NULL);
-#else
- /* The fragment table does not exist. Create it */
- *fragment_table = g_hash_table_new(fragment_hash,
- fragment_equal);
-#endif
}
}
* the keys are freed by calling dcerpc_fragment_free_key()
* and the values are freed in free_all_fragments().
*
- * If mem_chunks are used, the key and value data
- * are freed by "reassemble_cleanup()". free_all_fragments()
+ * free_all_fragments()
* will free the adrress data associated with the key
*/
g_hash_table_foreach_remove(*fragment_table,
free_all_fragments, NULL);
} else {
-#if GLIB_CHECK_VERSION(2,10,0)
/* The fragment table does not exist. Create it */
*fragment_table = g_hash_table_new_full(dcerpc_fragment_hash,
dcerpc_fragment_equal, dcerpc_fragment_free_key, NULL);
-#else
- /* The fragment table does not exist. Create it */
- *fragment_table = g_hash_table_new(dcerpc_fragment_hash,
- dcerpc_fragment_equal);
-#endif
}
}
* The reassembled-packet hash table exists.
*
* Remove all entries and free reassembled packet
- * data for each entry. (The key data is freed
- * by "reassemble_cleanup()".)
+ * data for each entry.
*/
g_hash_table_foreach_remove(*reassembled_table,
free_all_reassembled_fragments, NULL);
}
}
-/*
- * Free up all space allocated for fragment keys and data and
- * reassembled keys.
- */
-void
-reassemble_cleanup(void)
-{
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
- if (fragment_key_chunk != NULL)
- g_mem_chunk_destroy(fragment_key_chunk);
- if (dcerpc_fragment_key_chunk != NULL)
- g_mem_chunk_destroy(dcerpc_fragment_key_chunk);
- if (fragment_data_chunk != NULL)
- g_mem_chunk_destroy(fragment_data_chunk);
-
- fragment_key_chunk = NULL;
- dcerpc_fragment_key_chunk = NULL;
- fragment_data_chunk = NULL;
-#endif
-}
-
-void
-reassemble_init(void)
-{
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
- fragment_key_chunk = g_mem_chunk_new("fragment_key_chunk",
- sizeof(fragment_key),
- fragment_init_count * sizeof(fragment_key),
- G_ALLOC_AND_FREE);
- dcerpc_fragment_key_chunk = g_mem_chunk_new("dcerpc_fragment_key_chunk",
- sizeof(dcerpc_fragment_key),
- fragment_init_count * sizeof(dcerpc_fragment_key),
- G_ALLOC_AND_FREE);
- fragment_data_chunk = g_mem_chunk_new("fragment_data_chunk",
- sizeof(fragment_data),
- fragment_init_count * sizeof(fragment_data),
- G_ALLOC_ONLY);
-#endif
-}
-
/* This function cleans up the stored state and removes the reassembly data and
* (with one exception) all allocated memory for matching reassembly.
*
/* a function for copying hash keys */
typedef void *(*fragment_key_copier)(const void *key);
-
/*
* Initialize a fragment table.
*/
*/
extern void reassembled_table_init(GHashTable **reassembled_table);
-/*
- * Free up all space allocated for fragment keys and data.
- */
-void reassemble_cleanup(void);
-
-/*
- * Initialise fragment keys and data.
- */
-void reassemble_init(void);
-
/*
* This function adds a new fragment to the fragment hash table.
* If this is the first fragment seen for this datagram, a new entry
/* initialise stuff */
emem_init();
- tvbuff_init();
- reassemble_init();
/* a tvbuff for testing with */
data = g_malloc(DATA_LEN);
tvbuff_t *tvb_comp[6];
guint comp_length[6];
int len;
-
+
for (i = 0; i < 3; i++) {
small[i] = g_new(guint8, 16);
/* Composite tvbuffs don't work at the moment -- tests commented out until
* they do. */
-
+
/* One Real */
printf("Making Composite 0\n");
tvb_comp[0] = tvb_new_composite();
main(void)
{
except_init();
- tvbuff_init();
run_tests();
- tvbuff_cleanup();
except_deinit();
exit(failed?1:0);
}
static const guint8*
ensure_contiguous(tvbuff_t *tvb, const gint offset, const gint length);
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
-/* We dole out tvbuff's from this memchunk. */
-static GMemChunk *tvbuff_mem_chunk = NULL;
-#endif
-
-void
-tvbuff_init(void)
-{
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
- if (!tvbuff_mem_chunk)
- tvbuff_mem_chunk = g_mem_chunk_create(tvbuff_t, 20, G_ALLOC_AND_FREE);
-#endif
-}
-
-void
-tvbuff_cleanup(void)
-{
-#if GLIB_CHECK_VERSION(2,10,0)
-#else
- if (tvbuff_mem_chunk)
- g_mem_chunk_destroy(tvbuff_mem_chunk);
-
- tvbuff_mem_chunk = NULL;
-#endif
-}
-
static void
tvb_init(tvbuff_t *tvb, const tvbuff_type type)
{
{
tvbuff_t *tvb;
-#if GLIB_CHECK_VERSION(2,10,0)
tvb = g_slice_new(tvbuff_t);
-#else
- tvb = g_chunk_new(tvbuff_t, tvbuff_mem_chunk);
-#endif
tvb_init(tvb, type);
g_slist_free(tvb->used_in);
}
-#if GLIB_CHECK_VERSION(2,10,0)
g_slice_free(tvbuff_t, tvb);
-#else
- g_chunk_free(tvb, tvbuff_mem_chunk);
-#endif
}
}
typedef void (*tvbuff_free_cb_t)(void*);
-
-/** "class" initialization. Called once during execution of program
- * so that tvbuff.c can initialize its data. */
-extern void tvbuff_init(void);
-
-/** "class" cleanup. Called once during execution of program
- * so that tvbuff.c can clean up its data. */
-extern void tvbuff_cleanup(void);
-
-
/** Returns a pointer to a newly initialized tvbuff. Note that
* tvbuff's of types TVBUFF_SUBSET and TVBUFF_COMPOSITE
* require further initialization via the appropriate functions */
g_snprintf(num, sizeof(num), "%d", expert_data->packet_num);
#if 0
This does not have a big performance improvment :(
-if GTK_CHECK_VERSION(2,10,0)
gtk_tree_store_insert_with_values (store,
&new_iter, /* *iter */
&procedure->iter, /* *parent*/
envvar = getenv(varname);
/* since GLib 2.6 we need an utf8 version of the filename */
-#if GLIB_CHECK_VERSION(2,6,0)
/* using the wide char version of getenv should work under all circumstances */
/* convert given varname to utf16, needed by _wgetenv */
/* convert value to utf8 */
envvar = g_utf16_to_utf8(envvarw, -1, NULL, NULL, NULL);
/* XXX - memleak */
-#endif
return envvar;
}
-
* must tweak a given filename from UTF8 to UTF16 as we use NT Unicode (Win9x
* - now unsupported - used locale based encoding here).
*/
-#if GLIB_CHECK_VERSION(2,6,0)
-/* Win32, GLib 2.6 or later */
#include <stdio.h>
extern int ws_stdio_open (const gchar *filename, int flags, int mode);
#define ws_fopen ws_stdio_fopen
#define ws_freopen ws_stdio_freopen
-#else /* GLIB_CHECK_VERSION(2,6,0) */
-
-/* Win32, GLib prior to 2.6 */
-#define ws_open _open
-#define ws_rename rename
-#define ws_mkdir(dir,mode) _mkdir(dir) /* _mkdir() doesn't have a permission bits argument */
-#define ws_stat64 _stati64 /* use _stati64 for 64-bit size support */
-#define ws_unlink _unlink
-#define ws_remove remove
-#define ws_fopen fopen
-#define ws_freopen freopen
-
-#endif /* GLIB_CHECK_VERSION(2,6,0) */
-
/*
* These routines don't take pathnames, so they're the same regardless
* of what version of GLib we have.