#ifdef TRANS_SID
void session_adapt_uris(const char *, uint, char **, uint *);
#else
-#define session_adapt_uris(a,b,c,d) do { } while(0)
+#define session_adapt_uris(a,b,c,d)
#endif
void _php_session_auto_start(void *data);
convert_to_string(return_value);
}
+
PHP_FUNCTION(flush)
{
-#if APACHE
- SLS_FETCH();
-#endif
-
-#if APACHE
-# if MODULE_MAGIC_NUMBER > 19970110
- rflush(((request_rec *) SG(server_context)));
-# else
- bflush(((request_rec *) SG(server_context))->connection->client);
-# endif
-#endif
-#if FHTTPD
- /*FIXME -- what does it flush really? the whole response?*/
-#endif
-#if CGI_BINARY
- fflush(stdout);
-#endif
-#if USE_SAPI
- sapi_rqst->flush(sapi_rqst->scid);
-#endif
+ sapi_flush();
}
}
-
-
-
-#if 0
-/*
- * php_header() flushes the header info built up using calls to
- * the Header() function. If type is 1, a redirect to str is done.
- * Otherwise type should be 0 and str NULL.
- *
- * The function returns non-zero if output is allowed after the
- * call, and zero otherwise. Any call to php_header() must check
- * the return status and if false, no output must be sent. This
- * is in order to correctly handle HEAD requests.
- */
-PHPAPI int php_header(void)
-{
-#if APACHE
- CookieList *cookie;
- int len = 0;
- time_t t;
- char *dt, *cookievalue = NULL;
-#endif
-#if APACHE || defined(USE_SAPI) || FHTTPD
- char *tempstr;
-#endif
- PLS_FETCH();
- SLS_FETCH();
-
- if (PG(header_is_being_sent)) {
- return 0;
- } else {
- PG(header_is_being_sent) = 1;
- }
-
-#if APACHE
- if (!((request_rec *) SG(server_context))) { /* we're not in a request, allow output */
- PG(header_is_being_sent) = 0;
- return 1;
- }
- if ((php_print_header && !php_header_printed) || (php_print_header && php_header_printed == 2)) {
- cookie = php_pop_cookie_list();
- while (cookie) {
- if (cookie->name)
- len += strlen(cookie->name);
- if (cookie->value) {
- cookievalue = php_url_encode(cookie->value, strlen (cookie->value));
- len += strlen(cookievalue);
- }
- if (cookie->path)
- len += strlen(cookie->path);
- if (cookie->domain)
- len += strlen(cookie->domain);
- tempstr = emalloc(len + 100);
- if (!cookie->value || (cookie->value && !*cookie->value)) {
- /*
- * MSIE doesn't delete a cookie when you set it to a null value
- * so in order to force cookies to be deleted, even on MSIE, we
- * pick an expiry date 1 year and 1 second in the past
- */
- sprintf(tempstr, "%s=deleted", cookie->name);
- t = time(NULL) - 31536001;
- strcat(tempstr, "; expires=");
- dt = php_std_date(t);
- strcat(tempstr, dt);
- efree(dt);
- } else {
- /* FIXME: XXX: this is not binary data safe */
- sprintf(tempstr, "%s=%s", cookie->name, cookie->value ? cookievalue : "");
- if (cookie->name) efree(cookie->name);
- if (cookie->value) efree(cookie->value);
- if (cookievalue) efree(cookievalue);
- cookie->name=NULL;
- cookie->value=NULL;
- cookievalue=NULL;
- if (cookie->expires > 0) {
- strcat(tempstr, "; expires=");
- dt = php_std_date(cookie->expires);
- strcat(tempstr, dt);
- efree(dt);
- }
- }
- if (cookie->path && strlen(cookie->path)) {
- strcat(tempstr, "; path=");
- strcat(tempstr, cookie->path);
- efree(cookie->path);
- cookie->path=NULL;
- }
- if (cookie->domain && strlen(cookie->domain)) {
- strcat(tempstr, "; domain=");
- strcat(tempstr, cookie->domain);
- efree(cookie->domain);
- cookie->domain=NULL;
- }
- if (cookie->secure) {
- strcat(tempstr, "; secure");
- }
- table_add(((request_rec *) SG(server_context))->headers_out, "Set-Cookie", tempstr);
- if (cookie->domain) efree(cookie->domain);
- if (cookie->path) efree(cookie->path);
- if (cookie->name) efree(cookie->name);
- if (cookie->value) efree(cookie->value);
- if (cookievalue) efree(cookievalue);
- efree(cookie);
- cookie = php_pop_cookie_list();
- efree(tempstr);
- }
- php_header_printed = 1;
- header_called = 1;
- send_http_header(((request_rec *) SG(server_context)));
- if (((request_rec *) SG(server_context))->header_only) {
- set_header_request(1);
- PG(header_is_being_sent) = 0;
- return(0);
- }
- }
-#else
- if (php_print_header && !php_header_printed) {
- if (!cont_type) {
-#if USE_SAPI
- sapi_rqst->header(sapi_rqst->scid,"Content-type: text/html\015\012\015\012");
-#else
- PUTS_H("Content-type: text/html\015\012\015\012");
-#endif
- } else {
-#if 0 /*WIN32|WINNT / *M$ does us again*/
- if (!strcmp(cont_type,"text/html")){
-#endif
-#if USE_SAPI
- tempstr=emalloc(strlen(cont_type)+18);
- sprintf(tempstr,"Content-type: %s\015\012\015\012",cont_type);
- sapi_rqst->header(sapi_rqst->scid,tempstr);
- efree(tempstr);
-#else
- PUTS_H("Content-type:");
- PUTS_H(cont_type);
- PUTS_H("\015\012\015\012");
-#endif
- efree(cont_type);
-#if 0 /*WIN32|WINNT / *M$ does us again*/
- } else {
- PUTS_H("\015\012");
- }/*end excluding output of text/html*/
-#endif
- }
-#if USE_SAPI
- sapi_rqst->flush(sapi_rqst->scid);
-#else
- fflush(stdout);
-#endif
- php_header_printed = 1;
- header_called = 1;
- }
-#endif
- PG(header_is_being_sent) = 0;
- return(1);
-}
-#else
PHPAPI int php_header()
{
SLS_FETCH();
return 1; /* allow output */
}
}
-#endif
-
void php_push_cookie_list(char *name, char *value, time_t expires, char *path, char *domain, int secure)
#endif
static inline void php_ob_send(void);
-void php_start_ob_buffering(void);
-void php_end_ob_buffering(int send_buffer);
-int php_ob_get_buffer(pval *p);
-
-/* HEAD support */
-void set_header_request(int value);
typedef struct {
int (*php_body_write)(const char *str, uint str_length); /* string output */
uint ob_size;
uint ob_block_size;
uint ob_text_length;
+ unsigned char implicit_flush;
} php_output_globals;
#ifdef ZTS
OG(ob_size) = 0;
OG(ob_block_size) = 0;
OG(ob_text_length) = 0;
+ OG(implicit_flush) = 0;
}
PHP_GINIT_FUNCTION(output)
{
#ifdef ZTS
- output_globals_id = ts_allocate_id(sizeof(php_output_globals), NULL, NULL);
+ output_globals_id = ts_allocate_id(sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
#else
php_output_init_globals(OLS_C);
#endif
}
+PHPAPI void php_start_implicit_flush()
+{
+ php_end_ob_buffering(1); /* Switch out of output buffering if we're in it */
+
+}
+
+
+PHPAPI void php_end_implicit_flush()
+{
+}
+
+
/*
* Output buffering - implementation
*/
free(newstr);
}
+
return result;
}
* HEAD support
*/
-void set_header_request(int value)
-{
- /* deprecated */
-}
PHP_FUNCTION(ob_start)
{
}
+PHP_FUNCTION(ob_implicit_flush)
+{
+ zval **zv_flag;
+ int flag;
+
+ switch(ZEND_NUM_ARGS()) {
+ case 0:
+ flag = 1;
+ break;
+ case 1:
+ if (zend_get_parameters_ex(1, &zv_flag)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_long_ex(zv_flag);
+ flag = (*zv_flag)->value.lval;
+ break;
+ }
+}
+
+
+
/*
* Local variables:
* tab-width: 4
PHPAPI int php_header_write(const char *str, uint str_length);
PHPAPI void php_start_ob_buffering(void);
PHPAPI void php_end_ob_buffering(int send_buffer);
+PHPAPI int php_ob_get_buffer(pval *p);
+PHPAPI void php_start_implicit_flush();
+PHPAPI void php_end_implicit_flush();
+
extern zend_module_entry output_module_entry;
#define phpext_output_ptr &output_module_entry
return SUCCESS;
}
+
+SAPI_API int sapi_flush()
+{
+ if (sapi_module.flush) {
+ SLS_FETCH();
+
+ sapi_module.flush(SG(server_context));
+ return SUCCESS;
+ } else {
+ return FAILURE;
+ }
+}
SAPI_API void sapi_unregister_post_reader(sapi_post_content_type_reader *post_content_type_reader);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(char *content_type_dup SLS_DC));
+SAPI_API int sapi_flush();
+
+
struct _sapi_module_struct {
char *name;
int (*shutdown)(struct _sapi_module_struct *sapi_module);
int (*ub_write)(const char *str, unsigned int str_length);
+ void (*flush)(void *server_context);
void (*sapi_error)(int type, const char *error_msg, ...);
#endif
static inline void php_ob_send(void);
-void php_start_ob_buffering(void);
-void php_end_ob_buffering(int send_buffer);
-int php_ob_get_buffer(pval *p);
-
-/* HEAD support */
-void set_header_request(int value);
typedef struct {
int (*php_body_write)(const char *str, uint str_length); /* string output */
uint ob_size;
uint ob_block_size;
uint ob_text_length;
+ unsigned char implicit_flush;
} php_output_globals;
#ifdef ZTS
OG(ob_size) = 0;
OG(ob_block_size) = 0;
OG(ob_text_length) = 0;
+ OG(implicit_flush) = 0;
}
PHP_GINIT_FUNCTION(output)
{
#ifdef ZTS
- output_globals_id = ts_allocate_id(sizeof(php_output_globals), NULL, NULL);
+ output_globals_id = ts_allocate_id(sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
#else
php_output_init_globals(OLS_C);
#endif
}
+PHPAPI void php_start_implicit_flush()
+{
+ php_end_ob_buffering(1); /* Switch out of output buffering if we're in it */
+
+}
+
+
+PHPAPI void php_end_implicit_flush()
+{
+}
+
+
/*
* Output buffering - implementation
*/
free(newstr);
}
+
return result;
}
* HEAD support
*/
-void set_header_request(int value)
-{
- /* deprecated */
-}
PHP_FUNCTION(ob_start)
{
}
+PHP_FUNCTION(ob_implicit_flush)
+{
+ zval **zv_flag;
+ int flag;
+
+ switch(ZEND_NUM_ARGS()) {
+ case 0:
+ flag = 1;
+ break;
+ case 1:
+ if (zend_get_parameters_ex(1, &zv_flag)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_long_ex(zv_flag);
+ flag = (*zv_flag)->value.lval;
+ break;
+ }
+}
+
+
+
/*
* Local variables:
* tab-width: 4
PHPAPI int php_header_write(const char *str, uint str_length);
PHPAPI void php_start_ob_buffering(void);
PHPAPI void php_end_ob_buffering(int send_buffer);
+PHPAPI int php_ob_get_buffer(pval *p);
+PHPAPI void php_start_implicit_flush();
+PHPAPI void php_end_implicit_flush();
+
extern zend_module_entry output_module_entry;
#define phpext_output_ptr &output_module_entry
php_module_shutdown_wrapper, /* shutdown */
php_ns_sapi_ub_write, /* unbuffered write */
+ NULL, /* flush */
php_error, /* error handler */
}
-static int zend_apache_ub_write(const char *str, uint str_length)
+static int sapi_apache_ub_write(const char *str, uint str_length)
{
int ret;
SLS_FETCH();
}
+
+static void sapi_apache_flush(void *server_context)
+{
+#if MODULE_MAGIC_NUMBER > 19970110
+ rflush((request_rec *) server_context);
+#else
+ bflush((request_rec *) server_context->connection->client);
+#endif
+}
+
+
int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC)
{
uint total_read_bytes=0, read_bytes;
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
- zend_apache_ub_write, /* unbuffered write */
+ sapi_apache_ub_write, /* unbuffered write */
+ sapi_apache_flush, /* flush */
+
php_error, /* error handler */
PHPAPI extern int optind;
-static int zend_cgibin_ub_write(const char *str, uint str_length)
+static int sapi_cgibin_ub_write(const char *str, uint str_length)
{
return fwrite(str, 1, str_length, stdout);
}
+static void sapi_cgibin_flush(void *server_context)
+{
+ fflush(stdout);
+}
+
+
static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_context)
{
if (sapi_header) {
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
- zend_cgibin_ub_write, /* unbuffered write */
+ sapi_cgibin_ub_write, /* unbuffered write */
+ sapi_cgibin_flush, /* flush */
php_error, /* error handler */
};
-static int zend_isapi_ub_write(const char *str, uint str_length)
+static int sapi_isapi_ub_write(const char *str, uint str_length)
{
DWORD num_bytes = str_length;
LPEXTENSION_CONTROL_BLOCK ecb;
php_isapi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
- zend_isapi_ub_write, /* unbuffered write */
+ sapi_isapi_ub_write, /* unbuffered write */
+ NULL, /* flush */
php_error, /* error handler */
php_module_shutdown_wrapper, /* shutdown */
php_phttpd_sapi_ub_write, /* unbuffered write */
+ NULL, /* flush */
php_error, /* error handler */
"Roxen",
php_module_startup, /* startup */
- pike_module_exit, /* shutdown */
+ pike_module_exit, /* shutdown */
php_roxen_sapi_ub_write, /* unbuffered write */
+ NULL, /* flush */
php_error, /* error handler */
- php_roxen_sapi_header_handler, /* header handler */
+ php_roxen_sapi_header_handler, /* header handler */
php_roxen_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
+ NULL, /* send header handler */
php_roxen_sapi_read_post, /* read POST data */
php_roxen_sapi_read_cookies, /* read Cookies */
* sapi callbacks
*/
-static int zend_servlet_ub_write(const char *str, uint str_length)
+static int sapi_servlet_ub_write(const char *str, uint str_length)
{
SLS_FETCH();
if (!SG(server_context)) {
php_module_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
- zend_servlet_ub_write, /* unbuffered write */
+ sapi_servlet_ub_write, /* unbuffered write */
+ NULL, /* flush */
php_error, /* error handler */
php_module_shutdown_wrapper,
sapi_thttpd_ub_write,
+ NULL,
+
php_error,
NULL,