feat(gencat): add gencat implementation for GNU and OSX
the tests file contain *.cat file (which are the binary catalog file generated by gencat tool available in respective platform i.e OSX and the one that uses GNU)
So we are testing our result against output in those two platforms.
FYI: POSIX specification implies on the structure of the message file and not the binary catalog file, so it seems throughout time both OSX(which copied most of its implementation from BSD) and any OS that uses GNU(let's say linux) have developed their own version of binary catalog file and they completely differ from each other as of now
So, to implement gencat, means to adhere by those binary catalog format for that specific platform(hence the source code is needed)..luckily got the source code for OSX and GNU implementation(which were open source)
hexdump -C dump of the binary catalog file and it's structure in OSX.
I guess this can be a good reference of the structure of gencat (which is missing) in the internet
$set 1
1 This is the first message
2 This is the second message
$set 2
1 This is the third message
2 This is the fourth message
$set 3
1 This is the fifth message
2 This is the sixth message
$set 4
1 This is the seventh message
2 This is the eigth message
OSX(catfile structure)
00000000 <2a 6e 61 7a 67 75 6c 2a MAGIC HEADER> <00 00 00 01 MAJOR VERSION> <00 00 00 00 MINOR VERSION> |*nazgul*........|
00000010 <00 00 00 01 ENDIANESS OR FLAGS> <00 00 00 04 TOTAL NO OF SETS> <00 00 00 00 00 00 00 20 POSITION OF THE FIRIST SET WITHIN THIS CATFILE> |............... |
00000020 <00 00 00 01 FIRST SET ID> <00 00 00 00 00 00 00 9d NEXT SET POS> <00 00 00 00 |................|
00000030 00 00 00 7d FIRST MESSAGE POS> <00 00 00 00 00 00 00 48 DATA OFFSET> <00 00 00 35 DATA LENGTH> |...}.......H...5|
00000040 <00 00 00 02 TOTAL MESSAGE COUNT> 00 00 00 00<NOT INVALID FLAG> < STRING MESSAGE CONTINUES 54 68 69 73 20 69 73 20 |........This is |
00000050 74 68 65 20 66 69 72 73 74 20 6d 65 73 73 61 67 |the first messag|
00000060 65 00 54 68 69 73 20 69 73 20 74 68 65 20 73 65 |e.This is the se|
00000070 63 6f 6e 64 20 6d 65 73 73 61 67 65 00 00 00 00 |cond message....|
00000080 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000090 02 00 00 00 00 00 00 00 1a 00 00 00 00 (BOUNDARY FOR NEXT SET BOUNDARY AND SAME PATTERN CONTINUES) 00 00 00 |................|
000000a0 02 00 00 00 00 00 00 01 1a 00 00 00 00 00 00 00 |................|
000000b0 fa 00 00 00 00 00 00 00 c5 00 00 00 35 00 00 00 |............5...|
000000c0 02 00 00 00 00 54 68 69 73 20 69 73 20 74 68 65 |.....This is the|
000000d0 20 74 68 69 72 64 20 6d 65 73 73 61 67 65 00 54 | third message.T|
000000e0 68 69 73 20 69 73 20 74 68 65 20 66 6f 75 72 74 |his is the fourt|
000000f0 68 20 6d 65 73 73 61 67 65 00 00 00 00 01 00 00 |h message.......|
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 |................|
00000110 00 00 00 00 00 1a 00 00 00 00 00 00 00 03 00 00 |................|
00000120 00 00 00 00 01 96 00 00 00 00 00 00 01 76 00 00 |.............v..|
00000130 00 00 00 00 01 42 00 00 00 34 00 00 00 02 00 00 |.....B...4......|
00000140 00 00 54 68 69 73 20 69 73 20 74 68 65 20 66 69 |..This is the fi|
00000150 66 74 68 20 6d 65 73 73 61 67 65 00 54 68 69 73 |fth message.This|
00000160 20 69 73 20 74 68 65 20 73 69 78 74 68 20 6d 65 | is the sixth me|
00000170 73 73 61 67 65 00 00 00 00 01 00 00 00 00 00 00 |ssage...........|
00000180 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................|
00000190 00 1a 00 00 00 00 00 00 00 04 00 00 00 00 00 00 |................|
000001a0 00 00 00 00 00 00 00 00 01 f5 00 00 00 00 00 00 |................|
000001b0 01 be 00 00 00 37 00 00 00 02 00 00 00 00 54 68 |.....7........Th|
000001c0 69 73 20 69 73 20 74 68 65 20 73 65 76 65 6e 74 |is is the sevent|
000001d0 68 20 6d 65 73 73 61 67 65 00 54 68 69 73 20 69 |h message.This i|
000001e0 73 20 74 68 65 20 65 69 67 68 74 68 20 6d 65 73 |s the eighth mes|
000001f0 73 61 67 65 00 00 00 00 01 00 00 00 00 00 00 00 |sage............|
00000200 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 |................|
00000210 1c 00 00 00 00 |.....|
00000215
GNU (catfile structure)
Note: The set id that's in the message file is bumped by +1, this is how the GNU implementation handles it
00000000 <de 08 04 96 <03 00 00 00 BEST SIZE> <03 00 00 00 BEST DEPTH> <SET ID(LITTLE ENDIAN) 03 00 00 00 |................|
00000010 <MESSAGE ID 01 00 00 00> <MESSAGE POSITION WITHIN STRING POOL(see bottom) 6b 00 00 00> 05 00 00 00 02 00 00 00 |....k...........|
00000020 1c 00 00 00 05 00 00 00 01 00 00 00 00 00 00 00 |................|
00000030 03 00 00 00 02 00 00 00 85 00 00 00 04 00 00 00 |................|
00000040 01 00 00 00 37 00 00 00 04 00 00 00 02 00 00 00 |....7...........|
00000050 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |Q...............|
00000060 02 00 00 00 02 00 00 00 ba 00 00 00 02 00 00 00 |................|
00000070 01 00 00 00 a0 00 00 00 00 00 00 03 00 00 00 01 |................|
00000080 00 00 00 6b 00 00 00 05 00 00 00 02 00 00 00 1c |...k............|
00000090 00 00 00 05 00 00 00 01 00 00 00 00 00 00 00 03 |................|
000000a0 00 00 00 02 00 00 00 85 00 00 00 04 00 00 00 01 |................|
000000b0 00 00 00 37 00 00 00 04 00 00 00 02 00 00 00 51 |...7...........Q|
000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
000000d0 00 00 00 02 00 00 00 ba 00 00 00 02 00 00 00 01 |................|
000000e0 00 00 00 <STRING POOL a0 54 68 69 73 20 69 73 20 74 68 65 20 |....This is the |
000000f0 73 65 76 65 6e 74 68 20 6d 65 73 73 61 67 65 00 |seventh message.|
00000100 54 68 69 73 20 69 73 20 74 68 65 20 65 69 67 68 |This is the eigh|
00000110 74 68 20 6d 65 73 73 61 67 65 00 54 68 69 73 20 |th message.This |
00000120 69 73 20 74 68 65 20 66 69 66 74 68 20 6d 65 73 |is the fifth mes|
00000130 73 61 67 65 00 54 68 69 73 20 69 73 20 74 68 65 |sage.This is the|
00000140 20 73 69 78 74 68 20 6d 65 73 73 61 67 65 00 54 | sixth message.T|
00000150 68 69 73 20 69 73 20 74 68 65 20 74 68 69 72 64 |his is the third|
00000160 20 6d 65 73 73 61 67 65 00 54 68 69 73 20 69 73 | message.This is|
00000170 20 74 68 65 20 66 6f 75 72 74 68 20 6d 65 73 73 | the fourth mess|
00000180 61 67 65 00 54 68 69 73 20 69 73 20 74 68 65 20 |age.This is the |
00000190 66 69 72 73 74 20 6d 65 73 73 61 67 65 00 54 68 |first message.Th|
000001a0 69 73 20 69 73 20 74 68 65 20 73 65 63 6f 6e 64 |is is the second|
000001b0 20 6d 65 73 73 61 67 65 00 | message.|
000001b9
ready to be merged @jgarzik
@rishadbaniya I agree, ready to merge!
Need to resolve the Cargo.lock merge conflict.
@rishadbaniya I agree, ready to merge!
Need to resolve the Cargo.lock merge conflict.
merge conflict resolved!