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