A lot of cleanups... Removed old thread-safe code and other redundant code and files

This commit is contained in:
Zeev Suraski 1999-04-24 00:12:00 +00:00
parent 05d24c6022
commit 0818d96c97
55 changed files with 499 additions and 2219 deletions

View file

@ -1,705 +0,0 @@
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc. */
#endif /* not GNU C. */
#endif /* alloca not defined. */
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(token, value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ yychar = (token), yylval = (value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#ifndef YYPURE
#define YYLEX yylex()
#endif
#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
#ifdef PHP3_THREAD_SAFE /* PHP 3 Specific useage */
#define YYLEX yylex(&yylval,php3_globals,php_gbl)
#else
#define YYLEX yylex(&yylval)
#endif /* not using tls */
#endif
#endif /* not YYLSP_NEEDED */
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYPURE
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
#ifdef YYLSP_NEEDED
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
#endif
int yynerrs; /* number of parse errors so far */
#endif /* not YYPURE */
#if YYDEBUG != 0
int yydebug; /* nonzero means print parse trace */
/* Since this is uninitialized, it does not stop multiple parsers
from coexisting. */
#endif
/* YYINITDEPTH indicates the initial size of the parser's stacks */
#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif
/* YYMAXDEPTH is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
/* int yyparse (void); */
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_memcpy (to, from, count)
char *to;
char *from;
int count;
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#else /* __cplusplus */
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_memcpy (char *to, char *from, int count)
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#endif
#endif
#line 196 "bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
It should actually point to an object.
Grammar actions can access the variable by casting it
to the proper pointer type. */
#ifdef YYPARSE_PARAM
#ifdef __cplusplus
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#else /* not __cplusplus */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif /* not __cplusplus */
#else /* not YYPARSE_PARAM */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */
#ifndef TLS_VARS
#define TLS_VARS
#endif
#ifndef YY_TLS_VARS
#define YY_TLS_VARS
#endif
int
yyparse(YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
{
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
short yyssa[YYINITDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
#ifdef YYLSP_NEEDED
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK (yyvsp--, yyssp--)
#endif
int yystacksize = YYINITDEPTH;
#ifdef YYPURE
int yychar;
YYSTYPE yylval;
int yynerrs;
#ifdef YYLSP_NEEDED
YYLTYPE yylloc;
#endif
#endif
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
YY_TLS_VARS;
TLS_VARS;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Starting parse\n");
#endif
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss - 1;
yyvsp = yyvs;
#ifdef YYLSP_NEEDED
yylsp = yyls;
#endif
/* Push a new state, which is found in yystate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
yynewstate:
*++yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1)
{
/* Give user a chance to reallocate the stack */
/* Use copies of these so that the &'s don't force the real ones into memory. */
YYSTYPE *yyvs1 = yyvs;
short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
YYLTYPE *yyls1 = yyls;
#endif
/* Get the current used size of the three stacks, in elements. */
int size = yyssp - yyss + 1;
#ifdef yyoverflow
/* Each stack pointer address is followed by the size of
the data in use in that stack, in bytes. */
#ifdef YYLSP_NEEDED
/* This used to be a conditional around just the two extra args,
but that might be undefined if yyoverflow is a macro. */
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yyls1, size * sizeof (*yylsp),
&yystacksize);
#else
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yystacksize);
#endif
yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
yyls = yyls1;
#endif
#else /* no yyoverflow */
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
__yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
__yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
__yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
yyssp = yyss + size - 1;
yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
yylsp = yyls + size - 1;
#endif
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
}
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Entering state %d\n", yystate);
#endif
goto yybackup;
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Reading a token: ");
#endif
yychar = YYLEX;
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Now at end of input.\n");
#endif
}
else
{
yychar1 = YYTRANSLATE(yychar);
#if YYDEBUG != 0
if (yydebug)
{
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise meaning
of a token, for further debugging info. */
#ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
#endif
fprintf (stderr, ")\n");
}
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* count tokens shifted since error; after three, turn off error status. */
if (yyerrstatus) yyerrstatus--;
yystate = yyn;
goto yynewstate;
/* Do the default action for the current state. */
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
/* Do a reduction. yyn is the number of a rule to reduce with. */
yyreduce:
yylen = yyr2[yyn];
if (yylen > 0)
yyval = yyvsp[1-yylen]; /* implement default value of the action */
#if YYDEBUG != 0
if (yydebug)
{
int i;
fprintf (stderr, "Reducing via rule %d (line %d), ",
yyn, yyrline[yyn]);
/* Print the symbols being reduced, and their result. */
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
}
#endif
$ /* the action file gets copied in in place of this dollarsign */
#line 498 "bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
#ifdef YYLSP_NEEDED
yylsp -= yylen;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
*++yyvsp = yyval;
#ifdef YYLSP_NEEDED
yylsp++;
if (yylen == 0)
{
yylsp->first_line = yylloc.first_line;
yylsp->first_column = yylloc.first_column;
yylsp->last_line = (yylsp-1)->last_line;
yylsp->last_column = (yylsp-1)->last_column;
yylsp->text = 0;
}
else
{
yylsp->last_line = (yylsp+yylen-1)->last_line;
yylsp->last_column = (yylsp+yylen-1)->last_column;
}
#endif
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
yyerrlab: /* here on detecting error */
if (! yyerrstatus)
/* If not already recovering from an error, report this error. */
{
++yynerrs;
#ifdef YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
for (x = (yyn < 0 ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
if (msg != 0)
{
strcpy(msg, "parse error");
if (count < 5)
{
count = 0;
for (x = (yyn < 0 ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
strcat(msg, yytname[x]);
strcat(msg, "'");
count++;
}
}
yyerror(msg);
free(msg);
}
else
yyerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
yyerror("parse error");
}
goto yyerrlab1;
yyerrlab1: /* here on error raised explicitly by an action */
if (yyerrstatus == 3)
{
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
yyerrdefault: /* current state does not do anything special for the error token. */
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
if (yyn) goto yydefault;
#endif
yyerrpop: /* pop the current state because it cannot handle the error token */
if (yyssp == yyss) YYABORT;
yyvsp--;
yystate = *--yyssp;
#ifdef YYLSP_NEEDED
yylsp--;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "Error: state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting error token, ");
#endif
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
yystate = yyn;
goto yynewstate;
}

View file

@ -1,46 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP HTML Embedded Scripting Language Version 3.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of one of the following licenses: |
| |
| A) the GNU General Public License as published by the Free Software |
| Foundation; either version 2 of the License, or (at your option) |
| any later version. |
| |
| B) the PHP License as published by the PHP Development Team and |
| included in the distribution in the file: LICENSE |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of both licenses referred to here. |
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef _CONTROL_STRUCTURES_H
#define _CONTROL_STRUCTURES_H
#ifndef THREAD_SAFE
extern unsigned int param_index;
extern char *class_name;
extern HashTable *class_symbol_table;
#endif
extern inline void start_display_source(int start_in_php INLINE_TLS);
#endif

View file

@ -130,7 +130,6 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
pval *arg_name,*arg_val; pval *arg_name,*arg_val;
char *note_val; char *note_val;
int arg_count = ARG_COUNT(ht); int arg_count = ARG_COUNT(ht);
TLS_VARS;
if (arg_count<1 || arg_count>2 || if (arg_count<1 || arg_count>2 ||
getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) { getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) {
@ -138,11 +137,11 @@ TLS_VARS;
} }
convert_to_string(arg_name); convert_to_string(arg_name);
note_val = (char *) table_get(GLOBAL(php3_rqst)->notes,arg_name->value.str.val); note_val = (char *) table_get(php3_rqst->notes,arg_name->value.str.val);
if (arg_count == 2) { if (arg_count == 2) {
convert_to_string(arg_val); convert_to_string(arg_val);
table_set(GLOBAL(php3_rqst)->notes,arg_name->value.str.val,arg_val->value.str.val); table_set(php3_rqst->notes,arg_name->value.str.val,arg_val->value.str.val);
} }
if (note_val) { if (note_val) {
@ -159,7 +158,7 @@ void php3_info_apache(void) {
char name[64]; char name[64];
char *p; char *p;
#endif #endif
server_rec *serv = GLOBAL(php3_rqst)->server; server_rec *serv = php3_rqst->server;
extern char server_root[MAX_STRING_LEN]; extern char server_root[MAX_STRING_LEN];
extern uid_t user_id; extern uid_t user_id;
extern char *user_name; extern char *user_name;
@ -215,14 +214,13 @@ void php3_virtual(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *filename; pval *filename;
request_rec *rr = NULL; request_rec *rr = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
convert_to_string(filename); convert_to_string(filename);
if (!(rr = sub_req_lookup_uri (filename->value.str.val, GLOBAL(php3_rqst)))) { if (!(rr = sub_req_lookup_uri (filename->value.str.val, php3_rqst))) {
php3_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename->value.str.val); php3_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename->value.str.val);
if (rr) destroy_sub_req (rr); if (rr) destroy_sub_req (rr);
RETURN_FALSE; RETURN_FALSE;
@ -292,7 +290,7 @@ void php3_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS)
} }
convert_to_string(filename); convert_to_string(filename);
if(!(rr = sub_req_lookup_uri(filename->value.str.val, GLOBAL(php3_rqst)))) { if(!(rr = sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
php3_error(E_WARNING, "URI lookup failed", filename->value.str.val); php3_error(E_WARNING, "URI lookup failed", filename->value.str.val);
RETURN_FALSE; RETURN_FALSE;
} }
@ -364,7 +362,7 @@ void php3_apache_exec_uri(INTERNAL_FUNCTION_PARAMETERS) {
} }
convert_to_string(filename); convert_to_string(filename);
if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, GLOBAL(php3_rqst)))) { if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
php3_error(E_WARNING, "URI lookup failed", filename->value.str.val); php3_error(E_WARNING, "URI lookup failed", filename->value.str.val);
RETURN_FALSE; RETURN_FALSE;
} }

View file

