xref: /PHP-8.2/win32/globals.c (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: Wez Furlong <wez@php.net>                                    |
14    +----------------------------------------------------------------------+
15 */
16 
17 #include "php.h"
18 #include "php_win32_globals.h"
19 #include "syslog.h"
20 
21 #ifdef ZTS
22 PHPAPI int php_win32_core_globals_id;
23 #else
24 php_win32_core_globals the_php_win32_core_globals;
25 #endif
26 
php_win32_core_globals_ctor(void * vg)27 void php_win32_core_globals_ctor(void *vg)
28 {/*{{{*/
29 	php_win32_core_globals *wg = (php_win32_core_globals*)vg;
30 	memset(wg, 0, sizeof(*wg));
31 
32 	wg->mail_socket = INVALID_SOCKET;
33 
34 	wg->log_source = INVALID_HANDLE_VALUE;
35 }/*}}}*/
36 
php_win32_core_globals_dtor(void * vg)37 void php_win32_core_globals_dtor(void *vg)
38 {/*{{{*/
39 	php_win32_core_globals *wg = (php_win32_core_globals*)vg;
40 
41 	if (wg->registry_key) {
42 		RegCloseKey(wg->registry_key);
43 		wg->registry_key = NULL;
44 	}
45 	if (wg->registry_event) {
46 		CloseHandle(wg->registry_event);
47 		wg->registry_event = NULL;
48 	}
49 	if (wg->registry_directories) {
50 		zend_hash_destroy(wg->registry_directories);
51 		free(wg->registry_directories);
52 		wg->registry_directories = NULL;
53 	}
54 
55 	if (INVALID_SOCKET != wg->mail_socket) {
56 		closesocket(wg->mail_socket);
57 		wg->mail_socket = INVALID_SOCKET;
58 	}
59 }/*}}}*/
60 
61 
PHP_RSHUTDOWN_FUNCTION(win32_core_globals)62 PHP_RSHUTDOWN_FUNCTION(win32_core_globals)
63 {/*{{{*/
64 	closelog();
65 
66 	return SUCCESS;
67 }/*}}}*/
68