Skip to content

Commit bb6dff9

Browse files
committed
Buh-bye php3_ini
1 parent 4472d05 commit bb6dff9

File tree

12 files changed

+159
-323
lines changed

12 files changed

+159
-323
lines changed

internal_functions.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@
9090
#include "functions/php3_sysvshm.h"
9191
#include "functions/php3_dav.h"
9292

93-
94-
extern php3_ini_structure php3_ini;
95-
extern php3_ini_structure php3_ini_master;
96-
9793
unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE };
9894
unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW };
9995
unsigned char second_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };

main/configuration-parser.y

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define DEBUG_CFG_PARSER 1
3636
#include "php.h"
3737
#include "php_globals.h"
38+
#include "php_ini.h"
3839
#include "functions/dl.h"
3940
#include "functions/file.h"
4041
#include "functions/php3_browscap.h"
@@ -248,22 +249,22 @@ int php3_init_config(void)
248249

249250
int php3_minit_browscap(INIT_FUNC_ARGS)
250251
{
251-
TLS_VARS;
252+
char *browscap = INI_STR("browscap");
252253

253-
if (php3_ini.browscap) {
254+
if (browscap) {
254255
if (_php3_hash_init(&GLOBAL(browser_hash), 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) {
255256
return FAILURE;
256257
}
257258

258-
cfgin = fopen(php3_ini.browscap,"r");
259+
cfgin = fopen(browscap, "r");
259260
if (!cfgin) {
260-
php3_error(E_WARNING,"Cannot open '%s' for reading",php3_ini.browscap);
261+
php3_error(E_WARNING,"Cannot open '%s' for reading", browscap);
261262
return FAILURE;
262263
}
263264
init_cfg_scanner();
264265
active__php3_hash_table = &GLOBAL(browser_hash);
265266
parsing_mode = PARSING_MODE_BROWSCAP;
266-
currently_parsed_filename = php3_ini.browscap;
267+
currently_parsed_filename = browscap;
267268
yyparse();
268269
fclose(cfgin);
269270
}
@@ -281,9 +282,7 @@ int php3_shutdown_config(void)
281282

282283
int php3_mshutdown_browscap(SHUTDOWN_FUNC_ARGS)
283284
{
284-
TLS_VARS;
285-
286-
if (php3_ini.browscap) {
285+
if (INI_STR("browscap")) {
287286
_php3_hash_destroy(&GLOBAL(browser_hash));
288287
}
289288
return SUCCESS;

main/fopen_wrappers.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ PHPAPI int _php3_check_open_basedir(char *path)
111111
int local_open_basedir_pos;
112112

113113
/* Only check when open_basedir is available */
114-
if (php3_ini.open_basedir && *php3_ini.open_basedir) {
114+
if (PG(open_basedir) && *PG(open_basedir)) {
115115

116116
/* Special case basedir==".": Use script-directory */
117-
if ((strcmp(php3_ini.open_basedir, ".") == 0) &&
117+
if ((strcmp(PG(open_basedir), ".") == 0) &&
118118
GLOBAL(request_info).filename &&
119119
*GLOBAL(request_info).filename
120120
) {
@@ -149,7 +149,7 @@ PHPAPI int _php3_check_open_basedir(char *path)
149149

150150
} else {
151151
/* Else use the unmodified path */
152-
strcpy(local_open_basedir, php3_ini.open_basedir);
152+
strcpy(local_open_basedir, PG(open_basedir));
153153
}
154154

155155
/* Resolve the real path into resolved_name */
@@ -186,8 +186,8 @@ PHPAPI FILE *php3_fopen_wrapper(char *path, char *mode, int options, int *issock
186186
}
187187
#endif
188188

189-
if (options & USE_PATH && php3_ini.include_path != NULL) {
190-
return php3_fopen_with_path(path, mode, php3_ini.include_path, NULL);
189+
if (options & USE_PATH && PG(include_path) != NULL) {
190+
return php3_fopen_with_path(path, mode, PG(include_path), NULL);
191191
} else {
192192
if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;
193193
if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!_php3_checkuid(path, cm))) {
@@ -212,7 +212,7 @@ FILE *php3_fopen_for_parser(void)
212212
fn = GLOBAL(request_info).filename;
213213
path_info = GLOBAL(request_info).path_info;
214214
#if HAVE_PWD_H
215-
if (php3_ini.user_dir && *php3_ini.user_dir
215+
if (PG(user_dir) && *PG(user_dir)
216216
&& path_info && '/' == path_info[0] && '~' == path_info[1]) {
217217

218218
char user[32];
@@ -230,11 +230,11 @@ FILE *php3_fopen_for_parser(void)
230230

231231
pw = getpwnam(user);
232232
if (pw && pw->pw_dir) {
233-
fn = emalloc(strlen(php3_ini.user_dir) + strlen(path_info) + strlen(pw->pw_dir) + 4);
233+
fn = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4);
234234
if (fn) {
235235
strcpy(fn, pw->pw_dir); /* safe */
236236
strcat(fn, "/"); /* safe */
237-
strcat(fn, php3_ini.user_dir); /* safe */
237+
strcat(fn, PG(user_dir)); /* safe */
238238
strcat(fn, "/"); /* safe */
239239
strcat(fn, s + 1); /* safe (shorter than path_info) */
240240
STR_FREE(GLOBAL(request_info).filename);
@@ -245,16 +245,16 @@ FILE *php3_fopen_for_parser(void)
245245
} else
246246
#endif
247247
#if WIN32
248-
if (php3_ini.doc_root && path_info && ('/' == *php3_ini.doc_root ||
249-
'\\' == *php3_ini.doc_root || strstr(php3_ini.doc_root,":\\") ||
250-
strstr(php3_ini.doc_root,":/"))) {
248+
if (PG(doc_root) && path_info && ('/' == *PG(doc_root) ||
249+
'\\' == *PG(doc_root) || strstr(PG(doc_root),":\\") ||
250+
strstr(PG(doc_root),":/"))) {
251251
#else
252-
if (php3_ini.doc_root && '/' == *php3_ini.doc_root && path_info) {
252+
if (PG(doc_root) && '/' == *PG(doc_root) && path_info) {
253253
#endif
254-
l = strlen(php3_ini.doc_root);
254+
l = strlen(PG(doc_root));
255255
fn = emalloc(l + strlen(path_info) + 2);
256256
if (fn) {
257-
memcpy(fn, php3_ini.doc_root, l);
257+
memcpy(fn, PG(doc_root), l);
258258
if ('/' != fn[l - 1] || '\\' != fn[l - 1]) /* l is never 0 */
259259
fn[l++] = '/';
260260
if ('/' == path_info[0])
@@ -334,8 +334,8 @@ PHPAPI FILE *php3_fopen_with_path(char *filename, char *mode, char *path, char *
334334
if (*filename == '/') {
335335
#endif
336336
if (PG(safe_mode)) {
337-
if(php3_ini.doc_root) {
338-
snprintf(trypath, MAXPATHLEN, "%s%s", php3_ini.doc_root, filename);
337+
if(PG(doc_root)) {
338+
snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename);
339339
} else {
340340
strncpy(trypath,filename,MAXPATHLEN);
341341
}
@@ -883,7 +883,7 @@ static FILE *php3_fopen_url_wrapper(const char *path, char *mode, int options, i
883883

884884
} else {
885885
if (options & USE_PATH) {
886-
fp = php3_fopen_with_path((char *) path, mode, php3_ini.include_path, NULL);
886+
fp = php3_fopen_with_path((char *) path, mode, PG(include_path), NULL);
887887
} else {
888888
int cm=2;
889889
if(!strcmp(mode,"r") || !strcmp(mode,"r+")) cm=0;

0 commit comments

Comments
 (0)