<div dir="ltr">Thanks for the tip. However, i'm decided to write my own implementation. My Python knowledge is very limited, but i'm take a look of your code later, in winter holidays (they are so long in Russia).<div>
<br><div>It almost working now, except support for some data types: host16/32, little16/32, big16/32.</div><div>Am i correctly understand this current-machine endian, little-endian and big-endian integer values of length 2 and 4 bytes?</div>
</div><div><br></div><div>About Windows support - you are right, it haven't all features of Unix shared mime database. But it can be useful at least with searching of registered extension list.</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/12/14 Jerome Leclanche <span dir="ltr"><<a href="mailto:adys.wh@gmail.com" target="_blank">adys.wh@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There is a Qt 4 port of this.<br>
<br>
As for windows support... I've been down that road, trying to provide<br>
it. Windows' feature set doesn't even sort of come close; it only<br>
provides real mime types for a limited set of registered extensions,<br>
and it doesn't provide any of the very useful features such as<br>
subclassing, etc. In the end, I gave up and am only providing<br>
xdg-based mime types. I think Qt made an excellent choice in providing<br>
the xdg database itself. But if you choose against that, good luck.<br>
<br>
Anyway you can have a look at my python-based mimetype lib. Magic<br>
matches are implemented on line 192 onwards.<br>
<br>
<a href="https://github.com/Adys/python-xdg/blob/master/xdg/mime.py" target="_blank">https://github.com/Adys/python-xdg/blob/master/xdg/mime.py</a><br>
<br>
J. Leclanche<br>
<br>
<br>
On Fri, Dec 13, 2013 at 7:56 PM, Alexander Kamyshnikov<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:axill777@gmail.com">axill777@gmail.com</a>> wrote:<br>
> Yes, i had. But i decided to write my own implementation because:<br>
> a) my project is forced to use Qt4 only (clients have very old versions of<br>
> modified Red Hat with XDG_DATA_DIRS undefined);<br>
> b) Windows support (through reading registry HKCR/.ext keys) is required;<br>
> c) I'm very curious :)<br>
><br>
> You think i'm should look deeply at the qmimedatabase.cpp however?<br>
><br>
><br>
> 2013/12/13 Jerome Leclanche <<a href="mailto:adys.wh@gmail.com">adys.wh@gmail.com</a>><br>
>><br>
>> Have you had a look at the Qt 5 mimetype module?<br>
>><br>
>> <a href="http://qt-project.org/doc/qt-5.0/qtcore/qmimedatabase.html" target="_blank">http://qt-project.org/doc/qt-5.0/qtcore/qmimedatabase.html</a><br>
>> J. Leclanche<br>
>><br>
>><br>
>> On Fri, Dec 13, 2013 at 7:35 PM, Alexander Kamyshnikov<br>
>> <<a href="mailto:axill777@gmail.com">axill777@gmail.com</a>> wrote:<br>
>> > Hi all!<br>
>> > I'm developing the implementation of MIME database in C++/Qt for one<br>
>> > commercial program (requirement managment tool, if one will be<br>
>> > interested).<br>
>> > So my question is: the format of magic values to compare file header<br>
>> > data<br>
>> > with is not specified exactly in the spec. I mean the magic/match/value<br>
>> > attribute.<br>
>> > What exactly mean those magic strings from<br>
>> > /usr/share/mime/packages/freedesktop.org.xml from my Kubuntu?<br>
>> > 1) "\1\9"<br>
>> > 2) "\376\067\0\043"<br>
>> > 3) "\x8AMNG\x0D\x0A\x1A\x0A"<br>
>> > Second is looks like octal number in C notation, third - hexadecimal,<br>
>> > but<br>
>> > about first i'm not sure. It is just "usual" decimal value?<br>
>> > What format exactly should use magic values?<br>
>> > Thanks for your help. WBR, Alexander<br>
>> ><br>
>> > P.S. Spec i'm using living here:<br>
>> ><br>
>> > <a href="http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#id2661973" target="_blank">http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#id2661973</a><br>

>> > P.S. <match> items can be nested. But i can't find yet the clear way to<br>
>> > implement their storage programmatically. Some kind of tree, or reverse<br>
>> > polish notation should be used here? nevermind<br>
>> ><br>
>> > _______________________________________________<br>
>> > xdg mailing list<br>
>> > <a href="mailto:xdg@lists.freedesktop.org">xdg@lists.freedesktop.org</a><br>
>> > <a href="http://lists.freedesktop.org/mailman/listinfo/xdg" target="_blank">http://lists.freedesktop.org/mailman/listinfo/xdg</a><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br></div>