forked from osmocom/wireshark
When listing encapsulation types with -T or file types with -F, sort them.
svn path=/trunk/; revision=35022
This commit is contained in:
parent
4d4283ef98
commit
5519715365
47
editcap.c
47
editcap.c
|
@ -733,30 +733,61 @@ usage(gboolean is_error)
|
|||
fprintf(output, "\n");
|
||||
}
|
||||
|
||||
struct string_elem {
|
||||
const char *sstr; /* The short string */
|
||||
const char *lstr; /* The long string */
|
||||
};
|
||||
|
||||
static gint
|
||||
string_compare(const struct string_elem *a, const struct string_elem *b)
|
||||
{
|
||||
return strcmp(a->sstr, b->sstr);
|
||||
}
|
||||
|
||||
static void
|
||||
string_elem_print(const struct string_elem *data, void *not_used)
|
||||
{
|
||||
fprintf(stderr, " %s - %s\n", data->sstr, 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, "editcap: 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))
|
||||
fprintf(stderr, " %s - %s\n",
|
||||
wtap_file_type_short_string(i), wtap_file_type_string(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
|
||||
list_encap_types(void) {
|
||||
int i;
|
||||
const char *string;
|
||||
struct string_elem *encaps;
|
||||
GSList *list = NULL;
|
||||
|
||||
encaps = g_malloc(sizeof(struct string_elem) * WTAP_NUM_ENCAP_TYPES);
|
||||
fprintf(stderr, "editcap: The available encapsulation types for the \"-T\" flag are:\n");
|
||||
for (i = 0; i < WTAP_NUM_ENCAP_TYPES; i++) {
|
||||
string = wtap_encap_short_string(i);
|
||||
if (string != NULL)
|
||||
fprintf(stderr, " %s - %s\n",
|
||||
string, wtap_encap_string(i));
|
||||
encaps[i].sstr = wtap_encap_short_string(i);
|
||||
if (encaps[i].sstr != NULL) {
|
||||
encaps[i].lstr = wtap_encap_string(i);
|
||||
list = g_slist_insert_sorted(list, &encaps[i], string_compare);
|
||||
}
|
||||
}
|
||||
g_slist_foreach(list, string_elem_print, NULL);
|
||||
g_slist_free(list);
|
||||
g_free(encaps);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
|
|
Loading…
Reference in New Issue