1999-07-16 21:13:16 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| PHP version 4.0 |
|
|
|
|
+----------------------------------------------------------------------+
|
2001-02-26 14:11:02 +08:00
|
|
|
| Copyright (c) 1997-2001 The PHP Group |
|
1999-07-16 21:13:16 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2000-05-18 23:34:45 +08:00
|
|
|
| This source file is subject to version 2.02 of the PHP license, |
|
1999-07-16 21:13:16 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available at through the world-wide-web at |
|
2000-05-18 23:34:45 +08:00
|
|
|
| http://www.php.net/license/2_02.txt. |
|
1999-07-16 21:13:16 +08: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. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Zeev Suraski <zeev@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-07-03 07:46:51 +08:00
|
|
|
#ifndef SAPI_H
|
|
|
|
#define SAPI_H
|
1999-04-26 03:36:57 +08:00
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
#include "zend.h"
|
|
|
|
#include "zend_llist.h"
|
1999-05-26 05:14:54 +08:00
|
|
|
#include "zend_operators.h"
|
2000-02-11 02:19:04 +08:00
|
|
|
#include <sys/stat.h>
|
1999-05-06 02:25:20 +08:00
|
|
|
|
2001-04-17 07:20:47 +08:00
|
|
|
#define SAPI_OPTION_NO_CHDIR 1
|
|
|
|
|
1999-05-10 02:40:59 +08:00
|
|
|
#define SAPI_POST_BLOCK_SIZE 4000
|
1999-04-26 22:00:49 +08:00
|
|
|
|
2000-02-11 23:59:30 +08:00
|
|
|
#ifdef PHP_WIN32
|
1999-04-26 22:00:49 +08:00
|
|
|
# ifdef SAPI_EXPORTS
|
|
|
|
# define SAPI_API __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define SAPI_API __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
#define SAPI_API
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
typedef struct {
|
|
|
|
char *header;
|
|
|
|
uint header_len;
|
2000-10-27 02:18:21 +08:00
|
|
|
zend_bool replace;
|
1999-05-06 02:25:20 +08:00
|
|
|
} sapi_header_struct;
|
1999-05-03 02:07:41 +08:00
|
|
|
|
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
typedef struct {
|
|
|
|
zend_llist headers;
|
|
|
|
int http_response_code;
|
1999-05-09 16:48:05 +08:00
|
|
|
unsigned char send_default_content_type;
|
1999-05-12 04:38:16 +08:00
|
|
|
char *http_status_line;
|
1999-05-06 02:25:20 +08:00
|
|
|
} sapi_headers_struct;
|
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
typedef struct _sapi_post_entry sapi_post_entry;
|
1999-05-06 02:25:20 +08:00
|
|
|
typedef struct _sapi_module_struct sapi_module_struct;
|
1999-05-03 02:07:41 +08:00
|
|
|
|
1999-04-26 03:36:57 +08:00
|
|
|
|
2001-01-03 06:49:31 +08:00
|
|
|
extern SAPI_API sapi_module_struct sapi_module; /* true global */
|
1999-05-03 02:07:41 +08:00
|
|
|
|
2000-11-28 14:54:16 +08:00
|
|
|
/* Some values in this structure needs to be filled in before
|
2000-11-27 21:33:33 +08:00
|
|
|
* calling sapi_activate(). We WILL change the `char *' entries,
|
|
|
|
* so make sure that you allocate a separate buffer for them
|
|
|
|
* and that you free them after sapi_deactivate().
|
|
|
|
*/
|
1999-05-03 02:07:41 +08:00
|
|
|
|
|
|
|
typedef struct {
|
2000-11-02 23:47:02 +08:00
|
|
|
const char *request_method;
|
1999-05-03 02:07:41 +08:00
|
|
|
char *query_string;
|
1999-05-09 16:48:05 +08:00
|
|
|
char *post_data;
|
2000-11-08 02:12:06 +08:00
|
|
|
char *cookie_data;
|
2000-09-09 23:02:15 +08:00
|
|
|
long content_length;
|
1999-09-17 07:18:15 +08:00
|
|
|
uint post_data_length;
|
1999-05-03 03:31:56 +08:00
|
|
|
|
|
|
|
char *path_translated;
|
|
|
|
char *request_uri;
|
1999-05-06 02:25:20 +08:00
|
|
|
|
2000-11-02 23:47:02 +08:00
|
|
|
const char *content_type;
|
1999-05-09 16:48:05 +08:00
|
|
|
|
2000-11-14 02:54:37 +08:00
|
|
|
zend_bool headers_only;
|
|
|
|
zend_bool no_headers;
|
1999-05-12 04:38:16 +08:00
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
sapi_post_entry *post_entry;
|
|
|
|
|
|
|
|
char *content_type_dup;
|
|
|
|
|
1999-05-12 04:38:16 +08:00
|
|
|
/* for HTTP authentication */
|
|
|
|
char *auth_user;
|
|
|
|
char *auth_password;
|
2000-02-11 04:03:17 +08:00
|
|
|
|
|
|
|
/* this is necessary for the CGI SAPI module */
|
|
|
|
char *argv0;
|
2000-02-11 04:13:08 +08:00
|
|
|
|
|
|
|
/* this is necessary for Safe Mode */
|
|
|
|
char *current_user;
|
|
|
|
int current_user_length;
|
1999-05-03 02:07:41 +08:00
|
|
|
} sapi_request_info;
|
1999-04-26 03:36:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void *server_context;
|
1999-05-03 02:07:41 +08:00
|
|
|
sapi_request_info request_info;
|
1999-05-06 02:25:20 +08:00
|
|
|
sapi_headers_struct sapi_headers;
|
2000-04-01 09:11:39 +08:00
|
|
|
int read_post_bytes;
|
1999-05-06 03:53:15 +08:00
|
|
|
unsigned char headers_sent;
|
2000-02-11 02:19:04 +08:00
|
|
|
struct stat global_stat;
|
2000-02-26 05:27:03 +08:00
|
|
|
char *default_mimetype;
|
|
|
|
char *default_charset;
|
2000-09-09 05:56:47 +08:00
|
|
|
HashTable *rfc1867_uploaded_files;
|
2000-09-09 23:02:15 +08:00
|
|
|
long post_max_size;
|
2001-04-17 07:20:47 +08:00
|
|
|
int options;
|
1999-04-26 03:36:57 +08:00
|
|
|
} sapi_globals_struct;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ZTS
|
2001-07-28 19:36:37 +08:00
|
|
|
# define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v)
|
1999-04-26 22:00:49 +08:00
|
|
|
SAPI_API extern int sapi_globals_id;
|
1999-04-26 03:36:57 +08:00
|
|
|
#else
|
|
|
|
# define SG(v) (sapi_globals.v)
|
1999-04-26 22:00:49 +08:00
|
|
|
extern SAPI_API sapi_globals_struct sapi_globals;
|
1999-04-26 03:36:57 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-05-06 05:11:27 +08:00
|
|
|
SAPI_API void sapi_startup(sapi_module_struct *sf);
|
1999-12-06 00:43:32 +08:00
|
|
|
SAPI_API void sapi_shutdown(void);
|
2001-07-28 19:36:37 +08:00
|
|
|
SAPI_API void sapi_activate(TSRMLS_D);
|
|
|
|
SAPI_API void sapi_deactivate(TSRMLS_D);
|
|
|
|
SAPI_API void sapi_initialize_empty_request(TSRMLS_D);
|
1999-05-06 05:11:27 +08:00
|
|
|
|
2001-07-31 14:28:05 +08:00
|
|
|
SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC);
|
2000-10-27 02:18:21 +08:00
|
|
|
#define sapi_add_header(header_line, header_line_len, duplicate) \
|
2001-07-31 14:28:05 +08:00
|
|
|
sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1 TSRMLS_CC)
|
|
|
|
SAPI_API int sapi_send_headers(TSRMLS_D);
|
1999-12-10 20:38:20 +08:00
|
|
|
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
|
2001-07-28 19:36:37 +08:00
|
|
|
SAPI_API void sapi_handle_post(void *arg TSRMLS_DC);
|
1999-05-06 05:11:27 +08:00
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
|
|
|
|
SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
|
|
|
|
SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
|
2001-07-28 19:36:37 +08:00
|
|
|
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D));
|
1999-05-26 05:14:54 +08:00
|
|
|
|
2001-07-31 14:28:05 +08:00
|
|
|
SAPI_API int sapi_flush(TSRMLS_D);
|
|
|
|
SAPI_API struct stat *sapi_get_stat(TSRMLS_D);
|
|
|
|
SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC);
|
2000-01-14 01:37:25 +08:00
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
SAPI_API char *sapi_get_default_content_type(TSRMLS_D);
|
|
|
|
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header TSRMLS_DC);
|
|
|
|
SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC);
|
2000-02-26 05:27:03 +08:00
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
struct _sapi_module_struct {
|
|
|
|
char *name;
|
2000-06-27 02:05:55 +08:00
|
|
|
char *pretty_name;
|
1999-05-06 02:25:20 +08:00
|
|
|
|
|
|
|
int (*startup)(struct _sapi_module_struct *sapi_module);
|
|
|
|
int (*shutdown)(struct _sapi_module_struct *sapi_module);
|
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
int (*activate)(TSRMLS_D);
|
|
|
|
int (*deactivate)(TSRMLS_D);
|
2000-02-11 00:44:59 +08:00
|
|
|
|
2001-08-05 23:29:47 +08:00
|
|
|
int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC);
|
2000-01-14 01:37:25 +08:00
|
|
|
void (*flush)(void *server_context);
|
2001-07-28 19:36:37 +08:00
|
|
|
struct stat *(*get_stat)(TSRMLS_D);
|
|
|
|
char *(*getenv)(char *name, size_t name_len TSRMLS_DC);
|
1999-05-06 02:25:20 +08:00
|
|
|
|
1999-05-07 05:58:49 +08:00
|
|
|
void (*sapi_error)(int type, const char *error_msg, ...);
|
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC);
|
|
|
|
int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC);
|
2001-07-31 12:53:54 +08:00
|
|
|
void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC);
|
1999-05-09 16:48:05 +08:00
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC);
|
|
|
|
char *(*read_cookies)(TSRMLS_D);
|
1999-09-17 07:18:15 +08:00
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
|
2000-02-10 23:55:10 +08:00
|
|
|
void (*log_message)(char *message);
|
2000-01-29 01:24:53 +08:00
|
|
|
|
2001-01-03 06:49:31 +08:00
|
|
|
char *php_ini_path_override;
|
|
|
|
|
2000-02-11 02:44:33 +08:00
|
|
|
void (*block_interruptions)(void);
|
|
|
|
void (*unblock_interruptions)(void);
|
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
void (*default_post_reader)(TSRMLS_D);
|
1999-05-06 02:25:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-02-18 04:23:59 +08:00
|
|
|
struct _sapi_post_entry {
|
|
|
|
char *content_type;
|
|
|
|
uint content_type_len;
|
2001-07-28 19:36:37 +08:00
|
|
|
void (*post_reader)(TSRMLS_D);
|
|
|
|
void (*post_handler)(char *content_type_dup, void *arg TSRMLS_DC);
|
2000-02-18 04:23:59 +08:00
|
|
|
};
|
|
|
|
|
1999-05-06 02:25:20 +08:00
|
|
|
/* header_handler() constants */
|
|
|
|
#define SAPI_HEADER_ADD (1<<0)
|
|
|
|
#define SAPI_HEADER_DELETE_ALL (1<<1)
|
|
|
|
#define SAPI_HEADER_SEND_NOW (1<<2)
|
|
|
|
|
|
|
|
|
|
|
|
#define SAPI_HEADER_SENT_SUCCESSFULLY 1
|
|
|
|
#define SAPI_HEADER_DO_SEND 2
|
|
|
|
#define SAPI_HEADER_SEND_FAILED 3
|
|
|
|
|
2000-02-25 06:00:47 +08:00
|
|
|
#define SAPI_DEFAULT_MIMETYPE "text/html"
|
2000-03-20 16:19:51 +08:00
|
|
|
#define SAPI_DEFAULT_CHARSET ""
|
1999-09-14 04:03:56 +08:00
|
|
|
#define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION
|
1999-05-06 02:25:20 +08:00
|
|
|
|
2001-07-28 19:36:37 +08:00
|
|
|
#define SAPI_POST_READER_FUNC(post_reader) SAPI_API void post_reader(TSRMLS_D)
|
|
|
|
#define SAPI_POST_HANDLER_FUNC(post_handler) SAPI_API void post_handler(char *content_type_dup, void *arg TSRMLS_DC)
|
1999-05-26 05:14:54 +08:00
|
|
|
|
1999-06-13 01:50:39 +08:00
|
|
|
SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
|
2000-10-12 06:44:15 +08:00
|
|
|
SAPI_POST_READER_FUNC(php_default_post_reader);
|
1999-06-13 01:50:39 +08:00
|
|
|
|
2001-01-03 19:56:00 +08:00
|
|
|
#define STANDARD_SAPI_MODULE_PROPERTIES NULL
|
1999-09-17 07:18:15 +08:00
|
|
|
|
2000-07-03 07:46:51 +08:00
|
|
|
#endif /* SAPI_H */
|
2000-02-25 06:00:47 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
*/
|