16fca56fbSSascha Wildner.\" $File: libmagic.man,v 1.45 2019/06/08 22:16:24 christos Exp $ 2327e51cbSPeter Avalos.\" 36fca56fbSSascha Wildner.\" Copyright (c) Christos Zoulas 2003, 2018. 4327e51cbSPeter Avalos.\" All Rights Reserved. 5327e51cbSPeter Avalos.\" 6327e51cbSPeter Avalos.\" Redistribution and use in source and binary forms, with or without 7327e51cbSPeter Avalos.\" modification, are permitted provided that the following conditions 8327e51cbSPeter Avalos.\" are met: 9327e51cbSPeter Avalos.\" 1. Redistributions of source code must retain the above copyright 10327e51cbSPeter Avalos.\" notice immediately at the beginning of the file, without modification, 11327e51cbSPeter Avalos.\" this list of conditions, and the following disclaimer. 12327e51cbSPeter Avalos.\" 2. Redistributions in binary form must reproduce the above copyright 13327e51cbSPeter Avalos.\" notice, this list of conditions and the following disclaimer in the 14327e51cbSPeter Avalos.\" documentation and/or other materials provided with the distribution. 15327e51cbSPeter Avalos.\" 16327e51cbSPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17327e51cbSPeter Avalos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18327e51cbSPeter Avalos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19327e51cbSPeter Avalos.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20327e51cbSPeter Avalos.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21327e51cbSPeter Avalos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22327e51cbSPeter Avalos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23327e51cbSPeter Avalos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24327e51cbSPeter Avalos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25327e51cbSPeter Avalos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26327e51cbSPeter Avalos.\" SUCH DAMAGE. 27327e51cbSPeter Avalos.\" 286fca56fbSSascha Wildner.Dd June 8, 2019 29f72f8299SJan Lentfer.Dt LIBMAGIC 3 30327e51cbSPeter Avalos.Os 31327e51cbSPeter Avalos.Sh NAME 32327e51cbSPeter Avalos.Nm magic_open , 33327e51cbSPeter Avalos.Nm magic_close , 34327e51cbSPeter Avalos.Nm magic_error , 35e8af9738SPeter Avalos.Nm magic_errno , 36e4d4ce0cSPeter Avalos.Nm magic_descriptor , 37327e51cbSPeter Avalos.Nm magic_buffer , 38*c30bd091SSascha Wildner.Nm magic_getflags , 39327e51cbSPeter Avalos.Nm magic_setflags , 40327e51cbSPeter Avalos.Nm magic_check , 41327e51cbSPeter Avalos.Nm magic_compile , 42e8af9738SPeter Avalos.Nm magic_list , 43e8af9738SPeter Avalos.Nm magic_load , 4482c5fa3eSPeter Avalos.Nm magic_load_buffers , 4582c5fa3eSPeter Avalos.Nm magic_setparam , 4682c5fa3eSPeter Avalos.Nm magic_getparam , 47e8af9738SPeter Avalos.Nm magic_version 48a96e001bSPeter Avalos.Nd Magic number recognition library 49327e51cbSPeter Avalos.Sh LIBRARY 50327e51cbSPeter Avalos.Lb libmagic 51327e51cbSPeter Avalos.Sh SYNOPSIS 52327e51cbSPeter Avalos.In magic.h 53327e51cbSPeter Avalos.Ft magic_t 54327e51cbSPeter Avalos.Fn magic_open "int flags" 55327e51cbSPeter Avalos.Ft void 56327e51cbSPeter Avalos.Fn magic_close "magic_t cookie" 57327e51cbSPeter Avalos.Ft const char * 58327e51cbSPeter Avalos.Fn magic_error "magic_t cookie" 59327e51cbSPeter Avalos.Ft int 60327e51cbSPeter Avalos.Fn magic_errno "magic_t cookie" 61327e51cbSPeter Avalos.Ft const char * 629f86ab30SPeter Avalos.Fn magic_descriptor "magic_t cookie" "int fd" 63e4d4ce0cSPeter Avalos.Ft const char * 649f86ab30SPeter Avalos.Fn magic_file "magic_t cookie" "const char *filename" 65327e51cbSPeter Avalos.Ft const char * 66a96e001bSPeter Avalos.Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length" 67327e51cbSPeter Avalos.Ft int 68*c30bd091SSascha Wildner.Fn magic_getflags "magic_t cookie" 69*c30bd091SSascha Wildner.Ft int 70a96e001bSPeter Avalos.Fn magic_setflags "magic_t cookie" "int flags" 71327e51cbSPeter Avalos.Ft int 72a96e001bSPeter Avalos.Fn magic_check "magic_t cookie" "const char *filename" 73327e51cbSPeter Avalos.Ft int 74a96e001bSPeter Avalos.Fn magic_compile "magic_t cookie" "const char *filename" 75327e51cbSPeter Avalos.Ft int 769f86ab30SPeter Avalos.Fn magic_list "magic_t cookie" "const char *filename" 779f86ab30SPeter Avalos.Ft int 78a96e001bSPeter Avalos.Fn magic_load "magic_t cookie" "const char *filename" 79e8af9738SPeter Avalos.Ft int 8082c5fa3eSPeter Avalos.Fn magic_load_buffers "magic_t cookie" "void **buffers" "size_t *sizes" "size_t nbuffers" 8182c5fa3eSPeter Avalos.Ft int 8282c5fa3eSPeter Avalos.Fn magic_getparam "magic_t cookie" "int param" "void *value" 8382c5fa3eSPeter Avalos.Ft int 8482c5fa3eSPeter Avalos.Fn magic_setparam "magic_t cookie" "int param" "const void *value" 8582c5fa3eSPeter Avalos.Ft int 86e8af9738SPeter Avalos.Fn magic_version "void" 87327e51cbSPeter Avalos.Sh DESCRIPTION 88327e51cbSPeter AvalosThese functions 89327e51cbSPeter Avalosoperate on the magic database file 90327e51cbSPeter Avaloswhich is described 91327e51cbSPeter Avalosin 92327e51cbSPeter Avalos.Xr magic __FSECTION__ . 93327e51cbSPeter Avalos.Pp 94327e51cbSPeter AvalosThe function 95327e51cbSPeter Avalos.Fn magic_open 96a96e001bSPeter Avaloscreates a magic cookie pointer and returns it. 97a96e001bSPeter AvalosIt returns 98a96e001bSPeter Avalos.Dv NULL 99a96e001bSPeter Avalosif there was an error allocating the magic cookie. 100a96e001bSPeter AvalosThe 101327e51cbSPeter Avalos.Ar flags 102327e51cbSPeter Avalosargument specifies how the other magic functions should behave: 103327e51cbSPeter Avalos.Bl -tag -width MAGIC_COMPRESS 104327e51cbSPeter Avalos.It Dv MAGIC_NONE 105327e51cbSPeter AvalosNo special handling. 106327e51cbSPeter Avalos.It Dv MAGIC_DEBUG 107327e51cbSPeter AvalosPrint debugging messages to stderr. 108327e51cbSPeter Avalos.It Dv MAGIC_SYMLINK 109327e51cbSPeter AvalosIf the file queried is a symlink, follow it. 110327e51cbSPeter Avalos.It Dv MAGIC_COMPRESS 111327e51cbSPeter AvalosIf the file is compressed, unpack it and look at the contents. 112327e51cbSPeter Avalos.It Dv MAGIC_DEVICES 113327e51cbSPeter AvalosIf the file is a block or character special device, then open the device 114327e51cbSPeter Avalosand try to look in its contents. 115327e51cbSPeter Avalos.It Dv MAGIC_MIME_TYPE 116327e51cbSPeter AvalosReturn a MIME type string, instead of a textual description. 117327e51cbSPeter Avalos.It Dv MAGIC_MIME_ENCODING 118327e51cbSPeter AvalosReturn a MIME encoding, instead of a textual description. 119e4d4ce0cSPeter Avalos.It Dv MAGIC_MIME 120e4d4ce0cSPeter AvalosA shorthand for MAGIC_MIME_TYPE | MAGIC_MIME_ENCODING. 121327e51cbSPeter Avalos.It Dv MAGIC_CONTINUE 122327e51cbSPeter AvalosReturn all matches, not just the first. 123327e51cbSPeter Avalos.It Dv MAGIC_CHECK 124327e51cbSPeter AvalosCheck the magic database for consistency and print warnings to stderr. 125327e51cbSPeter Avalos.It Dv MAGIC_PRESERVE_ATIME 126327e51cbSPeter AvalosOn systems that support 127a96e001bSPeter Avalos.Xr utime 3 128327e51cbSPeter Avalosor 129327e51cbSPeter Avalos.Xr utimes 2 , 130e4d4ce0cSPeter Avalosattempt to preserve the access time of files analysed. 131327e51cbSPeter Avalos.It Dv MAGIC_RAW 132327e51cbSPeter AvalosDon't translate unprintable characters to a \eooo octal representation. 133327e51cbSPeter Avalos.It Dv MAGIC_ERROR 134327e51cbSPeter AvalosTreat operating system errors while trying to open files and follow symlinks 135327e51cbSPeter Avalosas real errors, instead of printing them in the magic buffer. 136e4d4ce0cSPeter Avalos.It Dv MAGIC_APPLE 137e4d4ce0cSPeter AvalosReturn the Apple creator and type. 138*c30bd091SSascha Wildner.It Dv MAGIC_EXTENSION 139*c30bd091SSascha WildnerReturn a slash-separated list of extensions for this file type. 140*c30bd091SSascha Wildner.It Dv MAGIC_COMPRESS_TRANSP 141*c30bd091SSascha WildnerDon't report on compression, only report about the uncompressed data. 142327e51cbSPeter Avalos.It Dv MAGIC_NO_CHECK_APPTYPE 143e4d4ce0cSPeter AvalosDon't check for 144327e51cbSPeter Avalos.Dv EMX 145327e51cbSPeter Avalosapplication type (only on EMX). 146e4d4ce0cSPeter Avalos.It Dv MAGIC_NO_CHECK_CDF 147e4d4ce0cSPeter AvalosDon't get extra information on MS Composite Document Files. 148327e51cbSPeter Avalos.It Dv MAGIC_NO_CHECK_COMPRESS 149e4d4ce0cSPeter AvalosDon't look inside compressed files. 150327e51cbSPeter Avalos.It Dv MAGIC_NO_CHECK_ELF 151e4d4ce0cSPeter AvalosDon't print ELF details. 1529f86ab30SPeter Avalos.It Dv MAGIC_NO_CHECK_ENCODING 153e4d4ce0cSPeter AvalosDon't check text encodings. 154327e51cbSPeter Avalos.It Dv MAGIC_NO_CHECK_SOFT 155327e51cbSPeter AvalosDon't consult magic files. 156327e51cbSPeter Avalos.It Dv MAGIC_NO_CHECK_TAR 157327e51cbSPeter AvalosDon't examine tar files. 158e4d4ce0cSPeter Avalos.It Dv MAGIC_NO_CHECK_TEXT 159e4d4ce0cSPeter AvalosDon't check for various types of text files. 160327e51cbSPeter Avalos.It Dv MAGIC_NO_CHECK_TOKENS 161327e51cbSPeter AvalosDon't look for known tokens inside ascii files. 1626fca56fbSSascha Wildner.It Dv MAGIC_NO_CHECK_JSON 1636fca56fbSSascha WildnerDon't examine JSON files. 1646fca56fbSSascha Wildner.It Dv MAGIC_NO_CHECK_CSV 1656fca56fbSSascha WildnerDon't examine CSV files. 166327e51cbSPeter Avalos.El 167327e51cbSPeter Avalos.Pp 168327e51cbSPeter AvalosThe 169327e51cbSPeter Avalos.Fn magic_close 170327e51cbSPeter Avalosfunction closes the 171327e51cbSPeter Avalos.Xr magic __FSECTION__ 172327e51cbSPeter Avalosdatabase and deallocates any resources used. 173327e51cbSPeter Avalos.Pp 174327e51cbSPeter AvalosThe 175327e51cbSPeter Avalos.Fn magic_error 176a96e001bSPeter Avalosfunction returns a textual explanation of the last error, or 177a96e001bSPeter Avalos.Dv NULL 178a96e001bSPeter Avalosif there was no error. 179327e51cbSPeter Avalos.Pp 180327e51cbSPeter AvalosThe 181327e51cbSPeter Avalos.Fn magic_errno 182327e51cbSPeter Avalosfunction returns the last operating system error number 183327e51cbSPeter Avalos.Pq Xr errno 2 184327e51cbSPeter Avalosthat was encountered by a system call. 185327e51cbSPeter Avalos.Pp 186327e51cbSPeter AvalosThe 187327e51cbSPeter Avalos.Fn magic_file 188327e51cbSPeter Avalosfunction returns a textual description of the contents of the 189327e51cbSPeter Avalos.Ar filename 190a96e001bSPeter Avalosargument, or 191a96e001bSPeter Avalos.Dv NULL 192a96e001bSPeter Avalosif an error occurred. 193327e51cbSPeter AvalosIf the 194327e51cbSPeter Avalos.Ar filename 195a96e001bSPeter Avalosis 196a96e001bSPeter Avalos.Dv NULL , 197a96e001bSPeter Avalosthen stdin is used. 198327e51cbSPeter Avalos.Pp 199327e51cbSPeter AvalosThe 200e4d4ce0cSPeter Avalos.Fn magic_descriptor 201e4d4ce0cSPeter Avalosfunction returns a textual description of the contents of the 202e4d4ce0cSPeter Avalos.Ar fd 203a96e001bSPeter Avalosargument, or 204a96e001bSPeter Avalos.Dv NULL 205a96e001bSPeter Avalosif an error occurred. 206e4d4ce0cSPeter Avalos.Pp 207e4d4ce0cSPeter AvalosThe 208327e51cbSPeter Avalos.Fn magic_buffer 209327e51cbSPeter Avalosfunction returns a textual description of the contents of the 210327e51cbSPeter Avalos.Ar buffer 211327e51cbSPeter Avalosargument with 212327e51cbSPeter Avalos.Ar length 213327e51cbSPeter Avalosbytes size. 214327e51cbSPeter Avalos.Pp 215327e51cbSPeter AvalosThe 216*c30bd091SSascha Wildner.Fn magic_getflags 217*c30bd091SSascha Wildnerfunctions returns a value representing current 218*c30bd091SSascha Wildner.Ar flags 219*c30bd091SSascha Wildnerset. 220*c30bd091SSascha Wildner.Pp 221*c30bd091SSascha WildnerThe 222327e51cbSPeter Avalos.Fn magic_setflags 22379343712SPeter Avalosfunction sets the 224327e51cbSPeter Avalos.Ar flags 225a96e001bSPeter Avalosdescribed above. 226a96e001bSPeter AvalosNote that using both MIME flags together can also 227327e51cbSPeter Avalosreturn extra information on the charset. 228327e51cbSPeter Avalos.Pp 229327e51cbSPeter AvalosThe 230327e51cbSPeter Avalos.Fn magic_check 231327e51cbSPeter Avalosfunction can be used to check the validity of entries in the colon 232327e51cbSPeter Avalosseparated database files passed in as 233327e51cbSPeter Avalos.Ar filename , 234a96e001bSPeter Avalosor 235a96e001bSPeter Avalos.Dv NULL 236a96e001bSPeter Avalosfor the default database. 237a96e001bSPeter AvalosIt returns 0 on success and \-1 on failure. 238327e51cbSPeter Avalos.Pp 239327e51cbSPeter AvalosThe 240327e51cbSPeter Avalos.Fn magic_compile 241*c30bd091SSascha Wildnerfunction can be used to compile the colon 242327e51cbSPeter Avalosseparated list of database files passed in as 243327e51cbSPeter Avalos.Ar filename , 244a96e001bSPeter Avalosor 245a96e001bSPeter Avalos.Dv NULL 246a96e001bSPeter Avalosfor the default database. 247a96e001bSPeter AvalosIt returns 0 on success and \-1 on failure. 248a96e001bSPeter AvalosThe compiled files created are named from the 249327e51cbSPeter Avalos.Xr basename 1 25079343712SPeter Avalosof each file argument with 25179343712SPeter Avalos.Dq .mgc 25279343712SPeter Avalosappended to it. 253327e51cbSPeter Avalos.Pp 254327e51cbSPeter AvalosThe 2559f86ab30SPeter Avalos.Fn magic_list 2569f86ab30SPeter Avalosfunction dumps all magic entries in a human readable format, 2579f86ab30SPeter Avalosdumping first the entries that are matched against binary files and then the 2589f86ab30SPeter Avalosones that match text files. 2599f86ab30SPeter AvalosIt takes and optional 2609f86ab30SPeter Avalos.Fa filename 2619f86ab30SPeter Avalosargument which is a colon separated list of database files, or 2629f86ab30SPeter Avalos.Dv NULL 2639f86ab30SPeter Avalosfor the default database. 2649f86ab30SPeter Avalos.Pp 2659f86ab30SPeter AvalosThe 266327e51cbSPeter Avalos.Fn magic_load 267*c30bd091SSascha Wildnerfunction must be used to load the colon 268327e51cbSPeter Avalosseparated list of database files passed in as 269327e51cbSPeter Avalos.Ar filename , 270a96e001bSPeter Avalosor 271a96e001bSPeter Avalos.Dv NULL 272a96e001bSPeter Avalosfor the default database file before any magic queries can performed. 273327e51cbSPeter Avalos.Pp 274a96e001bSPeter AvalosThe default database file is named by the MAGIC environment variable. 275a96e001bSPeter AvalosIf that variable is not set, the default database file name is __MAGIC__. 276327e51cbSPeter Avalos.Fn magic_load 27779343712SPeter Avalosadds 27879343712SPeter Avalos.Dq .mgc 27979343712SPeter Avalosto the database filename as appropriate. 280e8af9738SPeter Avalos.Pp 281e8af9738SPeter AvalosThe 28282c5fa3eSPeter Avalos.Fn magic_load_buffers 28382c5fa3eSPeter Avalosfunction takes an array of size 28482c5fa3eSPeter Avalos.Fa nbuffers 28582c5fa3eSPeter Avalosof 28682c5fa3eSPeter Avalos.Fa buffers 28782c5fa3eSPeter Avaloswith a respective size for each in the array of 28882c5fa3eSPeter Avalos.Fa sizes 28982c5fa3eSPeter Avalosloaded with the contents of the magic databases from the filesystem. 29082c5fa3eSPeter AvalosThis function can be used in environment where the magic library does 29182c5fa3eSPeter Avalosnot have direct access to the filesystem, but can access the magic 29282c5fa3eSPeter Avalosdatabase via shared memory or other IPC means. 29382c5fa3eSPeter Avalos.Pp 29482c5fa3eSPeter AvalosThe 29582c5fa3eSPeter Avalos.Fn magic_getparam 29682c5fa3eSPeter Avalosand 29782c5fa3eSPeter Avalos.Fn magic_setparam 298*c30bd091SSascha Wildnerallow getting and setting various limits related to the magic 29982c5fa3eSPeter Avaloslibrary. 30082c5fa3eSPeter Avalos.Bl -column "MAGIC_PARAM_ELF_PHNUM_MAX" "size_t" "Default" -offset indent 30182c5fa3eSPeter Avalos.It Sy "Parameter" Ta Sy "Type" Ta Sy "Default" 30282c5fa3eSPeter Avalos.It Li MAGIC_PARAM_INDIR_MAX Ta size_t Ta 15 30382c5fa3eSPeter Avalos.It Li MAGIC_PARAM_NAME_MAX Ta size_t Ta 30 30482c5fa3eSPeter Avalos.It Li MAGIC_PARAM_ELF_NOTES_MAX Ta size_t Ta 256 30582c5fa3eSPeter Avalos.It Li MAGIC_PARAM_ELF_PHNUM_MAX Ta size_t Ta 128 30682c5fa3eSPeter Avalos.It Li MAGIC_PARAM_ELF_SHNUM_MAX Ta size_t Ta 32768 307*c30bd091SSascha Wildner.It Li MAGIC_PARAM_REGEX_MAX Ta size_t Ta 8192 308*c30bd091SSascha Wildner.It Li MAGIC_PARAM_BYTES_MAX Ta size_t Ta 1048576 30982c5fa3eSPeter Avalos.El 31082c5fa3eSPeter Avalos.Pp 31182c5fa3eSPeter AvalosThe 31282c5fa3eSPeter Avalos.Dv MAGIC_PARAM_INDIR_RECURSION 31382c5fa3eSPeter Avalosparameter controls how many levels of recursion will be followed for 31482c5fa3eSPeter Avalosindirect magic entries. 31582c5fa3eSPeter Avalos.Pp 31682c5fa3eSPeter AvalosThe 31782c5fa3eSPeter Avalos.Dv MAGIC_PARAM_NAME_RECURSION 31882c5fa3eSPeter Avalosparameter controls how many levels of recursion will be followed for 31982c5fa3eSPeter Avalosfor name/use calls. 32082c5fa3eSPeter Avalos.Pp 32182c5fa3eSPeter AvalosThe 32282c5fa3eSPeter Avalos.Dv MAGIC_PARAM_NAME_MAX 32382c5fa3eSPeter Avalosparameter controls the maximum number of calls for name/use. 32482c5fa3eSPeter Avalos.Pp 32582c5fa3eSPeter AvalosThe 32682c5fa3eSPeter Avalos.Dv MAGIC_PARAM_NOTES_MAX 32782c5fa3eSPeter Avalosparameter controls how many ELF notes will be processed. 32882c5fa3eSPeter Avalos.Pp 32982c5fa3eSPeter AvalosThe 33082c5fa3eSPeter Avalos.Dv MAGIC_PARAM_PHNUM_MAX 33182c5fa3eSPeter Avalosparameter controls how many ELF program sections will be processed. 33282c5fa3eSPeter Avalos.Pp 33382c5fa3eSPeter AvalosThe 33482c5fa3eSPeter Avalos.Dv MAGIC_PARAM_SHNUM_MAX 33582c5fa3eSPeter Avalosparameter controls how many ELF sections will be processed. 33682c5fa3eSPeter Avalos.Pp 33782c5fa3eSPeter AvalosThe 338e8af9738SPeter Avalos.Fn magic_version 339e8af9738SPeter Avaloscommand returns the version number of this library which is compiled into 340e8af9738SPeter Avalosthe shared library using the constant 341e8af9738SPeter Avalos.Dv MAGIC_VERSION 342e8af9738SPeter Avalosfrom 343e8af9738SPeter Avalos.In magic.h . 344e8af9738SPeter AvalosThis can be used by client programs to verify that the version they compile 345e8af9738SPeter Avalosagainst is the same as the version that they run against. 346327e51cbSPeter Avalos.Sh RETURN VALUES 347327e51cbSPeter AvalosThe function 348327e51cbSPeter Avalos.Fn magic_open 349a96e001bSPeter Avalosreturns a magic cookie on success and 350a96e001bSPeter Avalos.Dv NULL 351a96e001bSPeter Avaloson failure setting errno to an appropriate value. 352a96e001bSPeter AvalosIt will set errno to 353a96e001bSPeter Avalos.Er EINVAL 354a96e001bSPeter Avalosif an unsupported value for flags was given. 355327e51cbSPeter AvalosThe 3569f86ab30SPeter Avalos.Fn magic_list , 357327e51cbSPeter Avalos.Fn magic_load , 358327e51cbSPeter Avalos.Fn magic_compile , 359327e51cbSPeter Avalosand 360327e51cbSPeter Avalos.Fn magic_check 361a96e001bSPeter Avalosfunctions return 0 on success and \-1 on failure. 362327e51cbSPeter AvalosThe 3639f86ab30SPeter Avalos.Fn magic_buffer , 3649f86ab30SPeter Avalos.Fn magic_getpath , 365327e51cbSPeter Avalosand 3669f86ab30SPeter Avalos.Fn magic_file , 367a96e001bSPeter Avalosfunctions return a string on success and 368a96e001bSPeter Avalos.Dv NULL 369a96e001bSPeter Avaloson failure. 370a96e001bSPeter AvalosThe 371327e51cbSPeter Avalos.Fn magic_error 372327e51cbSPeter Avalosfunction returns a textual description of the errors of the above 373a96e001bSPeter Avalosfunctions, or 374a96e001bSPeter Avalos.Dv NULL 375a96e001bSPeter Avalosif there was no error. 376e8af9738SPeter AvalosThe 377e8af9738SPeter Avalos.Fn magic_version 378e8af9738SPeter Avalosalways returns the version number of the library. 379327e51cbSPeter AvalosFinally, 380327e51cbSPeter Avalos.Fn magic_setflags 381a96e001bSPeter Avalosreturns \-1 on systems that don't support 382a96e001bSPeter Avalos.Xr utime 3 , 383327e51cbSPeter Avalosor 384327e51cbSPeter Avalos.Xr utimes 2 385327e51cbSPeter Avaloswhen 386327e51cbSPeter Avalos.Dv MAGIC_PRESERVE_ATIME 387327e51cbSPeter Avalosis set. 388327e51cbSPeter Avalos.Sh FILES 38979343712SPeter Avalos.Bl -tag -width __MAGIC__.mgc -compact 390327e51cbSPeter Avalos.It Pa __MAGIC__ 391327e51cbSPeter AvalosThe non-compiled default magic database. 392327e51cbSPeter Avalos.It Pa __MAGIC__.mgc 393327e51cbSPeter AvalosThe compiled default magic database. 394327e51cbSPeter Avalos.El 395327e51cbSPeter Avalos.Sh SEE ALSO 396327e51cbSPeter Avalos.Xr file __CSECTION__ , 397327e51cbSPeter Avalos.Xr magic __FSECTION__ 3986fca56fbSSascha Wildner.Sh BUGS 3996fca56fbSSascha WildnerThe results from 4006fca56fbSSascha Wildner.Fn magic_buffer 4016fca56fbSSascha Wildnerand 4026fca56fbSSascha Wildner.Fn magic_file 4036fca56fbSSascha Wildnerwhere the buffer and the file contain the same data 4046fca56fbSSascha Wildnercan produce different results, because in the 4056fca56fbSSascha Wildner.Fn magic_file 4066fca56fbSSascha Wildnercase, the program can 4076fca56fbSSascha Wildner.Xr lseek 2 4086fca56fbSSascha Wildnerand 4096fca56fbSSascha Wildner.Xr stat 2 4106fca56fbSSascha Wildnerthe file descriptor. 411327e51cbSPeter Avalos.Sh AUTHORS 412a96e001bSPeter Avalos.An M\(oans Rullg\(oard 413a96e001bSPeter AvalosInitial libmagic implementation, and configuration. 414a96e001bSPeter Avalos.An Christos Zoulas 415a96e001bSPeter AvalosAPI cleanup, error code and allocation handling. 416