#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <asm/ioctl.h>
#include <linux/types.h>
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);
}
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);