aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorChris Maynard <Christopher.Maynard@GTECH.COM>2013-07-10 16:18:37 +0000
committerChris Maynard <Christopher.Maynard@GTECH.COM>2013-07-10 16:18:37 +0000
commitd602662b36b7322573e83fe80c3ab820992073c9 (patch)
tree5fda0e507b0a842f2851f5a8ab4814f23dfa168e /editcap.c
parentd3e9ec675a21f9a52871c271855de7575868b792 (diff)
Add strnatcmp by Martin Pool for 'natural order' string comparisons, and make use of it in editcap and mergecap for listing encapsulation types. For example:
Before: user0 - USER 0 user1 - USER 1 user10 - USER 10 user11 - USER 11 user12 - USER 12 user13 - USER 13 user14 - USER 14 user15 - USER 15 user2 - USER 2 user3 - USER 3 user4 - USER 4 user5 - USER 5 user6 - USER 6 user7 - USER 7 user8 - USER 8 user9 - USER 9 After: user0 - USER 0 user1 - USER 1 user2 - USER 2 user3 - USER 3 user4 - USER 4 user5 - USER 5 user6 - USER 6 user7 - USER 7 user8 - USER 8 user9 - USER 9 user10 - USER 10 user11 - USER 11 user12 - USER 12 user13 - USER 13 user14 - USER 14 user15 - USER 15 svn path=/trunk/; revision=50482
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/editcap.c b/editcap.c
index a0a4dfc227..34a1509bed 100644
--- a/editcap.c
+++ b/editcap.c
@@ -89,6 +89,7 @@
#include "epan/plugins.h"
#include "epan/report_err.h"
#include "epan/filesystem.h"
+#include "epan/strnatcmp.h"
#include "wsutil/nstime.h"
#undef WS_BUILD_DLL
#define RESET_SYMBOL_EXPORT
@@ -780,6 +781,13 @@ string_compare(gconstpointer a, gconstpointer b)
((const struct string_elem *)b)->sstr);
}
+static gint
+string_nat_compare(gconstpointer a, gconstpointer b)
+{
+ return strnatcmp(((const struct string_elem *)a)->sstr,
+ ((const struct string_elem *)b)->sstr);
+}
+
static void
string_elem_print(gpointer data, gpointer not_used _U_)
{
@@ -820,7 +828,7 @@ list_encap_types(void) {
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);
+ list = g_slist_insert_sorted(list, &encaps[i], string_nat_compare);
}
}
g_slist_foreach(list, string_elem_print, NULL);
@@ -900,7 +908,7 @@ main(int argc, char *argv[])
#endif
/* Process the options */
- while ((opt = getopt(argc, argv, "A:B:c:C:dD:E:F:hrs:i:t:S:T:vw:")) !=-1) {
+ while ((opt = getopt(argc, argv, "A:B:c:C:dD:E:F:hi:rs:S:t:T:vw:")) !=-1) {
switch (opt) {