xref: /PHP-7.4/win32/winutil.h (revision 9b5d66bd)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author:                                                              |
16    +----------------------------------------------------------------------+
17  */
18 
19 #ifndef PHP_WIN32_WINUTIL_H
20 #define PHP_WIN32_WINUTIL_H
21 
22 #ifdef PHP_EXPORTS
23 # define PHP_WINUTIL_API __declspec(dllexport)
24 #else
25 # define PHP_WINUTIL_API __declspec(dllimport)
26 #endif
27 
28 PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error);
29 PHP_WINUTIL_API void php_win32_error_msg_free(char *msg);
30 
31 #define php_win_err()	php_win32_error_to_msg(GetLastError())
32 #define php_win_err_free(err) php_win32_error_msg_free(err)
33 int php_win32_check_trailing_space(const char * path, const size_t path_len);
34 PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size);
35 #ifdef PHP_EXPORTS
36 BOOL php_win32_init_random_bytes(void);
37 BOOL php_win32_shutdown_random_bytes(void);
38 #endif
39 
40 #if !defined(ECURDIR)
41 # define ECURDIR        EACCES
42 #endif /* !ECURDIR */
43 #if !defined(ENOSYS)
44 # define ENOSYS         EPERM
45 #endif /* !ENOSYS */
46 
47 PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err);
48 
49 #define SET_ERRNO_FROM_WIN32_CODE(err) \
50 	do { \
51 	int ern = php_win32_code_to_errno(err); \
52 	SetLastError(err); \
53 	_set_errno(ern); \
54 	} while (0)
55 
56 PHP_WINUTIL_API char *php_win32_get_username(void);
57 
58 PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *img, char **err);
59 PHP_WINUTIL_API BOOL php_win32_crt_compatible(const char *img, char **err);
60 
61 #endif
62