xref: /php-src/TSRM/tsrm_win32.h (revision d7bdc040)
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	segment;
54 	struct	shmid_ds	*descriptor;
55 } shm_pair;
56 
57 typedef struct {
58 	process_pair	*process;
59 	shm_pair		*shm;
60 	int				process_size;
61 	int				shm_size;
62 	char			*comspec;
63 	HANDLE impersonation_token;
64 	PSID			impersonation_token_sid;
65 } tsrm_win32_globals;
66 
67 #ifdef ZTS
68 # define TWG(v) TSRMG_STATIC(win32_globals_id, tsrm_win32_globals *, v)
69 TSRMLS_CACHE_EXTERN()
70 #else
71 # define TWG(v) (win32_globals.v)
72 #endif
73 
74 #define IPC_PRIVATE	0
75 #define IPC_CREAT	00001000
76 #define IPC_EXCL	00002000
77 #define IPC_NOWAIT	00004000
78 
79 #define IPC_RMID	0
80 #define IPC_SET		1
81 #define IPC_STAT	2
82 #define IPC_INFO	3
83 
84 #define SHM_R		PAGE_READONLY
85 #define SHM_W		PAGE_READWRITE
86 
87 #define	SHM_RDONLY	FILE_MAP_READ
88 #define	SHM_RND		FILE_MAP_WRITE
89 #define	SHM_REMAP	FILE_MAP_COPY
90 
91 const char * tsrm_win32_get_path_sid_key(const char *pathname, size_t pathname_len, size_t *key_len);
92 
93 TSRM_API void tsrm_win32_startup(void);
94 TSRM_API void tsrm_win32_shutdown(void);
95 
96 TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, const char *env);
97 TSRM_API FILE *popen(const char *command, const char *type);
98 TSRM_API int pclose(FILE *stream);
99 TSRM_API int tsrm_win32_access(const char *pathname, int mode);
100 TSRM_API int win32_utime(const char *filename, struct utimbuf *buf);
101 
102 TSRM_API int shmget(key_t key, size_t size, int flags);
103 TSRM_API void *shmat(int key, const void *shmaddr, int flags);
104 TSRM_API int shmdt(const void *shmaddr);
105 TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf);
106 #endif
107