xref: /PHP-8.4/ext/fileinfo/php_libmagic.h (revision 845af777)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Author: Anatol Belski <ab@php.net>                                   |
14   +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_LIBMAGIC_H
18 #define PHP_LIBMAGIC_H
19 
20 #include "main/php_network.h"
21 #include "ext/pcre/php_pcre.h"
22 
23 #ifdef PHP_WIN32
24 #include "win32/param.h"
25 
26 #ifdef _WIN64
27 #define FINFO_LSEEK_FUNC _lseeki64
28 #else
29 #define FINFO_LSEEK_FUNC _lseek
30 #endif
31 #define FINFO_READ_FUNC _read
32 
33 #define strtoull _strtoui64
34 
35 
36 #define HAVE_ASCTIME_R 1
37 #define asctime_r php_asctime_r
38 #define HAVE_CTIME_R 1
39 #define ctime_r php_ctime_r
40 
41 #else
42 #define FINFO_LSEEK_FUNC lseek
43 #define FINFO_READ_FUNC read
44 #endif
45 
46 #if defined(__hpux) && !defined(HAVE_STRTOULL)
47 #if SIZEOF_LONG == 8
48 # define strtoull strtoul
49 #else
50 # define strtoull __strtoull
51 #endif
52 #endif
53 
54 #ifndef offsetof
55 #define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
56 #endif
57 
58 #ifndef UINT32_MAX
59 # define UINT32_MAX (0xffffffff)
60 #endif
61 
62 #ifndef PREG_OFFSET_CAPTURE
63 # define PREG_OFFSET_CAPTURE                 (1<<8)
64 #endif
65 
66 #define abort()	zend_error_noreturn(E_ERROR, "fatal libmagic error")
67 
68 zend_string* convert_libmagic_pattern(const char *val, size_t len, uint32_t options);
69 
70 #endif	/* PHP_LIBMAGIC_H */
71