]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
use versionsort when available
authorVitalii Demianets <vitas@nppfactor.kiev.ua>
Wed, 28 Sep 2011 13:05:02 +0000 (13:05 +0000)
committerVitalii Demianets <vitas@nppfactor.kiev.ua>
Wed, 28 Sep 2011 13:05:02 +0000 (13:05 +0000)
git-svn-id: http://svn.code.sf.net/p/mstpd/code/trunk@12 fbe50366-0c72-4402-a84b-5d246361dba7

Makefile
ctl_main.c

index f01f513219fe3a861a324b91a01d16346c32d753..30957dde9e7ab53e697266973287725389d33b34 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,8 @@ CTLSOURCES = ctl_main.c ctl_socket_client.c
 
 CTLOBJECTS = $(CTLSOURCES:.c=.o)
 
-CFLAGS += -Werror -O2 -D_REENTRANT -D__LINUX__ -DVERSION=$(version) -I.
+CFLAGS += -Werror -O2 -D_REENTRANT -D__LINUX__ -DVERSION=$(version) -I. \
+          -D_GNU_SOURCE -D__LIBC_HAS_VERSIONSORT__
 
 all: mstpd mstpctl
 
index 0df94f1070dcd4418a325e89ff5d0662acb4d902..5473a1826f95bcb3a5d99b0a1f1d13fa938842f0 100644 (file)
 #include "ctl_socket_client.h"
 #include "log.h"
 
+#ifdef  __LIBC_HAS_VERSIONSORT__
+#define sorting_func    versionsort
+#else
+#define sorting_func    alphasort
+#endif
+
 static int get_index_die(const char *ifname, const char *doc, bool die)
 {
     int r = if_nametoindex(ifname);
@@ -147,7 +153,7 @@ static int cmd_showbridge(int argc, char *const *argv)
     else
     {
         /* TODO: use versionsort, if available */
-        count = scandir(SYSFS_CLASS_NET, &namelist, isbridge, alphasort);
+        count = scandir(SYSFS_CLASS_NET, &namelist, isbridge, sorting_func);
         if(0 > count)
         {
             fprintf(stderr, "Error getting list of all bridges\n");
@@ -379,7 +385,7 @@ static int cmd_showport(int argc, char *const *argv)
         char buf[SYSFS_PATH_MAX];
         snprintf(buf, sizeof(buf), SYSFS_CLASS_NET "/%s/brif", argv[1]);
         /* TODO: use versionsort, if available */
-        count = scandir(buf, &namelist, not_dot_dotdot, alphasort);
+        count = scandir(buf, &namelist, not_dot_dotdot, sorting_func);
         if(0 > count)
         {
             fprintf(stderr, "Error getting list of all ports of bridge %s\n",