Pull the stuff done in "dissect_packet()" to initialize a column_info

structure into its own routine; rename "col_init()" to "col_setup()",
and call the new routine "col_init()".

svn path=/trunk/; revision=7467
This commit is contained in:
Guy Harris 2003-04-16 05:55:41 +00:00
parent 24ec2110d1
commit 2678786425
5 changed files with 30 additions and 22 deletions

View File

@ -1,7 +1,7 @@
/* column-utils.c
* Routines for column utilities.
*
* $Id: column-utils.c,v 1.33 2003/04/16 04:52:52 guy Exp $
* $Id: column-utils.c,v 1.34 2003/04/16 05:55:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -48,7 +48,7 @@
/* 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_setup(column_info *col_info, gint num_cols)
{
col_info->num_cols = num_cols;
col_info->col_fmt = (gint *) g_malloc(sizeof(gint) * num_cols);
@ -62,6 +62,22 @@ col_init(column_info *col_info, gint num_cols)
col_info->col_expr_val = (gchar **) g_malloc(sizeof(gchar *) * num_cols);
}
/* Initialize the data structures for constructing column data. */
void
col_init(column_info *cinfo)
{
int i;
for (i = 0; i < cinfo->num_cols; i++) {
cinfo->col_buf[i][0] = '\0';
cinfo->col_data[i] = cinfo->col_buf[i];
cinfo->col_fence[i] = 0;
cinfo->col_expr[i][0] = '\0';
cinfo->col_expr_val[i][0] = '\0';
}
cinfo->writable = TRUE;
}
gboolean
col_get_writable(column_info *cinfo)
{

View File

@ -1,7 +1,7 @@
/* column-utils.h
* Definitions for column utility structures and routines
*
* $Id: column-utils.h,v 1.10 2003/04/16 04:52:53 guy Exp $
* $Id: column-utils.h,v 1.11 2003/04/16 05:55:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -35,7 +35,10 @@
/* Allocate all the data structures for constructing column data, given
the number of columns. */
extern void col_init(column_info *, gint);
extern void col_setup(column_info *, gint);
/* Initialize the data structures for constructing column data. */
extern void col_init(column_info *);
/* Utility routines used by packet*.c */

View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.89 2003/04/16 04:52:53 guy Exp $
* $Id: packet.c,v 1.90 2003/04/16 05:55:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -249,19 +249,8 @@ void
dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header,
const guchar *pd, frame_data *fd, column_info *cinfo)
{
int i;
if (cinfo != NULL) {
for (i = 0; i < cinfo->num_cols; i++) {
cinfo->col_buf[i][0] = '\0';
cinfo->col_data[i] = cinfo->col_buf[i];
cinfo->col_fence[i] = 0;
cinfo->col_expr[i][0] = '\0';
cinfo->col_expr_val[i][0] = '\0';
}
col_set_writable(cinfo, TRUE);
}
if (cinfo != NULL)
col_init(cinfo);
edt->pi.current_proto = "<Missing Protocol Name>";
edt->pi.cinfo = cinfo;
edt->pi.fd = fd;

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.287 2003/04/16 04:52:55 guy Exp $
* $Id: main.c,v 1.288 2003/04/16 05:55:41 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1951,7 +1951,7 @@ main(int argc, char *argv[])
#endif
/* Build the column format array */
col_init(&cfile.cinfo, prefs->num_cols);
col_setup(&cfile.cinfo, prefs->num_cols);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
cfile.cinfo.col_fmt[i] = get_column_format(i);
cfile.cinfo.col_title[i] = g_strdup(get_column_title(i));

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.179 2003/04/16 04:52:50 guy Exp $
* $Id: tethereal.c,v 1.180 2003/04/16 05:55:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -780,7 +780,7 @@ main(int argc, char *argv[])
}
/* Build the column format array */
col_init(&cfile.cinfo, prefs->num_cols);
col_setup(&cfile.cinfo, prefs->num_cols);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
cfile.cinfo.col_fmt[i] = get_column_format(i);
cfile.cinfo.col_title[i] = g_strdup(get_column_title(i));