Re: [LIP] Using libmagic to check file type
Y Giridhar Appaji Nag <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
On 09/07/14 14:11 -0500, Kumar Appaiah said ... > I wish to use libmagic to verify whether the file I am currently > scanning is of a particular type. One possible way (which I've seen > being used) is to get the string which libmagic returns, and see if it > matches the pattern I expect. Is there a more "correct" way of > matching, say with an enumeration of file types and matching against > that, or is the former method the way it should be done? I was under the impression that file(1) uses libmagic which inturn reads a file of 'magic' patterns for the tests and the same file also has the 'file type string' to be printed. And looking at libmagic(3) ... The magic_file() function returns a textual description of the contents of the filename argument, or NULL if an error occurred. If the filename is NULL, then stdin is used. ... Giridhar -- Y Giridhar Appaji Nag | http://appaji.net/ ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ linux-india-programmers mailing list linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/linux-india-programmers
signature.asc
(application/pgp-signature, 489 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iQEcBAEBCAAGBQJKXVRKAAoJENbfLHnbvsrcf9QH/3Pub4QeotYtEP1ma4cgbGTF lW8QQSv/qz+SHIXh8v6wrXOSfNyEQp34ogqRz89b8oH3jDCekjtiCjTiSY0MG2/g DcMcpZc3cIZUTPPCwCix58heZURznM/eDlj5BAJr9h/FJqSyl1n5pcOsgOCT1AGb 9MdLzP7wzpKB1V4v4v2FmvWOSHhVioJMy/qJw29lln9fKCITT1+00fWoZtKCKXzx sgXaxOE1LTrYgFhFtC6ZppUC1LvsDdMuXCTDsXycn/y6Zxca+0yGzWBPGbM4f2Np cgk8CmIsPvK6gDSnJf3j9AtvY+l/qwuFOslVvmAlCWu7t2oCXTKy4rvjVmfvCe8= =PPiL -----END PGP SIGNATURE-----