[File] [PATCH] Magdir/maple help database *.hdb versus XBase index *.cdx

Jörg Jenderek joerg.jen.der.ek at gmx.net
Wed Aug 4 00:04:22 UTC 2021


Hello,

some days ago i inspected some Maple examples. Now i looked at Maple
help examples with hdb extension.

When running running file command version 5.40 on such examples and
related files i get an output like:

algolib.hdb:  Maple help database
exterior.hdb: Maple help database
hsum.hdb:     Maple help database
LieAlg.hdb:   Maple help database
maple.hdb:    Maple help database
CUSTREG.CDX:  Maple help database
HIGHWAY.CDX:  Maple help database
MailTo.CDX:   Maple help database
PARCEL.CDX:   Maple help database
Security.CDX: Maple help database

With --extension only ??? is displayed and with -i option
application/octet-stream  is shown for examples.

For comparison reason i run the file format identification utility
TrID ( See https://mark0.net/soft-trid-e.html).
All HDB examples are described by TrID also as "Maple Help Database"
by hdb-maple.trid.xml. The CDX examples, which are misidentified by
file command, are described correctly as "Compound index MS Visual
FoxPro 7" by cdx-vfp7.trid.xml or as "Sybase iAnywhere index files"
by sybase-ianywhere-cdx.trid.xml (See appended hdb-trid-v.txt.gz ).

The detection of examples happens by lines inside Magdir/maple like:
0	string	\000\004\000\000	Maple help database

So 4 bytes are used for detection, but that low value with 3 null
bytes is obviously not very unique enough. That pattern is also true
for many xBASE Compound Index files (*.CDX).

Unfortunately i found no file format specification. At least on
software producer page maplesoft i found a short page about the HDB
files. So at least i used the information of TrID database for
further information. That is expressed by additional comment lines likes
# URL:	https://www.maplesoft.com/support/help/maple/view.aspx?
# path=Formats/HDB
# Ref.:	https://mark0.net/download/triddefs_xml.7z
#       /defs/h/hdb-maple.trid.xml

According to TrID definition the HDB examples contain string
sequences like "Maple Input" and "Maple Output". This should be
unique enough to distinguish HDB from CDX examples. Unfortunately
these sequence can occur at "very high" offsets. So i look for
another test. In many example at fixed 1k range i found keyword
version. So i use this as first test and if this not possible then i
look for Maple keyword. So the magic lines now becomes like:
  0	string	\000\004\000\000
  >1028	string	version			Maple help database
  !:mime application/x-maple-hdb
  !:ext	hdb
  >1028	default	x
  >>4		search/0xCC41	Maple	KEY_Maple help database
  !:mime application/x-maple-hdb
  !:ext	hdb
Furthermore instead of generic mime typ application/octet-stream a
use defined one is shown.

After applying the above mentioned modifications by patch
file-5.40-maple-hdb.diff then all HDB examples are still recognized
and misidentifications of CDX examples vanished like:

algolib.hdb:  Maple help database
exterior.hdb: Maple help database
hsum.hdb:     Maple help database
LieAlg.hdb:   Maple help database
maple.hdb:    Maple help database
CUSTREG.CDX:  data
HIGHWAY.CDX:  data
MailTo.CDX:   data
PARCEL.CDX:   data
Security.CDX: data

I hope my diff file can be applied in future version of file utility.

I will try to create magic lines for CDX examples in a future session.

With best wishes
Jörg Jenderek
--
Jörg Jenderek























-------------- next part --------------
--- file-5.40/magic/Magdir/maple.old	2021-02-22 23:49:24 +0000
+++ file-5.40/magic/Magdir/maple	2021-08-03 23:43:07 +0000
@@ -15,5 +15,22 @@
 
 # .hdb
-0	string	\000\004\000\000	Maple help database
+# Update:	Joerg Jenderek
+# URL:		https://www.maplesoft.com/support/help/maple/view.aspx?path=Formats/HDB
+# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/h/hdb-maple.trid.xml
+# Note:		This format was replaced in Maple 18 by the Maple Help format (*.help)
+0	string	\000\004\000\000
+# skip xBASE Compound Index file *.CDX by looking for version
+>1028	string		version	Maple help database
+# length of string version
+#>>1024	ulelong		!7	\b, at 0x400 unexpected %u
+#!:mime application/octet-stream
+!:mime application/x-maple-hdb
+!:ext	hdb
+>1028	default		x
+# skip more xBASE Compound Index file *.CDX by looking for keyword Maple
+# like hsum.hdb
+>>4	search/0xCC41	Maple	Maple help database
+!:mime	application/x-maple-hdb
+!:ext	hdb
 
 # .mhp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.40-maple-hdb.diff.sig
Type: application/octet-stream
Size: 692 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20210804/c1d9eb44/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hdb-trid-v.txt.gz
Type: application/x-gzip
Size: 1209 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20210804/c1d9eb44/attachment.bin>


More information about the File mailing list