]> granicus.if.org Git - strace/commitdiff
2004-05-02 Dmitry V. Levin <ldv@altlinux.org>
authorRoland McGrath <roland@redhat.com>
Fri, 4 Jun 2004 02:03:05 +0000 (02:03 +0000)
committerRoland McGrath <roland@redhat.com>
Fri, 4 Jun 2004 02:03:05 +0000 (02:03 +0000)
* linux/ioctlsort.c (compare): When ioctl codes equal, compare
names.
(main): Print a note that program output is generated by
ioctlsort.

linux/ioctlsort.c

index ff55d7870d09e3752bb7d375e7cded0004898624..735e131e6a1d8905395b9bacf3c20131350731b5 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <asm/ioctl.h>
 #include <linux/types.h>
@@ -23,7 +24,9 @@ int nioctls = sizeof(ioctls) / sizeof(ioctls[0]);
 int compare(const void* a, const void* b) {
        unsigned long code1 = ((struct ioctlent *) a)->code;
        unsigned long code2 = ((struct ioctlent *) b)->code;
-       return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
+       const char *name1 = ((struct ioctlent *) a)->name;
+       const char *name2 = ((struct ioctlent *) b)->name;
+       return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp (name1, name2);
 }
 
 
@@ -31,6 +34,7 @@ int main(int argc, char** argv) {
        int i;
 
        qsort(ioctls, nioctls, sizeof(ioctls[0]), compare);
+       puts ("\t/* Generated by ioctlsort */");
        for (i = 0; i < nioctls; i++)
                printf("\t{\"%s\",\t\"%s\",\t%#lx},\n",
                        ioctls[i].header, ioctls[i].name, ioctls[i].code);