xref: /PHP-7.1/win32/winutil.h (revision 03f3b847)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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 #ifdef PHP_EXPORTS
20 # define PHP_WINUTIL_API __declspec(dllexport)
21 #else
22 # define PHP_WINUTIL_API __declspec(dllimport)
23 #endif
24 
25 PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error);
26 
27 #define php_win_err()	php_win32_error_to_msg(GetLastError())
28 int php_win32_check_trailing_space(const char * path, const int path_len);
29 PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size);
30 
31 #ifdef ZTS
32 void php_win32_init_rng_lock();
33 void php_win32_free_rng_lock();
34 #else
35 #define php_win32_init_rng_lock();
36 #define php_win32_free_rng_lock();
37 #endif
38 
39 #if !defined(ECURDIR)
40 # define ECURDIR        EACCES
41 #endif /* !ECURDIR */
42 #if !defined(ENOSYS)
43 # define ENOSYS         EPERM
44 #endif /* !ENOSYS */
45 
46 PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err);
47 
48 #define SET_ERRNO_FROM_WIN32_CODE(err) \
49 	do { \
50 	int ern = php_win32_code_to_errno(err); \
51 	SetLastError(err); \
52 	_set_errno(ern); \
53 	} while (0)
54 
55 PHP_WINUTIL_API char *php_win32_get_username(void);
56