CVS update: php31/sapi
| From: | zeev | Date: | Fri, 21 Aug 1998 13:48:44 +0000 |
| Subject: | CVS update: php31/sapi | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-413@lists.php.net to get a copy of this message | ||
Date: Friday August 21, 1998 @ 9:48
Author: zeev
Update of /repository/php31/sapi
In directory asf:/tmp/cvs-serv26336/sapi
Modified Files:
apache_sapi.c cgi_sapi.c isapi_sapi.c nsapi_sapi.c sapi.h
Log Message:
Add the ability to buffer output:
* Removed all puts and putc implementations. Only the PUTC and PUTS macros should be used - they go
through
writeclient.
* Add buffering support
Right now, buffered_output is always turned off, and the buffered content isn't yet sent at
all. The
framework is there though.
Index: php31/sapi/apache_sapi.c
diff -c php31/sapi/apache_sapi.c:2.4 php31/sapi/apache_sapi.c:2.5
*** php31/sapi/apache_sapi.c:2.4 Thu Aug 20 19:06:41 1998
--- php31/sapi/apache_sapi.c Fri Aug 21 09:48:43 1998
***************
*** 274,305 ****
}
}
- /* this was php3_apache_puts */
- int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string)
- {
- SAPI_FUNC_VARS;
-
- if (php3_rqst) {
- return rputs(string, php3_rqst);
- } else {
- return fputs(string, stdout);
- }
- return FAILURE;
- }
-
- /* this was php3_apache_putc */
- int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c)
- {
- SAPI_FUNC_VARS;
-
- if (php3_rqst) {
- return rputc(c, php3_rqst);
- } else {
- return fputc(c, stdout);
- }
- return FAILURE;
- }
-
int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
{
SAPI_FUNC_VARS;
--- 274,279 ----
***************
*** 579,586 ****
sapi_info->cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
- sapi_info->puts = sapi_puts;
- sapi_info->sputc = sapi_putc;
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
--- 553,558 ----
Index: php31/sapi/cgi_sapi.c
diff -c php31/sapi/cgi_sapi.c:2.12 php31/sapi/cgi_sapi.c:2.13
*** php31/sapi/cgi_sapi.c:2.12 Fri Aug 21 08:09:22 1998
--- php31/sapi/cgi_sapi.c Fri Aug 21 09:48:44 1998
***************
*** 107,124 ****
}
- int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string)
- {
- if (fputs(string, stdout) < 0) {
- sapi_info->abort = 1;
- #if MSVC5
- OutputDebugString("fputs() failed\n");
- #endif
- }
- return SUCCESS;
- }
-
-
int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c)
{
if (putc(c, stdout) < 0) {
--- 107,112 ----
***************
*** 261,268 ****
sapi_info->aborted = 0;
- sapi_info->puts = sapi_puts;
- sapi_info->sputc = sapi_putc;
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
--- 249,254 ----
***************
*** 407,413 ****
sapi_info->filename = NULL;
sapi_info->query_string = NULL;
sapi_info->argv0=NULL;
- sapi_info->buffered_output=0;
/* Make sure we detect we are a cgi - a bit redundancy here,
but the default case is that we have to check only the first one. */
--- 393,398 ----
Index: php31/sapi/isapi_sapi.c
diff -c php31/sapi/isapi_sapi.c:2.9 php31/sapi/isapi_sapi.c:2.10
*** php31/sapi/isapi_sapi.c:2.9 Thu Aug 20 19:06:42 1998
--- php31/sapi/isapi_sapi.c Fri Aug 21 09:48:44 1998
***************
*** 289,325 ****
return SUCCESS;
}
- int sapi_puts(SAPI_GLOBAL_INCLUDE unsigned char *string)
- {
- SAPI_FUNC_VARS;
- int n;
- n = strlen(string);
- if (!lpEcb->WriteClient(lpEcb->ConnID, string, &n, 0)) {
- /*FIXME request_shutdown on failure! */
- #if defined(CRASH_DETECTION)
- debug_log("sapi_puts Failure called from %s,%d\n", cfilename, clineno);
- #endif
- sapi_info->abort = 1;
- return FAILURE;
- }
- return SUCCESS;
- }
-
- int sapi_putc(SAPI_GLOBAL_INCLUDE unsigned char c)
- {
- SAPI_FUNC_VARS;
- int n = 1;
- if (!lpEcb->WriteClient(lpEcb->ConnID, &c, &n, 0)) {
- /*FIXME request_shutdown on failure! */
- #if defined(CRASH_DETECTION)
- debug_log("sapi_putc failure called from %s,%d\n", cfilename, clineno);
- #endif
- sapi_info->abort = 1;
- return FAILURE;
- }
- return SUCCESS;
- }
-
int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
{
SAPI_FUNC_VARS;
--- 289,294 ----
***************
*** 424,446 ****
int i = 0;
SAPI_FUNC_VARS;
! sapi_puts(SAPI_GLOBAL_PASS "<center><h2>ISAPI Request
Environment</h2></center>");
! sapi_puts(SAPI_GLOBAL_PASS "<table border=5 width=\"600\">\n");
! sapi_puts(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
while (isapi_env[i] != NULL) {
temp = sapi_getenv(SAPI_GLOBAL_PASS isapi_env[i]);
! sapi_puts(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
! sapi_puts(SAPI_GLOBAL_PASS isapi_env[i]);
! sapi_puts(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
! if (temp)
! sapi_puts(SAPI_GLOBAL_PASS temp);
! sapi_puts(SAPI_GLOBAL_PASS " </td></tr>\n");
if (temp)
efree(temp);
i++;
}
! sapi_puts(SAPI_GLOBAL_PASS "</table>\n");
!
}
struct sapi_request_info *sapi_init(LPEXTENSION_CONTROL_BLOCK lpEcb)
--- 393,415 ----
int i = 0;
SAPI_FUNC_VARS;
! PUTS(SAPI_GLOBAL_PASS "<center><h2>ISAPI Request
Environment</h2></center>");
! PUTS(SAPI_GLOBAL_PASS "<table border=5 width=\"600\">\n");
! PUTS(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
while (isapi_env[i] != NULL) {
temp = sapi_getenv(SAPI_GLOBAL_PASS isapi_env[i]);
! PUTS(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
! PUTS(SAPI_GLOBAL_PASS isapi_env[i]);
! PUTS(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
! if (temp) {
! PUTS(SAPI_GLOBAL_PASS temp);
! }
! PUTSs(SAPI_GLOBAL_PASS " </td></tr>\n");
if (temp)
efree(temp);
i++;
}
! PUTS(SAPI_GLOBAL_PASS "</table>\n");
}
struct sapi_request_info *sapi_init(LPEXTENSION_CONTROL_BLOCK lpEcb)
***************
*** 461,468 ****
sapi_info->content_type = lpEcb->lpszContentType;
sapi_info->cookies = _sapi_getenv(lpEcb, "HTTP_COOKIE");
- sapi_info->puts = sapi_puts;
- sapi_info->sputc = sapi_putc;
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
--- 430,435 ----
Index: php31/sapi/nsapi_sapi.c
diff -c php31/sapi/nsapi_sapi.c:2.1 php31/sapi/nsapi_sapi.c:2.2
*** php31/sapi/nsapi_sapi.c:2.1 Thu Aug 20 19:06:43 1998
--- php31/sapi/nsapi_sapi.c Fri Aug 21 09:48:44 1998
***************
*** 465,482 ****
return net_read(sn->csd, buf, len, 10);
}
- int sapi_puts(SAPI_GLOBAL_INCLUDE char *string)
- {
- SAPI_FUNC_VARS;
- return net_write(sn->csd, string, strlen(string));
- }
-
- int sapi_putc(SAPI_GLOBAL_INCLUDE char c)
- {
- SAPI_FUNC_VARS;
- return net_write(sn->csd, &c, 1);
- }
-
int sapi_writeclient(SAPI_GLOBAL_INCLUDE char *string, int len)
{
SAPI_FUNC_VARS;
--- 465,470 ----
***************
*** 501,523 ****
char *temp;
SAPI_FUNC_VARS;
! sapi_puts(SAPI_GLOBAL_PASS "<center><h2>NSAPI
Environment</h2></center>");
! sapi_puts(SAPI_GLOBAL_PASS "<table border=5 width=\"600\">\n");
! sapi_puts(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
/* print out the server environment table here */
while (nsapi_env[i].type != -1) {
temp = _php3_nsapi_env_get(ns_rqst, nsapi_env[i].name1);
! sapi_puts(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
! sapi_puts(SAPI_GLOBAL_PASS nsapi_env[i].name1);
! sapi_puts(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
! sapi_puts(SAPI_GLOBAL_PASS temp);
! sapi_puts(SAPI_GLOBAL_PASS " </td></tr>\n");
i++;
}
-
- sapi_puts(SAPI_GLOBAL_PASS "</table>\n");
}
/*********************************************************
--- 489,510 ----
char *temp;
SAPI_FUNC_VARS;
! PUTS(SAPI_GLOBAL_PASS "<center><h2>NSAPI
Environment</h2></center>");
! PUTS(SAPI_GLOBAL_PASS "<table border=5 width=\"600\">\n");
! PUTS(SAPI_GLOBAL_PASS "<tr><th bgcolor=\"" HEADER_COLOR
"\">Variable</th><th bgcolor=\"" HEADER_COLOR
"\">Value</th></tr>\n");
/* print out the server environment table here */
while (nsapi_env[i].type != -1) {
temp = _php3_nsapi_env_get(ns_rqst, nsapi_env[i].name1);
! PUTS(SAPI_GLOBAL_PASS "<tr><td bgcolor=\"" ENTRY_NAME_COLOR
"\">");
! PUTS(SAPI_GLOBAL_PASS nsapi_env[i].name1);
! PUTS(SAPI_GLOBAL_PASS "</td><td bgcolor=\"" CONTENTS_COLOR
"\">");
! PUTS(SAPI_GLOBAL_PASS temp);
! PUTS(SAPI_GLOBAL_PASS " </td></tr>\n");
i++;
}
+ PUTS(SAPI_GLOBAL_PASS "</table>\n");
}
/*********************************************************
***************
*** 608,615 ****
sapi_info->content_length = atoi(pblock_findval("content-length", rq->headers));
sapi_info->content_type = pblock_findval("content-type", rq->srvhdrs);
- sapi_info->puts = sapi_puts;
- sapi_info->sputc = sapi_putc;
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
--- 595,600 ----
Index: php31/sapi/sapi.h
diff -c php31/sapi/sapi.h:2.7 php31/sapi/sapi.h:2.8
*** php31/sapi/sapi.h:2.7 Fri Aug 21 08:09:22 1998
--- php31/sapi/sapi.h Fri Aug 21 09:48:44 1998
***************
*** 14,19 ****
--- 14,20 ----
#define _PHP3_SAPI_H_
#include "modules.h"
#include "php3_ini.h"
+ #include "string_buffer.h"
#ifdef THREAD_SAFE
#if DEBUG
***************
*** 70,82 ****
/* io functions */
int (*readclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
void (*info) (SAPI_GLOBAL_INCLUDE_V);
- int (*puts) (SAPI_GLOBAL_INCLUDE unsigned char *);
- int (*sputc) (SAPI_GLOBAL_INCLUDE unsigned char);
char *(*getenv) (SAPI_GLOBAL_INCLUDE char *);
int (*writeclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
int (*flush) (SAPI_GLOBAL_INCLUDE_V); /*flush writes to client */
void (*log) (SAPI_GLOBAL_INCLUDE char *); /*use server error log */
unsigned char buffered_output;
/* signal and thread functions */
void (*blockalarms) (SAPI_GLOBAL_INCLUDE_V); /*signal blocking */
--- 71,83 ----
/* io functions */
int (*readclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
void (*info) (SAPI_GLOBAL_INCLUDE_V);
char *(*getenv) (SAPI_GLOBAL_INCLUDE char *);
int (*writeclient) (SAPI_GLOBAL_INCLUDE unsigned char *, int);
int (*flush) (SAPI_GLOBAL_INCLUDE_V); /*flush writes to client */
void (*log) (SAPI_GLOBAL_INCLUDE char *); /*use server error log */
+
unsigned char buffered_output;
+ StringBuffer output_buffer;
/* signal and thread functions */
void (*blockalarms) (SAPI_GLOBAL_INCLUDE_V); /*signal blocking */
***************
*** 112,124 ****
#endif
#if defined(COMPILE_DL)
! #define PUTS(a) php3_printf(a)
! #define PUTC(a) PUTS(a)
#define PHPWRITE(a,n) php3_write((a),(n))
#else
! #define PUTS(a) GLOBAL(sapi_rqst)->puts(SAPI_GLOBAL_PASS a)
! #define PUTC(a) GLOBAL(sapi_rqst)->sputc(SAPI_GLOBAL_PASS a)
! #define PHPWRITE(a,n) GLOBAL(sapi_rqst)->writeclient(SAPI_GLOBAL_PASS (a),(n))
#define BLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->blockalarms(SAPI_GLOBAL_PASS_V)
#define UNBLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->unblockalarms(SAPI_GLOBAL_PASS_V)
#endif
--- 113,125 ----
#endif
#if defined(COMPILE_DL)
! #define PUTS(s) php3_putc(s);
! #define PUTC(c) php3_puts(c);
#define PHPWRITE(a,n) php3_write((a),(n))
#else
! #define PUTS(s) { char *str=(s); PHPWRITE(s,strlen(s)); }
! #define PUTC(c) { char ch=(c); PHPWRITE(&ch, 1); }
! #define PHPWRITE(a,n) php3_sapi_writeclient(SAPI_GLOBAL_PASS (a),(n))
#define BLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->blockalarms(SAPI_GLOBAL_PASS_V)
#define UNBLOCK_INTERRUPTIONS
if(GLOBAL(sapi_rqst))GLOBAL(sapi_rqst)->unblockalarms(SAPI_GLOBAL_PASS_V)
#endif
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net