forked from osmocom/wireshark
Sort capture file types listed by "-F" like editcap does.
svn path=/trunk/; revision=36008
This commit is contained in:
parent
46865581e5
commit
7180a53aff
46
tshark.c
46
tshark.c
|
@ -186,15 +186,45 @@ static void write_failure_message(const char *filename, int err);
|
|||
|
||||
capture_file cfile;
|
||||
|
||||
static void list_capture_types(void) {
|
||||
int i;
|
||||
struct string_elem {
|
||||
const char *sstr; /* The short string */
|
||||
const char *lstr; /* The long string */
|
||||
};
|
||||
|
||||
fprintf(stderr, "editcap: The available capture file types for \"F\":\n");
|
||||
for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) {
|
||||
if (wtap_dump_can_open(i))
|
||||
fprintf(stderr, " %s - %s\n",
|
||||
wtap_file_type_short_string(i), wtap_file_type_string(i));
|
||||
}
|
||||
static gint
|
||||
string_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return strcmp(((struct string_elem *)a)->sstr,
|
||||
((struct string_elem *)b)->sstr);
|
||||
}
|
||||
|
||||
static void
|
||||
string_elem_print(gpointer data, gpointer not_used _U_)
|
||||
{
|
||||
fprintf(stderr, " %s - %s\n",
|
||||
((struct string_elem *)data)->sstr,
|
||||
((struct string_elem *)data)->lstr);
|
||||
}
|
||||
|
||||
static void
|
||||
list_capture_types(void) {
|
||||
int i;
|
||||
struct string_elem *captypes;
|
||||
GSList *list = NULL;
|
||||
|
||||
captypes = g_malloc(sizeof(struct string_elem) * WTAP_NUM_FILE_TYPES);
|
||||
|
||||
fprintf(stderr, "tshark: The available capture file types for the \"-F\" flag are:\n");
|
||||
for (i = 0; i < WTAP_NUM_FILE_TYPES; i++) {
|
||||
if (wtap_dump_can_open(i)) {
|
||||
captypes[i].sstr = wtap_file_type_short_string(i);
|
||||
captypes[i].lstr = wtap_file_type_string(i);
|
||||
list = g_slist_insert_sorted(list, &captypes[i], string_compare);
|
||||
}
|
||||
}
|
||||
g_slist_foreach(list, string_elem_print, NULL);
|
||||
g_slist_free(list);
|
||||
g_free(captypes);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue