Pull the code to set the fields in the "cfile.cinfo" structure into a

common routine to initialize a "column_info()" structure, shared by
Ethereal and Tethereal.

svn path=/trunk/; revision=2739
This commit is contained in:
Guy Harris 2000-12-03 22:12:21 +00:00
parent 6c4de764d1
commit 35b1907af8
4 changed files with 24 additions and 18 deletions

View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.7 2000/11/19 08:54:34 guy Exp $
* $Id: packet.c,v 1.8 2000/12/03 22:12:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -494,6 +494,20 @@ decode_numeric_bitfield(guint32 val, guint32 mask, int width,
return buf;
}
/* Allocate all the data structures for constructing column data, given
the number of columns. */
void
col_init(column_info *col_info, gint num_cols)
{
col_info->num_cols = num_cols;
col_info->col_fmt = (gint *) g_malloc(sizeof(gint) * num_cols);
col_info->fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * num_cols);
col_info->col_width = (gint *) g_malloc(sizeof(gint) * num_cols);
col_info->col_title = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
col_info->col_data = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
col_info->col_buf = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
}
gboolean
col_get_writable(frame_data *fd)
{

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.11 2000/11/21 14:15:21 girlich Exp $
* $Id: packet.h,v 1.12 2000/12/03 22:12:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -69,6 +69,10 @@ typedef struct _column_info {
#define COL_MAX_LEN 256
#define COL_MAX_INFO_LEN 4096
/* Allocate all the data structures for constructing column data, given
the number of columns. */
void col_init(column_info *, gint);
typedef struct _packet_counts {
gint sctp;
gint tcp;

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.166 2000/11/22 04:07:00 gram Exp $
* $Id: main.c,v 1.167 2000/12/03 22:12:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -930,13 +930,7 @@ main(int argc, char *argv[])
cfile.save_file_fd = -1;
cfile.snap = WTAP_MAX_PACKET_SIZE;
cfile.count = 0;
cfile.cinfo.num_cols = prefs->num_cols;
cfile.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
cfile.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cfile.cinfo.num_cols);
cfile.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
cfile.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
cfile.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
cfile.cinfo.col_buf = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
col_init(&cfile.cinfo, prefs->num_cols);
/* Assemble the compile-time options */
snprintf(comp_info_str, 256,

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.59 2000/11/21 23:50:56 guy Exp $
* $Id: tethereal.c,v 1.60 2000/12/03 22:12:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -240,13 +240,7 @@ main(int argc, char *argv[])
cfile.save_file_fd = -1;
cfile.snap = WTAP_MAX_PACKET_SIZE;
cfile.count = 0;
cfile.cinfo.num_cols = prefs->num_cols;
cfile.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
cfile.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cfile.cinfo.num_cols);
cfile.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
cfile.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
cfile.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
cfile.cinfo.col_buf = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
col_init(&cfile.cinfo, prefs->num_cols);
/* Assemble the compile-time options */
snprintf(comp_info_str, 256,