Changes

Jump to: navigation, search

ZIM File Example

1,696 bytes added, 17:31, 9 May 2011
no edit summary
This is a example of a small zim file. You can find the documentation about the format at [[ZIM File Format]].
0000000: 5a49 4d04 0500 0000 3803 66de 7f7a d95d 19fd 9100 732b cfb6 ZIM.....8.f..z.]s+.. 0000010: d81c 7f3d ee01 7596 0200 3406 5519 ac2e 03c4 0300 0000 0100 0000 4.U..=..u......... 0000020: 6600 0000 0000 0000 7600 7e00 0000 0000 0000 f.......v~....... 0000030: aa00 ce00 0000 0000 0000 5000 0000 0000 0000 ........P....... 0000040: ffff ffff ffff ffff 0301 2701 0000 0000 0000 .........'.......
0000050: 7465 7874 2f68 746d 6c00 7465 7874 2f70 text/html.text/p
0000060: 6c61 696e 0000 7e00 8a00 0000 0000 0000 9400 a000 lain..~.......... 0000070: 0000 0000 0000 b800 0000 0000 0100 0000 0000 ................ 0000080: 0041 0000 0000 0100 0000 0200 0000 0000 0041 0000 4175 .A............AuA.. 0000090: 0000 0000 0000 0000 0000 4175 746f 0000 0100 0042 ..........Auto.. 00000a0: ffff 0041 0000 0000 0000 0000 4175 746f to...A........BAuto 00000b0: 6d6f 6269 6c65 0000 0100 0042 0000 0000 mobile.....B.... 00000a000000c0: 0000 0000 0100 0000 4175 746f 0000 b200 0000 0000 d600 ....Auto....Auto.... 00000b000000d0: 0000 0000 0000 04fd 377a 585a 0000 0169 22de 3602 ........7zXZ...i".6. 00000c000000e0: 22de 3602 0021 0110 0000 00a8 708e 86e0 001c 0018 ".6..!......p....... 00000d000000f0: 001c 0018 5e00 0600 34fb de91 72a3 8034 fc31 871f ....^...4...r..4.1.. 00000e00000100: fc31 871f e6aa 6104 7025 b184 dc00 00e1 66f9 e700 .1....a.p%......f... 00000f00000110: 66f9 e700 0130 1d01 efc6 9c90 4299 0d01 0000 0000 f.0...0...B....B... 00001000000120: 0000 0000 0159 5a78 bdf4 58bd 108c 16c6 9ef5 d42c 5a6c d75d be78 953c 79d9 .YZx..X..YZl.].x.<y..., 00001100000130: a3f4 e3 5054 034b 5726 c4 PT.KW&....
==Header==
0000000: <u>5a49 4d04</u> 0500 0000 0998 0d07 1f75 e653 19fd 9100 732b cfb6 ZIM.........s+.u.S
This is the magic number 72173914, which is in hex 44D495A and since all data is little endian, the result is this 5a49 4d04.
0000000: 5a49 4d04 <u>0500</u> 0000 0998 0d07 1f75 e653 19fd 9100 732b cfb6 ZIM.........s+.u.S
The major version number of the zim format is 5...
0000000: 5a49 4d04 0500 <u>0000</u> 0998 0d07 1f75 e653 19fd 9100 732b cfb6 ZIM.........s+.u.S
...and the minor version number is 0.
0000000: 5a49 4d04 0500 0000 <u>0998 0d07 1f75 e65319fd 9100 732b cfb6</u> ZIM.........s+.u.S 0000010: <u>7106 3faf 3c40 cba13406 5519 ac2e 03c4</u> 0200 0300 0000 0100 0000 q4.U..?.<@..........
The uuid.
0000010: 7106 3faf 3c40 cba1 3406 5519 ac2e 03c4 <u>0200 0300 0000</u> 0100 0000 q4.U..?.<@..........The file has 2 3 articles.
0000010: 7106 3faf 3c40 cba1 0200 3406 5519 ac2e 03c4 0300 0000 <u>0100 0000</u> q4.U..?.<@..........
And one cluster.
0000020: <u>6600 0000 0000 0000</u> 7600 7e00 0000 0000 0000 f.......v.......
You will find the url pointer list at offset 0000 0000 0000 0066.
0000020: 6600 0000 0000 0000 <u>7600 7e00 0000 0000 0000</u> f.......v.......The title pointer list follows at offset 0000 0000 0000 0076007e.
0000030: <u>aa00 ce00 0000 0000 0000</u> 5000 0000 0000 0000 ........P.......The cluster pointer list can be found at offset 0000 0000 0000 00aa00ce.
0000030: aa00 ce00 0000 0000 0000 <u>5000 0000 0000 0000</u> ........P.......
A list of used mime types is at offset 0000 0000 0000 0050.
0000040: <u>ffff ffff</u> ffff ffff 0301 2701 0000 0000 0000 .........'.......
No main page is defined here...
0000040: ffff ffff <u>ffff ffff</u> 0301 2701 0000 0000 0000 ................
...nor a layout page.
0000040: ffff ffff ffff ffff <u>0301 2701 0000 0000 0000</u> ................A md5 checksum of the file until that can be found at 0000 0000 0000 01030127.
==Mime type list==
0000050: <u>7465 7874 2f68 746d 6c00 7465 7874 2f70</u> text/html.text/p
0000060: <u>6c61 696e 0000</u> 7e00 8a00 0000 0000 0000 9400 a000 lain..~..........
As seen the mime type list starts at 0000 0000 0000 0050.
0000050: <u>7465 7874 2f68 746d 6c00</u> 7465 7874 2f70 text/html.text/p
0000060: 6c61 696e 0000 7e00 8a00 0000 0000 0000 9400 a000 lain..~.........
Mime types are zero terminated.
0000050: 7465 7874 2f68 746d 6c00 7465 7874 2f70 text/html.text/p
0000060: 6c61 696e 00<u>00</u> 7e00 8a00 0000 0000 0000 9400 a000 lain..~.........
After the last mime type, a single zero byte follows.
==Url pointer list==
0000060: 6c61 696e 0000 <u>7e00 8a00 0000 0000 0000 9400a000</u> lain..~.......... 0000070: <u>0000 0000 0000 b800 0000 0000 0000</u> 0000 0000 0100 0000 0000 ................The url pointer list starting at 0000 0000 0000 0066 has 2 3 pointers to the 2 3 directory entries of the 2 3 articles. The list is ordered by the url of the articlearticles. The first directory entry can be found at 0000 0000 0000 007e 008a, the second at 0000 0000 0000 00a0 and the second third at 0000 0000 0000 009400b8.
==Title pointer list==
0000070: 0000 0000 0000 b800 0000 0000 0000 <u>0000 </u> ................ 0000080: <u>0000 0100 0000 0200 0000</u> 0000 0041 0000 ..............A..
Here is the title pointer list.
0000070: 0000 0000 0000 b800 0000 0000 0000 <u>0000 </u> ................ 0000080: <u>0000</u> 0100 0000 0200 0000 0000 0041 0000 ..............A..When ordering by title, the article number 0 is the first. This actually refers to the 0th article in the url pointer list. To find the directory entry of the article, you have to look up the offset in the url pointer list. The offset to the directory entry can be found at (url-pointer-list + 0*sizeof(pointer))=0066+0*8=0066.
00000700000080: 0000 0000 0000 0000 0000 <u>0100 0000</u> 0200 0000 0000 0041 0000 ..............A..
When ordering by title, the article number 1 is the second. The offset to the directory entry can be found at (url-pointer-list + 1*sizeof(pointer))=0066+1*8=006E.
 
