blob: f544d843bf419a124cd78343a8d450f3c0657aaa [file] [log] [blame]
Wichert Akkermane2613b42001-03-17 17:29:43 +00001#include <stdio.h>
2#include <stdlib.h>
Roland McGrath3dfd7992004-06-04 02:03:05 +00003#include <string.h>
Roland McGrathbd102452004-07-12 07:04:39 +00004#include <sys/types.h>
5#include <stdint.h>
Wichert Akkermane2613b42001-03-17 17:29:43 +00006
7#include <asm/ioctl.h>
8#include <linux/types.h>
9
10#include "ioctldefs.h"
11#include <linux/atmioc.h>
12
13struct ioctlent {
14 const char* header;
15 const char* name;
16 unsigned long code;
17};
18
19struct ioctlent ioctls[] = {
20#include "ioctls.h"
21};
22
23int nioctls = sizeof(ioctls) / sizeof(ioctls[0]);
24
25
26int compare(const void* a, const void* b) {
27 unsigned long code1 = ((struct ioctlent *) a)->code;
28 unsigned long code2 = ((struct ioctlent *) b)->code;
Roland McGrath3dfd7992004-06-04 02:03:05 +000029 const char *name1 = ((struct ioctlent *) a)->name;
30 const char *name2 = ((struct ioctlent *) b)->name;
31 return (code1 > code2) ? 1 : (code1 < code2) ? -1 : strcmp (name1, name2);
Wichert Akkermane2613b42001-03-17 17:29:43 +000032}
33
34
35int main(int argc, char** argv) {
36 int i;
37
Roland McGrathbd102452004-07-12 07:04:39 +000038#ifdef POWERPC /* unspeakable kludge */
39 for (i = 0; i < nioctls; i++)
40 ioctls[i].code &= ~_IOC_DIRMASK;
41#endif
42
Wichert Akkermane2613b42001-03-17 17:29:43 +000043 qsort(ioctls, nioctls, sizeof(ioctls[0]), compare);
Roland McGrath3dfd7992004-06-04 02:03:05 +000044 puts ("\t/* Generated by ioctlsort */");
Wichert Akkermane2613b42001-03-17 17:29:43 +000045 for (i = 0; i < nioctls; i++)
Roland McGrath7166bb02004-10-06 22:31:38 +000046 if (i == 0 || ioctls[i].code != ioctls[i-1].code ||
47 strcmp (ioctls[i].name, ioctls[i-1].name))
48 printf("\t{\"%s\",\t\"%s\",\t%#lx},\n",
49 ioctls[i].header, ioctls[i].name, ioctls[i].code);
Roland McGrathbd102452004-07-12 07:04:39 +000050
Wichert Akkermane2613b42001-03-17 17:29:43 +000051 return 0;
52}