On 09/11/2013 08:10:22 PM, Conroy, Bradley Quentin wrote:
> At some point, I need to do file. It's a posix command, but all the
> brains of the thing are in a file of match heuristics, and so far
> toybox doesn't depend on external data files.
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/file.html

funny you should mention that, I have a version of "file --mime-type" that
works similar to the blkid after checking the file extension(s).

The commands implement the same general idea. :)

Currently I
have about 30kb of extension-based mime-type checks some are not
very common though and could be commened out.  If the ext check fails
it then falls back to magic@offset checks (currently I only have common image types implemented) I only wrote this because it is a choke point
in a lot of web servers, so all the code is in 7 switch cases rather
than an external file (it is ~60x faster though, since most of the time
it doesn't even need to open the file) again, if's may be better than
switch case in hind sight.  My initial implementation is here:
http://murga-linux.com/puppy/viewtopic.php?p=715660#715660
but I have fixed some stuff since and added the magic checks.

The speed is indeed awesome, but hardwiring in a lot of stuff makes me uncomfortable. Have to think about it.

(I initially thought Posix's "example" table would be a good thing to hardwire in, until I looked at it. Trust posix to come up with truly useless examples.)

> The current command's name is this.which->name (because this.which is a
> pointer to our entry in toylist[], and then name is the command name
> field, main is the function pointer, and so on).

That should be enough to do a strncmp to determine whether to handle
the UUID and device name. It will be early next week before I can get to
it though.

You see how far behind I am on my email. :)

Rob
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to