php-src/main/php.h

360 lines
8.8 KiB
C
Raw Normal View History

2001-04-17 17:03:18 +00:00
/*
1999-04-07 21:05:13 +00:00
+----------------------------------------------------------------------+
1999-07-16 13:13:16 +00:00
| PHP version 4.0 |
1999-04-07 21:05:13 +00:00
+----------------------------------------------------------------------+
2001-02-26 06:11:02 +00:00
| Copyright (c) 1997-2001 The PHP Group |
1999-04-07 21:05:13 +00:00
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
1999-07-16 13:13:16 +00:00
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
1999-07-16 13:13:16 +00:00
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
1999-04-07 21:05:13 +00:00
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_H
#define PHP_H
1999-04-07 21:05:13 +00:00
1999-06-26 00:34:36 +00:00
#ifdef HAVE_DMALLOC
#include <dmalloc.h>
#endif
2001-09-01 14:55:29 +00:00
#define PHP_API_VERSION 20010901
1999-04-07 21:05:13 +00:00
#define YYDEBUG 0
#include "php_version.h"
#include "zend.h"
#include "php_compat.h"
1999-04-21 23:28:00 +00:00
1999-04-07 21:05:13 +00:00
#include "zend_API.h"
#if PHP_BROKEN_SPRINTF
#undef sprintf
#define sprintf php_sprintf
#endif
1999-04-07 21:05:13 +00:00
2000-02-11 15:59:30 +00:00
#ifdef PHP_WIN32
2001-04-27 16:41:53 +00:00
#include "tsrm_win32.h"
1999-04-07 21:05:13 +00:00
#include "win95nt.h"
# ifdef PHP_EXPORTS
2001-04-17 17:03:18 +00:00
# define PHPAPI __declspec(dllexport)
# else
2001-04-17 17:03:18 +00:00
# define PHPAPI __declspec(dllimport)
# endif
#define PHP_DIR_SEPARATOR '\\'
1999-04-07 21:05:13 +00:00
#else
#define PHPAPI
#define THREAD_LS
#define PHP_DIR_SEPARATOR '/'
1999-04-07 21:05:13 +00:00
#endif
#include "php_regex.h"
1999-04-07 21:05:13 +00:00
/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
#undef PHP_DEBUG
#define PHP_DEBUG ZEND_DEBUG
1999-04-07 21:05:13 +00:00
#define APACHE 0
1999-04-07 21:05:13 +00:00
#if HAVE_UNIX_H
#include <unix.h>
#endif
#if HAVE_ALLOCA_H
#include <alloca.h>
#endif
/*
* This is a fast version of strlcpy which should be used, if you
2000-08-27 09:38:33 +00:00
* know the size of the destination buffer and if you know
* the length of the source string.
*
2000-08-27 09:38:33 +00:00
* size is the allocated number of bytes of dst
* src_size is the number of bytes excluding the NUL of src
*/
#define PHP_STRLCPY(dst, src, size, src_size) \
{ \
size_t php_str_len; \
\
if (src_size >= size) \
php_str_len = size - 1; \
else \
php_str_len = src_size; \
memcpy(dst, src, php_str_len); \
dst[php_str_len] = '\0'; \
}
1999-09-15 09:35:20 +00:00
#ifndef HAVE_STRLCPY
2001-05-30 05:00:39 +00:00
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
#define strlcpy php_strlcpy
#endif
1999-09-15 09:35:20 +00:00
#ifndef HAVE_STRLCAT
2001-05-30 05:00:39 +00:00
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
#define strlcat php_strlcat
#endif
1999-11-27 00:48:50 +00:00
#ifndef HAVE_STRTOK_R
char *strtok_r(char *s, const char *delim, char **last);
#endif
#ifndef HAVE_SOCKLEN_T
typedef unsigned int socklen_t;
#endif
2001-08-05 01:43:02 +00:00
#define CREATE_MUTEX(a, b)
1999-04-07 21:05:13 +00:00
#define SET_MUTEX(a)
#define FREE_MUTEX(a)
/*
* 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>
2001-04-17 17:03:18 +00:00
#else
1999-04-07 21:05:13 +00:00
# if HAVE_SYS_VARARGS_H
# include <sys/varargs.h>
2001-04-17 17:03:18 +00:00
# endif
#endif
1999-04-07 21:05:13 +00:00
#include "zend_hash.h"
#include "php3_compat.h"
1999-04-07 21:05:13 +00:00
#include "zend_alloc.h"
#include "zend_stack.h"
#if STDC_HEADERS
# include <string.h>
#else
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy((s), (d), (n))
# endif
# ifndef HAVE_MEMMOVE
1999-04-07 21:05:13 +00:00
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#include "safe_mode.h"
#ifndef HAVE_STRERROR
2000-08-21 09:50:53 +00:00
char *strerror(int);
1999-04-07 21:05:13 +00:00
#endif
2001-04-17 17:03:18 +00:00
#include "php_streams.h"
2001-02-23 22:07:16 +00:00
#include "fopen_wrappers.h"
1999-04-07 21:05:13 +00:00
#if (REGEX == 1 || REGEX == 0) && !defined(NO_REGEX_EXTRA_H)
#include "regex/regex_extra.h"
#endif
1999-04-07 21:05:13 +00:00
#if HAVE_PWD_H
2000-02-11 15:59:30 +00:00
# ifdef PHP_WIN32
1999-04-07 21:05:13 +00:00
#include "win32/pwd.h"
#include "win32/param.h"
# else
#include <pwd.h>
#include <sys/param.h>
# endif
#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 !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || defined(BROKEN_SPRINTF) || defined(BROKEN_SNPRINTF) || defined(BROKEN_VSNPRINTF)
#include "snprintf.h"
1999-04-07 21:05:13 +00:00
#endif
#define EXEC_INPUT_BUF 4096
1999-12-21 19:40:27 +00:00
#define PHP_MIME_TYPE "application/x-httpd-php"
1999-04-07 21:05:13 +00:00
/* macros */
1999-07-08 19:18:42 +00:00
#define STR_PRINT(str) ((str)?(str):"")
1999-04-07 21:05:13 +00:00
#ifndef MAXPATHLEN
2000-09-07 15:20:29 +00:00
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
# else
# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
# endif
1999-04-07 21:05:13 +00:00
#endif
/* global variables */
extern pval *data;
2000-02-11 15:59:30 +00:00
#if !defined(PHP_WIN32)
1999-04-07 21:05:13 +00:00
extern char **environ;
#define php_sleep sleep
1999-04-07 21:05:13 +00:00
#endif
#ifdef PHP_PWRITE_64
ssize_t pwrite(int, void *, size_t, off64_t);
#endif
#ifdef PHP_PREAD_64
ssize_t pread(int, void *, size_t, off64_t);
#endif
2000-08-21 09:50:53 +00:00
void phperror(char *error);
PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
2000-08-21 09:50:53 +00:00
PHPAPI int php_printf(const char *format, ...);
PHPAPI void php_log_err(char *log_message TSRMLS_DC);
2000-08-21 09:50:53 +00:00
int Debug(char *format, ...);
int cfgparse(void);
1999-04-07 21:05:13 +00:00
#define php_error zend_error
1999-04-07 21:05:13 +00:00
#define zenderror phperror
#define zendlex phplex
#define phpparse zendparse
#define phprestart zendrestart
#define phpin zendin
/* functions */
int php_startup_internal_extensions(void);
1999-04-07 21:05:13 +00:00
int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp) (const void *, const void *));
1999-10-15 19:23:04 +00:00
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
1999-04-07 21:05:13 +00:00
PHPAPI int cfg_get_long(char *varname, long *result);
PHPAPI int cfg_get_double(char *varname, double *result);
PHPAPI int cfg_get_string(char *varname, char **result);
/* PHP-named Zend macro wrappers */
#define PHP_FN ZEND_FN
#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
#define PHP_FUNCTION ZEND_FUNCTION
#define PHP_NAMED_FE ZEND_NAMED_FE
#define PHP_FE ZEND_FE
#define PHP_FALIAS ZEND_FALIAS
#define PHP_STATIC_FE ZEND_STATIC_FE
#define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
#define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
#define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
#define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
#define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
#define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
#define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
#define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
#define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
#define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
/* Compatibility macros */
#define PHP_MINIT ZEND_MODULE_STARTUP_N
#define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
#define PHP_RINIT ZEND_MODULE_ACTIVATE_N
#define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
#define PHP_MINFO ZEND_MODULE_INFO_N
#define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
#define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
#define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
#define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
#define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
1999-04-07 21:05:13 +00:00
/* Output support */
2001-07-20 14:40:30 +00:00
#include "main/php_output.h"
#define PHPWRITE(str, str_len) php_body_write((str), (str_len) TSRMLS_CC)
#define PUTS(str) php_body_write((str), strlen((str)) TSRMLS_CC)
#define PUTC(c) (php_body_write(&(c), 1 TSRMLS_CC), (c))
#define PHPWRITE_H(str, str_len) php_header_write((str), (str_len) TSRMLS_CC)
#define PUTS_H(str) php_header_write((str), strlen((str)) TSRMLS_CC)
#define PUTC_H(c) (php_header_write(&(c), 1 TSRMLS_CC), (c))
1999-04-07 21:05:13 +00:00
#ifdef ZTS
#define VIRTUAL_DIR
#endif
/* Virtual current working directory support */
2000-09-03 18:45:02 +00:00
#include "tsrm_virtual_cwd.h"
1999-04-07 21:05:13 +00:00
#include "zend_constants.h"
/* connection status states */
#define PHP_CONNECTION_NORMAL 0
#define PHP_CONNECTION_ABORTED 1
#define PHP_CONNECTION_TIMEOUT 2
1999-04-07 21:05:13 +00:00
#include "php_reentrancy.h"
/* Finding offsets of elements within structures.
* Taken from the Apache code, which in turn, was taken from X code...
*/
#ifndef XtOffset
#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
#ifdef __STDC__
2001-08-05 01:43:02 +00:00
#define XtOffset(p_type, field) _Offsetof(p_type, field)
#else
#ifdef CRAY2
2001-08-05 01:43:02 +00:00
#define XtOffset(p_type, field) \
(sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
#else /* !CRAY2 */
2001-08-05 01:43:02 +00:00
#define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
2001-04-17 17:03:18 +00:00
#endif /* !CRAY2 */
#endif /* __STDC__ */
#else /* ! (CRAY || __arm) */
2001-08-05 01:43:02 +00:00
#define XtOffset(p_type, field) \
((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
#endif /* !CRAY */
#endif /* ! XtOffset */
#ifndef XtOffsetOf
#ifdef offsetof
2001-08-05 01:43:02 +00:00
#define XtOffsetOf(s_type, field) offsetof(s_type, field)
#else
2001-08-05 01:43:02 +00:00
#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
#endif
#endif /* !XtOffsetOf */
PHPAPI PHP_FUNCTION(warn_not_available);
1999-04-07 21:05:13 +00:00
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
1999-04-07 21:05:13 +00:00
*/