@ -61,11 +61,9 @@ static long bc_precision;
int php3_rinit_bcmath(INIT_FUNC_ARGS) int php3_rinit_bcmath(INIT_FUNC_ARGS)
{ {
TLS_VARS;
init_numbers(); init_numbers();
if (cfg_get_long("bcmath.scale",&GLOBAL(bc_precision))==FAILURE) { if (cfg_get_long("bcmath.scale",&bc_precision)==FAILURE) {
GLOBAL(bc_precision)=0; bc_precision=0;
} }
return SUCCESS; return SUCCESS;
} }
@ -82,7 +80,7 @@ void php3_bcmath_add(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left, *right,*scale_param; pval *left, *right,*scale_param;
bc_num first, second, result; bc_num first, second, result;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:
@ -125,7 +123,7 @@ void php3_bcmath_sub(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left, *right,*scale_param; pval *left, *right,*scale_param;
bc_num first, second, result; bc_num first, second, result;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:
@ -168,7 +166,7 @@ void php3_bcmath_mul(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left, *right,*scale_param; pval *left, *right,*scale_param;
bc_num first, second, result; bc_num first, second, result;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:
@ -211,7 +209,7 @@ void php3_bcmath_div(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left, *right,*scale_param; pval *left, *right,*scale_param;
bc_num first, second, result; bc_num first, second, result;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:
@ -301,7 +299,7 @@ void php3_bcmath_pow(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left, *right,*scale_param; pval *left, *right,*scale_param;
bc_num first, second, result; bc_num first, second, result;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:
@ -344,7 +342,7 @@ void php3_bcmath_sqrt(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left,*scale_param; pval *left,*scale_param;
bc_num result; bc_num result;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 1: case 1:
@ -384,7 +382,7 @@ void php3_bcmath_comp(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *left, *right, *scale_param; pval *left, *right, *scale_param;
bc_num first, second; bc_num first, second;
int scale=GLOBAL(bc_precision); int scale=bc_precision;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:
@ -431,7 +429,7 @@ void php3_bcmath_set_scale(INTERNAL_FUNCTION_PARAMETERS)
} }
convert_to_long(new_scale); convert_to_long(new_scale);
GLOBAL(bc_precision) = new_scale->value.lval; bc_precision = new_scale->value.lval;
RETURN_TRUE; RETURN_TRUE;
} }
/* }}} */ /* }}} */

View file

@ -116,16 +116,13 @@ new_num (length, scale)
/* Intitialize the number package! */ /* Intitialize the number package! */
void void init_numbers (void)
init_numbers (void)
{ {
TLS_VARS; _zero_ = new_num (1,0);
_one_ = new_num (1,0);
GLOBAL(_zero_) = new_num (1,0); _one_->n_value[0] = 1;
GLOBAL(_one_) = new_num (1,0); _two_ = new_num (1,0);
GLOBAL(_one_)->n_value[0] = 1; _two_->n_value[0] = 2;
GLOBAL(_two_) = new_num (1,0);
GLOBAL(_two_)->n_value[0] = 2;
} }
/* Intitialize the number package! */ /* Intitialize the number package! */
@ -133,11 +130,9 @@ init_numbers (void)
void void
destruct_numbers () destruct_numbers ()
{ {
TLS_VARS; free_num(&_zero_);
free_num(&_one_);
free_num(&GLOBAL(_zero_)); free_num(&_two_);
free_num(&GLOBAL(_one_));
free_num(&GLOBAL(_two_));
} }
/* Make a copy of a number! Just increments the reference count! */ /* Make a copy of a number! Just increments the reference count! */
@ -157,8 +152,7 @@ void
init_num (num) init_num (num)
bc_num *num; bc_num *num;
{ {
TLS_VARS; *num = copy_num (_zero_);
*num = copy_num (GLOBAL(_zero_));
} }
@ -376,10 +370,9 @@ is_zero (num)
{ {
int count; int count;
char *nptr; char *nptr;
TLS_VARS;
/* Quick check. */ /* Quick check. */
if (num == GLOBAL(_zero_)) return TRUE; if (num == _zero_) return TRUE;
/* Initialize */ /* Initialize */
count = num->n_len + num->n_scale; count = num->n_len + num->n_scale;
@ -1083,7 +1076,6 @@ bc_raisemod (base, expo, mod, result, scale)
{ {
bc_num power, exponent, parity, temp; bc_num power, exponent, parity, temp;
int rscale; int rscale;
TLS_VARS;
/* Check for correct numbers. */ /* Check for correct numbers. */
if (is_zero(mod)) return -1; if (is_zero(mod)) return -1;
@ -1092,14 +1084,14 @@ bc_raisemod (base, expo, mod, result, scale)
/* Set initial values. */ /* Set initial values. */
power = copy_num (base); power = copy_num (base);
exponent = copy_num (expo); exponent = copy_num (expo);
temp = copy_num (GLOBAL(_one_)); temp = copy_num (_one_);
init_num (&parity); init_num (&parity);
/* Check the exponent for scale digits. */ /* Check the exponent for scale digits. */
if (exponent->n_scale != 0) if (exponent->n_scale != 0)
{ {
rt_warn ("non-zero scale in exponent"); rt_warn ("non-zero scale in exponent");
bc_divide (exponent, GLOBAL(_one_), &exponent, 0); /*truncate */ bc_divide (exponent, _one_, &exponent, 0); /*truncate */
} }
/* Check the modulus for scale digits. */ /* Check the modulus for scale digits. */
@ -1110,7 +1102,7 @@ bc_raisemod (base, expo, mod, result, scale)
rscale = MAX(scale, base->n_scale); rscale = MAX(scale, base->n_scale);
while ( !is_zero(exponent) ) while ( !is_zero(exponent) )
{ {
(void) bc_divmod (exponent, GLOBAL(_two_), &exponent, &parity, 0); (void) bc_divmod (exponent, _two_, &exponent, &parity, 0);
if ( !is_zero(parity) ) if ( !is_zero(parity) )
{ {
bc_multiply (temp, power, &temp, rscale); bc_multiply (temp, power, &temp, rscale);
@ -1143,7 +1135,6 @@ bc_raise (num1, num2, result, scale)
long exponent; long exponent;
int rscale; int rscale;
char neg; char neg;
TLS_VARS;
/* Check the exponent for scale digits and convert to a long. */ /* Check the exponent for scale digits and convert to a long. */
if (num2->n_scale != 0) if (num2->n_scale != 0)
@ -1156,7 +1147,7 @@ bc_raise (num1, num2, result, scale)
if (exponent == 0) if (exponent == 0)
{ {
free_num (result); free_num (result);
*result = copy_num (GLOBAL(_one_)); *result = copy_num (_one_);
return; return;
} }
@ -1196,7 +1187,7 @@ bc_raise (num1, num2, result, scale)
/* Assign the value. */ /* Assign the value. */
if (neg) if (neg)
{ {
bc_divide (GLOBAL(_one_), temp, result, rscale); bc_divide (_one_, temp, result, rscale);
free_num (&temp); free_num (&temp);
} }
else else
@ -1241,10 +1232,9 @@ bc_sqrt (num, scale)
int rscale, cmp_res, done; int rscale, cmp_res, done;
int cscale; int cscale;
bc_num guess, guess1, point5, diff; bc_num guess, guess1, point5, diff;
TLS_VARS;
/* Initial checks. */ /* Initial checks. */
cmp_res = bc_compare (*num, GLOBAL(_zero_)); cmp_res = bc_compare (*num, _zero_);
if (cmp_res < 0) if (cmp_res < 0)
return 0; /* error */ return 0; /* error */
else else
@ -1252,15 +1242,15 @@ bc_sqrt (num, scale)
if (cmp_res == 0) if (cmp_res == 0)
{ {
free_num (num); free_num (num);
*num = copy_num (GLOBAL(_zero_)); *num = copy_num (_zero_);
return 1; return 1;
} }
} }
cmp_res = bc_compare (*num, GLOBAL(_one_)); cmp_res = bc_compare (*num, _one_);
if (cmp_res == 0) if (cmp_res == 0)
{ {
free_num (num); free_num (num);
*num = copy_num (GLOBAL(_one_)); *num = copy_num (_one_);
return 1; return 1;
} }
@ -1276,7 +1266,7 @@ bc_sqrt (num, scale)
/* Calculate the initial guess. */ /* Calculate the initial guess. */
if (cmp_res < 0) if (cmp_res < 0)
/* The number is between 0 and 1. Guess should start at 1. */ /* The number is between 0 and 1. Guess should start at 1. */
guess = copy_num (GLOBAL(_one_)); guess = copy_num (_one_);
else else
{ {
/* The number is greater than 1. Guess should start at 10^(exp/2). */ /* The number is greater than 1. Guess should start at 10^(exp/2). */
@ -1309,7 +1299,7 @@ bc_sqrt (num, scale)
/* Assign the number and clean up. */ /* Assign the number and clean up. */
free_num (num); free_num (num);
bc_divide (guess,GLOBAL(_one_),num,rscale); bc_divide (guess,_one_,num,rscale);
free_num (&guess); free_num (&guess);
free_num (&guess1); free_num (&guess1);
free_num (&point5); free_num (&point5);
@ -1534,7 +1524,6 @@ str2num (num, str, scale)
int digits, strscale; int digits, strscale;
char *ptr, *nptr; char *ptr, *nptr;
char zero_int; char zero_int;
TLS_VARS;
/* Prepare num. */ /* Prepare num. */
free_num (num); free_num (num);
@ -1551,7 +1540,7 @@ str2num (num, str, scale)
while (isdigit(*ptr)) ptr++, strscale++; /* digits */ while (isdigit(*ptr)) ptr++, strscale++; /* digits */
if ((*ptr != '\0') || (digits+strscale == 0)) if ((*ptr != '\0') || (digits+strscale == 0))
{ {
*num = copy_num (GLOBAL(_zero_)); *num = copy_num (_zero_);
return; return;
} }

View file

@ -108,7 +108,6 @@ static void _php3_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
off_t start, end; off_t start, end;
char *buf = NULL; char *buf = NULL;
char *string = NULL; char *string = NULL;
TLS_VARS;
if (icase) if (icase)
copts |= REG_ICASE; copts |= REG_ICASE;
@ -176,7 +175,7 @@ static void _php3_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
RETURN_FALSE; RETURN_FALSE;
} }
pval_destructor(array _INLINE_TLS); /* start with clean array */ pval_destructor(array); /* start with clean array */
array_init(array); array_init(array);
for (i = 0; i < NS; i++) { for (i = 0; i < NS; i++) {
@ -366,7 +365,6 @@ static void _php3_eregreplace(INTERNAL_FUNCTION_PARAMETERS, int icase)
char *string; char *string;
char *replace; char *replace;
char *ret; char *ret;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -442,7 +440,6 @@ void php3_split(INTERNAL_FUNCTION_PARAMETERS)
regmatch_t subs[1]; regmatch_t subs[1];
char *strp, *endp; char *strp, *endp;
int err, size, count; int err, size, count;
TLS_VARS;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:

View file

@ -461,7 +461,7 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag) {
#if APACHE #if APACHE
{ {
int j; int j;
array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env); array_header *arr = table_elts(php3_rqst->subprocess_env);
table_entry *elts = (table_entry *)arr->elts; table_entry *elts = (table_entry *)arr->elts;
for (j=0; j < arr->nelts; j++) { for (j=0; j < arr->nelts; j++) {

View file

@ -426,7 +426,6 @@ static void php3_hw_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
hw_connection *ptr; hw_connection *ptr;
int do_swap; int do_swap;
int version = 0; int version = 0;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
switch(argc) { switch(argc) {
@ -694,7 +693,6 @@ void php3_hw_close(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
int id, type; int id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -719,7 +717,6 @@ void php3_hw_info(INTERNAL_FUNCTION_PARAMETERS)
int id, type; int id, type;
hw_connection *ptr; hw_connection *ptr;
char *str; char *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -752,7 +749,6 @@ void php3_hw_error(INTERNAL_FUNCTION_PARAMETERS)
pval *arg1; pval *arg1;
int id, type; int id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -776,7 +772,6 @@ void php3_hw_errormsg(INTERNAL_FUNCTION_PARAMETERS)
int id, type; int id, type;
hw_connection *ptr; hw_connection *ptr;
char errstr[100]; char errstr[100];
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -861,7 +856,6 @@ void php3_hw_errormsg(INTERNAL_FUNCTION_PARAMETERS)
Returns object id of root collection */ Returns object id of root collection */
void php3_hw_root(INTERNAL_FUNCTION_PARAMETERS) void php3_hw_root(INTERNAL_FUNCTION_PARAMETERS)
{ {
TLS_VARS;
return_value->value.lval = 0; return_value->value.lval = 0;
return_value->type = IS_LONG; return_value->type = IS_LONG;
} }
@ -871,7 +865,6 @@ char *php3_hw_command(INTERNAL_FUNCTION_PARAMETERS, int comm) {
pval *arg1; pval *arg1;
int link, type; int link, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
return NULL; return NULL;
@ -1024,7 +1017,6 @@ void php3_hw_dummy(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2, *arg3; pval *arg1, *arg2, *arg3;
int link, id, type, msgid; int link, id, type, msgid;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1060,7 +1052,6 @@ void php3_hw_getobject(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, id, type; int link, id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1097,7 +1088,6 @@ void php3_hw_insertobject(INTERNAL_FUNCTION_PARAMETERS) {
int link, type; int link, type;
char *objrec, *parms; char *objrec, *parms;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1131,7 +1121,6 @@ void php3_hw_getandlock(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, id, type; int link, id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1164,7 +1153,6 @@ void php3_hw_unlock(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, id, type; int link, id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1193,7 +1181,6 @@ void php3_hw_deleteobject(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, id, type; int link, id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1223,7 +1210,6 @@ void php3_hw_changeobject(INTERNAL_FUNCTION_PARAMETERS) {
hw_connection *ptr; hw_connection *ptr;
char *modification, *oldobjrec, buf[200]; char *modification, *oldobjrec, buf[200];
HashTable *newobjarr; HashTable *newobjarr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1304,7 +1290,6 @@ void php3_hw_mvcp(INTERNAL_FUNCTION_PARAMETERS, int mvcp) {
HashTable *src_arr; HashTable *src_arr;
hw_connection *ptr; hw_connection *ptr;
int collIDcount, docIDcount, i, *docIDs, *collIDs; int collIDcount, docIDcount, i, *docIDs, *collIDs;
TLS_VARS;
switch(mvcp) { switch(mvcp) {
case MOVE: /* Move also has fromID */ case MOVE: /* Move also has fromID */
@ -1418,7 +1403,6 @@ void php3_hw_gettext(INTERNAL_FUNCTION_PARAMETERS) {
int rootid = 0; int rootid = 0;
hw_document *doc; hw_document *doc;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
if((argc > 3) || (argc < 2)) if((argc > 3) || (argc < 2))
@ -1470,7 +1454,6 @@ void php3_hw_edittext(INTERNAL_FUNCTION_PARAMETERS) {
int link, id, doc, type; int link, id, doc, type;
hw_connection *ptr; hw_connection *ptr;
hw_document *docptr; hw_document *docptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1513,7 +1496,6 @@ void php3_hw_getcgi(INTERNAL_FUNCTION_PARAMETERS) {
hw_document *doc; hw_document *doc;
hw_connection *ptr; hw_connection *ptr;
char cgi_env_str[1000]; char cgi_env_str[1000];
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1549,9 +1531,9 @@ void php3_hw_getcgi(INTERNAL_FUNCTION_PARAMETERS) {
getenv("QUERY_STRING")); getenv("QUERY_STRING"));
#else #else
sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s", sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
GLOBAL(request_info).request_method, request_info.request_method,
GLOBAL(request_info).path_info, request_info.path_info,
GLOBAL(request_info).query_string); request_info.query_string);
#endif #endif
/* !!!! memory for object and attributes is allocated with malloc !!!! */ /* !!!! memory for object and attributes is allocated with malloc !!!! */
if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, cgi_env_str, &attributes, &object, &count))) if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, cgi_env_str, &attributes, &object, &count)))
@ -1574,7 +1556,6 @@ void php3_hw_getremote(INTERNAL_FUNCTION_PARAMETERS) {
int link, id, type; int link, id, type;
hw_document *doc; hw_document *doc;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1615,7 +1596,6 @@ void php3_hw_getremotechildren(INTERNAL_FUNCTION_PARAMETERS) {
int link, type, i; int link, type, i;
hw_connection *ptr; hw_connection *ptr;
char *objrec; char *objrec;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1673,7 +1653,6 @@ void php3_hw_setlinkroot(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, type, rootid; int link, type, rootid;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1702,9 +1681,8 @@ void php3_hw_pipedocument(INTERNAL_FUNCTION_PARAMETERS) {
hw_connection *ptr; hw_connection *ptr;
hw_document *doc; hw_document *doc;
#if APACHE #if APACHE
server_rec *serv = GLOBAL(php3_rqst)->server; server_rec *serv = php3_rqst->server;
#endif #endif
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
if((argc > 2) || (argc < 2)) if((argc > 2) || (argc < 2))
@ -1770,9 +1748,8 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) {
hw_document *doc; hw_document *doc;
char cgi_env_str[1000]; char cgi_env_str[1000];
#if APACHE #if APACHE
server_rec *serv = GLOBAL(php3_rqst)->server; server_rec *serv = php3_rqst->server;
#endif #endif
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1800,9 +1777,9 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) {
getenv("QUERY_STRING")); getenv("QUERY_STRING"));
#else #else
sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s", sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
GLOBAL(request_info).request_method, request_info.request_method,
GLOBAL(request_info).path_info, request_info.path_info,
GLOBAL(request_info).query_string); request_info.query_string);
#endif #endif
/* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */ /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
if (0 != (ptr->lasterror = send_pipecgi(ptr->socket, if (0 != (ptr->lasterror = send_pipecgi(ptr->socket,
@ -1832,9 +1809,8 @@ void php3_hw_insertdocument(INTERNAL_FUNCTION_PARAMETERS) {
hw_connection *ptr; hw_connection *ptr;
hw_document *docptr; hw_document *docptr;
#if APACHE #if APACHE
server_rec *serv = GLOBAL(php3_rqst)->server; server_rec *serv = php3_rqst->server;
#endif #endif
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1902,7 +1878,6 @@ void php3_hw_free_document(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
int id, type; int id, type;
hw_document *ptr; hw_document *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1925,7 +1900,6 @@ void php3_hw_output_document(INTERNAL_FUNCTION_PARAMETERS) {
int id, type, count; int id, type, count;
hw_document *ptr; hw_document *ptr;
char *ptr1; char *ptr1;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1955,7 +1929,6 @@ void php3_hw_document_bodytag(INTERNAL_FUNCTION_PARAMETERS) {
int id, type, argc; int id, type, argc;
hw_document *ptr; hw_document *ptr;
char *temp, *str = NULL; char *temp, *str = NULL;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
if((argc > 2) || (argc < 1)) if((argc > 2) || (argc < 1))
@ -1994,7 +1967,6 @@ void php3_hw_document_content(INTERNAL_FUNCTION_PARAMETERS) {
pval *argv[1]; pval *argv[1];
int id, type, argc; int id, type, argc;
hw_document *ptr; hw_document *ptr;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
if(argc != 1) if(argc != 1)
@ -2020,7 +1992,6 @@ void php3_hw_document_size(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
int id, type; int id, type;
hw_document *ptr; hw_document *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2042,7 +2013,6 @@ void php3_hw_document_attributes(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
int id, type; int id, type;
hw_document *ptr; hw_document *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2067,7 +2037,6 @@ void php3_hw_getparentsobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **childObjRecs = NULL; char **childObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2101,7 +2070,6 @@ void php3_hw_getparents(INTERNAL_FUNCTION_PARAMETERS) {
int link, id, type; int link, id, type;
int count; int count;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2146,7 +2114,6 @@ void php3_hw_children(INTERNAL_FUNCTION_PARAMETERS) {
int link, id, type; int link, id, type;
int count; int count;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2192,7 +2159,6 @@ void php3_hw_childrenobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **childObjRecs = NULL; char **childObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2226,7 +2192,6 @@ void php3_hw_getchildcoll(INTERNAL_FUNCTION_PARAMETERS) {
int link, id, type; int link, id, type;
int count; int count;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2272,7 +2237,6 @@ void php3_hw_getchildcollobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **childObjRecs = NULL; char **childObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2305,7 +2269,6 @@ void php3_hw_docbyanchor(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, id, type; int link, id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2336,7 +2299,6 @@ void php3_hw_docbyanchorobj(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1, *arg2; pval *arg1, *arg2;
int link, id, type; int link, id, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2374,7 +2336,6 @@ void php3_hw_getobjectbyquery(INTERNAL_FUNCTION_PARAMETERS) {
int count, i; int count, i;
int *childIDs = NULL; int *childIDs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2417,7 +2378,6 @@ void php3_hw_getobjectbyqueryobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **childObjRecs = NULL; char **childObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2455,7 +2415,6 @@ void php3_hw_getobjectbyquerycoll(INTERNAL_FUNCTION_PARAMETERS) {
int count, i; int count, i;
hw_connection *ptr; hw_connection *ptr;
int *childIDs = NULL; int *childIDs = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2500,7 +2459,6 @@ void php3_hw_getobjectbyquerycollobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
hw_connection *ptr; hw_connection *ptr;
char **childObjRecs = NULL; char **childObjRecs = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2539,7 +2497,6 @@ void php3_hw_getchilddoccoll(INTERNAL_FUNCTION_PARAMETERS) {
int count, i; int count, i;
int *childIDs = NULL; int *childIDs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2578,7 +2535,6 @@ void php3_hw_getchilddoccollobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **childObjRecs = NULL; char **childObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2613,7 +2569,6 @@ void php3_hw_getanchors(INTERNAL_FUNCTION_PARAMETERS) {
int count, i; int count, i;
int *anchorIDs = NULL; int *anchorIDs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2652,7 +2607,6 @@ void php3_hw_getanchorsobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **anchorObjRecs = NULL; char **anchorObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2684,7 +2638,6 @@ void php3_hw_getusername(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
int link, type; int link, type;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2710,7 +2663,6 @@ void php3_hw_identify(INTERNAL_FUNCTION_PARAMETERS) {
int link, type; int link, type;
char *name, *passwd, *userdata; char *name, *passwd, *userdata;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2757,7 +2709,6 @@ void php3_hw_identify(INTERNAL_FUNCTION_PARAMETERS) {
Returns object array of object record*/ Returns object array of object record*/
void php3_hw_objrec2array(INTERNAL_FUNCTION_PARAMETERS) { void php3_hw_objrec2array(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2772,7 +2723,6 @@ void php3_hw_objrec2array(INTERNAL_FUNCTION_PARAMETERS) {
void php3_hw_array2objrec(INTERNAL_FUNCTION_PARAMETERS) { void php3_hw_array2objrec(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg1; pval *arg1;
char *objrec, *retobj; char *objrec, *retobj;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2795,7 +2745,6 @@ void php3_hw_incollections(INTERNAL_FUNCTION_PARAMETERS) {
int type, link, i; int type, link, i;
hw_connection *ptr; hw_connection *ptr;
int cobjids, ccollids, *objectIDs, *collIDs, cretids, *retIDs, retcoll; int cobjids, ccollids, *objectIDs, *collIDs, cretids, *retIDs, retcoll;
TLS_VARS;
if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2857,7 +2806,6 @@ void php3_hw_inscoll(INTERNAL_FUNCTION_PARAMETERS) {
char *objrec; char *objrec;
int id, newid, type, link; int id, newid, type, link;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2896,7 +2844,6 @@ void php3_hw_insdoc(INTERNAL_FUNCTION_PARAMETERS) {
char *objrec, *text; char *objrec, *text;
int id, newid, type, link, argc; int id, newid, type, link, argc;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
if((argc < 3) || (argc > 4)) if((argc < 3) || (argc > 4))
@ -2940,7 +2887,6 @@ void php3_hw_getsrcbydestobj(INTERNAL_FUNCTION_PARAMETERS) {
int count; int count;
char **childObjRecs = NULL; char **childObjRecs = NULL;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -2975,7 +2921,6 @@ void php3_hw_getrellink(INTERNAL_FUNCTION_PARAMETERS) {
int rootid, destid, sourceid; int rootid, destid, sourceid;
char *anchorstr; char *anchorstr;
hw_connection *ptr; hw_connection *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { if (ARG_COUNT(ht) != 4 || getParameters(ht, 4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -1187,9 +1187,6 @@ PHP_FUNCTION(odbc_result)
UDWORD crow; UDWORD crow;
UWORD RowStatus[1]; UWORD RowStatus[1];
#endif #endif
#if !defined(COMPILE_DL) && defined(THREAD_SAFE)
TLS_VARS;
#endif
field_ind = -1; field_ind = -1;
field = NULL; field = NULL;
@ -1368,9 +1365,6 @@ PHP_FUNCTION(odbc_result_all)
UDWORD crow; UDWORD crow;
UWORD RowStatus[1]; UWORD RowStatus[1];
#endif #endif
#if !defined(COMPILE_DL) && defined(THREAD_SAFE)
TLS_VARS
#endif
numArgs = ARG_COUNT(ht); numArgs = ARG_COUNT(ht);
if (numArgs == 1){ if (numArgs == 1){

View file

@ -144,7 +144,6 @@ void php3_base64_encode(INTERNAL_FUNCTION_PARAMETERS) {
pval *string; pval *string;
unsigned char *result; unsigned char *result;
int ret_length; int ret_length;
TLS_VARS;
if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) { if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -168,7 +167,6 @@ void php3_base64_decode(INTERNAL_FUNCTION_PARAMETERS) {
pval *string; pval *string;
unsigned char *result; unsigned char *result;
int ret_length; int ret_length;
TLS_VARS;
if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) { if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -364,8 +364,7 @@ int php3_mshutdown_basic(SHUTDOWN_FUNC_ARGS)
int php3_rinit_basic(INIT_FUNC_ARGS) int php3_rinit_basic(INIT_FUNC_ARGS)
{ {
TLS_VARS; strtok_string = NULL;
GLOBAL(strtok_string) = NULL;
#if HAVE_PUTENV #if HAVE_PUTENV
if (_php3_hash_init(&putenv_ht, 1, NULL, (void (*)(void *)) _php3_putenv_destructor, 0) == FAILURE) { if (_php3_hash_init(&putenv_ht, 1, NULL, (void (*)(void *)) _php3_putenv_destructor, 0) == FAILURE) {
return FAILURE; return FAILURE;
@ -379,8 +378,7 @@ int php3_rinit_basic(INIT_FUNC_ARGS)
int php3_rshutdown_basic(SHUTDOWN_FUNC_ARGS) int php3_rshutdown_basic(SHUTDOWN_FUNC_ARGS)
{ {
TLS_VARS; STR_FREE(strtok_string);
STR_FREE(GLOBAL(strtok_string));
#if HAVE_PUTENV #if HAVE_PUTENV
_php3_hash_destroy(&putenv_ht); _php3_hash_destroy(&putenv_ht);
#endif #endif
@ -398,7 +396,6 @@ void php3_getenv(INTERNAL_FUNCTION_PARAMETERS)
#endif #endif
pval *str; pval *str;
char *ptr; char *ptr;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -426,14 +423,14 @@ void php3_getenv(INTERNAL_FUNCTION_PARAMETERS)
if (str->type == IS_STRING && if (str->type == IS_STRING &&
#if APACHE #if APACHE
((ptr = (char *)table_get(GLOBAL(php3_rqst)->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val))) ((ptr = (char *)table_get(php3_rqst->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val)))
#endif #endif
#if CGI_BINARY #if CGI_BINARY
(ptr = getenv(str->value.str.val)) (ptr = getenv(str->value.str.val))
#endif #endif
#if USE_SAPI #if USE_SAPI
(ptr = GLOBAL(sapi_rqst)->getenv(GLOBAL(sapi_rqst)->scid,str->value.str.val)) (ptr = sapi_rqst->getenv(sapi_rqst->scid,str->value.str.val))
#endif #endif
#endif #endif
) { ) {
@ -448,7 +445,6 @@ void php3_putenv(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -523,7 +519,6 @@ void php3_toggle_short_open_tag(INTERNAL_FUNCTION_PARAMETERS)
#if 0 #if 0
pval *value; pval *value;
int ret; int ret;
TLS_VARS;
ret = php3_ini.short_open_tag; ret = php3_ini.short_open_tag;
@ -621,7 +616,6 @@ void php3_key_sort(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *array; pval *array;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -727,7 +721,6 @@ void php3_asort(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *array; pval *array;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -751,7 +744,6 @@ void php3_arsort(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *array; pval *array;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -775,7 +767,6 @@ void php3_sort(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *array; pval *array;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -799,7 +790,6 @@ void php3_rsort(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *array; pval *array;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -848,7 +838,6 @@ void php3_user_sort(INTERNAL_FUNCTION_PARAMETERS)
pval *array; pval *array;
pval *old_compare_func; pval *old_compare_func;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
old_compare_func = user_compare_func_name; old_compare_func = user_compare_func_name;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) {
@ -875,7 +864,6 @@ void php3_auser_sort(INTERNAL_FUNCTION_PARAMETERS)
pval *array; pval *array;
pval *old_compare_func; pval *old_compare_func;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
old_compare_func = user_compare_func_name; old_compare_func = user_compare_func_name;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) {
@ -950,7 +938,6 @@ void php3_user_key_sort(INTERNAL_FUNCTION_PARAMETERS)
pval *array; pval *array;
pval *old_compare_func; pval *old_compare_func;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
old_compare_func = user_compare_func_name; old_compare_func = user_compare_func_name;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) == FAILURE) {
@ -1180,11 +1167,10 @@ void php3_flush(INTERNAL_FUNCTION_PARAMETERS)
#endif #endif
{ {
#if APACHE #if APACHE
TLS_VARS;
# if MODULE_MAGIC_NUMBER > 19970110 # if MODULE_MAGIC_NUMBER > 19970110
rflush(GLOBAL(php3_rqst)); rflush(php3_rqst);
# else # else
bflush(GLOBAL(php3_rqst)->connection->client); bflush(php3_rqst->connection->client);
# endif # endif
#endif #endif
#if FHTTPD #if FHTTPD
@ -1194,8 +1180,7 @@ void php3_flush(INTERNAL_FUNCTION_PARAMETERS)
fflush(stdout); fflush(stdout);
#endif #endif
#if USE_SAPI #if USE_SAPI
TLS_VARS; sapi_rqst->flush(sapi_rqst->scid);
GLOBAL(sapi_rqst)->flush(GLOBAL(sapi_rqst)->scid);
#endif #endif
} }
@ -1227,7 +1212,6 @@ void php3_usleep(INTERNAL_FUNCTION_PARAMETERS)
void php3_gettype(INTERNAL_FUNCTION_PARAMETERS) void php3_gettype(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1270,7 +1254,6 @@ void php3_settype(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *var, *type; pval *var, *type;
char *new_type; char *new_type;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &var, &type) == if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &var, &type) ==
FAILURE) { FAILURE) {
@ -1379,7 +1362,6 @@ static int _php3_array_walk(const void *a)
void php3_array_walk(INTERNAL_FUNCTION_PARAMETERS) { void php3_array_walk(INTERNAL_FUNCTION_PARAMETERS) {
pval *array, *old_walk_func_name; pval *array, *old_walk_func_name;
HashTable *target_hash; HashTable *target_hash;
TLS_VARS;
old_walk_func_name = php3_array_walk_func_name; old_walk_func_name = php3_array_walk_func_name;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &php3_array_walk_func_name) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &php3_array_walk_func_name) == FAILURE) {
@ -1404,7 +1386,6 @@ void php3_max(INTERNAL_FUNCTION_PARAMETERS)
pval **argv; pval **argv;
int argc, i; int argc, i;
unsigned short max_type = IS_LONG; unsigned short max_type = IS_LONG;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
/* if there is one parameter and this parameter is an array of /* if there is one parameter and this parameter is an array of
@ -1469,8 +1450,6 @@ void php3_max(INTERNAL_FUNCTION_PARAMETERS)
void php3_get_current_user(INTERNAL_FUNCTION_PARAMETERS) void php3_get_current_user(INTERNAL_FUNCTION_PARAMETERS)
{ {
TLS_VARS;
RETURN_STRING(_php3_get_current_user(),1); RETURN_STRING(_php3_get_current_user(),1);
} }
@ -1576,7 +1555,6 @@ void php3_error_log(INTERNAL_FUNCTION_PARAMETERS)
pval *string, *erropt = NULL, *option = NULL, *emailhead = NULL; pval *string, *erropt = NULL, *option = NULL, *emailhead = NULL;
int opt_err = 0; int opt_err = 0;
char *message, *opt=NULL, *headers=NULL; char *message, *opt=NULL, *headers=NULL;
TLS_VARS;
switch(ARG_COUNT(ht)) { switch(ARG_COUNT(ht)) {
case 1: case 1:

View file

@ -53,9 +53,8 @@ static int browser_reg_compare(pval *browser)
{ {
pval *browser_name; pval *browser_name;
regex_t r; regex_t r;
TLS_VARS;
if (GLOBAL(found_browser_entry)) { /* already found */ if (found_browser_entry) { /* already found */
return 0; return 0;
} }
_php3_hash_find(browser->value.ht,"browser_name_pattern",sizeof("browser_name_pattern"),(void **) &browser_name); _php3_hash_find(browser->value.ht,"browser_name_pattern",sizeof("browser_name_pattern"),(void **) &browser_name);
@ -65,8 +64,8 @@ static int browser_reg_compare(pval *browser)
if (regcomp(&r,browser_name->value.str.val,REG_NOSUB)!=0) { if (regcomp(&r,browser_name->value.str.val,REG_NOSUB)!=0) {
return 0; return 0;
} }
if (regexec(&r,GLOBAL(lookup_browser_name),0,NULL,0)==0) { if (regexec(&r,lookup_browser_name,0,NULL,0)==0) {
GLOBAL(found_browser_entry) = browser; found_browser_entry = browser;
} }
regfree(&r); regfree(&r);
return 0; return 0;
@ -100,14 +99,14 @@ void php3_get_browser(INTERNAL_FUNCTION_PARAMETERS)
convert_to_string(agent_name); convert_to_string(agent_name);
if (_php3_hash_find(&GLOBAL(browser_hash), agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) { if (_php3_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
GLOBAL(lookup_browser_name) = agent_name->value.str.val; lookup_browser_name = agent_name->value.str.val;
GLOBAL(found_browser_entry) = NULL; found_browser_entry = NULL;
_php3_hash_apply(&GLOBAL(browser_hash),(int (*)(void *)) browser_reg_compare); _php3_hash_apply(&browser_hash,(int (*)(void *)) browser_reg_compare);
if (GLOBAL(found_browser_entry)) { if (found_browser_entry) {
agent = GLOBAL(found_browser_entry); agent = found_browser_entry;
} else if (_php3_hash_find(&GLOBAL(browser_hash), "Default Browser", sizeof("Default Browser"), (void **) &agent)==FAILURE) { } else if (_php3_hash_find(&browser_hash, "Default Browser", sizeof("Default Browser"), (void **) &agent)==FAILURE) {
RETURN_FALSE; RETURN_FALSE;
} }
} }
@ -118,7 +117,7 @@ void php3_get_browser(INTERNAL_FUNCTION_PARAMETERS)
return_value->value.ht->pDestructor = PVAL_DESTRUCTOR; return_value->value.ht->pDestructor = PVAL_DESTRUCTOR;
while (_php3_hash_find(agent->value.ht, "parent", sizeof("parent"), (void **) &agent_name)==SUCCESS) { while (_php3_hash_find(agent->value.ht, "parent", sizeof("parent"), (void **) &agent_name)==SUCCESS) {
if (_php3_hash_find(&GLOBAL(browser_hash), agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) { if (_php3_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
break; break;
} }
_php3_hash_merge(return_value->value.ht,agent->value.ht,(void (*)(void *pData)) pval_copy_constructor, (void *) &tmp, sizeof(pval)); _php3_hash_merge(return_value->value.ht,agent->value.ht,(void (*)(void *pData)) pval_copy_constructor, (void *) &tmp, sizeof(pval));

View file

@ -153,7 +153,6 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
struct tm *ta; struct tm *ta;
int i, size = 0, length, h; int i, size = 0, length, h;
char tmp_buff[16]; char tmp_buff[16];
TLS_VARS;
switch(ARG_COUNT(ht)) { switch(ARG_COUNT(ht)) {
case 1: case 1:
@ -423,7 +422,6 @@ void php3_checkdate(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *month, *day, *year; pval *month, *day, *year;
int m, d, y; int m, d, y;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || if (ARG_COUNT(ht) != 3 ||
getParameters(ht, 3, &month, &day, &year) == FAILURE) { getParameters(ht, 3, &month, &day, &year) == FAILURE) {

View file

@ -73,9 +73,7 @@ php3_module_entry php3_dir_module_entry = {
int php3_minit_dir(INIT_FUNC_ARGS) int php3_minit_dir(INIT_FUNC_ARGS)
{ {
TLS_VARS; le_dirp = register_list_destructors(closedir,NULL);
GLOBAL(le_dirp) = register_list_destructors(closedir,NULL);
return SUCCESS; return SUCCESS;
} }
@ -86,7 +84,6 @@ void php3_opendir(INTERNAL_FUNCTION_PARAMETERS)
pval *arg; pval *arg;
DIR *dirp; DIR *dirp;
int ret; int ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -101,8 +98,8 @@ void php3_opendir(INTERNAL_FUNCTION_PARAMETERS)
php3_error(E_WARNING, "OpenDir: %s (errno %d)", strerror(errno),errno); php3_error(E_WARNING, "OpenDir: %s (errno %d)", strerror(errno),errno);
RETURN_FALSE; RETURN_FALSE;
} }
ret = php3_list_insert(dirp, GLOBAL(le_dirp)); ret = php3_list_insert(dirp, le_dirp);
GLOBAL(dirp_id) = ret; dirp_id = ret;
RETURN_LONG(ret); RETURN_LONG(ret);
} }
/* }}} */ /* }}} */
@ -115,7 +112,6 @@ void php3_closedir(INTERNAL_FUNCTION_PARAMETERS)
int id_to_find; int id_to_find;
DIR *dirp; DIR *dirp;
int dirp_type; int dirp_type;
TLS_VARS;
if (ARG_COUNT(ht) == 0) { if (ARG_COUNT(ht) == 0) {
if (getThis(&id) == SUCCESS) { if (getThis(&id) == SUCCESS) {
@ -125,7 +121,7 @@ void php3_closedir(INTERNAL_FUNCTION_PARAMETERS)
} }
id_to_find = tmp->value.lval; id_to_find = tmp->value.lval;
} else { } else {
id_to_find = GLOBAL(dirp_id); id_to_find = dirp_id;
} }
} else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) { } else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -135,7 +131,7 @@ void php3_closedir(INTERNAL_FUNCTION_PARAMETERS)
} }
dirp = (DIR *)php3_list_find(id_to_find, &dirp_type); dirp = (DIR *)php3_list_find(id_to_find, &dirp_type);
if (!dirp || dirp_type != GLOBAL(le_dirp)) { if (!dirp || dirp_type != le_dirp) {
php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find); php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
RETURN_FALSE; RETURN_FALSE;
} }
@ -149,7 +145,6 @@ void php3_chdir(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
int ret; int ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -173,7 +168,6 @@ void php3_rewinddir(INTERNAL_FUNCTION_PARAMETERS)
int id_to_find; int id_to_find;
DIR *dirp; DIR *dirp;
int dirp_type; int dirp_type;
TLS_VARS;
if (ARG_COUNT(ht) == 0) { if (ARG_COUNT(ht) == 0) {
if (getThis(&id) == SUCCESS) { if (getThis(&id) == SUCCESS) {
@ -183,7 +177,7 @@ void php3_rewinddir(INTERNAL_FUNCTION_PARAMETERS)
} }
id_to_find = tmp->value.lval; id_to_find = tmp->value.lval;
} else { } else {
id_to_find = GLOBAL(dirp_id); id_to_find = dirp_id;
} }
} else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) { } else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -193,7 +187,7 @@ void php3_rewinddir(INTERNAL_FUNCTION_PARAMETERS)
} }
dirp = (DIR *)php3_list_find(id_to_find, &dirp_type); dirp = (DIR *)php3_list_find(id_to_find, &dirp_type);
if (!dirp || dirp_type != GLOBAL(le_dirp)) { if (!dirp || dirp_type != le_dirp) {
php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find); php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
RETURN_FALSE; RETURN_FALSE;
} }
@ -210,7 +204,6 @@ void php3_readdir(INTERNAL_FUNCTION_PARAMETERS)
DIR *dirp; DIR *dirp;
int dirp_type; int dirp_type;
struct dirent *direntp; struct dirent *direntp;
TLS_VARS;
if (ARG_COUNT(ht) == 0) { if (ARG_COUNT(ht) == 0) {
if (getThis(&id) == SUCCESS) { if (getThis(&id) == SUCCESS) {
@ -220,7 +213,7 @@ void php3_readdir(INTERNAL_FUNCTION_PARAMETERS)
} }
id_to_find = tmp->value.lval; id_to_find = tmp->value.lval;
} else { } else {
id_to_find = GLOBAL(dirp_id); id_to_find = dirp_id;
} }
} else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) { } else if ((ARG_COUNT(ht) != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -230,7 +223,7 @@ void php3_readdir(INTERNAL_FUNCTION_PARAMETERS)
} }
dirp = (DIR *)php3_list_find(id_to_find, &dirp_type); dirp = (DIR *)php3_list_find(id_to_find, &dirp_type);
if (!dirp || dirp_type != GLOBAL(le_dirp)) { if (!dirp || dirp_type != le_dirp) {
php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find); php3_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
RETURN_FALSE; RETURN_FALSE;
} }
@ -248,7 +241,6 @@ void php3_getdir(INTERNAL_FUNCTION_PARAMETERS) {
pval *arg; pval *arg;
DIR *dirp; DIR *dirp;
int ret; int ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -263,8 +255,8 @@ void php3_getdir(INTERNAL_FUNCTION_PARAMETERS) {
php3_error(E_WARNING, "OpenDir: %s (errno %d)", strerror(errno), errno); php3_error(E_WARNING, "OpenDir: %s (errno %d)", strerror(errno), errno);
RETURN_FALSE; RETURN_FALSE;
} }
ret = php3_list_insert(dirp, GLOBAL(le_dirp)); ret = php3_list_insert(dirp, le_dirp);
GLOBAL(dirp_id) = ret; dirp_id = ret;
/* construct an object with some methods */ /* construct an object with some methods */
object_init(return_value); object_init(return_value);

View file

@ -149,7 +149,7 @@ void php3_dl(pval *file,int type,pval *return_value)
} }
/* update the .request_started property... */ /* update the .request_started property... */
if (_php3_hash_find(&GLOBAL(module_registry),module_entry->name,strlen(module_entry->name)+1,(void **) &tmp)==FAILURE) { if (_php3_hash_find(&module_registry,module_entry->name,strlen(module_entry->name)+1,(void **) &tmp)==FAILURE) {
php3_error(E_ERROR,"%s: Loaded module got lost",module_entry->name); php3_error(E_ERROR,"%s: Loaded module got lost",module_entry->name);
RETURN_FALSE; RETURN_FALSE;
} }
@ -159,8 +159,9 @@ void php3_dl(pval *file,int type,pval *return_value)
RETURN_TRUE; RETURN_TRUE;
} }
void php3_info_dl(void){
TLS_VARS; void php3_info_dl(void)
{
PUTS("Dynamic Library support enabled.\n"); PUTS("Dynamic Library support enabled.\n");
} }

View file

@ -68,7 +68,6 @@ char *_php3_gethostbyname(char *name);
void php3_gethostbyaddr(INTERNAL_FUNCTION_PARAMETERS) void php3_gethostbyaddr(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -108,7 +107,6 @@ char *_php3_gethostbyaddr(char *ip)
void php3_gethostbyname(INTERNAL_FUNCTION_PARAMETERS) void php3_gethostbyname(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -129,7 +127,6 @@ void php3_gethostbynamel(INTERNAL_FUNCTION_PARAMETERS)
struct hostent *hp; struct hostent *hp;
struct in_addr in; struct in_addr in;
int i; int i;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -185,7 +182,6 @@ void php3_checkdnsrr(INTERNAL_FUNCTION_PARAMETERS)
#define MAXPACKET 8192 /* max packet size used internally by BIND */ #define MAXPACKET 8192 /* max packet size used internally by BIND */
#endif #endif
u_char ans[MAXPACKET]; u_char ans[MAXPACKET];
TLS_VARS;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 1: case 1:
@ -270,7 +266,7 @@ void php3_getmxrr(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE; RETURN_FALSE;
} }
need_weight = 1; need_weight = 1;
pval_destructor(weight_list _INLINE_TLS); /* start with clean array */ pval_destructor(weight_list); /* start with clean array */
if ( array_init(weight_list) == FAILURE ) { if ( array_init(weight_list) == FAILURE ) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -280,7 +276,7 @@ void php3_getmxrr(INTERNAL_FUNCTION_PARAMETERS)
} }
convert_to_string( host ); convert_to_string( host );
pval_destructor(mx_list _INLINE_TLS); /* start with clean array */ pval_destructor(mx_list); /* start with clean array */
if ( array_init(mx_list) == FAILURE ) { if ( array_init(mx_list) == FAILURE ) {
RETURN_FALSE; RETURN_FALSE;
} }

View file

@ -111,7 +111,7 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
buf[0] = '\0'; buf[0] = '\0';
if (type==2) { if (type==2) {
if (array->type != IS_ARRAY) { if (array->type != IS_ARRAY) {
pval_destructor(array _INLINE_TLS); pval_destructor(array);
array_init(array); array_init(array);
} }
} }
@ -121,9 +121,9 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
if (output) PUTS(buf); if (output) PUTS(buf);
#if APACHE #if APACHE
# if MODULE_MAGIC_NUMBER > 19970110 # if MODULE_MAGIC_NUMBER > 19970110
if (output) rflush(GLOBAL(php3_rqst)); if (output) rflush(php3_rqst);
# else # else
if (output) bflush(GLOBAL(php3_rqst)->connection->client); if (output) bflush(php3_rqst->connection->client);
# endif # endif
#endif #endif
#if CGI_BINARY #if CGI_BINARY
@ -133,7 +133,7 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
/* fhttpd doesn't flush */ /* fhttpd doesn't flush */
#endif #endif
#if USE_SAPI #if USE_SAPI
GLOBAL(sapi_rqst)->flush(GLOBAL(sapi_rqst)->scid); sapi_rqst->flush(sapi_rqst->scid);
#endif #endif
} }
else if (type == 2) { else if (type == 2) {
@ -321,7 +321,6 @@ void php3_escapeshellcmd(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg1; pval *arg1;
char *cmd; char *cmd;
TLS_VARS;
if (getParameters(ht, 1, &arg1) == FAILURE) { if (getParameters(ht, 1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -222,7 +222,6 @@ PHP_FUNCTION(flock)
int issock=0; int issock=0;
int *sock, fd=0; int *sock, fd=0;
int act = 0; int act = 0;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -232,13 +231,13 @@ PHP_FUNCTION(flock)
convert_to_long(arg2); convert_to_long(arg2);
fp = php3_list_find(arg1->value.lval, &type); fp = php3_list_find(arg1->value.lval, &type);
if (type == GLOBAL(wsa_fp)){ if (type == wsa_fp){
issock = 1; issock = 1;
sock = php3_list_find(arg1->value.lval, &type); sock = php3_list_find(arg1->value.lval, &type);
fd = *sock; fd = *sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!fd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!fd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",arg1->value.lval); php3_error(E_WARNING,"Unable to find file identifier %d",arg1->value.lval);
RETURN_FALSE; RETURN_FALSE;
} }
@ -467,7 +466,7 @@ void php3_file(INTERNAL_FUNCTION_PARAMETERS)
static void __pclose(FILE *pipe) static void __pclose(FILE *pipe)
{ {
GLOBAL(pclose_ret) = pclose(pipe); pclose_ret = pclose(pipe);
} }
@ -497,10 +496,10 @@ static void _php3_unlink_uploaded_file(char *file)
int php3_minit_file(INIT_FUNC_ARGS) int php3_minit_file(INIT_FUNC_ARGS)
{ {
GLOBAL(le_fp) = register_list_destructors(fclose,NULL); le_fp = register_list_destructors(fclose,NULL);
GLOBAL(le_pp) = register_list_destructors(__pclose,NULL); le_pp = register_list_destructors(__pclose,NULL);
GLOBAL(wsa_fp) = register_list_destructors(_php3_closesocket,NULL); wsa_fp = register_list_destructors(_php3_closesocket,NULL);
GLOBAL(le_uploads) = register_list_destructors(_php3_unlink_uploaded_file,NULL); le_uploads = register_list_destructors(_php3_unlink_uploaded_file,NULL);
return SUCCESS; return SUCCESS;
} }
@ -575,13 +574,13 @@ void php3_fopen(INTERNAL_FUNCTION_PARAMETERS)
efree(p); efree(p);
RETURN_FALSE; RETURN_FALSE;
} }
GLOBAL(fgetss_state)=0; fgetss_state=0;
if (issock) { if (issock) {
sock=emalloc(sizeof(int)); sock=emalloc(sizeof(int));
*sock=socketd; *sock=socketd;
id = php3_list_insert(sock,GLOBAL(wsa_fp)); id = php3_list_insert(sock,wsa_fp);
} else { } else {
id = php3_list_insert(fp,GLOBAL(le_fp)); id = php3_list_insert(fp,le_fp);
} }
efree(p); efree(p);
RETURN_LONG(id); RETURN_LONG(id);
@ -603,7 +602,7 @@ void php3_fclose(INTERNAL_FUNCTION_PARAMETERS)
convert_to_long(arg1); convert_to_long(arg1);
id=arg1->value.lval; id=arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(wsa_fp))) { if (!fp || (type!=le_fp && type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -662,7 +661,7 @@ void php3_popen(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE; RETURN_FALSE;
} }
} }
id = php3_list_insert(fp,GLOBAL(le_pp)); id = php3_list_insert(fp,le_pp);
efree(p); efree(p);
RETURN_LONG(id); RETURN_LONG(id);
} }
@ -684,12 +683,12 @@ void php3_pclose(INTERNAL_FUNCTION_PARAMETERS)
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (!fp || type!=GLOBAL(le_pp)) { if (!fp || type!=le_pp) {
php3_error(E_WARNING,"Unable to find pipe identifier %d",id); php3_error(E_WARNING,"Unable to find pipe identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
php3_list_delete(id); php3_list_delete(id);
RETURN_LONG(GLOBAL(pclose_ret)); RETURN_LONG(pclose_ret);
} }
/* }}} */ /* }}} */
@ -711,12 +710,12 @@ void php3_feof(INTERNAL_FUNCTION_PARAMETERS)
convert_to_long(arg1); convert_to_long(arg1);
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd=*sock; socketd=*sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
/* we're at the eof if the file doesn't exist */ /* we're at the eof if the file doesn't exist */
RETURN_TRUE; RETURN_TRUE;
@ -748,7 +747,7 @@ void php3_set_socket_blocking(INTERNAL_FUNCTION_PARAMETERS)
block = arg2->value.lval; block = arg2->value.lval;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
if (type!=GLOBAL(wsa_fp)) { if (type!=wsa_fp) {
php3_error(E_WARNING,"%d is not a socket id",id); php3_error(E_WARNING,"%d is not a socket id",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -807,7 +806,7 @@ void php3_set_socket_timeout(INTERNAL_FUNCTION_PARAMETERS)
convert_to_long(timeout); convert_to_long(timeout);
sock = php3_list_find(socket->value.lval, &type); sock = php3_list_find(socket->value.lval, &type);
if (type!=GLOBAL(wsa_fp)) { if (type!=wsa_fp) {
php3_error(E_WARNING,"%d is not a socket id",socket->value.lval); php3_error(E_WARNING,"%d is not a socket id",socket->value.lval);
RETURN_FALSE; RETURN_FALSE;
} }
@ -841,12 +840,12 @@ void php3_fgets(INTERNAL_FUNCTION_PARAMETERS)
len = arg2->value.lval; len = arg2->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd=*sock; socketd=*sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -887,12 +886,12 @@ void php3_fgetc(INTERNAL_FUNCTION_PARAMETERS) {
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd = *sock; socketd = *sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -934,12 +933,12 @@ void php3_fgetss(INTERNAL_FUNCTION_PARAMETERS)
len = bytes->value.lval; len = bytes->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd=*sock; socketd=*sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING, "Unable to find file identifier %d", id); php3_error(E_WARNING, "Unable to find file identifier %d", id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -962,67 +961,67 @@ void php3_fgetss(INTERNAL_FUNCTION_PARAMETERS)
while (c) { while (c) {
switch (c) { switch (c) {
case '<': case '<':
if (GLOBAL(fgetss_state) == 0) { if (fgetss_state == 0) {
lc = '<'; lc = '<';
GLOBAL(fgetss_state) = 1; fgetss_state = 1;
} }
break; break;
case '(': case '(':
if (GLOBAL(fgetss_state) == 2) { if (fgetss_state == 2) {
if (lc != '\"') { if (lc != '\"') {
lc = '('; lc = '(';
br++; br++;
} }
} else if (GLOBAL(fgetss_state) == 0) { } else if (fgetss_state == 0) {
*(rp++) = c; *(rp++) = c;
} }
break; break;
case ')': case ')':
if (GLOBAL(fgetss_state) == 2) { if (fgetss_state == 2) {
if (lc != '\"') { if (lc != '\"') {
lc = ')'; lc = ')';
br--; br--;
} }
} else if (GLOBAL(fgetss_state) == 0) { } else if (fgetss_state == 0) {
*(rp++) = c; *(rp++) = c;
} }
break; break;
case '>': case '>':
if (GLOBAL(fgetss_state) == 1) { if (fgetss_state == 1) {
lc = '>'; lc = '>';
GLOBAL(fgetss_state) = 0; fgetss_state = 0;
} else if (GLOBAL(fgetss_state) == 2) { } else if (fgetss_state == 2) {
if (!br && lc != '\"') { if (!br && lc != '\"') {
GLOBAL(fgetss_state) = 0; fgetss_state = 0;
} }
} }
break; break;
case '\"': case '\"':
if (GLOBAL(fgetss_state) == 2) { if (fgetss_state == 2) {
if (lc == '\"') { if (lc == '\"') {
lc = '\0'; lc = '\0';
} else if (lc != '\\') { } else if (lc != '\\') {
lc = '\"'; lc = '\"';
} }
} else if (GLOBAL(fgetss_state) == 0) { } else if (fgetss_state == 0) {
*(rp++) = c; *(rp++) = c;
} }
break; break;
case '?': case '?':
if (GLOBAL(fgetss_state)==1) { if (fgetss_state==1) {
br=0; br=0;
GLOBAL(fgetss_state)=2; fgetss_state=2;
break; break;
} }
/* fall-through */ /* fall-through */
default: default:
if (GLOBAL(fgetss_state) == 0) { if (fgetss_state == 0) {
*(rp++) = c; *(rp++) = c;
} }
} }
@ -1073,12 +1072,12 @@ void php3_fwrite(INTERNAL_FUNCTION_PARAMETERS)
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd=*sock; socketd=*sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1112,7 +1111,7 @@ void php3_rewind(INTERNAL_FUNCTION_PARAMETERS)
convert_to_long(arg1); convert_to_long(arg1);
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) { if (!fp || (type!=le_fp && type!=le_pp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1137,7 +1136,7 @@ void php3_ftell(INTERNAL_FUNCTION_PARAMETERS)
convert_to_long(arg1); convert_to_long(arg1);
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) { if (!fp || (type!=le_fp && type!=le_pp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1164,7 +1163,7 @@ void php3_fseek(INTERNAL_FUNCTION_PARAMETERS)
pos = arg2->value.lval; pos = arg2->value.lval;
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) { if (!fp || (type!=le_fp && type!=le_pp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1342,12 +1341,12 @@ void php3_fpassthru(INTERNAL_FUNCTION_PARAMETERS)
convert_to_long(arg1); convert_to_long(arg1);
id = arg1->value.lval; id = arg1->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd=*sock; socketd=*sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1485,12 +1484,12 @@ void php3_fread(INTERNAL_FUNCTION_PARAMETERS)
len = arg2->value.lval; len = arg2->value.lval;
fp = php3_list_find(id,&type); fp = php3_list_find(id,&type);
if (type==GLOBAL(wsa_fp)){ if (type==wsa_fp){
issock=1; issock=1;
sock = php3_list_find(id,&type); sock = php3_list_find(id,&type);
socketd=*sock; socketd=*sock;
} }
if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
php3_error(E_WARNING,"Unable to find file identifier %d",id); php3_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1514,7 +1513,7 @@ void php3_fread(INTERNAL_FUNCTION_PARAMETERS)
/* aparently needed for pdf to be compiled as a module under windows */ /* aparently needed for pdf to be compiled as a module under windows */
PHPAPI int php3i_get_le_fp(void) PHPAPI int php3i_get_le_fp(void)
{ {
return GLOBAL(le_fp); return le_fp;
} }
/* /*

View file

@ -97,16 +97,16 @@ static struct stat lsb;
int php3_init_filestat(INIT_FUNC_ARGS) int php3_init_filestat(INIT_FUNC_ARGS)
{ {
GLOBAL(CurrentStatFile)=NULL; CurrentStatFile=NULL;
GLOBAL(CurrentStatLength)=0; CurrentStatLength=0;
return SUCCESS; return SUCCESS;
} }
int php3_shutdown_filestat(SHUTDOWN_FUNC_ARGS) int php3_shutdown_filestat(SHUTDOWN_FUNC_ARGS)
{ {
if (GLOBAL(CurrentStatFile)) { if (CurrentStatFile) {
efree (GLOBAL(CurrentStatFile)); efree (CurrentStatFile);
} }
return SUCCESS; return SUCCESS;
} }
@ -294,35 +294,35 @@ void php3_touch(INTERNAL_FUNCTION_PARAMETERS)
void php3_clearstatcache(INTERNAL_FUNCTION_PARAMETERS) void php3_clearstatcache(INTERNAL_FUNCTION_PARAMETERS)
{ {
if (GLOBAL(CurrentStatFile)) { if (CurrentStatFile) {
efree(GLOBAL(CurrentStatFile)); efree(CurrentStatFile);
GLOBAL(CurrentStatFile) = NULL; CurrentStatFile = NULL;
} }
} }
static void _php3_stat(const char *filename, int type, pval *return_value) static void _php3_stat(const char *filename, int type, pval *return_value)
{ {
struct stat *stat_sb = &GLOBAL(sb); struct stat *stat_sb = &sb;
if (!GLOBAL(CurrentStatFile) || strcmp(filename,GLOBAL(CurrentStatFile))) { if (!CurrentStatFile || strcmp(filename,CurrentStatFile)) {
if (!GLOBAL(CurrentStatFile) if (!CurrentStatFile
|| strlen(filename) > GLOBAL(CurrentStatLength)) { || strlen(filename) > CurrentStatLength) {
if (GLOBAL(CurrentStatFile)) efree(GLOBAL(CurrentStatFile)); if (CurrentStatFile) efree(CurrentStatFile);
GLOBAL(CurrentStatLength) = strlen(filename); CurrentStatLength = strlen(filename);
GLOBAL(CurrentStatFile) = estrndup(filename,GLOBAL(CurrentStatLength)); CurrentStatFile = estrndup(filename,CurrentStatLength);
} else { } else {
strcpy(GLOBAL(CurrentStatFile),filename); strcpy(CurrentStatFile,filename);
} }
#if HAVE_SYMLINK #if HAVE_SYMLINK
GLOBAL(lsb).st_mode = 0; /* mark lstat buf invalid */ lsb.st_mode = 0; /* mark lstat buf invalid */
#endif #endif
if (stat(GLOBAL(CurrentStatFile),&GLOBAL(sb))==-1) { if (stat(CurrentStatFile,&sb)==-1) {
if (type != 15 || errno != ENOENT) { /* fileexists() test must print no error */ if (type != 15 || errno != ENOENT) { /* fileexists() test must print no error */
php3_error(E_NOTICE,"stat failed for %s (errno=%d - %s)",GLOBAL(CurrentStatFile),errno,strerror(errno)); php3_error(E_NOTICE,"stat failed for %s (errno=%d - %s)",CurrentStatFile,errno,strerror(errno));
} }
efree(GLOBAL(CurrentStatFile)); efree(CurrentStatFile);
GLOBAL(CurrentStatFile)=NULL; CurrentStatFile=NULL;
RETURN_FALSE; RETURN_FALSE;
} }
} }
@ -334,9 +334,9 @@ static void _php3_stat(const char *filename, int type, pval *return_value)
/* do lstat if the buffer is empty */ /* do lstat if the buffer is empty */
if (!GLOBAL(lsb).st_mode) { if (!lsb.st_mode) {
if (lstat(GLOBAL(CurrentStatFile),&GLOBAL(lsb)) == -1) { if (lstat(CurrentStatFile,&lsb) == -1) {
php3_error(E_NOTICE,"lstat failed for %s (errno=%d - %s)",GLOBAL(CurrentStatFile),errno,strerror(errno)); php3_error(E_NOTICE,"lstat failed for %s (errno=%d - %s)",CurrentStatFile,errno,strerror(errno));
RETURN_FALSE; RETURN_FALSE;
} }
} }
@ -345,49 +345,49 @@ static void _php3_stat(const char *filename, int type, pval *return_value)
switch(type) { switch(type) {
case 0: /* fileperms */ case 0: /* fileperms */
RETURN_LONG((long)GLOBAL(sb).st_mode); RETURN_LONG((long)sb.st_mode);
case 1: /* fileinode */ case 1: /* fileinode */
RETURN_LONG((long)GLOBAL(sb).st_ino); RETURN_LONG((long)sb.st_ino);
case 2: /* filesize */ case 2: /* filesize */
RETURN_LONG((long)GLOBAL(sb).st_size); RETURN_LONG((long)sb.st_size);
case 3: /* fileowner */ case 3: /* fileowner */
RETURN_LONG((long)GLOBAL(sb).st_uid); RETURN_LONG((long)sb.st_uid);
case 4: /* filegroup */ case 4: /* filegroup */
RETURN_LONG((long)GLOBAL(sb).st_gid); RETURN_LONG((long)sb.st_gid);
case 5: /* fileatime */ case 5: /* fileatime */
RETURN_LONG((long)GLOBAL(sb).st_atime); RETURN_LONG((long)sb.st_atime);
case 6: /* filemtime */ case 6: /* filemtime */
RETURN_LONG((long)GLOBAL(sb).st_mtime); RETURN_LONG((long)sb.st_mtime);
case 7: /* filectime */ case 7: /* filectime */
RETURN_LONG((long)GLOBAL(sb).st_ctime); RETURN_LONG((long)sb.st_ctime);
case 8: /* filetype */ case 8: /* filetype */
#if HAVE_SYMLINK #if HAVE_SYMLINK
if (S_ISLNK(GLOBAL(lsb).st_mode)) { if (S_ISLNK(lsb.st_mode)) {
RETURN_STRING("link",1); RETURN_STRING("link",1);
} }
#endif #endif
switch(GLOBAL(sb).st_mode&S_IFMT) { switch(sb.st_mode&S_IFMT) {
case S_IFIFO: RETURN_STRING("fifo",1); case S_IFIFO: RETURN_STRING("fifo",1);
case S_IFCHR: RETURN_STRING("char",1); case S_IFCHR: RETURN_STRING("char",1);
case S_IFDIR: RETURN_STRING("dir",1); case S_IFDIR: RETURN_STRING("dir",1);
case S_IFBLK: RETURN_STRING("block",1); case S_IFBLK: RETURN_STRING("block",1);
case S_IFREG: RETURN_STRING("file",1); case S_IFREG: RETURN_STRING("file",1);
} }
php3_error(E_WARNING,"Unknown file type (%d)",GLOBAL(sb).st_mode&S_IFMT); php3_error(E_WARNING,"Unknown file type (%d)",sb.st_mode&S_IFMT);
RETURN_STRING("unknown",1); RETURN_STRING("unknown",1);
case 9: /*is writable*/ case 9: /*is writable*/
RETURN_LONG((GLOBAL(sb).st_mode&S_IWRITE)!=0); RETURN_LONG((sb.st_mode&S_IWRITE)!=0);
case 10: /*is readable*/ case 10: /*is readable*/
RETURN_LONG((GLOBAL(sb).st_mode&S_IREAD)!=0); RETURN_LONG((sb.st_mode&S_IREAD)!=0);
case 11: /*is executable*/ case 11: /*is executable*/
RETURN_LONG((GLOBAL(sb).st_mode&S_IEXEC)!=0 && !S_ISDIR(GLOBAL(sb).st_mode)); RETURN_LONG((sb.st_mode&S_IEXEC)!=0 && !S_ISDIR(sb.st_mode));
case 12: /*is file*/ case 12: /*is file*/
RETURN_LONG(S_ISREG(GLOBAL(sb).st_mode)); RETURN_LONG(S_ISREG(sb.st_mode));
case 13: /*is dir*/ case 13: /*is dir*/
RETURN_LONG(S_ISDIR(GLOBAL(sb).st_mode)); RETURN_LONG(S_ISDIR(sb.st_mode));
case 14: /*is link*/ case 14: /*is link*/
#if HAVE_SYMLINK #if HAVE_SYMLINK
RETURN_LONG(S_ISLNK(GLOBAL(lsb).st_mode)); RETURN_LONG(S_ISLNK(lsb.st_mode));
#else #else
RETURN_FALSE; RETURN_FALSE;
#endif #endif
@ -395,7 +395,7 @@ static void _php3_stat(const char *filename, int type, pval *return_value)
RETURN_TRUE; /* the false case was done earlier */ RETURN_TRUE; /* the false case was done earlier */
case 16: /* lstat */ case 16: /* lstat */
#if HAVE_SYMLINK #if HAVE_SYMLINK
stat_sb = &GLOBAL(lsb); stat_sb = &lsb;
#endif #endif
/* FALLTHROUGH */ /* FALLTHROUGH */
case 17: /* stat */ case 17: /* stat */

View file

@ -79,30 +79,29 @@ _php3_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
#ifndef THREAD_SAFE #ifndef THREAD_SAFE
static char cvt_buf[NDIG]; static char cvt_buf[NDIG];
#endif #endif
TLS_VARS;
if (ndigits >= NDIG - 1) if (ndigits >= NDIG - 1)
ndigits = NDIG - 2; ndigits = NDIG - 2;
r2 = 0; r2 = 0;
*sign = 0; *sign = 0;
p = &STATIC(cvt_buf)[0]; p = &cvt_buf[0];
if (arg < 0) { if (arg < 0) {
*sign = 1; *sign = 1;
arg = -arg; arg = -arg;
} }
arg = modf(arg, &fi); arg = modf(arg, &fi);
p1 = &STATIC(cvt_buf)[NDIG]; p1 = &cvt_buf[NDIG];
/* /*
* Do integer part * Do integer part
*/ */
if (fi != 0) { if (fi != 0) {
p1 = &STATIC(cvt_buf)[NDIG]; p1 = &cvt_buf[NDIG];
while (fi != 0) { while (fi != 0) {
fj = modf(fi / 10, &fi); fj = modf(fi / 10, &fi);
*--p1 = (int) ((fj + .03) * 10) + '0'; *--p1 = (int) ((fj + .03) * 10) + '0';
r2++; r2++;
} }
while (p1 < &STATIC(cvt_buf)[NDIG]) while (p1 < &cvt_buf[NDIG])
*p++ = *p1++; *p++ = *p1++;
} else if (arg > 0) { } else if (arg > 0) {
while ((fj = arg * 10) < 1) { while ((fj = arg * 10) < 1) {
@ -110,41 +109,41 @@ _php3_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag)
r2--; r2--;
} }
} }
p1 = &STATIC(cvt_buf)[ndigits]; p1 = &cvt_buf[ndigits];
if (eflag == 0) if (eflag == 0)
p1 += r2; p1 += r2;
*decpt = r2; *decpt = r2;
if (p1 < &STATIC(cvt_buf)[0]) { if (p1 < &cvt_buf[0]) {
STATIC(cvt_buf)[0] = '\0'; cvt_buf[0] = '\0';
return (STATIC(cvt_buf)); return (cvt_buf);
} }
while (p <= p1 && p < &STATIC(cvt_buf)[NDIG]) { while (p <= p1 && p < &cvt_buf[NDIG]) {
arg *= 10; arg *= 10;
arg = modf(arg, &fj); arg = modf(arg, &fj);
*p++ = (int) fj + '0'; *p++ = (int) fj + '0';
} }
if (p1 >= &STATIC(cvt_buf)[NDIG]) { if (p1 >= &cvt_buf[NDIG]) {
STATIC(cvt_buf)[NDIG - 1] = '\0'; cvt_buf[NDIG - 1] = '\0';
return (STATIC(cvt_buf)); return (cvt_buf);
} }
p = p1; p = p1;
*p1 += 5; *p1 += 5;
while (*p1 > '9') { while (*p1 > '9') {
*p1 = '0'; *p1 = '0';
if (p1 > STATIC(cvt_buf)) if (p1 > cvt_buf)
++ * --p1; ++ * --p1;
else { else {
*p1 = '1'; *p1 = '1';
(*decpt)++; (*decpt)++;
if (eflag == 0) { if (eflag == 0) {
if (p > STATIC(cvt_buf)) if (p > cvt_buf)
*p = '0'; *p = '0';
p++; p++;
} }
} }
} }
*p = '\0'; *p = '\0';
return (STATIC(cvt_buf)); return (cvt_buf);
} }
@ -567,7 +566,6 @@ PHP_FUNCTION(user_sprintf)
{ {
char *result; char *result;
int len; int len;
TLS_VARS;
if ((result=php3_formatted_print(ht,&len))==NULL) { if ((result=php3_formatted_print(ht,&len))==NULL) {
RETURN_FALSE; RETURN_FALSE;
@ -581,7 +579,6 @@ PHP_FUNCTION(user_printf)
{ {
char *result; char *result;
int len; int len;
TLS_VARS;
if ((result=php3_formatted_print(ht,&len))==NULL) { if ((result=php3_formatted_print(ht,&len))==NULL) {
RETURN_FALSE; RETURN_FALSE;

View file

@ -154,7 +154,6 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) {
int socketd = -1; int socketd = -1;
unsigned short portno; unsigned short portno;
char *key = NULL; char *key = NULL;
TLS_VARS;
if (arg_count > 4 || arg_count < 2 || getParametersArray(ht,arg_count,args)==FAILURE) { if (arg_count > 4 || arg_count < 2 || getParametersArray(ht,arg_count,args)==FAILURE) {
FREE_SOCK; FREE_SOCK;
@ -189,7 +188,7 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) {
(void *) &sockp) == SUCCESS) { (void *) &sockp) == SUCCESS) {
efree(key); efree(key);
*sock = *sockp; *sock = *sockp;
RETURN_LONG(php3_list_insert(sock, GLOBAL(wsa_fp))); RETURN_LONG(php3_list_insert(sock, wsa_fp));
} }
if (portno) { if (portno) {
@ -266,7 +265,7 @@ static void _php3_fsockopen(INTERNAL_FUNCTION_PARAMETERS, int persistent) {
key, strlen(key) + 1, NULL); key, strlen(key) + 1, NULL);
} }
if(key) efree(key); if(key) efree(key);
id = php3_list_insert(sock,GLOBAL(wsa_fp)); id = php3_list_insert(sock,wsa_fp);
RETURN_LONG(id); RETURN_LONG(id);
} }
/* }}} */ /* }}} */

View file

@ -58,21 +58,19 @@ CookieList *php3_PopCookieList(void);
int php3_init_head(INIT_FUNC_ARGS) int php3_init_head(INIT_FUNC_ARGS)
{ {
TLS_VARS; php3_HeaderPrinted = 0;
GLOBAL(php3_HeaderPrinted) = 0; if (header_called == 0)
if (GLOBAL(header_called) == 0) php3_PrintHeader = 1;
GLOBAL(php3_PrintHeader) = 1; top = NULL;
GLOBAL(top) = NULL; cont_type = NULL;
GLOBAL(cont_type) = NULL;
return SUCCESS; return SUCCESS;
} }
void php3_noheader(void) void php3_noheader(void)
{ {
TLS_VARS; php3_PrintHeader = 0;
GLOBAL(php3_PrintHeader) = 0; header_called = 1;
GLOBAL(header_called) = 1;
} }
@ -87,7 +85,7 @@ void php4i_add_header_information(char *header_information)
char temp2[32]; char temp2[32];
#endif #endif
if (GLOBAL(php3_HeaderPrinted) == 1) { if (php3_HeaderPrinted == 1) {
#if DEBUG #if DEBUG
php3_error(E_WARNING, "Cannot add more header information - the header was already sent " php3_error(E_WARNING, "Cannot add more header information - the header was already sent "
"(header information may be added only before any output is generated from the script - " "(header information may be added only before any output is generated from the script - "
@ -105,10 +103,10 @@ void php4i_add_header_information(char *header_information)
*r = '\0'; *r = '\0';
if (!strcasecmp(header_information, "Content-type")) { if (!strcasecmp(header_information, "Content-type")) {
if (*(r + 1) == ' ') if (*(r + 1) == ' ')
GLOBAL(php3_rqst)->content_type = pstrdup(GLOBAL(php3_rqst)->pool,r + 2); php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 2);
else else
GLOBAL(php3_rqst)->content_type = pstrdup(GLOBAL(php3_rqst)->pool,r + 1); php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 1);
GLOBAL(cont_type) = (char *)GLOBAL(php3_rqst)->content_type; cont_type = (char *)php3_rqst->content_type;
} else { } else {
if (*(r + 1) == ' ') { if (*(r + 1) == ' ') {
rr = r + 2; rr = r + 2;
@ -127,36 +125,36 @@ void php4i_add_header_information(char *header_information)
temp = _php3_regreplace("$", temp2, rr, 0, 0); temp = _php3_regreplace("$", temp2, rr, 0, 0);
} }
} }
table_set(GLOBAL(php3_rqst)->headers_out, header_information, temp); table_set(php3_rqst->headers_out, header_information, temp);
} else } else
table_set(GLOBAL(php3_rqst)->headers_out, header_information, rr); table_set(php3_rqst->headers_out, header_information, rr);
} }
if (!strcasecmp(header_information, "location")) { if (!strcasecmp(header_information, "location")) {
GLOBAL(php3_rqst)->status = REDIRECT; php3_rqst->status = REDIRECT;
} }
*r = ':'; *r = ':';
GLOBAL(php3_HeaderPrinted) = 2; php3_HeaderPrinted = 2;
} }
if (!strncasecmp(header_information, "http/", 5)) { if (!strncasecmp(header_information, "http/", 5)) {
if (strlen(header_information) > 9) { if (strlen(header_information) > 9) {
GLOBAL(php3_rqst)->status = atoi(&((header_information)[9])); php3_rqst->status = atoi(&((header_information)[9]));
} }
/* Use a pstrdup here to get the memory straight from Apache's per-request pool to /* Use a pstrdup here to get the memory straight from Apache's per-request pool to
* avoid having our own memory manager complain about this memory not being freed * avoid having our own memory manager complain about this memory not being freed
* because it really shouldn't be freed until the end of the request and it isn't * because it really shouldn't be freed until the end of the request and it isn't
* easy for us to figure out when we allocated it vs. when something else might have. * easy for us to figure out when we allocated it vs. when something else might have.
*/ */
GLOBAL(php3_rqst)->status_line = pstrdup(GLOBAL(php3_rqst)->pool,&((header_information)[9])); php3_rqst->status_line = pstrdup(php3_rqst->pool,&((header_information)[9]));
} }
#else #else
r = strchr(header_information, ':'); r = strchr(header_information, ':');
if (r) { if (r) {
*r = '\0'; *r = '\0';
if (!strcasecmp(header_information, "Content-type")) { if (!strcasecmp(header_information, "Content-type")) {
if (GLOBAL(cont_type)) efree(GLOBAL(cont_type)); if (cont_type) efree(cont_type);
GLOBAL(cont_type) = estrdup(r + 1); cont_type = estrdup(r + 1);
#if 0 /*WIN32|WINNT / *M$ does us again*/ #if 0 /*WIN32|WINNT / *M$ does us again*/
if (!strcmp(GLOBAL(cont_type)," text/html")){ if (!strcmp(cont_type," text/html")){
*r=':'; *r=':';
PUTS_H(header_information); PUTS_H(header_information);
PUTS_H("\015\012"); PUTS_H("\015\012");
@ -169,7 +167,7 @@ void php4i_add_header_information(char *header_information)
char *tempstr=emalloc(strlen(header_information)+2); char *tempstr=emalloc(strlen(header_information)+2);
sprintf(tempstr,"%s\015\012",tempstr); sprintf(tempstr,"%s\015\012",tempstr);
GLOBAL(sapi_rqst)->header(GLOBAL(sapi_rqst)->scid,tempstr); sapi_rqst->header(sapi_rqst->scid,tempstr);
efree(tempstr); efree(tempstr);
} }
#elif FHTTPD #elif FHTTPD
@ -185,7 +183,7 @@ void php4i_add_header_information(char *header_information)
{ {
char *tempstr=emalloc(strlen(header_information)+2); char *tempstr=emalloc(strlen(header_information)+2);
sprintf(tempstr,"%s\015\012",tempstr); sprintf(tempstr,"%s\015\012",tempstr);
GLOBAL(sapi_rqst)->header(GLOBAL(sapi_rqst)->scid,tempstr); sapi_rqst->header(sapi_rqst->scid,tempstr);
efree(tempstr); efree(tempstr);
} }
#elif FHTTPD #elif FHTTPD
@ -245,11 +243,11 @@ PHPAPI int php3_header(void)
} }
#if APACHE #if APACHE
if (!GLOBAL(php3_rqst)) { /* we're not in a request, allow output */ if (!php3_rqst) { /* we're not in a request, allow output */
PG(header_is_being_sent) = 0; PG(header_is_being_sent) = 0;
return 1; return 1;
} }
if ((GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) || (GLOBAL(php3_PrintHeader) && GLOBAL(php3_HeaderPrinted) == 2)) { if ((php3_PrintHeader && !php3_HeaderPrinted) || (php3_PrintHeader && php3_HeaderPrinted == 2)) {
cookie = php3_PopCookieList(); cookie = php3_PopCookieList();
while (cookie) { while (cookie) {
if (cookie->name) if (cookie->name)
@ -306,7 +304,7 @@ PHPAPI int php3_header(void)
if (cookie->secure) { if (cookie->secure) {
strcat(tempstr, "; secure"); strcat(tempstr, "; secure");
} }
table_add(GLOBAL(php3_rqst)->headers_out, "Set-Cookie", tempstr); table_add(php3_rqst->headers_out, "Set-Cookie", tempstr);
if (cookie->domain) efree(cookie->domain); if (cookie->domain) efree(cookie->domain);
if (cookie->path) efree(cookie->path); if (cookie->path) efree(cookie->path);
if (cookie->name) efree(cookie->name); if (cookie->name) efree(cookie->name);
@ -316,20 +314,20 @@ PHPAPI int php3_header(void)
cookie = php3_PopCookieList(); cookie = php3_PopCookieList();
efree(tempstr); efree(tempstr);
} }
GLOBAL(php3_HeaderPrinted) = 1; php3_HeaderPrinted = 1;
GLOBAL(header_called) = 1; header_called = 1;
send_http_header(GLOBAL(php3_rqst)); send_http_header(php3_rqst);
if (GLOBAL(php3_rqst)->header_only) { if (php3_rqst->header_only) {
set_header_request(1); set_header_request(1);
PG(header_is_being_sent) = 0; PG(header_is_being_sent) = 0;
return(0); return(0);
} }
} }
#else #else
if (GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) { if (php3_PrintHeader && !php3_HeaderPrinted) {
if (!GLOBAL(cont_type)) { if (!cont_type) {
#if USE_SAPI #if USE_SAPI
GLOBAL(sapi_rqst)->header(GLOBAL(sapi_rqst)->scid,"Content-type: text/html\015\012\015\012"); sapi_rqst->header(sapi_rqst->scid,"Content-type: text/html\015\012\015\012");
#elif FHTTPD #elif FHTTPD
php3_fhttpd_puts_header("Content-type: text/html\r\n"); php3_fhttpd_puts_header("Content-type: text/html\r\n");
#else #else
@ -337,30 +335,30 @@ PHPAPI int php3_header(void)
#endif #endif
} else { } else {
#if 0 /*WIN32|WINNT / *M$ does us again*/ #if 0 /*WIN32|WINNT / *M$ does us again*/
if (!strcmp(GLOBAL(cont_type),"text/html")){ if (!strcmp(cont_type,"text/html")){
#endif #endif
#if USE_SAPI #if USE_SAPI
tempstr=emalloc(strlen(GLOBAL(cont_type))+18); tempstr=emalloc(strlen(cont_type)+18);
sprintf(tempstr,"Content-type: %s\015\012\015\012",GLOBAL(cont_type)); sprintf(tempstr,"Content-type: %s\015\012\015\012",cont_type);
GLOBAL(sapi_rqst)->header(GLOBAL(sapi_rqst)->scid,tempstr); sapi_rqst->header(sapi_rqst->scid,tempstr);
efree(tempstr); efree(tempstr);
#elif FHTTPD #elif FHTTPD
tempstr = emalloc(strlen(GLOBAL(cont_type)) tempstr = emalloc(strlen(cont_type)
+ sizeof("Content-type:") + 2); + sizeof("Content-type:") + 2);
if(tempstr) { if(tempstr) {
strcpy(tempstr, "Content-type:"); strcpy(tempstr, "Content-type:");
strcpy(tempstr + sizeof("Content-type:") - 1, strcpy(tempstr + sizeof("Content-type:") - 1,
GLOBAL(cont_type)); cont_type);
strcat(tempstr, "\r\n"); strcat(tempstr, "\r\n");
php3_fhttpd_puts_header(tempstr); php3_fhttpd_puts_header(tempstr);
efree(tempstr); efree(tempstr);
} }
#else #else
PUTS_H("Content-type:"); PUTS_H("Content-type:");
PUTS_H(GLOBAL(cont_type)); PUTS_H(cont_type);
PUTS_H("\015\012\015\012"); PUTS_H("\015\012\015\012");
#endif #endif
efree(GLOBAL(cont_type)); efree(cont_type);
#if 0 /*WIN32|WINNT / *M$ does us again*/ #if 0 /*WIN32|WINNT / *M$ does us again*/
} else { } else {
PUTS_H("\015\012"); PUTS_H("\015\012");
@ -368,12 +366,12 @@ PHPAPI int php3_header(void)
#endif #endif
} }
#if USE_SAPI #if USE_SAPI
GLOBAL(sapi_rqst)->flush(GLOBAL(sapi_rqst)->scid); sapi_rqst->flush(sapi_rqst->scid);
#else #else
fflush(stdout); fflush(stdout);
#endif #endif
GLOBAL(php3_HeaderPrinted) = 1; php3_HeaderPrinted = 1;
GLOBAL(header_called) = 1; header_called = 1;
} }
#endif #endif
PG(header_is_being_sent) = 0; PG(header_is_being_sent) = 0;
@ -383,27 +381,25 @@ PHPAPI int php3_header(void)
void php3_PushCookieList(char *name, char *value, time_t expires, char *path, char *domain, int secure) void php3_PushCookieList(char *name, char *value, time_t expires, char *path, char *domain, int secure)
{ {
CookieList *new; CookieList *new;
TLS_VARS;
new = emalloc(sizeof(CookieList)); new = emalloc(sizeof(CookieList));
new->next = GLOBAL(top); new->next = top;
new->name = name; new->name = name;
new->value = value; new->value = value;
new->expires = expires; new->expires = expires;
new->path = path; new->path = path;
new->domain = domain; new->domain = domain;
new->secure = secure; new->secure = secure;
GLOBAL(top) = new; top = new;
} }
CookieList *php3_PopCookieList(void) CookieList *php3_PopCookieList(void)
{ {
CookieList *ret; CookieList *ret;
TLS_VARS;
ret = GLOBAL(top); ret = top;
if (GLOBAL(top)) if (top)
GLOBAL(top) = GLOBAL(top)->next; top = top->next;
return (ret); return (ret);
} }
@ -424,13 +420,12 @@ void php3_SetCookie(INTERNAL_FUNCTION_PARAMETERS)
int secure = 0; int secure = 0;
pval *arg[6]; pval *arg[6];
int arg_count; int arg_count;
TLS_VARS;
arg_count = ARG_COUNT(ht); arg_count = ARG_COUNT(ht);
if (arg_count < 1 || arg_count > 6 || getParametersArray(ht, arg_count, arg) == FAILURE) { if (arg_count < 1 || arg_count > 6 || getParametersArray(ht, arg_count, arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
if (GLOBAL(php3_HeaderPrinted) == 1) { if (php3_HeaderPrinted == 1) {
php3_error(E_WARNING, "Oops, php3_SetCookie called after header has been sent\n"); php3_error(E_WARNING, "Oops, php3_SetCookie called after header has been sent\n");
return; return;
} }
@ -509,7 +504,7 @@ void php3_SetCookie(INTERNAL_FUNCTION_PARAMETERS)
{ {
char *tempstr2=emalloc(strlen(tempstr)+14); char *tempstr2=emalloc(strlen(tempstr)+14);
sprintf(tempstr2,"Set-Cookie: %s\015\012",tempstr); sprintf(tempstr2,"Set-Cookie: %s\015\012",tempstr);
GLOBAL(sapi_rqst)->header(GLOBAL(sapi_rqst)->scid,tempstr2); sapi_rqst->header(sapi_rqst->scid,tempstr2);
efree(tempstr2); efree(tempstr2);
} }
#elif FHTTPD #elif FHTTPD
@ -538,8 +533,7 @@ void php3_SetCookie(INTERNAL_FUNCTION_PARAMETERS)
int php3_headers_unsent(void) int php3_headers_unsent(void)
{ {
TLS_VARS; if (php3_HeaderPrinted!=1 || !php3_PrintHeader) {
if (GLOBAL(php3_HeaderPrinted)!=1 || !GLOBAL(php3_PrintHeader)) {
return 1; return 1;
} else { } else {
return 0; return 0;

View file

@ -60,7 +60,6 @@ static void _php3_htmlentities(INTERNAL_FUNCTION_PARAMETERS, int all)
int i, len, maxlen; int i, len, maxlen;
unsigned char *old; unsigned char *old;
char *new; char *new;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -331,7 +331,7 @@ void php3_getimagesize(INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE; RETURN_FALSE;
} }
pval_destructor(info _INLINE_TLS); pval_destructor(info);
if (array_init(info) == FAILURE) { if (array_init(info) == FAILURE) {
return; return;
} }

View file

@ -106,7 +106,7 @@ void _php3_info(void)
PUTS("<img src=\""); PUTS("<img src=\"");
/*PUTS(GLOBAL(php3_rqst)->uri);*/ /*PUTS(php3_rqst->uri);*/
PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"56\" align=\"right\">\n"); PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"56\" align=\"right\">\n");
php3_printf("<center><h1>PHP Version %s</h1></center>\n", PHP_VERSION); php3_printf("<center><h1>PHP Version %s</h1></center>\n", PHP_VERSION);
PUTS("<p>by <a href=\"mailto:rasmus@lerdorf.on.ca\">Rasmus Lerdorf</a>,\n"); PUTS("<p>by <a href=\"mailto:rasmus@lerdorf.on.ca\">Rasmus Lerdorf</a>,\n");
@ -134,7 +134,7 @@ void _php3_info(void)
PUTS("HSREGEX=" PHP_HSREGEX "</td></tr>\n"); PUTS("HSREGEX=" PHP_HSREGEX "</td></tr>\n");
#endif #endif
_php3_hash_apply(&GLOBAL(module_registry),(int (*)(void *))_display_module_info); _php3_hash_apply(&module_registry,(int (*)(void *))_display_module_info);
PUTS("</table>\n"); PUTS("</table>\n");
SECTION("Configuration"); SECTION("Configuration");
@ -196,7 +196,7 @@ void _php3_info(void)
PUTS("</table>"); PUTS("</table>");
#if USE_SAPI /* call a server module specific info function */ #if USE_SAPI /* call a server module specific info function */
GLOBAL(sapi_rqst)->info(GLOBAL(sapi_rqst)); sapi_rqst->info(sapi_rqst);
#endif #endif
SECTION("Environment"); SECTION("Environment");
@ -323,7 +323,7 @@ void _php3_info(void)
#if APACHE #if APACHE
{ {
register int i; register int i;
array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env); array_header *arr = table_elts(php3_rqst->subprocess_env);
table_entry *elts = (table_entry *)arr->elts; table_entry *elts = (table_entry *)arr->elts;
SECTION("Apache Environment"); SECTION("Apache Environment");
@ -350,9 +350,9 @@ void _php3_info(void)
PUTS("<table border=5 width=\"600\">\n"); PUTS("<table border=5 width=\"600\">\n");
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Request Headers</th></tr>\n"); PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Request Headers</th></tr>\n");
PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">HTTP Request</td><td bgcolor=\"" CONTENTS_COLOR "\">"); PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">HTTP Request</td><td bgcolor=\"" CONTENTS_COLOR "\">");
PUTS(GLOBAL(php3_rqst)->the_request); PUTS(php3_rqst->the_request);
PUTS("&nbsp;</td></tr>\n"); PUTS("&nbsp;</td></tr>\n");
env_arr = table_elts(GLOBAL(php3_rqst)->headers_in); env_arr = table_elts(php3_rqst->headers_in);
env = (table_entry *)env_arr->elts; env = (table_entry *)env_arr->elts;
for (i = 0; i < env_arr->nelts; ++i) { for (i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) { if (env[i].key) {
@ -364,7 +364,7 @@ void _php3_info(void)
} }
} }
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Response Headers</th></tr>\n"); PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Response Headers</th></tr>\n");
env_arr = table_elts(GLOBAL(php3_rqst)->headers_out); env_arr = table_elts(php3_rqst->headers_out);
env = (table_entry *)env_arr->elts; env = (table_entry *)env_arr->elts;
for(i = 0; i < env_arr->nelts; ++i) { for(i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) { if (env[i].key) {
@ -385,7 +385,7 @@ void _php3_info(void)
PUTS("<table width=\"100%%\"><tr>\n"); PUTS("<table width=\"100%%\"><tr>\n");
php3_printf("<td><h2>Zend</h2>This program makes use of the Zend scripting language engine:<br><pre>%s</pre></td>", get_zend_version()); php3_printf("<td><h2>Zend</h2>This program makes use of the Zend scripting language engine:<br><pre>%s</pre></td>", get_zend_version());
PUTS("<td width=\"100\"><a href=\"http://www.zend.com/\"><img src=\""); PUTS("<td width=\"100\"><a href=\"http://www.zend.com/\"><img src=\"");
/*PUTS(GLOBAL(php3_rqst)->uri);*/ /*PUTS(php3_rqst->uri);*/
PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"89\"></a></td>\n"); PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"89\"></a></td>\n");
PUTS("</tr></table>\n"); PUTS("</tr></table>\n");
@ -415,8 +415,6 @@ void _php3_info(void)
Output a page of useful information about PHP and the current request */ Output a page of useful information about PHP and the current request */
void php3_info(INTERNAL_FUNCTION_PARAMETERS) void php3_info(INTERNAL_FUNCTION_PARAMETERS)
{ {
TLS_VARS;
_php3_info(); _php3_info();
RETURN_TRUE; RETURN_TRUE;
} }
@ -426,8 +424,6 @@ void php3_info(INTERNAL_FUNCTION_PARAMETERS)
Return the current PHP version */ Return the current PHP version */
void php3_version(INTERNAL_FUNCTION_PARAMETERS) void php3_version(INTERNAL_FUNCTION_PARAMETERS)
{ {
TLS_VARS;
RETURN_STRING(PHP_VERSION,1); RETURN_STRING(PHP_VERSION,1);
} }
/* }}} */ /* }}} */

View file

@ -72,7 +72,6 @@ void php3_mail(INTERNAL_FUNCTION_PARAMETERS)
pval *argv[4]; pval *argv[4];
char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL; char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL;
int argc; int argc;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
if (argc < 3 || argc > 4 || getParametersArray(ht, argc, argv) == FAILURE) { if (argc < 3 || argc > 4 || getParametersArray(ht, argc, argv) == FAILURE) {

View file

@ -44,7 +44,6 @@ char *_php3_number_format(double, int, char ,char);
Return the absolute value of the number */ Return the absolute value of the number */
void php3_abs(INTERNAL_FUNCTION_PARAMETERS) { void php3_abs(INTERNAL_FUNCTION_PARAMETERS) {
pval *value; pval *value;
TLS_VARS;
if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) { if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -69,7 +68,6 @@ void php3_abs(INTERNAL_FUNCTION_PARAMETERS) {
Returns the next highest integer value of the number */ Returns the next highest integer value of the number */
void php3_ceil(INTERNAL_FUNCTION_PARAMETERS) { void php3_ceil(INTERNAL_FUNCTION_PARAMETERS) {
pval *value; pval *value;
TLS_VARS;
if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) { if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -94,7 +92,6 @@ void php3_ceil(INTERNAL_FUNCTION_PARAMETERS) {
Returns the next lowest integer value from the number */ Returns the next lowest integer value from the number */
void php3_floor(INTERNAL_FUNCTION_PARAMETERS) { void php3_floor(INTERNAL_FUNCTION_PARAMETERS) {
pval *value; pval *value;
TLS_VARS;
if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) { if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -134,7 +131,6 @@ inline double rint(double n)
void php3_round(INTERNAL_FUNCTION_PARAMETERS) void php3_round(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *value; pval *value;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &value) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &value) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -272,7 +268,6 @@ void php3_pi(INTERNAL_FUNCTION_PARAMETERS)
void php3_pow(INTERNAL_FUNCTION_PARAMETERS) void php3_pow(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *num1, *num2; pval *num1, *num2;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&num1,&num2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&num1,&num2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -348,7 +343,6 @@ void php3_sqrt(INTERNAL_FUNCTION_PARAMETERS)
void php3_deg2rad(INTERNAL_FUNCTION_PARAMETERS) void php3_deg2rad(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *deg; pval *deg;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &deg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &deg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -363,7 +357,6 @@ void php3_deg2rad(INTERNAL_FUNCTION_PARAMETERS)
void php3_rad2deg(INTERNAL_FUNCTION_PARAMETERS) void php3_rad2deg(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *rad; pval *rad;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &rad) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &rad) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -452,7 +445,6 @@ void php3_bindec(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
long ret; long ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -471,7 +463,6 @@ void php3_hexdec(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
long ret; long ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -490,7 +481,6 @@ void php3_octdec(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
long ret; long ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -46,7 +46,6 @@ void php3_md5(INTERNAL_FUNCTION_PARAMETERS)
unsigned char digest[16]; unsigned char digest[16];
int i; int i;
char *r; char *r;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -65,7 +65,6 @@ void php3_microtime(INTERNAL_FUNCTION_PARAMETERS)
long sec = 0L; long sec = 0L;
double msec = 0.0; double msec = 0.0;
char ret[100]; char ret[100];
TLS_VARS;
if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) { if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) {
msec = (double) (tp.tv_usec / MICRO_IN_SEC); msec = (double) (tp.tv_usec / MICRO_IN_SEC);

View file

@ -222,7 +222,7 @@ void php3_mime_split(char *buf, int cnt, char *boundary, pval *http_post_vars PL
} }
bytes = fwrite(ptr, 1, loc - ptr - 4, fp); bytes = fwrite(ptr, 1, loc - ptr - 4, fp);
fclose(fp); fclose(fp);
php3_list_insert(fn,GLOBAL(le_uploads)); /* Tell PHP about the file so the destructor can unlink it later */ php3_list_insert(fn,le_uploads); /* Tell PHP about the file so the destructor can unlink it later */
if (bytes < (loc - ptr - 4)) { if (bytes < (loc - ptr - 4)) {
php3_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes, loc - ptr - 4); php3_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes, loc - ptr - 4);
} }

View file

@ -122,7 +122,6 @@ PHP_FUNCTION(pack)
int formatcount = 0; int formatcount = 0;
int outputpos = 0, outputsize = 0; int outputpos = 0, outputsize = 0;
char *output; char *output;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
@ -502,7 +501,6 @@ PHP_FUNCTION(unpack)
int formatlen; int formatlen;
int inputpos, inputlen; int inputpos, inputlen;
int i; int i;
TLS_VARS;
if ((ARG_COUNT(ht) != 2) || getParameters(ht, 2, &formatarg, &inputarg) == FAILURE) { if ((ARG_COUNT(ht) != 2) || getParameters(ht, 2, &formatarg, &inputarg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -811,7 +809,6 @@ int php3_minit_pack(INIT_FUNC_ARGS)
{ {
int machine_endian_check = 1; int machine_endian_check = 1;
int i; int i;
TLS_VARS;
machine_little_endian = ((char *)&machine_endian_check)[0]; machine_little_endian = ((char *)&machine_endian_check)[0];

View file

@ -60,7 +60,6 @@ static void _php3_statpage(void)
char *path; char *path;
struct stat sb; struct stat sb;
#endif #endif
TLS_VARS;
#if APACHE #if APACHE
/* Apache has already gone through the trouble of doing /* Apache has already gone through the trouble of doing
@ -68,20 +67,20 @@ static void _php3_statpage(void)
values. We can afford it, and it means we don't have to values. We can afford it, and it means we don't have to
worry about resetting the static variables after every worry about resetting the static variables after every
hit. */ hit. */
GLOBAL(page_uid) = GLOBAL(php3_rqst)->finfo.st_uid; page_uid = php3_rqst->finfo.st_uid;
GLOBAL(page_inode) = GLOBAL(php3_rqst)->finfo.st_ino; page_inode = php3_rqst->finfo.st_ino;
GLOBAL(page_mtime) = GLOBAL(php3_rqst)->finfo.st_mtime; page_mtime = php3_rqst->finfo.st_mtime;
#else #else
if (GLOBAL(page_uid) == -1) { if (page_uid == -1) {
path = GLOBAL(request_info).filename; path = request_info.filename;
if (path != NULL) { if (path != NULL) {
if (stat(path, &sb) == -1) { if (stat(path, &sb) == -1) {
php3_error(E_WARNING, "Unable to find file: '%s'", path); php3_error(E_WARNING, "Unable to find file: '%s'", path);
return; return;
} }
GLOBAL(page_uid) = sb.st_uid; page_uid = sb.st_uid;
GLOBAL(page_inode) = sb.st_ino; page_inode = sb.st_ino;
GLOBAL(page_mtime) = sb.st_mtime; page_mtime = sb.st_mtime;
} }
} }
#endif #endif
@ -89,9 +88,8 @@ static void _php3_statpage(void)
long _php3_getuid(void) long _php3_getuid(void)
{ {
TLS_VARS;
_php3_statpage(); _php3_statpage();
return (GLOBAL(page_uid)); return (page_uid);
} }
/* {{{ proto int getmyuid(void) /* {{{ proto int getmyuid(void)
@ -99,7 +97,6 @@ long _php3_getuid(void)
void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS) void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS)
{ {
long uid; long uid;
TLS_VARS;
uid = _php3_getuid(); uid = _php3_getuid();
if (uid < 0) { if (uid < 0) {
@ -115,7 +112,6 @@ void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS)
void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS) void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS)
{ {
int pid; int pid;
TLS_VARS;
pid = getpid(); pid = getpid();
if (pid < 0) { if (pid < 0) {
@ -130,13 +126,11 @@ void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS)
Get the inode of the current script being parsed */ Get the inode of the current script being parsed */
void php3_getmyinode(INTERNAL_FUNCTION_PARAMETERS) void php3_getmyinode(INTERNAL_FUNCTION_PARAMETERS)
{ {
TLS_VARS;
_php3_statpage(); _php3_statpage();
if (GLOBAL(page_inode) < 0) { if (page_inode < 0) {
RETURN_FALSE; RETURN_FALSE;
} else { } else {
RETURN_LONG(GLOBAL(page_inode)); RETURN_LONG(page_inode);
} }
} }
/* }}} */ /* }}} */
@ -145,13 +139,11 @@ void php3_getmyinode(INTERNAL_FUNCTION_PARAMETERS)
Get time of last page modification */ Get time of last page modification */
void php3_getlastmod(INTERNAL_FUNCTION_PARAMETERS) void php3_getlastmod(INTERNAL_FUNCTION_PARAMETERS)
{ {
TLS_VARS;
_php3_statpage(); _php3_statpage();
if (GLOBAL(page_mtime) < 0) { if (page_mtime < 0) {
RETURN_FALSE; RETURN_FALSE;
} else { } else {
RETURN_LONG(GLOBAL(page_mtime)); RETURN_LONG(page_mtime);
} }
} }
/* }}} */ /* }}} */

View file

@ -54,9 +54,8 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
int file_upload = 0; int file_upload = 0;
char *mb; char *mb;
char boundary[100]; char boundary[100];
TLS_VARS;
ctype = GLOBAL(request_info).content_type; ctype = request_info.content_type;
if (!ctype) { if (!ctype) {
php3_error(E_WARNING, "POST Error: content-type missing"); php3_error(E_WARNING, "POST Error: content-type missing");
return NULL; return NULL;
@ -81,7 +80,7 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
return NULL; return NULL;
} }
} }
length = GLOBAL(request_info).content_length; length = request_info.content_length;
cnt = length; cnt = length;
buf = (char *) emalloc((length + 1) * sizeof(char)); buf = (char *) emalloc((length + 1) * sizeof(char));
if (!buf) { if (!buf) {
@ -93,23 +92,23 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
buf[length]=0; buf[length]=0;
#else #else
#if MODULE_MAGIC_NUMBER > 19961007 #if MODULE_MAGIC_NUMBER > 19961007
if (should_client_block(GLOBAL(php3_rqst))) { if (should_client_block(php3_rqst)) {
void (*handler) (int); void (*handler) (int);
int dbsize, len_read, dbpos = 0; int dbsize, len_read, dbpos = 0;
hard_timeout("copy script args", GLOBAL(php3_rqst)); /* start timeout timer */ hard_timeout("copy script args", php3_rqst); /* start timeout timer */
handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */ handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */
while ((len_read = get_client_block(GLOBAL(php3_rqst), argsbuffer, HUGE_STRING_LEN)) > 0) { while ((len_read = get_client_block(php3_rqst, argsbuffer, HUGE_STRING_LEN)) > 0) {
if ((dbpos + len_read) > length) if ((dbpos + len_read) > length)
dbsize = length - dbpos; dbsize = length - dbpos;
else else
dbsize = len_read; dbsize = len_read;
reset_timeout(GLOBAL(php3_rqst)); /* Make sure we don't timeout */ reset_timeout(php3_rqst); /* Make sure we don't timeout */
memcpy(buf + dbpos, argsbuffer, dbsize); memcpy(buf + dbpos, argsbuffer, dbsize);
dbpos += dbsize; dbpos += dbsize;
} }
signal(SIGPIPE, handler); /* restore normal sigpipe handling */ signal(SIGPIPE, handler); /* restore normal sigpipe handling */
kill_timeout(GLOBAL(php3_rqst)); /* stop timeout timer */ kill_timeout(php3_rqst); /* stop timeout timer */
} }
#else #else
cnt = 0; cnt = 0;
@ -121,7 +120,7 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
bytes = fread(buf + cnt, 1, length - cnt, stdin); bytes = fread(buf + cnt, 1, length - cnt, stdin);
#endif #endif
#if USE_SAPI #if USE_SAPI
bytes = GLOBAL(sapi_rqst)->readclient(GLOBAL(sapi_rqst)->scid,buf + cnt, 1, length - cnt); bytes = sapi_rqst->readclient(sapi_rqst->scid,buf + cnt, 1, length - cnt);
#endif #endif
cnt += bytes; cnt += bytes;
} while (bytes && cnt < length); } while (bytes && cnt < length);
@ -143,7 +142,7 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
postdata_ptr->value.str.len = cnt; postdata_ptr->value.str.len = cnt;
postdata_ptr->refcount=1; postdata_ptr->refcount=1;
postdata_ptr->is_ref=0; postdata_ptr->is_ref=0;
_php3_hash_add(&GLOBAL(symbol_table), "HTTP_FDF_DATA", sizeof("HTTP_FDF_DATA"), postdata_ptr, sizeof(pval *),NULL); _php3_hash_add(&symbol_table, "HTTP_FDF_DATA", sizeof("HTTP_FDF_DATA"), postdata_ptr, sizeof(pval *),NULL);
} }
#endif #endif
return (buf); return (buf);
@ -349,12 +348,12 @@ void php3_treat_data(int arg, char *str)
if (arg == PARSE_POST) { if (arg == PARSE_POST) {
res = php3_getpost(array_ptr PLS_CC); res = php3_getpost(array_ptr PLS_CC);
} else if (arg == PARSE_GET) { /* Get data */ } else if (arg == PARSE_GET) { /* Get data */
var = GLOBAL(request_info).query_string; var = request_info.query_string;
if (var && *var) { if (var && *var) {
res = (char *) estrdup(var); res = (char *) estrdup(var);
} }
} else if (arg == PARSE_COOKIE) { /* Cookie data */ } else if (arg == PARSE_COOKIE) { /* Cookie data */
var = (char *)GLOBAL(request_info).cookies; var = (char *)request_info.cookies;
if (var && *var) { if (var && *var) {
res = (char *) estrdup(var); res = (char *) estrdup(var);
} }
@ -408,27 +407,27 @@ void php3_TreatHeaders(void)
char *escaped_str; char *escaped_str;
PLS_FETCH(); PLS_FETCH();
if (GLOBAL(php3_rqst)->headers_in) if (php3_rqst->headers_in)
s = table_get(GLOBAL(php3_rqst)->headers_in, "Authorization"); s = table_get(php3_rqst->headers_in, "Authorization");
if (!s) if (!s)
return; return;
/* Check to make sure that this URL isn't authenticated /* Check to make sure that this URL isn't authenticated
using a traditional auth module mechanism */ using a traditional auth module mechanism */
if (auth_type(GLOBAL(php3_rqst))) { if (auth_type(php3_rqst)) {
/*php3_error(E_WARNING, "Authentication done by server module\n");*/ /*php3_error(E_WARNING, "Authentication done by server module\n");*/
return; return;
} }
if (strcmp(t=getword(GLOBAL(php3_rqst)->pool, &s, ' '), "Basic")) { if (strcmp(t=getword(php3_rqst->pool, &s, ' '), "Basic")) {
/* Client tried to authenticate using wrong auth scheme */ /* Client tried to authenticate using wrong auth scheme */
php3_error(E_WARNING, "client used wrong authentication scheme (%s)", t); php3_error(E_WARNING, "client used wrong authentication scheme (%s)", t);
return; return;
} }
t = uudecode(GLOBAL(php3_rqst)->pool, s); t = uudecode(php3_rqst->pool, s);
#if MODULE_MAGIC_NUMBER > 19961007 #if MODULE_MAGIC_NUMBER > 19961007
user = getword_nulls_nc(GLOBAL(php3_rqst)->pool, &t, ':'); user = getword_nulls_nc(php3_rqst->pool, &t, ':');
#else #else
user = getword(GLOBAL(php3_rqst)->pool, &t, ':'); user = getword(php3_rqst->pool, &t, ':');
#endif #endif
type = "Basic"; type = "Basic";

View file

@ -108,7 +108,6 @@ static void _php3_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
off_t start, end; off_t start, end;
char *buf = NULL; char *buf = NULL;
char *string = NULL; char *string = NULL;
TLS_VARS;
if (icase) if (icase)
copts |= REG_ICASE; copts |= REG_ICASE;
@ -176,7 +175,7 @@ static void _php3_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
RETURN_FALSE; RETURN_FALSE;
} }
pval_destructor(array _INLINE_TLS); /* start with clean array */ pval_destructor(array); /* start with clean array */
array_init(array); array_init(array);
for (i = 0; i < NS; i++) { for (i = 0; i < NS; i++) {
@ -366,7 +365,6 @@ static void _php3_eregreplace(INTERNAL_FUNCTION_PARAMETERS, int icase)
char *string; char *string;
char *replace; char *replace;
char *ret; char *ret;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) { if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -442,7 +440,6 @@ void php3_split(INTERNAL_FUNCTION_PARAMETERS)
regmatch_t subs[1]; regmatch_t subs[1];
char *strp, *endp; char *strp, *endp;
int err, size, count; int err, size, count;
TLS_VARS;
switch (ARG_COUNT(ht)) { switch (ARG_COUNT(ht)) {
case 2: case 2:

View file

@ -49,7 +49,6 @@
void php3_strlen(INTERNAL_FUNCTION_PARAMETERS) void php3_strlen(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -125,7 +124,6 @@ void php3_chop(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
register int i; register int i;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -156,7 +154,6 @@ void php3_trim(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
register int i; register int i;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -198,7 +195,6 @@ void php3_ltrim(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
register int i; register int i;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -268,7 +264,6 @@ void php3_implode(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg1, *arg2, *delim, *tmp, *arr; pval *arg1, *arg2, *delim, *tmp, *arr;
int len = 0, count = 0; int len = 0, count = 0;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -337,7 +332,6 @@ void php3_strtok(INTERNAL_FUNCTION_PARAMETERS)
char *token = NULL, *tokp=NULL; char *token = NULL, *tokp=NULL;
char *first = NULL; char *first = NULL;
int argc; int argc;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
@ -352,35 +346,35 @@ void php3_strtok(INTERNAL_FUNCTION_PARAMETERS)
if (argc == 2) { if (argc == 2) {
convert_to_string(str); convert_to_string(str);
STR_FREE(GLOBAL(strtok_string)); STR_FREE(strtok_string);
GLOBAL(strtok_string) = estrndup(str->value.str.val,str->value.str.len); strtok_string = estrndup(str->value.str.val,str->value.str.len);
STATIC(strtok_pos1) = GLOBAL(strtok_string); strtok_pos1 = strtok_string;
STATIC(strtok_pos2) = NULL; strtok_pos2 = NULL;
} }
if (STATIC(strtok_pos1) && *STATIC(strtok_pos1)) { if (strtok_pos1 && *strtok_pos1) {
for ( /* NOP */ ; token && *token; token++) { for ( /* NOP */ ; token && *token; token++) {
STATIC(strtok_pos2) = strchr(STATIC(strtok_pos1), (int) *token); strtok_pos2 = strchr(strtok_pos1, (int) *token);
if (!first || (STATIC(strtok_pos2) && STATIC(strtok_pos2) < first)) { if (!first || (strtok_pos2 && strtok_pos2 < first)) {
first = STATIC(strtok_pos2); first = strtok_pos2;
} }
} /* NB: token is unusable now */ } /* NB: token is unusable now */
STATIC(strtok_pos2) = first; strtok_pos2 = first;
if (STATIC(strtok_pos2)) { if (strtok_pos2) {
*STATIC(strtok_pos2) = '\0'; *strtok_pos2 = '\0';
} }
RETVAL_STRING(STATIC(strtok_pos1),1); RETVAL_STRING(strtok_pos1,1);
#if 0 #if 0
/* skip 'token' white space for next call to strtok */ /* skip 'token' white space for next call to strtok */
while (STATIC(strtok_pos2) && while (strtok_pos2 &&
strchr(tokp, *(STATIC(strtok_pos2)+1))) { strchr(tokp, *(strtok_pos2+1))) {
STATIC(strtok_pos2)++; strtok_pos2++;
} }
#endif #endif
if (STATIC(strtok_pos2)) if (strtok_pos2)
STATIC(strtok_pos1) = STATIC(strtok_pos2) + 1; strtok_pos1 = strtok_pos2 + 1;
else else
STATIC(strtok_pos1) = NULL; strtok_pos1 = NULL;
} else { } else {
RETVAL_FALSE; RETVAL_FALSE;
} }
@ -406,7 +400,6 @@ void php3_strtoupper(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
char *ret; char *ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg)) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg)) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -438,7 +431,6 @@ void php3_strtolower(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
char *ret; char *ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -456,7 +448,6 @@ void php3_basename(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
char *ret, *c; char *ret, *c;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -509,7 +500,6 @@ void php3_dirname(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
char *ret; char *ret;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str)) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -544,7 +534,6 @@ void php3_stristr(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *haystack, *needle; pval *haystack, *needle;
char *found = NULL; char *found = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) == if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
FAILURE) { FAILURE) {
@ -573,7 +562,6 @@ void php3_strstr(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *haystack, *needle; pval *haystack, *needle;
char *found = NULL; char *found = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) == if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
FAILURE) { FAILURE) {
@ -608,7 +596,6 @@ void php3_strpos(INTERNAL_FUNCTION_PARAMETERS)
pval *haystack, *needle, *OFFSET; pval *haystack, *needle, *OFFSET;
int offset = 0; int offset = 0;
char *found = NULL; char *found = NULL;
TLS_VARS;
switch(ARG_COUNT(ht)) { switch(ARG_COUNT(ht)) {
case 2: case 2:
@ -657,7 +644,6 @@ void php3_strrpos(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *haystack, *needle; pval *haystack, *needle;
char *found = NULL; char *found = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) == FAILURE) { if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -685,7 +671,6 @@ void php3_strrchr(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *haystack, *needle; pval *haystack, *needle;
char *found = NULL; char *found = NULL;
TLS_VARS;
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) == if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
FAILURE) { FAILURE) {
@ -753,7 +738,6 @@ void php3_chunk_split(INTERNAL_FUNCTION_PARAMETERS)
char *end = "\r\n"; char *end = "\r\n";
int endlen = 2; int endlen = 2;
int chunklen = 76; int chunklen = 76;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
@ -799,7 +783,6 @@ void php3_substr(INTERNAL_FUNCTION_PARAMETERS)
pval *string, *from, *len; pval *string, *from, *len;
int argc, l; int argc, l;
int f; int f;
TLS_VARS;
argc = ARG_COUNT(ht); argc = ARG_COUNT(ht);
@ -858,7 +841,6 @@ void php3_quotemeta(INTERNAL_FUNCTION_PARAMETERS)
char *str, *old; char *str, *old;
char *p, *q; char *p, *q;
char c; char c;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -902,7 +884,6 @@ void php3_quotemeta(INTERNAL_FUNCTION_PARAMETERS)
void php3_ord(INTERNAL_FUNCTION_PARAMETERS) void php3_ord(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -918,7 +899,6 @@ void php3_chr(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *num; pval *num;
char temp[2]; char temp[2];
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &num) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -984,7 +964,6 @@ void php3_strtr(INTERNAL_FUNCTION_PARAMETERS)
unsigned char xlat[256]; unsigned char xlat[256];
unsigned char *str_from, *str_to, *string; unsigned char *str_from, *str_to, *string;
int i, len1, len2; int i, len1, len2;
TLS_VARS;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &str, &from, &to) == if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &str, &from, &to) ==
FAILURE) { FAILURE) {
@ -1117,7 +1096,6 @@ void php3_addslashes(INTERNAL_FUNCTION_PARAMETERS)
void php3_stripslashes(INTERNAL_FUNCTION_PARAMETERS) void php3_stripslashes(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *str; pval *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -1141,8 +1119,8 @@ char *strerror(int errnum)
#endif #endif
if ((unsigned int)errnum < sys_nerr) return(sys_errlist[errnum]); if ((unsigned int)errnum < sys_nerr) return(sys_errlist[errnum]);
(void)sprintf(STATIC(str_ebuf), "Unknown error: %d", errnum); (void)sprintf(str_ebuf, "Unknown error: %d", errnum);
return(STATIC(str_ebuf)); return(str_ebuf);
} }
#endif #endif
#endif #endif

View file

@ -54,11 +54,9 @@ void php3_uniqid(INTERNAL_FUNCTION_PARAMETERS)
{ {
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
pval *prefix; pval *prefix;
char uniqid[128]; char uniqid[128];
int sec, usec; int sec, usec;
struct timeval tv; struct timeval tv;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&prefix)==FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&prefix)==FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -161,7 +161,6 @@ void php3_parse_url(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *string; pval *string;
url *resource; url *resource;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &string) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &string) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -270,7 +269,6 @@ void php3_urlencode(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
char *str; char *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -292,7 +290,6 @@ void php3_urldecode(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
int len; int len;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -367,7 +364,6 @@ void php3_rawurlencode(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
char *str; char *str;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
@ -389,7 +385,6 @@ void php3_rawurldecode(INTERNAL_FUNCTION_PARAMETERS)
{ {
pval *arg; pval *arg;
int len; int len;
TLS_VARS;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;

View file

@ -169,7 +169,7 @@ PHPAPI void php3_fhttpd_puts_header(char *s)
} }
} }
void fhttpd_flush( /*GLOBAL(php3_rqst)->connection */ void) void fhttpd_flush( /*php3_rqst->connection */ void)
{ {
} }

2
main.h
View file

@ -39,7 +39,7 @@
#include "php_globals.h" #include "php_globals.h"
int php3_request_startup(CLS_D ELS_DC PLS_DC); int php3_request_startup(CLS_D ELS_DC PLS_DC);
extern void php3_request_shutdown(void *dummy INLINE_TLS); extern void php3_request_shutdown(void *dummy);
extern void php3_request_shutdown_for_exec(void *dummy); extern void php3_request_shutdown_for_exec(void *dummy);
extern int php3_module_startup(); extern int php3_module_startup();
extern void php3_module_shutdown(); extern void php3_module_shutdown();

View file

@ -177,8 +177,8 @@ int php3_init_config(void)
} }
#if WIN32|WINNT #if WIN32|WINNT
{ {
if (GLOBAL(php3_ini_path)) { if (php3_ini_path) {
default_location = GLOBAL(php3_ini_path); default_location = php3_ini_path;
} else { } else {
default_location = (char *) malloc(512); default_location = (char *) malloc(512);
@ -189,17 +189,17 @@ int php3_init_config(void)
} }
} }
#else #else
if (!GLOBAL(php3_ini_path)) { if (!php3_ini_path) {
default_location = CONFIGURATION_FILE_PATH; default_location = CONFIGURATION_FILE_PATH;
} else { } else {
default_location = GLOBAL(php3_ini_path); default_location = php3_ini_path;
} }
#endif #endif
/* build a path */ /* build a path */
php_ini_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); php_ini_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);
if (!GLOBAL(php3_ini_path)) { if (!php3_ini_path) {
#if WIN32|WINNT #if WIN32|WINNT
sprintf(php_ini_path,".;%s;%s",env_location,default_location); sprintf(php_ini_path,".;%s;%s",env_location,default_location);
#else #else
@ -258,7 +258,7 @@ int php3_minit_browscap(INIT_FUNC_ARGS)
char *browscap = INI_STR("browscap"); char *browscap = INI_STR("browscap");
if (browscap) { if (browscap) {
if (_php3_hash_init(&GLOBAL(browser_hash), 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) { if (_php3_hash_init(&browser_hash, 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) {
return FAILURE; return FAILURE;
} }
@ -268,7 +268,7 @@ int php3_minit_browscap(INIT_FUNC_ARGS)
return FAILURE; return FAILURE;
} }
init_cfg_scanner(); init_cfg_scanner();
active__php3_hash_table = &GLOBAL(browser_hash); active__php3_hash_table = &browser_hash;
parsing_mode = PARSING_MODE_BROWSCAP; parsing_mode = PARSING_MODE_BROWSCAP;
currently_parsed_filename = browscap; currently_parsed_filename = browscap;
yyparse(); yyparse();
@ -289,7 +289,7 @@ int php3_shutdown_config(void)
int php3_mshutdown_browscap(SHUTDOWN_FUNC_ARGS) int php3_mshutdown_browscap(SHUTDOWN_FUNC_ARGS)
{ {
if (INI_STR("browscap")) { if (INI_STR("browscap")) {
_php3_hash_destroy(&GLOBAL(browser_hash)); _php3_hash_destroy(&browser_hash);
} }
return SUCCESS; return SUCCESS;
} }

View file

@ -109,10 +109,10 @@ PHPAPI int _php3_check_open_basedir(char *path)
/* Special case basedir==".": Use script-directory */ /* Special case basedir==".": Use script-directory */
if ((strcmp(PG(open_basedir), ".") == 0) && if ((strcmp(PG(open_basedir), ".") == 0) &&
GLOBAL(request_info).filename && request_info.filename &&
*GLOBAL(request_info).filename *request_info.filename
) { ) {
strcpy(local_open_basedir, GLOBAL(request_info).filename); strcpy(local_open_basedir, request_info.filename);
local_open_basedir_pos = strlen(local_open_basedir) - 1; local_open_basedir_pos = strlen(local_open_basedir) - 1;
/* Strip filename */ /* Strip filename */
@ -206,8 +206,8 @@ FILE *php3_fopen_for_parser(void)
int l; int l;
PLS_FETCH(); PLS_FETCH();
fn = GLOBAL(request_info).filename; fn = request_info.filename;
path_info = GLOBAL(request_info).path_info; path_info = request_info.path_info;
#if HAVE_PWD_H #if HAVE_PWD_H
if (PG(user_dir) && *PG(user_dir) if (PG(user_dir) && *PG(user_dir)
&& path_info && '/' == path_info[0] && '~' == path_info[1]) { && path_info && '/' == path_info[0] && '~' == path_info[1]) {
@ -234,8 +234,8 @@ FILE *php3_fopen_for_parser(void)
strcat(fn, PG(user_dir)); /* safe */ strcat(fn, PG(user_dir)); /* safe */
strcat(fn, "/"); /* safe */ strcat(fn, "/"); /* safe */
strcat(fn, s + 1); /* safe (shorter than path_info) */ strcat(fn, s + 1); /* safe (shorter than path_info) */
STR_FREE(GLOBAL(request_info).filename); STR_FREE(request_info.filename);
GLOBAL(request_info).filename = fn; request_info.filename = fn;
} }
} }
} }
@ -257,8 +257,8 @@ FILE *php3_fopen_for_parser(void)
if ('/' == path_info[0]) if ('/' == path_info[0])
l--; l--;
strcpy(fn + l, path_info); strcpy(fn + l, path_info);
STR_FREE(GLOBAL(request_info).filename); STR_FREE(request_info.filename);
GLOBAL(request_info).filename = fn; request_info.filename = fn;
} }
} /* if doc_root && path_info */ } /* if doc_root && path_info */
if (!fn) { if (!fn) {
@ -266,8 +266,8 @@ FILE *php3_fopen_for_parser(void)
php3_destroy_request_info assumes that it will get php3_destroy_request_info assumes that it will get
freed when the include_names hash is emptied, but freed when the include_names hash is emptied, but
we're not adding it in this case */ we're not adding it in this case */
STR_FREE(GLOBAL(request_info).filename); STR_FREE(request_info.filename);
GLOBAL(request_info).filename = NULL; request_info.filename = NULL;
return NULL; return NULL;
} }
fp = fopen(fn, "r"); fp = fopen(fn, "r");
@ -279,7 +279,7 @@ FILE *php3_fopen_for_parser(void)
} }
if (!fp) { if (!fp) {
php3_error(E_CORE_ERROR, "Unable to open %s", fn); php3_error(E_CORE_ERROR, "Unable to open %s", fn);
STR_FREE(GLOBAL(request_info).filename); /* for same reason as above */ STR_FREE(request_info.filename); /* for same reason as above */
return NULL; return NULL;
} }

View file

@ -57,7 +57,6 @@
#include "php_ini.h" #include "php_ini.h"
#include "php_globals.h" #include "php_globals.h"
#include "main.h" #include "main.h"
#include "control_structures.h"
#include "fopen-wrappers.h" #include "fopen-wrappers.h"
#include "ext/standard/php3_standard.h" #include "ext/standard/php3_standard.h"
#include "snprintf.h" #include "snprintf.h"
@ -96,7 +95,7 @@ int core_globals_id;
void _php3_build_argv(char * ELS_DC); void _php3_build_argv(char * ELS_DC);
static void php3_timeout(int dummy); static void php3_timeout(int dummy);
static void php3_set_timeout(long seconds INLINE_TLS); static void php3_set_timeout(long seconds);
void *gLock; /*mutex variable */ void *gLock; /*mutex variable */
@ -268,10 +267,8 @@ request_rec *php3_rqst = NULL; /* request record pointer for apache module versi
#if APACHE #if APACHE
void php3_apache_puts(const char *s) void php3_apache_puts(const char *s)
{ {
TLS_VARS; if (php3_rqst) {
rputs(s, php3_rqst);
if (GLOBAL(php3_rqst)) {
rputs(s, GLOBAL(php3_rqst));
} else { } else {
fputs(s, stdout); fputs(s, stdout);
} }
@ -279,10 +276,8 @@ void php3_apache_puts(const char *s)
void php3_apache_putc(char c) void php3_apache_putc(char c)
{ {
TLS_VARS; if (php3_rqst) {
rputc(c, php3_rqst);
if (GLOBAL(php3_rqst)) {
rputc(c, GLOBAL(php3_rqst));
} else { } else {
fputc(c, stdout); fputc(c, stdout);
} }
@ -315,7 +310,7 @@ void php3_log_err(char *log_message)
} }
/* Otherwise fall back to the default logging location. */ /* Otherwise fall back to the default logging location. */
#if APACHE #if APACHE
if (GLOBAL(php3_rqst)) { if (php3_rqst) {
#if MODULE_MAGIC_NUMBER >= 19970831 #if MODULE_MAGIC_NUMBER >= 19970831
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message); aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message);
#else #else
@ -498,14 +493,14 @@ static void php3_timeout(int dummy)
#define SIGPROF 27 #define SIGPROF 27
#endif #endif
static void php3_set_timeout(long seconds INLINE_TLS) static void php3_set_timeout(long seconds)
{ {
#if WIN32|WINNT #if WIN32|WINNT
if (seconds > 0) { if (seconds > 0) {
GLOBAL(timerstart) = (unsigned int) clock(); timerstart = (unsigned int) clock();
GLOBAL(wintimer) = GLOBAL(timerstart) + (CLOCKS_PER_SEC * seconds); wintimer = timerstart + (CLOCKS_PER_SEC * seconds);
} else { } else {
GLOBAL(wintimer) = 0; wintimer = 0;
} }
#else #else
#if HAVE_SETITIMER #if HAVE_SETITIMER
@ -521,10 +516,10 @@ static void php3_set_timeout(long seconds INLINE_TLS)
} }
static void php3_unset_timeout(INLINE_TLS_VOID) static void php3_unset_timeout()
{ {
#if WIN32|WINNT #if WIN32|WINNT
GLOBAL(wintimer) = 0; wintimer = 0;
#else #else
#if HAVE_SETITIMER #if HAVE_SETITIMER
struct itimerval no_timeout; struct itimerval no_timeout;
@ -560,8 +555,8 @@ void php3_set_time_limit(INTERNAL_FUNCTION_PARAMETERS)
should work fine. Is this FIXME a WIN32 problem? Is should work fine. Is this FIXME a WIN32 problem? Is
there no way to do per-thread timers on WIN32? there no way to do per-thread timers on WIN32?
*/ */
php3_unset_timeout(_INLINE_TLS_VOID); php3_unset_timeout();
php3_set_timeout(new_timeout->value.lval _INLINE_TLS); php3_set_timeout(new_timeout->value.lval);
} }
@ -606,9 +601,9 @@ static void php_message_handler_for_zend(long message, void *data)
snprintf(memory_leak_buf,512,"Possible PHP4 memory leak detected (harmless): 0x%0.8lX, %d bytes from %s:%d", (long) t, t->size, t->filename, t->lineno); snprintf(memory_leak_buf,512,"Possible PHP4 memory leak detected (harmless): 0x%0.8lX, %d bytes from %s:%d", (long) t, t->size, t->filename, t->lineno);
# if MODULE_MAGIC_NUMBER >= 19970831 # if MODULE_MAGIC_NUMBER >= 19970831
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, GLOBAL(php3_rqst)->server, memory_leak_buf); aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, memory_leak_buf);
# else # else
log_error(memory_leak_buf,GLOBAL(php3_rqst)->server); log_error(memory_leak_buf,php3_rqst->server);
# endif # endif
# else # else
php3_printf("Freeing 0x%0.8X (%d bytes), allocated in %s on line %d<br>\n",(void *)((char *)t+sizeof(mem_header)+PLATFORM_PADDING),t->size,t->filename,t->lineno); php3_printf("Freeing 0x%0.8X (%d bytes), allocated in %s on line %d<br>\n",(void *)((char *)t+sizeof(mem_header)+PLATFORM_PADDING),t->size,t->filename,t->lineno);
@ -625,7 +620,7 @@ int php3_request_startup(CLS_D ELS_DC PLS_DC)
{ {
zend_output_startup(); zend_output_startup();
php3_set_timeout(PG(max_execution_time) _INLINE_TLS); php3_set_timeout(PG(max_execution_time));
#if APACHE #if APACHE
/* /*
@ -637,7 +632,7 @@ int php3_request_startup(CLS_D ELS_DC PLS_DC)
* memory. * memory.
*/ */
block_alarms(); block_alarms();
register_cleanup(GLOBAL(php3_rqst)->pool, NULL, php3_request_shutdown, php3_request_shutdown_for_exec); register_cleanup(php3_rqst->pool, NULL, php3_request_shutdown, php3_request_shutdown_for_exec);
unblock_alarms(); unblock_alarms();
#endif #endif
@ -663,8 +658,6 @@ int php3_request_startup(CLS_D ELS_DC PLS_DC)
void php3_request_shutdown_for_exec(void *dummy) void php3_request_shutdown_for_exec(void *dummy)
{ {
TLS_VARS;
/* used to close fd's in the 3..255 range here, but it's problematic /* used to close fd's in the 3..255 range here, but it's problematic
*/ */
shutdown_memory_manager(1, 1); shutdown_memory_manager(1, 1);
@ -677,7 +670,7 @@ int return_one(void *p)
} }
void php3_request_shutdown(void *dummy INLINE_TLS) void php3_request_shutdown(void *dummy)
{ {
#if FHTTPD #if FHTTPD
char tmpline[128]; char tmpline[128];
@ -701,14 +694,14 @@ void php3_request_shutdown(void *dummy INLINE_TLS)
php3_destroy_request_info(NULL); php3_destroy_request_info(NULL);
shutdown_memory_manager(0, 0); shutdown_memory_manager(0, 0);
php3_error(E_WARNING, "Unknown resources in request shutdown function"); php3_error(E_WARNING, "Unknown resources in request shutdown function");
php3_unset_timeout(_INLINE_TLS_VOID); php3_unset_timeout();
#if CGI_BINARY #if CGI_BINARY
fflush(stdout); fflush(stdout);
if(GLOBAL(request_info).php_argv0) { if(request_info.php_argv0) {
free(GLOBAL(request_info).php_argv0); free(request_info.php_argv0);
GLOBAL(request_info).php_argv0 = NULL; request_info.php_argv0 = NULL;
} }
#endif #endif
#if FHTTPD #if FHTTPD
@ -750,7 +743,7 @@ void php3_request_shutdown(void *dummy INLINE_TLS)
req = NULL; req = NULL;
#endif #endif
#if USE_SAPI #if USE_SAPI
GLOBAL(sapi_rqst)->flush(GLOBAL(sapi_rqst)->scid); sapi_rqst->flush(sapi_rqst->scid);
#endif #endif
} }
@ -764,7 +757,7 @@ static int php3_config_ini_startup()
return SUCCESS; return SUCCESS;
} }
static void php3_config_ini_shutdown(INLINE_TLS_VOID) static void php3_config_ini_shutdown()
{ {
php3_shutdown_config(); php3_shutdown_config();
} }
@ -855,9 +848,12 @@ void php3_module_shutdown()
CLS_FETCH(); CLS_FETCH();
ELS_FETCH(); ELS_FETCH();
if (!module_initialized) {
return;
}
#if !USE_SAPI #if !USE_SAPI
/* close down the ini config */ /* close down the ini config */
php3_config_ini_shutdown(_INLINE_TLS_VOID); php3_config_ini_shutdown();
#endif #endif
#if (WIN32|WINNT) && !(USE_SAPI) #if (WIN32|WINNT) && !(USE_SAPI)
@ -865,14 +861,11 @@ void php3_module_shutdown()
WSACleanup(); WSACleanup();
#endif #endif
if (GLOBAL(module_initialized)) {
php3_error(E_WARNING, "Unknown resource in module shutdown");
}
#if CGI_BINARY #if CGI_BINARY
fflush(stdout); fflush(stdout);
#endif #endif
#if 0 /* SAPI */ #if 0 /* SAPI */
GLOBAL(sapi_rqst)->flush(GLOBAL(sapi_rqst)->scid); sapi_rqst->flush(sapi_rqst->scid);
#endif #endif
zend_shutdown(); zend_shutdown();
@ -896,7 +889,7 @@ int _php3_hash_environment(PLS_D)
switch(*p++) { switch(*p++) {
case 'p': case 'p':
case 'P': case 'P':
if (!_gpc_flags[0] && php3_headers_unsent() && GLOBAL(request_info).request_method && !strcasecmp(GLOBAL(request_info).request_method, "post")) { if (!_gpc_flags[0] && php3_headers_unsent() && request_info.request_method && !strcasecmp(request_info.request_method, "post")) {
php3_treat_data(PARSE_POST, NULL); /* POST Data */ php3_treat_data(PARSE_POST, NULL); /* POST Data */
_gpc_flags[0]=1; _gpc_flags[0]=1;
} }
@ -940,7 +933,7 @@ int _php3_hash_environment(PLS_D)
{ {
pval **tmp_ptr; pval **tmp_ptr;
register int i; register int i;
array_header *arr = table_elts(GLOBAL(php3_rqst)->subprocess_env); array_header *arr = table_elts(php3_rqst->subprocess_env);
table_entry *elts = (table_entry *) arr->elts; table_entry *elts = (table_entry *) arr->elts;
int len; int len;
@ -966,8 +959,8 @@ int _php3_hash_environment(PLS_D)
_php3_hash_update(&EG(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), tmp_ptr, sizeof(pval *), NULL); _php3_hash_update(&EG(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), tmp_ptr, sizeof(pval *), NULL);
} }
tmp = (pval *) emalloc(sizeof(pval)); tmp = (pval *) emalloc(sizeof(pval));
tmp->value.str.len = strlen(GLOBAL(php3_rqst)->uri); tmp->value.str.len = strlen(php3_rqst->uri);
tmp->value.str.val = estrndup(GLOBAL(php3_rqst)->uri, tmp->value.str.len); tmp->value.str.val = estrndup(php3_rqst->uri, tmp->value.str.len);
tmp->refcount=1; tmp->refcount=1;
tmp->is_ref=0; tmp->is_ref=0;
tmp->type = IS_STRING; tmp->type = IS_STRING;
@ -1026,7 +1019,7 @@ int _php3_hash_environment(PLS_D)
/* Build the special-case PHP_SELF variable for the CGI version */ /* Build the special-case PHP_SELF variable for the CGI version */
char *pi; char *pi;
#if FORCE_CGI_REDIRECT #if FORCE_CGI_REDIRECT
pi = GLOBAL(request_info).path_info; pi = request_info.path_info;
tmp = (pval *) emalloc(sizeof(pval)); tmp = (pval *) emalloc(sizeof(pval));
tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1); tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1);
tmp->value.str.len = _php3_sprintf(tmp->value.str.val, "%s", (pi ? pi : "")); /* SAFE */ tmp->value.str.len = _php3_sprintf(tmp->value.str.val, "%s", (pi ? pi : "")); /* SAFE */
@ -1036,8 +1029,8 @@ int _php3_hash_environment(PLS_D)
#else #else
int l = 0; int l = 0;
char *sn; char *sn;
sn = GLOBAL(request_info).script_name; sn = request_info.script_name;
pi = GLOBAL(request_info).path_info; pi = request_info.path_info;
if (sn) if (sn)
l += strlen(sn); l += strlen(sn);
if (pi) if (pi)
@ -1059,7 +1052,7 @@ int _php3_hash_environment(PLS_D)
/* need argc/argv support as well */ /* need argc/argv support as well */
_php3_build_argv(GLOBAL(request_info).query_string ELS_CC); _php3_build_argv(request_info.query_string ELS_CC);
return SUCCESS; return SUCCESS;
} }
@ -1254,8 +1247,8 @@ int main(int argc, char *argv[])
|| getenv("REQUEST_METHOD")) { || getenv("REQUEST_METHOD")) {
cgi = 1; cgi = 1;
if (argc > 1) if (argc > 1)
GLOBAL(request_info).php_argv0 = strdup(argv[1]); request_info.php_argv0 = strdup(argv[1]);
else GLOBAL(request_info).php_argv0 = NULL; else request_info.php_argv0 = NULL;
#if FORCE_CGI_REDIRECT #if FORCE_CGI_REDIRECT
if (!getenv("REDIRECT_STATUS")) { if (!getenv("REDIRECT_STATUS")) {
PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\ PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\
@ -1292,7 +1285,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
CG(extended_info) = 0; CG(extended_info) = 0;
if (!cgi) { /* never execute the arguments if you are a CGI */ if (!cgi) { /* never execute the arguments if you are a CGI */
GLOBAL(request_info).php_argv0 = NULL; request_info.php_argv0 = NULL;
while ((c = getopt(argc, argv, "c:qvisnaeh?vf:")) != -1) { while ((c = getopt(argc, argv, "c:qvisnaeh?vf:")) != -1) {
switch (c) { switch (c) {
case 'f': case 'f':
@ -1337,7 +1330,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
behavior=PHP_MODE_INDENT; behavior=PHP_MODE_INDENT;
break; break;
case 'c': case 'c':
GLOBAL(php3_ini_path) = strdup(optarg); /* intentional leak */ php3_ini_path = strdup(optarg); /* intentional leak */
break; break;
case 'a': case 'a':
#if SUPPORT_INTERACTIVE #if SUPPORT_INTERACTIVE
@ -1377,13 +1370,13 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
file_handle.type = ZEND_HANDLE_FP; file_handle.type = ZEND_HANDLE_FP;
file_handle.handle.fp = stdin; file_handle.handle.fp = stdin;
if (_cgi_filename) { if (_cgi_filename) {
GLOBAL(request_info).filename = _cgi_filename; request_info.filename = _cgi_filename;
} }
php3_TreatHeaders(); php3_TreatHeaders();
if (!cgi) { if (!cgi) {
if (!GLOBAL(request_info).query_string) { if (!request_info.query_string) {
for (i = optind, len = 0; i < argc; i++) for (i = optind, len = 0; i < argc; i++)
len += strlen(argv[i]) + 1; len += strlen(argv[i]) + 1;
@ -1394,10 +1387,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
if (i < (argc - 1)) if (i < (argc - 1))
strcat(s, "+"); strcat(s, "+");
} }
GLOBAL(request_info).query_string = s; request_info.query_string = s;
} }
if (!GLOBAL(request_info).filename && argc > optind) if (!request_info.filename && argc > optind)
GLOBAL(request_info).filename = argv[optind]; request_info.filename = argv[optind];
} }
/* If for some reason the CGI interface is not setting the /* If for some reason the CGI interface is not setting the
PATH_TRANSLATED correctly, request_info.filename is NULL. PATH_TRANSLATED correctly, request_info.filename is NULL.
@ -1405,8 +1398,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
or user_dir configuration directives, PATH_INFO is used to construct or user_dir configuration directives, PATH_INFO is used to construct
the filename as a side effect of php3_fopen_for_parser. the filename as a side effect of php3_fopen_for_parser.
*/ */
if (cgi || GLOBAL(request_info).filename) { if (cgi || request_info.filename) {
file_handle.filename = GLOBAL(request_info).filename; file_handle.filename = request_info.filename;
file_handle.handle.fp = php3_fopen_for_parser(); file_handle.handle.fp = php3_fopen_for_parser();
} }
@ -1422,8 +1415,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
} }
} }
#endif #endif
php3_request_shutdown((void *) 0 _INLINE_TLS); php3_request_shutdown((void *) 0);
php3_module_shutdown(_INLINE_TLS_VOID); php3_module_shutdown();
return FAILURE; return FAILURE;
} else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) { } else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) {
/* #!php support */ /* #!php support */
@ -1462,8 +1455,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
} }
php3_header(); /* Make sure headers have been sent */ php3_header(); /* Make sure headers have been sent */
php3_request_shutdown((void *) 0 _INLINE_TLS); php3_request_shutdown((void *) 0);
php3_module_shutdown(_INLINE_TLS_VOID); php3_module_shutdown();
return SUCCESS; return SUCCESS;
} }
#endif /* CGI_BINARY */ #endif /* CGI_BINARY */
@ -1482,7 +1475,7 @@ PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_m
php_core_globals *core_globals=&pcg; php_core_globals *core_globals=&pcg;
#endif #endif
GLOBAL(php3_rqst) = r; php3_rqst = r;
if (php3_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) { if (php3_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) {
return FAILURE; return FAILURE;
@ -1499,587 +1492,6 @@ PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_m
} }
#endif /* APACHE */ #endif /* APACHE */
#if FHTTPD
char *get_pretokenized_name(void)
{
char *pretokenized_name = NULL;
if (GLOBAL(request_info).filename) {
int length = strlen(GLOBAL(request_info).filename);
if (length > (sizeof(".php3") - 1) && !strcmp(GLOBAL(request_info).filename + length - sizeof(".php3") + 1, ".php3")) {
pretokenized_name = (char *) emalloc(length + 2);
strcpy(pretokenized_name, GLOBAL(request_info).filename);
strcat(pretokenized_name, "p");
} else {
length += sizeof(".php3p");
pretokenized_name = (char *) emalloc(length + 1);
strcpy(pretokenized_name, GLOBAL(request_info).filename);
strcat(pretokenized_name, ".php3p");
}
} else {
pretokenized_name = estrdup("stdin.php3p");
}
return pretokenized_name;
}
void _php3_usage(char *progname)
{
fprintf(stderr,
"Usage: %s [options] [appname] [username] [hostname] [portname]\n"
"Options:\n"
" -d Daemon mode -- never attempt terminal I/O\n"
" -s Socket mode, fhttpd internal use only\n"
" -p Pipe mode, fhttpd internal use only\n"
" -u<mask> Set umask\n"
" -t<time> Idle timeout in seconds, 0 - disable\n"
" -S Display colour syntax highlighted source\n"
" -P Make and execute a pretokenized script\n"
" (.php3p file) or, if pretokenized script, newer\n"
" than original file exists, execute it instead\n"
" -E Execute a pretokenized (.php3p) script\n"
" -c<path> Look for php3.ini file in this directory\n"
" (must appear before any other options)\n"
" -v Version number\n"
" -h This help\n",
progname);
}
int main(int argc, char **argv)
{
int c, i, processing_error;
FILE *in = NULL;
FILE *in2;
int preprocess_mode = PREPROCESS_NONE;
int argc1;
char **argv1;
int human = 1, fd2;
int i0 = 0, i1 = 0;
char *pn;
struct stat statbuf, pstatbuf;
#ifdef ZTS
zend_compiler_globals cg;
zend_executor_globals eg;
zend_compiler_globals *compiler_globals=&cg;
zend_executor_globals *executor_globals=&eg;
#endif
#ifdef THREAD_SAFE
php3_globals_struct *php3_globals;
flex_globals *php_flex_gbl;
tls_startup();
tls_create();
php_flex_gbl = yy_init_tls();
php3_globals = TlsGetValue(TlsIndex);
if ((php3_globals == 0) && (GetLastError() != 0)) {
PUTS("TlsGetValue error\n");
return FAILURE;
}
#endif
#if HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
#endif
if (php3_module_startup() == FAILURE) {
return FAILURE;
}
signal(SIGPIPE, SIG_IGN);
umask(077);
while ((c = getopt(argc, argv, "spdu:t:c:PESvh")) != -1) {
switch (c) {
case 'd':
human = 0;
break;
case 's':
i0 = 1;
break;
case 'p':
i1 = 1;
break;
case 'u':
if (*optarg == '0')
umask(strtoul(optarg, NULL, 8));
else
umask(strtoul(optarg, NULL, 10));
break;
case 't':
idle_timeout = atoi(optarg);
break;
case 'c':
GLOBAL(php3_ini_path) = strdup(optarg); /* intentional leak */
break;
case 'P': /* preprocess */
preprocess_mode = PREPROCESS_PREPROCESS;
break;
case 'E': /* execute preprocessed script */
preprocess_mode = PREPROCESS_EXECUTE;
break;
case 'S':
printf ("Not implemented yet\n");
break;
case 'v':
printf("%s\n", PHP_VERSION);
exit(1);
break;
case 'h':
case ':':
case '?':
_php3_usage(argv[0]);
return -1;
}
}
argc1 = argc - optind;
argv1 = (char **) malloc(sizeof(char *) * (argc1 + 2));
if (!argv1)
return -1;
argv1 += 2;
for (i = optind; i < argc; i++)
argv1[i - optind] = argv[i];
if (i0) {
argv1--;
*argv1 = "-s";
argc1++;
} else {
if (i1) {
argv1--;
*argv1 = "-p";
argc1++;
}
}
argv1--;
argc1++;
*argv1 = *argv;
server = createserver();
if (!server)
return -1;
switch (servproc_init(server, human, argc1, argv1)) {
case 0:
break;
case APP_ERR_HUMAN:
_php3_usage(argv[0]);
exit(1);
break;
case APP_ERR_CONFIG:
fprintf(stderr, "%s: configuration error\n", server->app_progname);
exit(1);
break;
case APP_ERR_READ:
fprintf(stderr, "%s: read error\n", server->app_progname);
exit(1);
break;
case APP_ERR_HOSTNAME:
fprintf(stderr, "%s: can't resolve server hostname\n", server->app_progname);
exit(1);
break;
case APP_ERR_SOCKET:
fprintf(stderr, "%s: can't create socket\n", server->app_progname);
exit(1);
break;
case APP_ERR_CONNECT:
fprintf(stderr, "%s: can't connect\n", server->app_progname);
exit(1);
break;
case APP_ERR_APPCONNECT:
fprintf(stderr, "%s: connect error\n", server->app_progname);
exit(1);
break;
case APP_ERR_USER:
fprintf(stderr, "%s: login error\n", server->app_progname);
exit(1);
break;
case APP_ERR_PASSWORD:
fprintf(stderr, "%s: login error\n", server->app_progname);
exit(1);
break;
case APP_ERR_APPLICATION:
fprintf(stderr, "%s: application rejected by server\n", server->app_progname);
exit(1);
break;
case APP_ERR_INSANE:
case APP_ERR_DAEMON:
case APP_ERR_AUTH:
default:
if (server->infd < 0)
exit(1);
}
if (server->infd == 0 && server->outfd == 1) {
close(2);
fd2 = open("/dev/null", O_WRONLY);
if (fd2 != 2) {
dup2(fd2, 2);
close(fd2);
}
}
setcapabilities(server, APP_CAP_KEEPALIVE);
exit_status = 0;
while (!exit_status) {
processing_error = 0;
if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) {
processing_error = 1;
}
if (!processing_error) {
GLOBAL(phpin) = NULL;
GLOBAL(current_lineno) = 0;
php3_TreatHeaders();
in = php3_fopen_for_parser();
GLOBAL(php3_preprocess) = preprocess_mode;
if (!in) {
PUTS("No input file specified.\n");
php3_request_shutdown((void *) 0 _INLINE_TLS);
processing_error = 1;
} else {
if (GLOBAL(php3_preprocess) == PREPROCESS_PREPROCESS) {
pn = get_pretokenized_name();
if (pn) {
if (!stat(pn, &pstatbuf)
&& !fstat(fileno(in), &statbuf)
&& S_ISREG(pstatbuf.st_mode)
&& statbuf.st_mtime < pstatbuf.st_mtime) {
in2 = fopen(pn, "r");
if (in2) {
fclose(in);
in = in2;
GLOBAL(php3_preprocess) = PREPROCESS_EXECUTE;
}
}
efree(pn);
}
}
if (GLOBAL(php3_preprocess) != PREPROCESS_EXECUTE) {
/* #!php support */
c = fgetc(in);
if (c == '#') {
while (c != 10 && c != 13) {
c = fgetc(in); /* skip to end of line */
}
CG(phplineno)++;
} else {
rewind(in);
}
}
GLOBAL(phpin) = in;
phprestart(GLOBAL(phpin));
if (!processing_error) {
if (GLOBAL(php3_preprocess) == PREPROCESS_EXECUTE) {
if (tcm_load(&GLOBAL(token_cache_manager), GLOBAL(phpin))==FAILURE) {
/* should bail out on an error, don't know how to do it in fhttpd */
}
GLOBAL(php3_preprocess) = PREPROCESS_NONE;
}
if (GLOBAL(php3_preprocess)!=PREPROCESS_NONE) {
pval yylval;
while (phplex(&yylval)); /* create the token cache */
tcm_save(&GLOBAL(token_cache_manager));
seek_token(&GLOBAL(token_cache_manager), 0, NULL);
GLOBAL(php3_preprocess) = PREPROCESS_NONE;
}
php3_parse(GLOBAL(phpin) CLS_CC ELS_CC);
}
}
}
php3_header(); /* Make sure headers have been sent */
php3_request_shutdown((void *) 0 _INLINE_TLS);
}
php3_module_shutdown(_INLINE_TLS_VOID);
#ifdef THREAD_SAFE
yy_destroy_tls();
tls_shutdown();
tls_destroy();
#endif
return 0;
}
#endif /* FHTTPD */
#if USE_SAPI
PHPAPI int php3_sapi_main(struct sapi_request_info *sapi_info)
{
#if DEBUG
char logmessage[1024];
#endif
FILE *in = NULL;
int c;
YY_TLS_VARS;
TLS_VARS;
GLOBAL(php3_preprocess) = sapi_info->preprocess;
GLOBAL(php3_display_source) = sapi_info->display_source_mode;
GLOBAL(sapi_rqst) = sapi_info;
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: entry\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
/* if (php3_module_startup(php3_globals) == FAILURE) {
return FAILURE;
}*/
if (php3_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) {
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: request starup failed\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
return FAILURE;
}
if (sapi_info->preprocess == PREPROCESS_PREPROCESS || sapi_info->quiet_mode) {
php3_noheader();
}
if (sapi_info->info_only) {
_php3_info();
php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals);
/*php3_module_shutdown(php3_globals);*/
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: info_only\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
return (1);
}
/* if its not cgi, require that we have a filename now */
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: File: %s\n",GLOBAL(sapi_rqst)->scid,GLOBAL(sapi_rqst)->filename);
OutputDebugString(logmessage);
#endif
if (!sapi_info->cgi && !sapi_info->filename) {
php3_printf("No input file specified.\n");
php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals);
/*php3_module_shutdown(php3_globals);*/
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: No input file specified\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
return FAILURE;
}
/*
if request_info.filename is null and cgi, fopen_for_parser is responsible
request_info.filename will only be estrduped in fopen_for parser
if it is null at this point
*/
in = php3_fopen_for_parser();
if (sapi_info->cgi && !in) {
php3_printf("No input file specified for cgi.\n");
php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals);
/*php3_module_shutdown(php3_globals);*/
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: No input file specified for cgi.\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
return FAILURE;
}
if (sapi_info->cgi && in) {
/* #!php support */
c = fgetc(in);
if (c == '#') {
while (c != 10 && c != 13) {
c = fgetc(in); /* skip to end of line */
}
} else {
rewind(in);
}
}
if (in) {
GLOBAL(phpin) = in;
phprestart(GLOBAL(phpin));
}
if (sapi_info->display_source_mode) {
GLOBAL(php3_display_source) = 1;
PUTS("<html><head><title>Source for ");
PUTS(sapi_info->filename);
PUTS("</title></head><body bgcolor=\"");
PUTS(php3_ini.highlight_bg);
PUTS("\" text=\"");
PUTS(php3_ini.highlight_html);
PUTS("\">\n"); /* color: seashell */
}
if (sapi_info->display_source_mode && sapi_info->preprocess == PREPROCESS_PREPROCESS) {
php3_printf("Can't preprocess while displaying source.<br>\n");
return FAILURE;
}
if (sapi_info->preprocess == PREPROCESS_EXECUTE) {
tcm_load(&GLOBAL(token_cache_manager));
GLOBAL(php3_preprocess) = PREPROCESS_NONE;
}
if (sapi_info->preprocess==PREPROCESS_NONE) {
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: start php3_parse() file:%s\n",GLOBAL(sapi_rqst)->scid,GLOBAL(sapi_rqst)->filename);
OutputDebugString(logmessage);
#endif
php3_parse(GLOBAL(phpin) _INLINE_TLS);
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: done php3_parse()\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
} else {
pval yylval;
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: entering phplex()\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
#ifdef THREAD_SAFE
while (phplex(&yylval, php3_globals, php_gbl)); /* create the token cache */
#else
while (phplex(&yylval)); /* create the token cache */
#endif
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: done phplex()\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
tcm_save(&GLOBAL(token_cache_manager));
}
if (sapi_info->display_source_mode) {
php3_printf("\n</html>\n");
}
if (GLOBAL(initialized)) {
php3_header(); /* Make sure headers have been sent */
php3_request_shutdown((void *) GLOBAL(sapi_rqst), php3_globals);
/*php3_module_shutdown(php3_globals);*/
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: success!\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
return SUCCESS;
} else {
#if DEBUG
snprintf(logmessage,1024,"%d:php3_sapi_main: request not initialized!\n",GLOBAL(sapi_rqst)->scid);
OutputDebugString(logmessage);
#endif
return FAILURE;
}
}
#if WIN32|WINNT
extern int tls_create(void);
extern int tls_destroy(void);
extern int tls_startup(void);
extern int tls_shutdown(void);
extern flex_globals *yy_init_tls(void);
extern void yy_destroy_tls(void);
extern VOID ErrorExit(LPTSTR lpszMessage);
BOOL WINAPI DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
php3_globals_struct *php3_globals;
#if DEBUG
OutputDebugString("PHP_Core DllMain Entry\n");
#endif
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
/*
I should be loading ini vars here
and doing whatever true global inits
need to be done
*/
_fmode = _O_BINARY; /*sets default for file streams to binary */
/* make the stdio mode be binary */
setmode(_fileno(stdin), O_BINARY);
setmode(_fileno(stdout), O_BINARY);
setmode(_fileno(stderr), O_BINARY);
setlocale(LC_CTYPE, "");
CREATE_MUTEX(gLock, "GENERAL");
if (!tls_startup())
return 0;
if (!tls_create())
return 0;
php3_globals = TlsGetValue(TlsIndex);
yy_init_tls();
if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) {
return 0;
}
if (php3_module_startup() == FAILURE) {
ErrorExit("module startup failed");
return 0;
}
#if DEBUG
OutputDebugString("PHP_Core DllMain Process Attached\n");
#endif
break;
case DLL_THREAD_ATTACH:
#if DEBUG
OutputDebugString("PHP_Core DllMain Thread Attach\n");
#endif
if (!tls_create())
return 0;
php3_globals = TlsGetValue(TlsIndex);
yy_init_tls();
if (php3_module_startup() == FAILURE) {
ErrorExit("module startup failed");
#if DEBUG
OutputDebugString("PHP_Core DllMain module startup failed\n");
#endif
return 0;
}
break;
case DLL_THREAD_DETACH:
#if DEBUG
OutputDebugString("PHP_Core DllMain Detache\n");
#endif
php3_globals = TlsGetValue(TlsIndex);
php3_module_shutdown(php3_globals);
if (!tls_destroy())
#if DEBUG
OutputDebugString("PHP_Core DllMain Detache Error tls_destroy\n");
#endif
return 0;
yy_destroy_tls();
break;
case DLL_PROCESS_DETACH:
/*
close down anything down in process_attach
*/
php3_globals = TlsGetValue(TlsIndex);
php3_module_shutdown(php3_globals);
php3_config_ini_shutdown(_INLINE_TLS_VOID);
if (!tls_destroy())
#if DEBUG
OutputDebugString("PHP_Core DllMain tls_destroy failed\n");
#endif
return 0;
if (!tls_shutdown())
#if DEBUG
OutputDebugString("PHP_Core DllMain tls_shutdown failed\n");
#endif
return 0;
yy_destroy_tls();
#if DEBUG
OutputDebugString("PHP_Core DllMain Process Detatched\n");
#endif
break;
}
#if DEBUG
OutputDebugString("PHP_Core DllMain Successful Exit\n");
#endif
return 1;
}
#endif
#endif
/* /*
* Local variables: * Local variables:
* tab-width: 4 * tab-width: 4

View file

@ -117,43 +117,10 @@ extern unsigned char second_arg_allow_ref[];
# endif # endif
#endif #endif
/*Thread Safety*/
#if THREAD_SAFE
#define GLOBAL(a) php3_globals->a
#define STATIC GLOBAL
#define TLS_VARS \
php3_globals_struct *php3_globals; \
php3_globals = TlsGetValue(TlsIndex);
#define CREATE_MUTEX(a,b) a = CreateMutex (NULL, FALSE, b);
#define SET_MUTEX(a) WaitForSingleObject( a, INFINITE );
#define FREE_MUTEX(a) ReleaseMutex(a);
/*redirect variables to the flex structure*/
#if !defined(YY_BUFFER_NEW) && !defined(COMPILE_DL)
#include "FlexSafe.h"
#endif
#define INLINE_TLS ,struct php3_global_struct *php3_globals
#define INLINE_TLS_VOID struct php3_global_struct *php3_globals
#define _INLINE_TLS ,php3_globals
#define _INLINE_TLS_VOID php3_globals
#else
#define GLOBAL(a) a
#define STATIC GLOBAL
#define TLS_VARS
#define CREATE_MUTEX(a,b) #define CREATE_MUTEX(a,b)
#define SET_MUTEX(a) #define SET_MUTEX(a)
#define FREE_MUTEX(a) #define FREE_MUTEX(a)
/* needed in control structures */
#define INLINE_TLS
#define INLINE_TLS_VOID void
#define _INLINE_TLS
#define _INLINE_TLS_VOID
#endif
/* /*
* Then the ODBC support can use both iodbc and Solid, * Then the ODBC support can use both iodbc and Solid,
* uncomment this. * uncomment this.

View file

@ -125,30 +125,29 @@ PHPAPI char *_php3_get_current_user()
#endif #endif
struct passwd *pwd; struct passwd *pwd;
int uid; int uid;
TLS_VARS;
if (GLOBAL(request_info).current_user) { if (request_info.current_user) {
return GLOBAL(request_info).current_user; return request_info.current_user;
} }
/* FIXME: I need to have this somehow handled if /* FIXME: I need to have this somehow handled if
USE_SAPI is defined, because cgi will also be USE_SAPI is defined, because cgi will also be
interfaced in USE_SAPI */ interfaced in USE_SAPI */
#if CGI_BINARY || USE_SAPI || FHTTPD #if CGI_BINARY || USE_SAPI || FHTTPD
if (!GLOBAL(request_info).filename || (stat(GLOBAL(request_info).filename,&statbuf)==-1)) { if (!request_info.filename || (stat(request_info.filename,&statbuf)==-1)) {
return empty_string; return empty_string;
} }
uid = statbuf.st_uid; uid = statbuf.st_uid;
#endif #endif
#if APACHE #if APACHE
uid = GLOBAL(php3_rqst)->finfo.st_uid; uid = php3_rqst->finfo.st_uid;
#endif #endif
if ((pwd=getpwuid(uid))==NULL) { if ((pwd=getpwuid(uid))==NULL) {
return empty_string; return empty_string;
} }
GLOBAL(request_info).current_user_length = strlen(pwd->pw_name); request_info.current_user_length = strlen(pwd->pw_name);
GLOBAL(request_info).current_user = estrndup(pwd->pw_name,GLOBAL(request_info).current_user_length); request_info.current_user = estrndup(pwd->pw_name,request_info.current_user_length);
return GLOBAL(request_info).current_user; return request_info.current_user;
} }

View file

@ -67,23 +67,8 @@
module MODULE_VAR_EXPORT php3_module; module MODULE_VAR_EXPORT php3_module;
#ifndef THREAD_SAFE
int saved_umask; int saved_umask;
#else
#define GLOBAL(a) php3_globals->a
#define STATIC GLOBAL
#define TLS_VARS \
php3_globals_struct *php3_globals; \
php3_globals = TlsGetValue(TlsIndex);
#endif
#ifndef TLS_VARS
#define TLS_VARS
#endif
#ifndef GLOBAL
#define GLOBAL(x) x
#endif
#if WIN32|WINNT #if WIN32|WINNT
/* popenf isn't working on Windows, use open instead*/ /* popenf isn't working on Windows, use open instead*/
@ -167,15 +152,13 @@ BOOL WINAPI DllMain(HANDLE hModule,
void php3_save_umask() void php3_save_umask()
{ {
TLS_VARS; saved_umask = umask(077);
GLOBAL(saved_umask) = umask(077); umask(saved_umask);
umask(GLOBAL(saved_umask));
} }
void php3_restore_umask() void php3_restore_umask()
{ {
TLS_VARS; umask(saved_umask);
umask(GLOBAL(saved_umask));
} }
int send_php3(request_rec *r, int display_source_mode, char *filename) int send_php3(request_rec *r, int display_source_mode, char *filename)

View file

@ -197,8 +197,8 @@ static int zend_ub_body_write(const char *str, uint str_length)
static int zend_apache_ub_write(const char *str, uint str_length) static int zend_apache_ub_write(const char *str, uint str_length)
{ {
if (GLOBAL(php3_rqst)) { if (php3_rqst) {
return rwrite(str, str_length, GLOBAL(php3_rqst)); return rwrite(str, str_length, php3_rqst);
} else { } else {
return fwrite(str, 1, str_length, stdout); return fwrite(str, 1, str_length, stdout);
} }

View file

@ -1,79 +0,0 @@
#include <stdio.h>
#include "alloc.h"
#include <errno.h>
#if (WIN32|WINNT)
#include <windows.h>
#else
#include <pthread.h>
#endif
#include "php3_threads.h"
/* Function for allocating memory for mutexes */
static void *php3_mutex_alloc( void )
{
MUTEX_T *mutexp;
/* Allocate memory for the mutex and initialize it */
if ( (mutexp = emalloc( sizeof(MUTEX_T) )) != NULL ) {
MUTEX_INIT( mutexp, NULL );
}
return( mutexp );
}
/* Function for freeing mutexes */
static void php3_mutex_free( void *mutexp )
{
MUTEX_DESTROY( (MUTEX_T *) mutexp );
}
static void php3_mutex_lock( void *mutexp )
{
return MUTEX_LOCK(mutexp);
}
static void php3_mutex_unlock( void *mutexp )
{
return MUTEX_UNLOCK(mutexp);
}
/* Function for setting up thread-specific data */
/* should be called at thread start */
int php3_tls_init(void *key,void *tsd,int size)
{
/* Check if thread-specific data already exists */
tsd = TLS_GET_DATA( key );
if ( tsd != NULL ) {
/*FIXME what kind of output here? */
fprintf( stderr, "php3_tls_setup tls var non-null!\n" );
THREAD_EXIT( NULL );
}
/* Allocate memory for the LDAP error values */
tsd = (void *) ecalloc( 1, size );
/* Make the data specific to the calling thread */
TLS_SET_DATA( key, tsd );
}
/*should be called before thread exit*/
int php3_tls_free(void *key, void *tsd)
{
if (tsd)efree(tsd);
}
/*should be called at dl or process startup*/
int php3_tls_startup(void *key)
{
if (key == NULL){
if (TLS_ALLOC(key)==TLS_NOT_ALLOCED)
return 0;
}
return 1;
}
/*should be called before dl or process exit*/
int php3_tls_shutdown(void *key)
{
if (key != NULL){
if (!TLS_FREE(key))
return 0;
}
return 1;
}

View file

@ -1,33 +0,0 @@
#if WIN32|WINNT
#define MUTEX_T void
#define MUTEX_INIT(a,b) (a=CreateMutex(b,FALSE,NULL))
#define MUTEX_DESTROY(a) CloseHandle(a)
#define MUTEX_LOCK(a) WaitForSingleObject(a,INFINITE)
#define MUTEX_UNLOCK(a) ReleaseMutex(a)
#define TLS_ALLOC(a) (a=TlsAlloc())
#define TLS_NOT_ALLOCED 0xFFFFFFFF
#define TLS_GET_DATA(a) TlsGetValue(a)
#define TLS_SET_DATA(a,b) TlsSetValue(a,b)
#define TLS_FREE(a) TlsFree(a)
#else /*PTHREADS*/
#define MUTEX_T pthread_mutex_t
#define MUTEX_INIT(a,b) pthread_mutex_init(a,b)
#define MUTEX_DESTROY(a) pthread_mutex_destroy(a)
#define MUTEX_LOCK(a) pthread_mutex_lock(a)
#define MUTEX_UNLOCK(a) pthread_mutex_unlock(a)
#define TLS_ALLOC(a)
#define TLS_NOT_ALLOCED NULL
#define TLS_GET_DATA(a) pthread_getspecific(a)
#define TLS_SET_DATA(a,b) pthread_setspecific(a,b)
#define TLS_FREE(a)
#endif
extern static void *php3_mutex_alloc( void );
extern static void php3_mutex_free( void *mutexp );
extern static void php3_mutex_lock( void *mutexp );
extern static void php3_mutex_unlock( void *mutexp );
extern int php3_tls_init(void *key,void *tsd,int size);
extern int php3_tls_free(void *key, void *tsd);
extern int php3_tls_startup(void *key);
extern int php3_tls_shutdown(void *key);

View file

@ -161,10 +161,6 @@ SOURCE=".\configuration-parser.tab.h"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\control_structures.h
# End Source File
# Begin Source File
SOURCE=.\ext\standard\cyr_convert.h SOURCE=.\ext\standard\cyr_convert.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -161,10 +161,6 @@ SOURCE=".\configuration-parser.tab.h"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\control_structures.h
# End Source File
# Begin Source File
SOURCE=.\ext\standard\cyr_convert.h SOURCE=.\ext\standard\cyr_convert.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -37,23 +37,22 @@ php3_request_info request_info;
int php3_init_request_info(void *conf) int php3_init_request_info(void *conf)
{ {
char *buf; /* temporary buffers */ char *buf; /* temporary buffers */
TLS_VARS;
GLOBAL(request_info).path_info = getenv("PATH_INFO"); request_info.path_info = getenv("PATH_INFO");
GLOBAL(request_info).path_translated = getenv("PATH_TRANSLATED"); request_info.path_translated = getenv("PATH_TRANSLATED");
GLOBAL(request_info).query_string = getenv("QUERY_STRING"); request_info.query_string = getenv("QUERY_STRING");
GLOBAL(request_info).current_user = NULL; request_info.current_user = NULL;
GLOBAL(request_info).current_user_length = 0; request_info.current_user_length = 0;
GLOBAL(request_info).request_method = getenv("REQUEST_METHOD"); request_info.request_method = getenv("REQUEST_METHOD");
GLOBAL(request_info).script_name = getenv("SCRIPT_NAME"); request_info.script_name = getenv("SCRIPT_NAME");
buf = getenv("CONTENT_LENGTH"); buf = getenv("CONTENT_LENGTH");
GLOBAL(request_info).content_length = (buf ? atoi(buf) : 0); request_info.content_length = (buf ? atoi(buf) : 0);
GLOBAL(request_info).content_type = getenv("CONTENT_TYPE"); request_info.content_type = getenv("CONTENT_TYPE");
GLOBAL(request_info).cookies = getenv("HTTP_COOKIE"); request_info.cookies = getenv("HTTP_COOKIE");
GLOBAL(request_info).script_filename = getenv("SCRIPT_FILENAME"); request_info.script_filename = getenv("SCRIPT_FILENAME");
/* Hack for annoying servers that do not set SCRIPT_FILENAME for us */ /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */
if (!GLOBAL(request_info).script_filename) { if (!request_info.script_filename) {
GLOBAL(request_info).script_filename = GLOBAL(request_info).php_argv0; request_info.script_filename = request_info.php_argv0;
} }
#if WIN32|WINNT #if WIN32|WINNT
/* FIXME WHEN APACHE NT IS FIXED */ /* FIXME WHEN APACHE NT IS FIXED */
@ -61,10 +60,10 @@ int php3_init_request_info(void *conf)
script filename to php.exe thus makes us parse php.exe instead of file.php script filename to php.exe thus makes us parse php.exe instead of file.php
requires we get the info from path translated. This can be removed at requires we get the info from path translated. This can be removed at
such a time taht apache nt is fixed */ such a time taht apache nt is fixed */
else if (GLOBAL(request_info).path_translated) { else if (request_info.path_translated) {
GLOBAL(request_info).script_filename = GLOBAL(request_info).path_translated; request_info.script_filename = request_info.path_translated;
} else { } else {
GLOBAL(request_info).script_filename = NULL; request_info.script_filename = NULL;
} }
#endif #endif
@ -76,16 +75,16 @@ int php3_init_request_info(void *conf)
Notice that this means that we don't need to efree() it in Notice that this means that we don't need to efree() it in
php3_destroy_request_info()! */ php3_destroy_request_info()! */
#if DISCARD_PATH #if DISCARD_PATH
if (GLOBAL(request_info).script_filename) { if (request_info.script_filename) {
GLOBAL(request_info).filename = estrdup(GLOBAL(request_info).script_filename); request_info.filename = estrdup(request_info.script_filename);
} else { } else {
GLOBAL(request_info).filename = NULL; request_info.filename = NULL;
} }
#else #else
if (GLOBAL(request_info).path_translated) { if (request_info.path_translated) {
GLOBAL(request_info).filename = estrdup(GLOBAL(request_info).path_translated); request_info.filename = estrdup(request_info.path_translated);
} else { } else {
GLOBAL(request_info).filename = NULL; request_info.filename = NULL;
} }
#endif #endif
return SUCCESS; return SUCCESS;
@ -93,7 +92,7 @@ int php3_init_request_info(void *conf)
int php3_destroy_request_info(void *conf) int php3_destroy_request_info(void *conf)
{ {
STR_FREE(GLOBAL(request_info).current_user); STR_FREE(request_info.current_user);
return SUCCESS; return SUCCESS;
} }
#endif #endif
@ -107,7 +106,6 @@ int php3_init_request_info(void *conf)
{ {
static int exit_requested = 0; static int exit_requested = 0;
int i, len; int i, len;
TLS_VARS;
req = NULL; req = NULL;
setalarm(idle_timeout); setalarm(idle_timeout);
@ -123,22 +121,22 @@ int php3_init_request_info(void *conf)
strncpy(script_name_resolved_buffer, req->script_name_resolved, 2047); strncpy(script_name_resolved_buffer, req->script_name_resolved, 2047);
script_name_resolved_buffer[2047] = 0; script_name_resolved_buffer[2047] = 0;
GLOBAL(request_info).path_info = NULL; /* Not supported */ request_info.path_info = NULL; /* Not supported */
GLOBAL(request_info).path_translated = script_name_resolved_buffer; request_info.path_translated = script_name_resolved_buffer;
GLOBAL(request_info).query_string = req->query_string; request_info.query_string = req->query_string;
GLOBAL(request_info).current_user = NULL; request_info.current_user = NULL;
GLOBAL(request_info).current_user_length = 0; request_info.current_user_length = 0;
GLOBAL(request_info).request_method = method_names[req->method]; request_info.request_method = method_names[req->method];
GLOBAL(request_info).script_name = req->script_name; request_info.script_name = req->script_name;
GLOBAL(request_info).content_length = req->databuffsize; request_info.content_length = req->databuffsize;
GLOBAL(request_info).content_type = req->content_type; request_info.content_type = req->content_type;
GLOBAL(request_info).cookies = NULL; request_info.cookies = NULL;
for (i = 0; i < req->nlines; i++) { for (i = 0; i < req->nlines; i++) {
if (req->lines[i].paramc > 1) { if (req->lines[i].paramc > 1) {
if (req->lines[i].params[0]) { if (req->lines[i].params[0]) {
if (!strcasecmp(req->lines[i].params[0], "HTTP_COOKIE")) { if (!strcasecmp(req->lines[i].params[0], "HTTP_COOKIE")) {
if (req->lines[i].params[1]) { if (req->lines[i].params[1]) {
GLOBAL(request_info).cookies = req->lines[i].params[1]; request_info.cookies = req->lines[i].params[1];
} }
} }
} }
@ -151,10 +149,10 @@ int php3_init_request_info(void *conf)
the include file hash table, and gets freed with that table. the include file hash table, and gets freed with that table.
Notice that this means that we don't need to efree() it in Notice that this means that we don't need to efree() it in
php3_destroy_request_info()! */ php3_destroy_request_info()! */
if (GLOBAL(request_info).path_translated) if (request_info.path_translated)
GLOBAL(request_info).filename = estrdup(GLOBAL(request_info).path_translated); request_info.filename = estrdup(request_info.path_translated);
else else
GLOBAL(request_info).filename = NULL; request_info.filename = NULL;
return SUCCESS; return SUCCESS;
} else { } else {
@ -196,20 +194,19 @@ int php3_init_request_info(void *conf)
int php3_init_request_info(void *conf) int php3_init_request_info(void *conf)
{ {
const char *buf; const char *buf;
TLS_VARS;
GLOBAL(request_info).current_user = NULL; request_info.current_user = NULL;
GLOBAL(request_info).current_user_length = 0; request_info.current_user_length = 0;
GLOBAL(request_info).filename = GLOBAL(php3_rqst)->filename; request_info.filename = php3_rqst->filename;
GLOBAL(request_info).request_method = GLOBAL(php3_rqst)->method; request_info.request_method = php3_rqst->method;
GLOBAL(request_info).query_string = GLOBAL(php3_rqst)->args; request_info.query_string = php3_rqst->args;
GLOBAL(request_info).content_type = table_get(GLOBAL(php3_rqst)->subprocess_env, "CONTENT_TYPE"); request_info.content_type = table_get(php3_rqst->subprocess_env, "CONTENT_TYPE");
buf = table_get(GLOBAL(php3_rqst)->subprocess_env, "CONTENT_LENGTH"); buf = table_get(php3_rqst->subprocess_env, "CONTENT_LENGTH");
GLOBAL(request_info).content_length = (buf ? atoi(buf) : 0); request_info.content_length = (buf ? atoi(buf) : 0);
GLOBAL(request_info).cookies = table_get(GLOBAL(php3_rqst)->subprocess_env, "HTTP_COOKIE"); request_info.cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
return SUCCESS; return SUCCESS;
} }
@ -220,21 +217,20 @@ int php3_init_request_info(void *conf)
/* temporary until I figure a beter way to do it */ /* temporary until I figure a beter way to do it */
int php3_init_request_info(void *conf) int php3_init_request_info(void *conf)
{ {
TLS_VARS; if (sapi_rqst->filename)
if (GLOBAL(sapi_rqst)->filename) request_info.filename = estrdup(sapi_rqst->filename);
GLOBAL(request_info).filename = estrdup(GLOBAL(sapi_rqst)->filename);
else else
GLOBAL(request_info).filename = NULL; request_info.filename = NULL;
GLOBAL(request_info).path_info = GLOBAL(sapi_rqst)->path_info; request_info.path_info = sapi_rqst->path_info;
GLOBAL(request_info).path_translated = GLOBAL(sapi_rqst)->path_translated; request_info.path_translated = sapi_rqst->path_translated;
GLOBAL(request_info).query_string = GLOBAL(sapi_rqst)->query_string; request_info.query_string = sapi_rqst->query_string;
GLOBAL(request_info).current_user = GLOBAL(sapi_rqst)->current_user; request_info.current_user = sapi_rqst->current_user;
GLOBAL(request_info).current_user_length = GLOBAL(sapi_rqst)->current_user_length; request_info.current_user_length = sapi_rqst->current_user_length;
GLOBAL(request_info).request_method = GLOBAL(sapi_rqst)->request_method; request_info.request_method = sapi_rqst->request_method;
GLOBAL(request_info).script_name = GLOBAL(sapi_rqst)->script_name; request_info.script_name = sapi_rqst->script_name;
GLOBAL(request_info).content_length = GLOBAL(sapi_rqst)->content_length; request_info.content_length = sapi_rqst->content_length;
GLOBAL(request_info).content_type = GLOBAL(sapi_rqst)->content_type; request_info.content_type = sapi_rqst->content_type;
GLOBAL(request_info).cookies = GLOBAL(sapi_rqst)->cookies; request_info.cookies = sapi_rqst->cookies;
return SUCCESS; return SUCCESS;
} }

View file

@ -57,14 +57,12 @@ char *getlogin()
struct passwd * struct passwd *
getpwuid(int uid) getpwuid(int uid)
{ {
TLS_VARS; pw.pw_name = getlogin();
pw.pw_dir = home_dir;
pw.pw_shell = login_shell;
pw.pw_uid = 0;
GLOBAL(pw).pw_name = getlogin(); return &pw;
GLOBAL(pw).pw_dir = home_dir;
GLOBAL(pw).pw_shell = login_shell;
GLOBAL(pw).pw_uid = 0;
return &GLOBAL(pw);
} }
/* /*

View file

@ -109,9 +109,8 @@ int TSendMail(char *host, int *error,
{ {
int ret; int ret;
char *RPath = NULL; char *RPath = NULL;
TLS_VARS;
GLOBAL(WinsockStarted) = FALSE; WinsockStarted = FALSE;
if (host == NULL) { if (host == NULL) {
*error = BAD_MAIL_HOST; *error = BAD_MAIL_HOST;
@ -120,7 +119,7 @@ int TSendMail(char *host, int *error,
*error = BAD_MAIL_HOST; *error = BAD_MAIL_HOST;
return BAD_MAIL_HOST; return BAD_MAIL_HOST;
} else { } else {
strcpy(GLOBAL(MailHost), host); strcpy(MailHost, host);
} }
if (INI_STR("sendmail_from")){ if (INI_STR("sendmail_from")){
@ -155,8 +154,6 @@ int TSendMail(char *host, int *error,
//******************************************************************** //********************************************************************
void TSMClose() void TSMClose()
{ {
TLS_VARS;
Post("QUIT\n"); Post("QUIT\n");
Ack(); Ack();
// to guarantee that the cleanup is not made twice and // to guarantee that the cleanup is not made twice and
@ -202,7 +199,6 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
int res, i; int res, i;
char *p; char *p;
TLS_VARS;
// check for NULL parameters // check for NULL parameters
if (data == NULL) if (data == NULL)
@ -217,27 +213,27 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
if (strchr(mailTo, '@') == NULL) if (strchr(mailTo, '@') == NULL)
return (BAD_MSG_DESTINATION); return (BAD_MSG_DESTINATION);
sprintf(GLOBAL(Buffer), "HELO %s\n", GLOBAL(LocalHost)); sprintf(Buffer, "HELO %s\n", LocalHost);
// in the beggining of the dialog // in the beggining of the dialog
// attempt reconnect if the first Post fail // attempt reconnect if the first Post fail
if ((res = Post(GLOBAL(Buffer))) != SUCCESS) { if ((res = Post(Buffer)) != SUCCESS) {
MailConnect(); MailConnect();
if ((res = Post(GLOBAL(Buffer))) != SUCCESS) if ((res = Post(Buffer)) != SUCCESS)
return (res); return (res);
} }
if ((res = Ack()) != SUCCESS) if ((res = Ack()) != SUCCESS)
return (res); return (res);
sprintf(GLOBAL(Buffer), "MAIL FROM:<%s>\n", RPath); sprintf(Buffer, "MAIL FROM:<%s>\n", RPath);
if ((res = Post(GLOBAL(Buffer))) != SUCCESS) if ((res = Post(Buffer)) != SUCCESS)
return (res); return (res);
if ((res = Ack()) != SUCCESS) if ((res = Ack()) != SUCCESS)
return (res); return (res);
sprintf(GLOBAL(Buffer), "RCPT TO:<%s>\n", mailTo); sprintf(Buffer, "RCPT TO:<%s>\n", mailTo);
if ((res = Post(GLOBAL(Buffer))) != SUCCESS) if ((res = Post(Buffer)) != SUCCESS)
return (res); return (res);
if ((res = Ack()) != SUCCESS) if ((res = Ack()) != SUCCESS)
return (res); return (res);
@ -272,12 +268,12 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
i = strlen(p); i = strlen(p);
// put next chunk in buffer // put next chunk in buffer
strncpy(GLOBAL(Buffer), p, i); strncpy(Buffer, p, i);
GLOBAL(Buffer)[i] = '\0'; Buffer[i] = '\0';
p += i; p += i;
// send chunk // send chunk
if ((res = Post(GLOBAL(Buffer))) != SUCCESS) if ((res = Post(Buffer)) != SUCCESS)
return (res); return (res);
} }
} }
@ -315,9 +311,8 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
int zoneh = abs(_timezone); int zoneh = abs(_timezone);
int zonem, res; int zonem, res;
char *p; char *p;
TLS_VARS;
p = GLOBAL(Buffer); p = Buffer;
zoneh /= (60 * 60); zoneh /= (60 * 60);
zonem = (abs(_timezone) / 60) - (zoneh * 60); zonem = (abs(_timezone) / 60) - (zoneh * 60);
@ -342,7 +337,7 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
p += sprintf(p, "%s\r\n", xheaders); p += sprintf(p, "%s\r\n", xheaders);
} }
if ((res = Post(GLOBAL(Buffer))) != SUCCESS) if ((res = Post(Buffer)) != SUCCESS)
return (res); return (res);
if ((res = Post("\r\n")) != SUCCESS) if ((res = Post("\r\n")) != SUCCESS)
@ -365,29 +360,27 @@ int MailConnect()
{ {
int res; int res;
TLS_VARS;
// Create Socket // Create Socket
if ((GLOBAL(sc) = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
return (FAILED_TO_OBTAIN_SOCKET_HANDLE); return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
// Get our own host name // Get our own host name
if (gethostname(GLOBAL(LocalHost), HOST_NAME_LEN)) if (gethostname(LocalHost, HOST_NAME_LEN))
return (FAILED_TO_GET_HOSTNAME); return (FAILED_TO_GET_HOSTNAME);
// Resolve the servers IP // Resolve the servers IP
//if (!isdigit(GLOBAL(MailHost)[0])||!gethostbyname(GLOBAL(MailHost))) //if (!isdigit(MailHost[0])||!gethostbyname(MailHost))
//{ //{
// return (FAILED_TO_RESOLVE_HOST); // return (FAILED_TO_RESOLVE_HOST);
//} //}
// Connect to server // Connect to server
GLOBAL(sock_in).sin_family = AF_INET; sock_in.sin_family = AF_INET;
GLOBAL(sock_in).sin_port = htons(25); sock_in.sin_port = htons(25);
GLOBAL(sock_in).sin_addr.S_un.S_addr = GetAddr(GLOBAL(MailHost)); sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost);
if (connect(GLOBAL(sc), (LPSOCKADDR) & GLOBAL(sock_in), sizeof(GLOBAL(sock_in)))) if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in)))
return (FAILED_TO_CONNECT); return (FAILED_TO_CONNECT);
// receive Server welcome message // receive Server welcome message
@ -413,10 +406,9 @@ int Post(LPCSTR msg)
int len = strlen(msg); int len = strlen(msg);
int slen; int slen;
int index = 0; int index = 0;
TLS_VARS;
while (len > 0) { while (len > 0) {
if ((slen = send(GLOBAL(sc), msg + index, len, 0)) < 1) if ((slen = send(sc, msg + index, len, 0)) < 1)
return (FAILED_TO_SEND); return (FAILED_TO_SEND);
len -= slen; len -= slen;
index += slen; index += slen;
@ -442,7 +434,6 @@ int Ack()
int rlen; int rlen;
int Index = 0; int Index = 0;
int Received = 0; int Received = 0;
TLS_VARS;
if (!buf) if (!buf)
if ((buf = (char *) malloc(1024 * 4)) == NULL) if ((buf = (char *) malloc(1024 * 4)) == NULL)
@ -450,7 +441,7 @@ int Ack()
again: again:
if ((rlen = recv(GLOBAL(sc), buf + Index, ((1024 * 4) - 1) - Received, 0)) < 1) if ((rlen = recv(sc, buf + Index, ((1024 * 4) - 1) - Received, 0)) < 1)
return (FAILED_TO_RECEIVE); return (FAILED_TO_RECEIVE);
Received += rlen; Received += rlen;

View file

@ -101,10 +101,9 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
{ {
int timeout = value->it_value.tv_sec * 1000 + value->it_value.tv_usec; int timeout = value->it_value.tv_sec * 1000 + value->it_value.tv_usec;
int repeat = TIME_ONESHOT; int repeat = TIME_ONESHOT;
TLS_VARS;
/*make sure the message queue is initialized */ /*make sure the message queue is initialized */
PeekMessage(GLOBAL(phpmsg), NULL, WM_USER, WM_USER, PM_NOREMOVE); PeekMessage(phpmsg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
if (timeout > 0) { if (timeout > 0) {
struct timer_msg *msg = malloc(sizeof(struct timer_msg)); struct timer_msg *msg = malloc(sizeof(struct timer_msg));
msg->threadid = GetCurrentThreadId(); msg->threadid = GetCurrentThreadId();
@ -114,15 +113,15 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
switch (which) { switch (which) {
case ITIMER_REAL: case ITIMER_REAL:
msg->signal = SIGALRM; msg->signal = SIGALRM;
GLOBAL(realtimer) = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); realtimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
break; break;
case ITIMER_VIRT: case ITIMER_VIRT:
msg->signal = SIGVTALRM; msg->signal = SIGVTALRM;
GLOBAL(virttimer) = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); virttimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
break; break;
case ITIMER_PROF: case ITIMER_PROF:
msg->signal = SIGPROF; msg->signal = SIGPROF;
GLOBAL(proftimer) = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); proftimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
break; break;
default: default:
errno = EINVAL; errno = EINVAL;
@ -132,13 +131,13 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
} else { } else {
switch (which) { switch (which) {
case ITIMER_REAL: case ITIMER_REAL:
timeKillEvent(GLOBAL(realtimer)); timeKillEvent(realtimer);
break; break;
case ITIMER_VIRT: case ITIMER_VIRT:
timeKillEvent(GLOBAL(virttimer)); timeKillEvent(virttimer);
break; break;
case ITIMER_PROF: case ITIMER_PROF:
timeKillEvent(GLOBAL(proftimer)); timeKillEvent(proftimer);
break; break;
default: default:
errno = EINVAL; errno = EINVAL;

View file

@ -63,9 +63,8 @@ static HANDLE loghdl = NULL; /* handle of event source */
void closelog(void) void closelog(void)
{ {
TLS_VARS; DeregisterEventSource(loghdl);
DeregisterEventSource(GLOBAL(loghdl)); efree(loghdr);
efree(GLOBAL(loghdr));
} }
/* Emulator for BSD syslog() routine /* Emulator for BSD syslog() routine
@ -80,10 +79,9 @@ void syslog(int priority, const char *message,...)
LPTSTR strs[2]; LPTSTR strs[2];
char tmp[1024]; /* callers must be careful not to pop this */ char tmp[1024]; /* callers must be careful not to pop this */
unsigned short etype; unsigned short etype;
TLS_VARS;
/* default event source */ /* default event source */
if (!GLOBAL(loghdl)) if (!loghdl)
openlog("c-client", LOG_PID, LOG_MAIL); openlog("c-client", LOG_PID, LOG_MAIL);
switch (priority) { /* translate UNIX type into NT type */ switch (priority) { /* translate UNIX type into NT type */
case LOG_ALERT: case LOG_ALERT:
@ -97,10 +95,10 @@ void syslog(int priority, const char *message,...)
} }
va_start(args, message); /* initialize vararg mechanism */ va_start(args, message); /* initialize vararg mechanism */
vsprintf(tmp, message, args); /* build message */ vsprintf(tmp, message, args); /* build message */
strs[0] = GLOBAL(loghdr); /* write header */ strs[0] = loghdr; /* write header */
strs[1] = tmp; /* then the message */ strs[1] = tmp; /* then the message */
/* report the event */ /* report the event */
ReportEvent(GLOBAL(loghdl), etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL); ReportEvent(loghdl, etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL);
va_end(args); va_end(args);
} }
@ -114,12 +112,11 @@ void syslog(int priority, const char *message,...)
void openlog(const char *ident, int logopt, int facility) void openlog(const char *ident, int logopt, int facility)
{ {
char tmp[1024]; char tmp[1024];
TLS_VARS;
if (GLOBAL(loghdl)) { if (loghdl) {
closelog(); closelog();
} }
GLOBAL(loghdl) = RegisterEventSource(NULL, ident); loghdl = RegisterEventSource(NULL, ident);
sprintf(tmp, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid()); sprintf(tmp, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
GLOBAL(loghdr) = estrdup(tmp); /* save header for later */ loghdr = estrdup(tmp); /* save header for later */
} }