From: Vitalii Demianets Date: Wed, 28 Sep 2011 13:05:02 +0000 (+0000) Subject: use versionsort when available X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8993038568d3a0c4ae971ef2e0cebb403d893b42;p=people%2Fms%2Fmstpd.git use versionsort when available git-svn-id: http://svn.code.sf.net/p/mstpd/code/trunk@12 fbe50366-0c72-4402-a84b-5d246361dba7 --- diff --git a/Makefile b/Makefile index f01f513..30957dd 100644 --- 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 diff --git a/ctl_main.c b/ctl_main.c index 0df94f1..5473a18 100644 --- a/ctl_main.c +++ b/ctl_main.c @@ -32,6 +32,12 @@ #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",