xref: /php-src/win32/winutil.h (revision 01b3fc03)
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:                                                              |
14    +----------------------------------------------------------------------+
15  */
16 
17 #ifndef PHP_WIN32_WINUTIL_H
18 #define PHP_WIN32_WINUTIL_H
19 
20 #ifdef PHP_EXPORTS
21 # define PHP_WINUTIL_API __declspec(dllexport)
22 #else
23 # define PHP_WINUTIL_API __declspec(dllimport)
24 #endif
25 
26 PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error);
27 PHP_WINUTIL_API void php_win32_error_msg_free(char *msg);
28 
29 #define php_win_err()	php_win32_error_to_msg(GetLastError())
30 #define php_win_err_free(err) php_win32_error_msg_free(err)
31 int php_win32_check_trailing_space(const char * path, const size_t path_len);
32 PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size);
33 #ifdef PHP_EXPORTS
34 BOOL php_win32_init_random_bytes(void);
35 BOOL php_win32_shutdown_random_bytes(void);
36 #endif
37 
38 #if !defined(ECURDIR)
39 # define ECURDIR        EACCES
40 #endif /* !ECURDIR */
41 #if !defined(ENOSYS)
42 # define ENOSYS         EPERM
43 #endif /* !ENOSYS */
44 
45 PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err);
46 
47 #define SET_ERRNO_FROM_WIN32_CODE(err) \
48 	do { \
49 	int ern = php_win32_code_to_errno(err); \
50 	SetLastError(err); \
51 	_set_errno(ern); \
52 	} while (0)
53 
54 PHP_WINUTIL_API char *php_win32_get_username(void);
55 
56 PHP_WINUTIL_API BOOL php_win32_image_compatible(HMODULE handle, char **err);
57 PHP_WINUTIL_API BOOL php_win32_crt_compatible(char **err);
58 
59 #endif
60