xref: /PHP-7.4/TSRM/tsrm_win32.h (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    | Authors: Daniel Beulshausen <daniel@php4win.de>                      |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef TSRM_WIN32_H
20 #define TSRM_WIN32_H
21 
22 #include "TSRM.h"
23 #include <windows.h>
24 #if HAVE_UTIME
25 # include <sys/utime.h>
26 #endif
27 #include "win32/ipc.h"
28 
29 struct ipc_perm {
30 	key_t		key;
31 	unsigned short	uid;
32 	unsigned short	gid;
33 	unsigned short	cuid;
34 	unsigned short	cgid;
35 	unsigned short	mode;
36 	unsigned short	seq;
37 };
38 
39 struct shmid_ds {
40 	struct	ipc_perm	shm_perm;
41 	size_t			shm_segsz;
42 	time_t			shm_atime;
43 	time_t			shm_dtime;
44 	time_t			shm_ctime;
45 	unsigned short	shm_cpid;
46 	unsigned short	shm_lpid;
47 	short			shm_nattch;
48 };
49 
50 typedef struct {
51 	FILE	*stream;
52 	HANDLE	prochnd;
53 } process_pair;
54 
55 typedef struct {
56 	void	*addr;
57 	HANDLE	info;
58 	HANDLE	segment;
59 	struct	shmid_ds	*descriptor;
60 } shm_pair;
61 
62 typedef struct {
63 	process_pair	*process;
64 	shm_pair		*shm;
65 	int				process_size;
66 	int				shm_size;
67 	char			*comspec;
68 	HANDLE impersonation_token;
69 	PSID			impersonation_token_sid;
70 } tsrm_win32_globals;
71 
72 #ifdef ZTS
73 # define TWG(v) TSRMG_STATIC(win32_globals_id, tsrm_win32_globals *, v)
74 TSRMLS_CACHE_EXTERN()
75 #else
76 # define TWG(v) (win32_globals.v)
77 #endif
78 
79 #define IPC_PRIVATE	0
80 #define IPC_CREAT	00001000
81 #define IPC_EXCL	00002000
82 #define IPC_NOWAIT	00004000
83 
84 #define IPC_RMID	0
85 #define IPC_SET		1
86 #define IPC_STAT	2
87 #define IPC_INFO	3
88 
89 #define SHM_R		PAGE_READONLY
90 #define SHM_W		PAGE_READWRITE
91 
92 #define	SHM_RDONLY	FILE_MAP_READ
93 #define	SHM_RND		FILE_MAP_WRITE
94 #define	SHM_REMAP	FILE_MAP_COPY
95 
96 char * tsrm_win32_get_path_sid_key(const char *pathname, size_t pathname_len, size_t *key_len);
97 
98 TSRM_API void tsrm_win32_startup(void);
99 TSRM_API void tsrm_win32_shutdown(void);
100 
101 TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
102 TSRM_API FILE *popen(const char *command, const char *type);
103 TSRM_API int pclose(FILE *stream);
104 TSRM_API int tsrm_win32_access(const char *pathname, int mode);
105 TSRM_API int win32_utime(const char *filename, struct utimbuf *buf);
106 
107 TSRM_API int shmget(key_t key, size_t size, int flags);
108 TSRM_API void *shmat(int key, const void *shmaddr, int flags);
109 TSRM_API int shmdt(const void *shmaddr);
110 TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf);
111 #endif
112