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