xref: /PHP-7.4/win32/winutil.h (revision 9b5d66bd)
1ce75d269SDaniel Beulshausen /*
2ce75d269SDaniel Beulshausen    +----------------------------------------------------------------------+
3d0cb7153SJohannes Schlüter    | PHP Version 7                                                        |
4ce75d269SDaniel Beulshausen    +----------------------------------------------------------------------+
50cf7de1cSZeev Suraski    | Copyright (c) The PHP Group                                          |
6ce75d269SDaniel Beulshausen    +----------------------------------------------------------------------+
75bd93221Sfoobar    | This source file is subject to version 3.01 of the PHP license,      |
8ce75d269SDaniel Beulshausen    | that is bundled with this package in the file LICENSE, and is        |
9f68c7ff2SJames Cox    | available through the world-wide-web at the following url:           |
105bd93221Sfoobar    | http://www.php.net/license/3_01.txt                                  |
11ce75d269SDaniel Beulshausen    | If you did not receive a copy of the PHP license and are unable to   |
12ce75d269SDaniel Beulshausen    | obtain it through the world-wide-web, please send a note to          |
13ce75d269SDaniel Beulshausen    | license@php.net so we can mail you a copy immediately.               |
14ce75d269SDaniel Beulshausen    +----------------------------------------------------------------------+
15ce75d269SDaniel Beulshausen    | Author:                                                              |
16ce75d269SDaniel Beulshausen    +----------------------------------------------------------------------+
17ce75d269SDaniel Beulshausen  */
18ce75d269SDaniel Beulshausen 
19bae668eeSAnatol Belski #ifndef PHP_WIN32_WINUTIL_H
20bae668eeSAnatol Belski #define PHP_WIN32_WINUTIL_H
21bae668eeSAnatol Belski 
223d3f11edSAnatol Belski #ifdef PHP_EXPORTS
233d3f11edSAnatol Belski # define PHP_WINUTIL_API __declspec(dllexport)
243d3f11edSAnatol Belski #else
253d3f11edSAnatol Belski # define PHP_WINUTIL_API __declspec(dllimport)
263d3f11edSAnatol Belski #endif
273d3f11edSAnatol Belski 
283d3f11edSAnatol Belski PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error);
29321c0cc3SAnatol Belski PHP_WINUTIL_API void php_win32_error_msg_free(char *msg);
30ce75d269SDaniel Beulshausen 
314574844cSPierre Joye #define php_win_err()	php_win32_error_to_msg(GetLastError())
32321c0cc3SAnatol Belski #define php_win_err_free(err) php_win32_error_msg_free(err)
3384079f4aSAnatol Belski int php_win32_check_trailing_space(const char * path, const size_t path_len);
343d3f11edSAnatol Belski PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size);
35d53d0a5dSAnatol Belski #ifdef PHP_EXPORTS
36d53d0a5dSAnatol Belski BOOL php_win32_init_random_bytes(void);
37d53d0a5dSAnatol Belski BOOL php_win32_shutdown_random_bytes(void);
381d357d96SPierre Joye #endif
393d3f11edSAnatol Belski 
403d3f11edSAnatol Belski #if !defined(ECURDIR)
413d3f11edSAnatol Belski # define ECURDIR        EACCES
423d3f11edSAnatol Belski #endif /* !ECURDIR */
433d3f11edSAnatol Belski #if !defined(ENOSYS)
443d3f11edSAnatol Belski # define ENOSYS         EPERM
453d3f11edSAnatol Belski #endif /* !ENOSYS */
463d3f11edSAnatol Belski 
473d3f11edSAnatol Belski PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err);
483d3f11edSAnatol Belski 
493d3f11edSAnatol Belski #define SET_ERRNO_FROM_WIN32_CODE(err) \
503d3f11edSAnatol Belski 	do { \
513d3f11edSAnatol Belski 	int ern = php_win32_code_to_errno(err); \
523d3f11edSAnatol Belski 	SetLastError(err); \
533d3f11edSAnatol Belski 	_set_errno(ern); \
543d3f11edSAnatol Belski 	} while (0)
553d3f11edSAnatol Belski 
563d3f11edSAnatol Belski PHP_WINUTIL_API char *php_win32_get_username(void);
573d3f11edSAnatol Belski 
58*9b5d66bdSAnatol Belski PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *img, char **err);
59dd0aca0cSAnatol Belski PHP_WINUTIL_API BOOL php_win32_crt_compatible(const char *img, char **err);
60ddce7adaSAnatol Belski 
61bae668eeSAnatol Belski #endif