Added a function proto_get_id_by_filter_name() function to proto.{c,h}

to allow the lookup of proto_ids by filter_name.

svn path=/trunk/; revision=3235
This commit is contained in:
Ed Warnicke 2001-04-01 22:50:08 +00:00
parent 10cd0c5f70
commit cb21a9735a
2 changed files with 24 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
* $Id: proto.c,v 1.17 2001/04/01 07:06:24 hagbard Exp $
* $Id: proto.c,v 1.18 2001/04/01 22:50:08 hagbard Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1656,6 +1656,25 @@ find_protocol_by_id(int proto_id)
return list_entry->data;
}
static gint compare_filter_name(gconstpointer proto_arg,
gconstpointer filter_name)
{
const protocol_t *protocol = proto_arg;
const gchar* f_name = filter_name;
return (strcmp(protocol->filter_name, f_name));
}
int proto_get_id_by_filter_name(gchar* filter_name)
{
GList *list_entry;
protocol_t *protocol;
list_entry = g_list_find_custom(protocols,filter_name,compare_filter_name);
if(list_entry == NULL)
return -1;
protocol = list_entry->data;
return(protocol->proto_id);
}
char *
proto_get_protocol_name(int proto_id)
{

View File

@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
* $Id: proto.h,v 1.9 2001/03/23 14:44:02 jfoster Exp $
* $Id: proto.h,v 1.10 2001/04/01 22:50:08 hagbard Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -493,6 +493,9 @@ gboolean proto_can_disable_protocol(int proto_id);
int proto_get_first_protocol(void **cookie);
int proto_get_next_protocol(void **cookie);
/* Given a protocol's filter_name, return it's proto_id */
int proto_get_id_by_filter_name(gchar* filter_name);
/* Given a protocol's item number, return its name. */
char *proto_get_protocol_name(int n);