0000080: 0000 0100 0000 <u>0200 0000</u> 0000 0041 0000 .............A..
When ordering by title, the article number 2 is the third. The offset to the directory entry can be found at (url-pointer-list + 2*sizeof(pointer))=0066+2*8=0076.
==Directory entry==
00000700000080: 0000 0100 0000 0000 0000 0000 0100 0200 0000 <u>0000 0041 0000</u> ..............A.. 00000800000090: <u>0041 0000 0000 0000 0000 0000 0000 4175</u> .A............Au 0000090: <u>746f 0000</u> 0100 0042 ff7f 0000 0000 0000 to.....B......Auto..This is the first directory entry at 007e008a.
00000700000080: 0000 0100 0000 0000 0000 0000 0100 0200 0000 <u>0000</u> 0041 0000 ..............A..
The article has the 0th mime type from the list, which is "text/html".
0000080: 0000 0100 0000 0200 0000 0000 0041 <u>00</u>00 0000 0000 0000 0000 0000 4175 .A............AuA..
No extra bytes are set.
0000080: 0000 0100 0000 0200 0000 0000 00<u>41</u> 0000 0000 0000 0000 0000 0000 4175 .<u>A</u>............Au<u>A</u>..
The namespace of the article is 'A'.
0000080: 0000 0100 0000 0200 0000 0000 0041 <u>0000 </u> .............A.. 0000090: <u>0000</u> 0000 0000 0000 0000 4175 746f 0000 .A..........Auto..Au
The version is 0000 0000.
00000800000090: 0041 0000 0000 <u>0000 0000</u> 0000 0000 4175 746f 0000 .A..........Auto..Au
The data can be found in cluster 0.
00000800000090: 0041 0000 0000 0000 0000 <u>0000 0000</u> 4175 746f 0000 .A..........Auto..Au
And it is the 0th blob in the cluster.
00000800000090: 0041 0000 0000 0000 0000 0000 0000 <u>4175746f 00</u> 00 .A............<u>Au</u> 0000090: <u>746f 00</u>00 0100 0042 0000 0000 0000 0000 <u>toAuto.</u>....B........
The url of the article is "Auto" and is zero terminated.
0000090: 0000 0000 0000 0000 0000 4175 746f 00<u>00</u> 0100 0042 0000 0000 0000 0000 to.....B......Auto..
The title is empty and hence the title is the same as the url: "Auto".
000009000000a0: 746f 0000 <u>0100 0042 ffff 0041 0000 0000 0000 00004175 746f</u> to.....BA........Auto 00000a000000b0: <u>0100 0000 4175 746f 6d6f 6269 6c65 0000</u> b200 0100 0042 0000 0000 mobile....Auto....B....The next second directory entry can be found at offset 0000 0000 0000 0094 00a0 and is the Article "AutoAutomobile" of namespace 'BA'.  00000a0: <u>ffff</u> 0041 0000 0000 0000 0000 4175 746f ...A........AutoThe mime type is set to ffff, which means, that this is a redirect.  00000a0: ffff <u>00</u>41 0000 0000 0000 0000 4175 746f ...A........Auto No extra bytes are set.  00000a0: ffff 00<u>41</u> 0000 0000 0000 0000 4175 746f ...<u>A</u>........Auto The namespace of the redirect is 'A'.
000009000000a0: ffff 0041 <u>0000 0000</u> 0000 0000 4175 746f ...A........Auto The version is 0000 0000.  00000a0: ffff 0041 0000 0000 <u>0000 0000</u> 4175 746f ...A........Auto It points to the 0th article, which is A/Auto.  00000a0: ffff 0041 0000 0000 0000 0000 <u>4175 746f</u> ...A........<u>Auto</u> 00000b0: <u>6d6f 6269 6c65 00</u>00 01000042 0000 0000 mobile.....B....The url of the redirect is "Automobile" and is zero terminated.  00000b0: 6d6f 6269 6c65 0000 <u>0100 0042 0000 0000</u> 0042 mobile.....B.... 00000c0: <u>0000 0000 0100 0000 4175 746f 0000</u> d600 ........Auto.... 00000d0: 0000 0000 0000 04fd 377a 585a 0000 0169 to........7zXZ...iThe next directory entry can be found at offset 0000 0000 0000 00b8 and is the Article "Auto" of namespace 'B' 00000b0: 6d6f 6269 6c65 0000 <u>01</u>00 0042 0000 0000 mobile.....B....
The mimetype is entry number 1 and hence the 2nd since the first is the number 0. The mimetype is then "text/plain".
The rest of the directory entry is similar to the fist one.
==Cluster pointer list==
00000a000000c0: 0000 0000 0100 0000 4175 746f 0000 <u>b200 0000 0000d600</u> ....Auto....Auto.... 00000b000000d0: <u>0000 0000 0000</u> 04fd 377a 585a 0000 0169 22de 3602 ........7zXZ...i".6.The cluster pointer list is just one offset in this case. The cluster can be found at offset 0000 0000 0000 00b200d6.
==Cluster==
  00000b000000d0: 0000 0000 0000 <u>04fd 377a 585a 0000 0169 22de 3602</u> ........7zXZ...i".6. 00000c000000e0: <u>22de 3602 0021 0110 0000 00a8 708e 86e0 001c 0018</u> ".6..!......p....... 00000d000000f0: <u>001c 0018 5e00 0600 34fb de91 72a3 8034 fc31 871f</u> ....^...4...r..4.1.. 00000e00000100: <u>fc31 871f e6aa 6104 7025 b184 dc00 00e1 66f9 e700</u> .1....a.p%......f... 00000f00000110: <u>66f9 e700 0130 1d01 efc6 9c90 4299 0d01 0000 0000</u> .0f....0..B....B... 00001000000120: <u>0000 0000 0159 5a</u>78 bdf4 58bd 108c 16c6 9ef5 d42c 6c d75d be78 953c 79d9 .YZx..X..YZl.].x...., 0000110: a3f4 e3 ..<y.
This is the cluster. Note that you can't know how large the cluster is until you uncompress the first bytes.
00000b000000d0: 0000 0000 0000 <u>04</u>fd 377a 585a 0000 0169 22de 3602 ........7zXZ...i".6.
The first byte specifies the compression algorithm, which is 4, which means lzma (or more precise xz) here.

Navigation menu