OK, I found magic.h in /usr/include/linux.
I added the include directory to Makefile, here is output from make:
address@hidden:~/gms_sandbox$ make
gcc -I/usr/include/linux/ -o checkmagic checkmagic.c -lmagic
In file included from /usr/include/stdio.h:75,
from checkmagic.c:6:
/usr/include/libio.h:332: error: expected specifier-qualifier-list
before ‘size_t’
/usr/include/libio.h:364: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/libio.h:373: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/libio.h:493: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘_IO_sgetn’
In file included from checkmagic.c:6:
/usr/include/stdio.h:296: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:302: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:314: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:321: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:363: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:365: error: format string argument not a string type
/usr/include/stdio.h:367: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:639: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:642: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:652: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdio.h:682: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fread’
/usr/include/stdio.h:688: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fwrite’
/usr/include/stdio.h:710: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fread_unlocked’
/usr/include/stdio.h:712: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fwrite_unlocked’
In file included from checkmagic.c:7:
/usr/include/stdlib.h:140: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘__ctype_get_mb_cur_max’
In file included from /usr/include/sys/select.h:46,
from /usr/include/sys/types.h:220,
from /usr/include/stdlib.h:320,
from checkmagic.c:7:
/usr/include/bits/time.h:70: error: redefinition of ‘struct timeval’
In file included from checkmagic.c:7:
/usr/include/stdlib.h:337: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:367: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:369: error: nonnull argument with out-of-range
operand number (argument 1, operand 4)
/usr/include/stdlib.h:471: error: expected ‘)’ before ‘__size’
/usr/include/stdlib.h:473: error: expected ‘)’ before ‘__nmemb’
/usr/include/stdlib.h:485: error: expected declaration specifiers or
‘...’ before ‘size_t’
In file included from /usr/include/stdlib.h:497,
from checkmagic.c:7:
/usr/include/alloca.h:33: error: expected ‘)’ before ‘__size’
In file included from checkmagic.c:7:
/usr/include/stdlib.h:502: error: expected ‘)’ before ‘__size’
/usr/include/stdlib.h:507: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:507: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:705: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:705: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:706: error: nonnull argument with out-of-range
operand number (argument 1, operand 5)
/usr/include/stdlib.h:710: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:710: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:711: error: nonnull argument with out-of-range
operand number (argument 1, operand 4)
/usr/include/stdlib.h:788: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:791: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:795: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:799: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:808: error: expected declaration specifiers or
‘...’ before ‘size_t’
/usr/include/stdlib.h:811: error: expected ‘)’ before ‘*’ token
/usr/include/stdlib.h:815: error: expected declaration specifiers or
‘...’ before ‘wchar_t’
/usr/include/stdlib.h:819: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘mbstowcs’
/usr/include/stdlib.h:822: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘wcstombs’
checkmagic.c: In function ‘main’:
checkmagic.c:13: error: ‘magic_t’ undeclared (first use in this function)
checkmagic.c:13: error: (Each undeclared identifier is reported only once
checkmagic.c:13: error: for each function it appears in.)
checkmagic.c:13: error: expected ‘;’ before ‘magic_cookie’
checkmagic.c:20: error: ‘magic_cookie’ undeclared (first use in this
function)
checkmagic.c:20: error: ‘MAGIC_SYMLINK’ undeclared (first use in this
function)
checkmagic.c:20: error: ‘MAGIC_MIME’ undeclared (first use in this function)
checkmagic.c:20: error: ‘MAGIC_ERROR’ undeclared (first use in this
function)
checkmagic.c:33: warning: assignment makes pointer from integer without
a cast
checkmagic.c:40: warning: incompatible implicit declaration of built-in
function ‘strstr’
make: *** [checkmagic] Chyba 1
When I copy magic.h to checkmagic.c directory and change the respective
line in checkmagic.c to #include "magic.h" and remove additional include
directory from Makefile, I get:
address@hidden:~/gms_sandbox$ make
gcc -o checkmagic checkmagic.c -lmagic
checkmagic.c: In function ‘main’:
checkmagic.c:13: error: ‘magic_t’ undeclared (first use in this function)
checkmagic.c:13: error: (Each undeclared identifier is reported only once
checkmagic.c:13: error: for each function it appears in.)
checkmagic.c:13: error: expected ‘;’ before ‘magic_cookie’
checkmagic.c:20: error: ‘magic_cookie’ undeclared (first use in this
function)
checkmagic.c:20: error: ‘MAGIC_SYMLINK’ undeclared (first use in this
function)
checkmagic.c:20: error: ‘MAGIC_MIME’ undeclared (first use in this function)
checkmagic.c:20: error: ‘MAGIC_ERROR’ undeclared (first use in this
function)
checkmagic.c:33: warning: assignment makes pointer from integer without
a cast
make: *** [checkmagic] Chyba 1
Content of magic.h:
#ifndef __LINUX_MAGIC_H__
#define __LINUX_MAGIC_H__
#define ADFS_SUPER_MAGIC 0xadf5
#define AFFS_SUPER_MAGIC 0xadff
#define AFS_SUPER_MAGIC 0x5346414F
#define AUTOFS_SUPER_MAGIC 0x0187
#define CODA_SUPER_MAGIC 0x73757245
#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
#define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong
endianess */
#define DEBUGFS_MAGIC 0x64626720
#define SYSFS_MAGIC 0x62656572
#define SECURITYFS_MAGIC 0x73636673
#define SELINUX_MAGIC 0xf97cff8c
#define TMPFS_MAGIC 0x01021994
#define SQUASHFS_MAGIC 0x73717368
#define EFS_SUPER_MAGIC 0x414A53
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT3_SUPER_MAGIC 0xEF53
#define XENFS_SUPER_MAGIC 0xabba1974
#define EXT4_SUPER_MAGIC 0xEF53
#define BTRFS_SUPER_MAGIC 0x9123683E
#define HPFS_SUPER_MAGIC 0xf995e849
#define ISOFS_SUPER_MAGIC 0x9660
#define JFFS2_SUPER_MAGIC 0x72b6
#define ANON_INODE_FS_MAGIC 0x09041934
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
#define MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 fs */
#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
#define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */
#define NFS_SUPER_MAGIC 0x6969
#define OPENPROM_SUPER_MAGIC 0x9fa1
#define PROC_SUPER_MAGIC 0x9fa0
#define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
#define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
/* used by file system utilities that
look at the superblock, etc. */
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
#define SMB_SUPER_MAGIC 0x517B
#define USBDEVICE_SUPER_MAGIC 0x9fa2
#define CGROUP_SUPER_MAGIC 0x27e0eb
#define FUTEXFS_SUPER_MAGIC 0xBAD1DEA
#define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA
#define STACK_END_MAGIC 0x57AC6E9D
#endif /* __LINUX_MAGIC_H__ */
2010/5/12 Andrej Repiský <
address@hidden