12 #include "osmbinary.h"
14 int main(int argc
, char *argv
[]) {
21 fprintf(stderr
, "Analysing %s...\n", argv
[1]);
23 fd
= open(argv
[1], O_RDONLY
);
28 if (fstat (fd
, &statbuf
) == -1) { perror("fstat:"); exit(-1); }
30 if (statbuf
.st_size
> 0) {
32 range
= mmap(NULL
, statbuf
.st_size
, PROT_READ
, MAP_SHARED
, fd
, (off_t
) 0);
33 if (range
== MAP_FAILED
) { perror("Mmap:"); printf("(did you compile PAE in the kernel?)\n"); exit(-1); }
37 while (i
< statbuf
.st_size
) {
48 // fprintf(stderr, "\nindex: %d\n", i);
49 i
+= sizeof(bin_node
.id
) +
50 sizeof(bin_node
.lat
) +
51 sizeof(bin_node
.lon
) +
52 sizeof(bin_node
.stamp
);
54 len
= (unsigned char *) &range
[i
];
55 i
+= sizeof(bin_node
.userlen
);
57 for (j
= 0; j
< *len
; j
++)
58 putchar(range
[i
+ j
]);
66 unsigned short int *len
;
68 len
= (unsigned short int *) &range
[i
];
69 i
+= sizeof(bin_tag
.klen
);
71 for (j
= 0; j
< *len
; j
++)
72 putchar(range
[i
+ j
]);
76 len
= (unsigned short int *) &range
[i
];
77 i
+= sizeof(bin_tag
.vlen
);
79 for (j
= 0; j
< *len
; j
++)
80 putchar(range
[i
+ j
]);
88 i
+= sizeof(bin_other
.id
) +
89 sizeof(bin_other
.stamp
);
91 len
= (unsigned char *) &range
[i
];
92 i
+= sizeof(bin_other
.userlen
);
94 for (j
= 0; j
< *len
; j
++)
95 putchar(range
[i
+ j
]);
101 i
+= sizeof(bin_nd
.id
);
106 i
+= sizeof(bin_other
.id
) +
107 sizeof(bin_other
.stamp
);
109 len
= (unsigned char *) &range
[i
];
110 i
+= sizeof(bin_other
.userlen
);
112 for (j
= 0; j
< *len
; j
++)
113 putchar(range
[i
+ j
]);
119 unsigned short int *len
;
121 len
= (unsigned short int *) &range
[i
];
122 i
+= sizeof(bin_member
.typelen
);
124 for (j
= 0; j
< *len
; j
++)
125 putchar(range
[i
+ j
]);
129 len
= (unsigned short int *) &range
[i
];
130 i
+= sizeof(bin_member
.reflen
);
132 for (j
= 0; j
< *len
; j
++)
133 putchar(range
[i
+ j
]);
137 len
= (unsigned short int *) &range
[i
];
138 i
+= sizeof(bin_member
.rolelen
);
140 for (j
= 0; j
< *len
; j
++)
141 putchar(range
[i
+ j
]);
147 fprintf(stderr
, "otherstate");
152 munmap(range
, statbuf
.st_size
);