summaryrefslogtreecommitdiff
path: root/main/php_virtual_cwd.h
blob: 035314c8812f0f0452fad9e135dc2891915f662e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H

#include "zend.h"

#ifdef ZEND_WIN32
#       ifdef CWD_EXPORTS
#       define CWD_API __declspec(dllexport)
#       else
#       define CWD_API __declspec(dllimport)
#       endif
#else
#define CWD_API
#endif

typedef struct _cwd_state {
	char *cwd;
	int cwd_length;
} cwd_state;

typedef int (*verify_path_func)(const cwd_state *);

void virtual_cwd_startup();
char *virtual_getcwd_ex(int *length);
char *virtual_getcwd(char *buf, size_t size);
int virtual_chdir(char *path);
int virtual_filepath(char *path, char **filepath);
FILE *virtual_fopen(char *path, const char *mode);

typedef struct _cwd_globals_struct {
	cwd_state cwd;
} cwd_globals_struct;

#ifdef ZTS
# define CWDLS_D  cwd_globals_struct *cwd_globals
# define CWDLS_DC , CWDLS_D
# define CWDLS_C  cwd_globals
# define CWDLS_CC , CWDLS_C
# define CWDG(v) (cwd_globals->v)
# define CWDLS_FETCH()    cwd_globals_struct *cwd_globals = ts_resource(cwd_globals_id)
CWD_API extern int cwd_globals_id;
#else
# define CWDLS_D  void
# define CWDLS_DC
# define CWDLS_C
# define CWDLS_CC
# define CWDG(v) (cwd_globals.v)
# define CWDLS_FETCH()
extern CWD_API cwd_globals_struct cwd_globals;
#endif

#endif /* VIRTUAL_CWD_H */