1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
|
/*
+----------------------------------------------------------------------+
| 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@php.net> |
| Zeev Suraski <bourbon@netvision.net.il> |
+----------------------------------------------------------------------+
*/
/* $Id: php.h,v 1.24 1998/06/04 17:00:05 rasmus Exp $ */
#ifndef _PHP_H
#define _PHP_H
#define YYDEBUG 0
#define CGI_BINARY (!APACHE && !USE_SAPI && !FHTTPD)
#include "php_version.h"
/* somebody stealing BOOL from windows. pick something else!
#ifndef BOOL
#define BOOL MYBOOL
#endif
*/
#if DEBUG || !(defined(__GNUC__)||defined(WIN32))
#ifdef inline
#undef inline
#endif
#define inline
#endif
#if MSVC5
#include "config.w32.h"
#include "win95nt.h"
# if defined(COMPILE_DL)
# define PHPAPI __declspec(dllimport)
# else
# define PHPAPI __declspec(dllexport)
# endif
#else
# include "config.h"
# define PHPAPI
# define THREAD_LS
#endif
#if HAVE_UNIX_H
#include <unix.h>
#endif
#if HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include "request_info.h"
#if HAVE_LIBDL
# if MSVC5
# include <windows.h>
# define dlclose FreeLibrary
# define dlopen(a,b) LoadLibrary(a)
# define dlsym GetProcAddress
# else
#if HAVE_DLFCN_H
# include <dlfcn.h>
#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 SET_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,
* uncomment this.
* #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
*/
#include <stdlib.h>
#include <ctype.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_STDARG_H
#include <stdarg.h>
#else
# if HAVE_SYS_VARARGS_H
# include <sys/varargs.h>
# endif
#endif
#include "hash.h"
#include "alloc.h"
#if REGEX
#include "regex/regex.h"
#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */
#define _RX_H 1 /* Try defining these for Linux to */
#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */
#define _H_REGEX 1 /* This one is for AIX */
#else
#include <regex.h>
#endif
#if STDC_HEADERS
# include <string.h>
#else
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#include "safe_mode.h"
#ifndef HAVE_STRERROR
extern char *strerror(int);
#endif
#include "fopen-wrappers.h"
#include "mod_php3.h" /* the php3_ini structure comes from here */
#if APACHE /* apache httpd */
# if HAVE_AP_CONFIG_H
#include "ap_config.h"
# endif
# if HAVE_AP_COMPAT_H
#include "compat.h"
# endif
#include "httpd.h"
#include "http_main.h"
#include "http_core.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_config.h"
#include "http_log.h"
#define BLOCK_INTERRUPTIONS block_alarms()
#define UNBLOCK_INTERRUPTIONS unblock_alarms()
# ifndef THREAD_SAFE
extern request_rec *php3_rqst;
# endif
#endif
#if HAVE_PWD_H
# if MSVC5
#include "win32/pwd.h"
#include "win32/param.h"
# else
#include <pwd.h>
#include <sys/param.h>
# endif
#endif
#if CGI_BINARY /* CGI version */
#define BLOCK_INTERRUPTIONS
#define UNBLOCK_INTERRUPTIONS
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef LONG_MAX
#define LONG_MAX 2147483647L
#endif
#ifndef LONG_MIN
#define LONG_MIN (- LONG_MAX - 1)
#endif
#if FHTTPD /* fhttpd */
#define BLOCK_INTERRUPTIONS
#define UNBLOCK_INTERRUPTIONS
#endif
#if (!HAVE_SNPRINTF)
#define snprintf ap_snprintf
#define vsnprintf ap_vsnprintf
extern int ap_snprintf(char *, size_t, const char *, ...);
extern int ap_vsnprintf(char *, size_t, const char *, va_list);
#endif
extern PHPAPI char *empty_string;
extern PHPAPI char *undefined_variable_string;
#define EXEC_INPUT_BUF 4096
#if APACHE
extern PHPAPI void php3_apache_puts(const char *s);
extern PHPAPI void php3_apache_putc(char c);
#define PUTS(s) php3_apache_puts(s)
#define PUTC(c) php3_apache_putc(c)
#define PHPWRITE(a,n) rwrite((a),(n),GLOBAL(php3_rqst))
#endif
#if FHTTPD
#include <servproc.h>
#ifndef IDLE_TIMEOUT
#define IDLE_TIMEOUT 120
#endif
#ifndef SIGACTARGS
#define SIGACTARGS int n
#endif
extern struct http_server *server;
extern struct request *req;
extern struct httpresponse *response;
extern int global_alarmflag;
extern int idle_timeout;
extern int exit_status;
extern int headermade;
extern char **currentheader;
extern char *headerfirstline;
extern int headerlines;
void alarmhandler(SIGACTARGS);
void setalarm(int t);
int checkinput(int h);
extern PHPAPI void php3_fhttpd_free_header(void);
extern PHPAPI void php3_fhttpd_puts_header(char *s);
extern PHPAPI void php3_fhttpd_puts(char *s);
extern PHPAPI void php3_fhttpd_putc(char c);
extern PHPAPI int php3_fhttpd_write(char *a,int n);
# if !defined(COMPILE_DL)
# define PUTS(s) php3_fhttpd_puts(s)
# define PUTC(c) php3_fhttpd_putc(c)
# define PHPWRITE(a,n) php3_fhttpd_write((a),(n))
# endif
#endif
#if CGI_BINARY
# if !defined(COMPILE_DL)
# define PUTS(a) fputs((a),stdout)
# define PUTC(a) fputc((a),stdout)
# define PHPWRITE(a,n) fwrite((a),(n),1,stdout)
# endif
#endif
#if defined(THREAD_SAFE) && defined(COMPILE_DL)
#define PUTS(a) php3_printf("%s",a)
#define PUTC(a) PUTS(a)
#define PHPWRITE(a,n) php3_write((a),(n))
#endif
#define E_ERROR 0x1
#define E_WARNING 0x2
#define E_PARSE 0x4
#define E_NOTICE 0x8
#define E_CORE_ERROR 0x10
#define E_CORE_WARNING 0x20
#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING)
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
/* data types */
#define IS_LONG 0x1
#define IS_DOUBLE 0x2
#define IS_STRING 0x4
#define IS_ARRAY 0x8
#define IS_USER_FUNCTION 0x10
#define IS_INTERNAL_FUNCTION 0x20
#define IS_UNSUPPORTED_FUNCTION 0x40
#define IS_CLASS 0x80
#define IS_OBJECT 0x100
#define IS_NULL 0x200
#define IS_BC 0x400
#define VALID_FUNCTION (IS_USER_FUNCTION|IS_INTERNAL_FUNCTION)
#define IS_HASH (IS_ARRAY | IS_OBJECT)
/* general definitions */
#undef SUCCESS
#undef FAILURE
#define SUCCESS 0
#define FAILURE -1 /* this MUST stay a negative number, or it may effect functions! */
#define DONT_FREE 0
#define DO_FREE 1
#define PHP3_MIME_TYPE "application/x-httpd-php3"
/* macros */
#undef MIN
#undef MAX
#undef COPY_STRING
#define DO_OR_DIE(retvalue) if (retvalue==FAILURE) { return FAILURE; }
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define STR_FREE(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree(ptr); }
#define COPY_STRING(yy) (yy).value.str.val = (char *) estrndup((yy).value.str.val,(yy).value.str.len)
#define DO_NOTHING 0
#define DO_BREAK 1
#define DO_CONTINUE 2
#ifndef MAXPATHLEN
#define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
#endif
typedef union {
unsigned char switched;
unsigned char included;
unsigned short function_call_type;
unsigned char array_write;
unsigned char error_reporting;
} control_structure_data; /* control-structure data */
typedef struct _pval_struct pval;
#define YYSTYPE pval
#define INTERNAL_FUNCTION_PARAMETERS HashTable *ht, pval *return_value, HashTable *list, HashTable *plist
#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, list, plist
typedef union {
long lval; /* long value */
double dval; /* double value */
struct {
char *val;
int len;
} str;
char chval; /* char value */
HashTable *ht; /* hash table value */
struct {
union {
void (*internal)(INTERNAL_FUNCTION_PARAMETERS);
HashTable *statics; /* static symbol table for user functions */
} addr;
unsigned char *arg_types;
} func;
struct {
pval *yystype; /* used for implementation of multi-dimensional arrays */
int string_offset;
} varptr;
} yystype_value;
struct _pval_struct {
/* Variable information */
unsigned short type; /* active type */
/* Control structures */
control_structure_data cs_data;
unsigned int offset;
yystype_value value; /* value */
};
typedef struct {
char *fname;
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
unsigned char *func_arg_types;
} function_entry;
typedef struct {
int loop_nest_level;
int loop_change_type;
int loop_change_level;
int returned;
HashTable *symbol_table;
HashTable *function_symbol_table;
HashTable *hosting_function_table;
unsigned char *func_arg_types;
int lineno;
char *function_name;
unsigned short function_type;
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
} FunctionState;
/* global variables */
#ifndef THREAD_SAFE
extern HashTable symbol_table, function_table;
extern HashTable include_names;
extern HashTable *active_symbol_table;
extern int phplineno, current_lineno;
extern int error_reporting,tmp_error_reporting;
extern pval *data,globals;
extern FunctionState function_state;
extern int include_count;
#if (!PHP_ISAPI)
extern char **environ;
#endif
#endif
extern PHPAPI int le_index_ptr; /* list entry type for index pointers */
#ifndef THREAD_SAFE
extern int phplex(pval *phplval);
#endif
extern int lex_scan(pval *phplval);
extern void phperror(char *error);
extern PHPAPI void php3_error(int type, const char *format,...);
extern PHPAPI int php3_printf(const char *format,...);
extern void php3_log_err(char *log_message);
extern int Debug(char *format,...);
extern int phpparse(void);
extern int cfgparse(void);
extern void reset_scanner(void);
extern void html_putc(char c);
/* functions */
#ifndef THREAD_SAFE
extern int include_file(pval *file,int display_source);
extern int conditional_include_file(pval *file, pval *return_offset);
extern void initialize_input_file_buffer(FILE *f);
extern void eval_string(pval *str, pval *return_offset, int display_source);
#endif
extern void clean_input_source_stack(void);
extern int hash_environment(void);
extern int module_startup_modules(void);
/*from basic functions*/
extern PHPAPI int _php3_error_log(int opt_err,char *message,char *opt,char *headers);
/* configuration abstraction layer */
extern PHPAPI int cfg_get_long(char *varname, long *result);
extern PHPAPI int cfg_get_double(char *varname, double *result);
extern PHPAPI int cfg_get_string(char *varname, char **result);
extern PHPAPI php3_ini_structure php3_ini;
#include "stack.h"
#include "operators.h"
#include "token_cache.h"
#include "variables.h"
#include "constants.h"
#define RETVAL_LONG(l) { return_value->type = IS_LONG; \
return_value->value.lval = l; }
#define RETVAL_DOUBLE(d) { return_value->type = IS_DOUBLE; \
return_value->value.dval = d; }
#define RETVAL_STRING(s,duplicate) { char *__s=(s); \
return_value->value.str.len = strlen(__s); \
return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s); \
return_value->type = IS_STRING; }
#define RETVAL_STRINGL(s,l,duplicate) { char *__s=(s); int __l=l; \
return_value->value.str.len = __l; \
return_value->value.str.val = (duplicate?estrndup(__s,__l):__s); \
return_value->type = IS_STRING; }
#define RETVAL_FALSE {var_reset(return_value);}
#define RETVAL_TRUE RETVAL_LONG(1L)
#define RETURN_LONG(l) { return_value->type = IS_LONG; \
return_value->value.lval = l; \
return; }
#define RETURN_DOUBLE(d) { return_value->type = IS_DOUBLE; \
return_value->value.dval = d; \
return; }
#define RETURN_STRING(s,duplicate) { char *__s=(s); \
return_value->value.str.len = strlen(__s); \
return_value->value.str.val = (duplicate?estrndup(__s,return_value->value.str.len):__s); \
return_value->type = IS_STRING; \
return; }
#define RETURN_STRINGL(s,l,duplicate) { char *__s=(s); int __l=l; \
return_value->value.str.len = __l; \
return_value->value.str.val = (duplicate?estrndup(__s,__l):__s); \
return_value->type = IS_STRING; \
return; }
/*#define RETURN_NEG RETURN_LONG(-1L) */
#define RETURN_ZERO RETURN_LONG(0L)
#define RETURN_FALSE {var_reset(return_value); return;}
#define RETURN_TRUE RETURN_LONG(1L)
#define SET_VAR_STRING(n,v) { \
{ \
pval var; \
char *str=v; /* prevent 'v' from being evaluated more than once */ \
var.value.str.val = (str); \
var.value.str.len = strlen((str)); \
var.type = IS_STRING; \
hash_update(&GLOBAL(symbol_table), (n), strlen((n))+1, &var, sizeof(pval),NULL); \
} \
}
#define SET_VAR_STRINGL(n,v,l) { \
{ \
pval var; \
char *name=(n); \
var.value.str.val = (v); \
var.value.str.len = (l); \
var.type = IS_STRING; \
hash_update(&GLOBAL(symbol_table), name, strlen(name)+1, &var, sizeof(pval),NULL); \
} \
}
#define SET_VAR_LONG(n,v) { \
{ \
pval var; \
var.value.lval = (v); \
var.type = IS_LONG; \
hash_update(&GLOBAL(symbol_table), (n), strlen((n))+1, &var, sizeof(pval),NULL); \
} \
}
#define SET_VAR_DOUBLE(n,v) { \
{ \
pval var; \
var.value.dval = (v); \
var.type = IS_DOUBLE; \
hash_update(&GLOBAL(symbol_table)), (n), strlen((n))+1, &var, sizeof(pval),NULL); \
} \
}
#ifndef THREAD_SAFE
extern int yylineno;
#endif
extern void phprestart(FILE *input_file);
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
|