summaryrefslogtreecommitdiff
path: root/epan/stat_cmd_args.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-08-31 19:43:37 +0000
committerGuy Harris <guy@alum.mit.edu>2005-08-31 19:43:37 +0000
commitb0c4c7559387730403f33502a46b07fc673ac9e8 (patch)
treef74a481cc56f682b866672060dc688fc4037b43a /epan/stat_cmd_args.c
parenta5bb1bc88cf894a4b43e06c0a847c87cc3ba40d5 (diff)
downloadwireshark-b0c4c7559387730403f33502a46b07fc673ac9e8.tar.gz
Keep the list of possible "-z" arguments sorted, so we can display them
in sorted order (to make it a bit easier to find the one you're interested in). svn path=/trunk/; revision=15638
Diffstat (limited to 'epan/stat_cmd_args.c')
-rw-r--r--epan/stat_cmd_args.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/epan/stat_cmd_args.c b/epan/stat_cmd_args.c
index 434b09c1b5..7499228b46 100644
--- a/epan/stat_cmd_args.c
+++ b/epan/stat_cmd_args.c
@@ -38,11 +38,10 @@
arguments.
*/
typedef struct _stat_cmd_arg {
- struct _stat_cmd_arg *next;
const char *cmd;
void (*func)(const char *arg);
} stat_cmd_arg;
-static stat_cmd_arg *stat_cmd_arg_list=NULL;
+static GSList *stat_cmd_arg_list=NULL;
/* structure to keep track of what stats have been specified on the
command line.
@@ -57,16 +56,22 @@ static GSList *stats_requested = NULL;
* Function called from stat to register the stat's command-line argument
* and initialization routine
* ********************************************************************** */
+static gint
+sort_by_name(gconstpointer a, gconstpointer b)
+{
+ return strcmp(((const stat_cmd_arg *)a)->cmd,
+ ((const stat_cmd_arg *)b)->cmd);
+}
void
register_stat_cmd_arg(const char *cmd, void (*func)(const char *arg))
{
stat_cmd_arg *newsca;
newsca=g_malloc(sizeof(stat_cmd_arg));
- newsca->next=stat_cmd_arg_list;
- stat_cmd_arg_list=newsca;
newsca->cmd=cmd;
newsca->func=func;
+ stat_cmd_arg_list=g_slist_insert_sorted(stat_cmd_arg_list, newsca,
+ sort_by_name);
}
/* **********************************************************************
@@ -75,10 +80,12 @@ register_stat_cmd_arg(const char *cmd, void (*func)(const char *arg))
gboolean
process_stat_cmd_arg(char *optarg)
{
+ GSList *entry;
stat_cmd_arg *sca;
stat_requested *tr;
- for(sca=stat_cmd_arg_list;sca;sca=sca->next){
+ for(entry=stat_cmd_arg_list;entry;entry=g_slist_next(entry)){
+ sca=entry->data;
if(!strncmp(sca->cmd,optarg,strlen(sca->cmd))){
tr=g_malloc(sizeof (stat_requested));
tr->sca = sca;
@@ -96,9 +103,11 @@ process_stat_cmd_arg(char *optarg)
void
list_stat_cmd_args(void)
{
+ GSList *entry;
stat_cmd_arg *sca;
- for(sca=stat_cmd_arg_list;sca;sca=sca->next){
+ for(entry=stat_cmd_arg_list;entry;entry=g_slist_next(entry)){
+ sca=entry->data;
fprintf(stderr," %s\n",sca->cmd);
}
}