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