Skip to content

Commit

Permalink
* Finalizing the PHP version of SAPI. Support POST and cookies among …
Browse files Browse the repository at this point in the history
…other things.

* Fully implement ISAPI support - POST and cookies among other things.
* Almost completely rewrote phpinfo().  Allow modules to easily display their
  information in phpinfo() without modifying phpinfo() itself (prototype for
  the module info function was changed, thus the large amount of updated module
  files).
* Initial extended SAPI support for Apache, completely untested.
* CGI now uses SAPI fully as well.
  • Loading branch information
zsuraski committed May 9, 1999
1 parent 91cf2e5 commit bc415d5
Show file tree
Hide file tree
Showing 56 changed files with 540 additions and 344 deletions.
37 changes: 34 additions & 3 deletions cgi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_c
}


static char *sapi_cgi_read_post(SLS_D)
{
uint read_bytes=0, tmp_read_bytes;
char *result = (char *) emalloc(SG(request_info).content_length+1);

while (read_bytes < SG(request_info).content_length) {
tmp_read_bytes = read(0, result+read_bytes, SG(request_info).content_length-read_bytes);
if (tmp_read_bytes<=0) {
break;
}
read_bytes += tmp_read_bytes;
}
result[read_bytes]=0;
return result;
}


static char *sapi_cgi_read_cookies(SLS_D)
{
return getenv("HTTP_COOKIE");
}


static sapi_module_struct sapi_module = {
"PHP Language", /* name */

Expand All @@ -98,6 +121,9 @@ static sapi_module_struct sapi_module = {
NULL, /* header handler */
NULL, /* send headers handler */
sapi_cgi_send_header, /* send header handler */

sapi_cgi_read_post, /* read POST data */
sapi_cgi_read_cookies /* read Cookies */
};


Expand Down Expand Up @@ -132,15 +158,19 @@ static void php_cgi_usage(char *argv0)

static void init_request_info(SLS_D)
{
char *request_method = getenv("REQUEST_METHOD");
char *content_length = getenv("CONTENT_LENGTH");

SG(request_info).request_method = getenv("REQUEST_METHOD");
SG(request_info).query_string = getenv("QUERY_STRING");
SG(request_info).request_uri = getenv("PATH_INFO");
if (request_method && !strcmp(request_method, "HEAD")) {
SG(request_info).path_translated = NULL; /* we have to update it later, when we have that information */
if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) {
SG(request_info).headers_only = 1;
} else {
SG(request_info).headers_only = 0;
}
SG(request_info).content_type = getenv("CONTENT_TYPE");
SG(request_info).content_length = (content_length?atoi(content_length):0);
}


Expand Down Expand Up @@ -229,6 +259,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
sapi_globals = ts_resource(sapi_globals_id);
#endif

init_request_info(SLS_C);
SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
CG(extended_info) = 0;

if (!cgi) { /* never execute the arguments if you are a CGI */
Expand Down Expand Up @@ -322,7 +354,6 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine

php3_TreatHeaders();

init_request_info(SLS_C);

if (!cgi) {
if (!SG(request_info).query_string) {
Expand Down
4 changes: 2 additions & 2 deletions ext/apache/apache.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern module *top_module;
void php3_virtual(INTERNAL_FUNCTION_PARAMETERS);
void php3_getallheaders(INTERNAL_FUNCTION_PARAMETERS);
void php3_apachelog(INTERNAL_FUNCTION_PARAMETERS);
void php3_info_apache(void);
void php3_info_apache(ZEND_MODULE_INFO_FUNC_ARGS);
void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS);
void php3_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS);

Expand Down Expand Up @@ -154,7 +154,7 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
}
/* }}} */

void php3_info_apache(void) {
void php3_info_apache(ZEND_MODULE_INFO_FUNC_ARGS) {
module *modp = NULL;
#if !defined(WIN32) && !defined(WINNT)
char name[64];
Expand Down
4 changes: 2 additions & 2 deletions ext/dav/dav.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int php3_minit_phpdav(INIT_FUNC_ARGS);
int php3_rinit_phpdav(INIT_FUNC_ARGS);
int php3_mshutdown_phpdav(SHUTDOWN_FUNC_ARGS);
int php3_rshutdown_phpdav(SHUTDOWN_FUNC_ARGS);
void php3_info_phpdav(void);
void php3_info_phpdav(ZEND_MODULE_INFO_FUNC_ARGS);

/* }}} */
/* {{{ extension definition structures */
Expand Down Expand Up @@ -186,7 +186,7 @@ int php3_rshutdown_phpdav(SHUTDOWN_FUNC_ARGS)
/* }}} */
/* {{{ php3_info_phpdav() */

void php3_info_phpdav()
void php3_info_phpdav(ZEND_MODULE_INFO_FUNC_ARGS)
{
}

Expand Down
2 changes: 1 addition & 1 deletion ext/db/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static char *php3_get_info_db(void)
}


void php3_info_db(void)
void php3_info_db(ZEND_MODULE_INFO_FUNC_ARGS)
{
php3_printf(php3_get_info_db());
}
Expand Down
2 changes: 1 addition & 1 deletion ext/db/php3_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ char *_php3_dbmnextkey(dbm_info *info, char *key);
/* db file functions */
extern int php3_minit_db(INIT_FUNC_ARGS);
extern int php3_rinit_db(INIT_FUNC_ARGS);
extern void php3_info_db(void);
extern void php3_info_db(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_dblist(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_dbmopen(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_dbmclose(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/fdf/fdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int php3_minit_fdf(INIT_FUNC_ARGS)
return SUCCESS;
}

void php3_info_fdf(void) {
void php3_info_fdf(ZEND_MODULE_INFO_FUNC_ARGS) {
/* need to use a PHPAPI function here because it is external module in windows */
php3_printf("FdfTk Version %s", FDFGetVersion());
}
Expand Down
2 changes: 1 addition & 1 deletion ext/fdf/php3_fdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern php3_module_entry fdf_module_entry;

extern int php3_minit_fdf(INIT_FUNC_ARGS);
extern int php3_mend_fdf(void);
extern void php3_info_fdf(void);
extern void php3_info_fdf(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_fdf_open(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_fdf_close(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_fdf_create(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int php3_minit_gd(INIT_FUNC_ARGS)
return SUCCESS;
}

void php3_info_gd(void) {
void php3_info_gd(ZEND_MODULE_INFO_FUNC_ARGS) {
/* need to use a PHPAPI function here because it is external module in windows */
#if HAVE_LIBGD13
php3_printf("Version 1.3");
Expand Down
2 changes: 1 addition & 1 deletion ext/gettext/gettext.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ php3_module_entry php3_gettext_module_entry = {
"gettext", php3_gettext_functions, NULL, NULL, NULL, NULL, php3_info_gettext, STANDARD_MODULE_PROPERTIES
};

void php3_info_gettext(void)
void php3_info_gettext(ZEND_MODULE_INFO_FUNC_ARGS)
{
php3_printf("GNU gettext support active.");
}
Expand Down
2 changes: 1 addition & 1 deletion ext/gettext/php3_gettext.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
extern php3_module_entry php3_gettext_module_entry;
#define php3_gettext_module_ptr &php3_gettext_module_entry

extern void php3_info_gettext(void);
extern void php3_info_gettext(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_textdomain(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_gettext(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_dgettext(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
6 changes: 3 additions & 3 deletions ext/hyperwave/hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ void php3_hw_getcgi(INTERNAL_FUNCTION_PARAMETERS) {
getenv("QUERY_STRING"));
#else
sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
request_info.request_method,
SG(request_info).request_method,
SG(request_info).request_uri,
SG(request_info).query_string);
#endif
Expand Down Expand Up @@ -1783,7 +1783,7 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) {
getenv("QUERY_STRING"));
#else
sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
request_info.request_method,
SG(request_info).request_method,
SG(request_info).request_uri,
SG(request_info).query_string);
#endif
Expand Down Expand Up @@ -2959,7 +2959,7 @@ void php3_hw_getrellink(INTERNAL_FUNCTION_PARAMETERS) {
/* }}} */


void php3_info_hw()
void php3_info_hw(ZEND_MODULE_INFO_FUNC_ARGS)
{
php3_printf("HG-CSP Version: 7.17");
}
Expand Down
2 changes: 1 addition & 1 deletion ext/hyperwave/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extern void php3_hw_document_content(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_objrec2array(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_array2objrec(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_connection_info(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_info_hw(void);
extern void php3_info_hw(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_hw_getsrcbydestobj(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_getrellink(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hw_dummy(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/informix/php3_ifx.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extern php3_module_entry ifx_module_entry;
extern int php3_minit_ifx(INIT_FUNC_ARGS);
extern int php3_rinit_ifx(INIT_FUNC_ARGS);
extern int php3_mshutdown_ifx(SHUTDOWN_FUNC_ARGS);
extern void php3_info_ifx(void);
extern void php3_info_ifx(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_ifx_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ifx_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ifx_close(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/interbase/interbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int php3_rfinish_ibase(void)
}
*/

void php3_info_ibase(void)
void php3_info_ibase(ZEND_MODULE_INFO_FUNC_ARGS)
{
/* TODO */
}
Expand Down
2 changes: 1 addition & 1 deletion ext/interbase/php3_interbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern php3_module_entry ibase_module_entry;
extern int php3_minit_ibase(INIT_FUNC_ARGS);
extern int php3_rinit_ibase(INIT_FUNC_ARGS);
extern int php3_mfinish_ibase(void);
extern void php3_info_ibase(void);
extern void php3_info_ibase(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_ibase_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_close(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ int php3_mshutdown_ldap(SHUTDOWN_FUNC_ARGS) {
return SUCCESS;
}

void php3_info_ldap(void)
void php3_info_ldap(ZEND_MODULE_INFO_FUNC_ARGS)
{
char maxl[16];
#if HAVE_NSLDAP
Expand Down
2 changes: 1 addition & 1 deletion ext/ldap/php3_ldap.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern php3_module_entry ldap_module_entry;
extern int php3_minit_ldap(INIT_FUNC_ARGS);
extern int php3_mshutdown_ldap(SHUTDOWN_FUNC_ARGS);

extern void php3_info_ldap(void);
extern void php3_info_ldap(ZEND_MODULE_INFO_FUNC_ARGS);

extern void php3_ldap_connect(INTERNAL_FUNCTION_PARAMETERS);

Expand Down
2 changes: 1 addition & 1 deletion ext/msql/msql.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ DLEXPORT int php3_rinit_msql(INIT_FUNC_ARGS)
return SUCCESS;
}

DLEXPORT void php3_info_msql(void)
DLEXPORT void php3_info_msql(ZEND_MODULE_INFO_FUNC_ARGS)
{
char maxp[16],maxl[16];
MSQL_TLS_VARS;
Expand Down
2 changes: 1 addition & 1 deletion ext/msql/php3_msql.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern php3_module_entry msql_module_entry;
extern DLEXPORT int php3_minit_msql(INIT_FUNC_ARGS);
extern DLEXPORT int php3_rinit_msql(INIT_FUNC_ARGS);
extern DLEXPORT int php3_mshutdown_msql(SHUTDOWN_FUNC_ARGS);
extern DLEXPORT void php3_info_msql(void);
extern DLEXPORT void php3_info_msql(ZEND_MODULE_INFO_FUNC_ARGS);
extern DLEXPORT void php3_msql_connect(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern DLEXPORT void php3_msql_close(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysql/mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ int php3_rinit_mysql(INIT_FUNC_ARGS)
}


void php3_info_mysql(void)
void php3_info_mysql(ZEND_MODULE_INFO_FUNC_ARGS)
{
char maxp[16],maxl[16];
MySLS_FETCH();
Expand Down
2 changes: 1 addition & 1 deletion ext/mysql/php3_mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern php3_module_entry mysql_module_entry;
extern int php3_minit_mysql(INIT_FUNC_ARGS);
extern int php3_rinit_mysql(INIT_FUNC_ARGS);
extern int php3_mshutdown_mysql(SHUTDOWN_FUNC_ARGS);
extern void php3_info_mysql(void);
extern void php3_info_mysql(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_mysql_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_mysql_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_mysql_close(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/odbc/odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ int php3_mshutdown_odbc(SHUTDOWN_FUNC_ARGS)
}


void php3_info_odbc(void)
void php3_info_odbc(ZEND_MODULE_INFO_FUNC_ARGS)
{
ODBC_TLS_VARS;

Expand Down
2 changes: 1 addition & 1 deletion ext/odbc/php3_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extern php3_module_entry odbc_module_entry;
extern int php3_minit_odbc(INIT_FUNC_ARGS);
extern int php3_mshutdown_odbc(SHUTDOWN_FUNC_ARGS);
extern int php3_rinit_odbc(INIT_FUNC_ARGS);
extern void php3_info_odbc(void);
extern void php3_info_odbc(ZEND_MODULE_INFO_FUNC_ARGS);
extern PHP_FUNCTION(odbc_setoption);
extern PHP_FUNCTION(odbc_autocommit);
extern PHP_FUNCTION(odbc_close);
Expand Down
4 changes: 2 additions & 2 deletions ext/odbc/php3_velocis.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ extern php3_module_entry velocis_module_entry;
/* velocis.c functions */
extern int php3_minit_velocis(INIT_FUNC_ARGS);
extern int php3_rinit_velocis(INIT_FUNC_ARGS);
extern void php3_info_velocis(void);
extern int php3_shutdown_velocis(void);
extern void php3_info_velocis(ZEND_MODULE_INFO_FUNC_ARGS);
extern int php3_shutdown_velocis(SHUTDOWN_FUNC_ARGS);
extern void php3_velocis_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_velocis_close(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_velocis_exec(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
2 changes: 1 addition & 1 deletion ext/odbc/velocis.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int php3_rinit_velocis(INIT_FUNC_ARGS)
}


void php3_info_velocis(void)
void php3_info_velocis(ZEND_MODULE_INFO_FUNC_ARGS)
{
php3_printf("RAIMA Velocis Support Active");
}
Expand Down
4 changes: 2 additions & 2 deletions ext/oracle/oci8.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ int php3_minit_oci8(INIT_FUNC_ARGS);
int php3_rinit_oci8(INIT_FUNC_ARGS);
int php3_mshutdown_oci8(SHUTDOWN_FUNC_ARGS);
int php3_rshutdown_oci8(SHUTDOWN_FUNC_ARGS);
void php3_info_oci8(void);
void php3_info_oci8(ZEND_MODULE_INFO_FUNC_ARGS);

static ub4 oci8_error(OCIError *err_p, char *what, sword status);
/* static int oci8_ping(oci8_connection *conn); XXX NYI */
Expand Down Expand Up @@ -536,7 +536,7 @@ int php3_rshutdown_oci8(SHUTDOWN_FUNC_ARGS)
}


void php3_info_oci8()
void php3_info_oci8(ZEND_MODULE_INFO_FUNC_ARGS)
{
#if !(WIN32|WINNT)
php3_printf("Oracle version: %s<br>\n"
Expand Down
2 changes: 1 addition & 1 deletion ext/oracle/oracle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ void php3_Ora_ErrorCode(INTERNAL_FUNCTION_PARAMETERS)
}
/* }}} */

void php3_info_oracle()
void php3_info_oracle(ZEND_MODULE_INFO_FUNC_ARGS)
{
#if !(WIN32|WINNT)
php3_printf("Oracle version: %s<br>\n"
Expand Down
2 changes: 1 addition & 1 deletion ext/oracle/oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ extern void php3_Ora_Rollback(INTERNAL_FUNCTION_PARAMETERS);
extern int php3_minit_oracle(INIT_FUNC_ARGS);
extern int php3_mshutdown_oracle(SHUTDOWN_FUNC_ARGS);
extern int php3_rshutdown_oracle(SHUTDOWN_FUNC_ARGS);
extern void php3_info_oracle(void);
extern void php3_info_oracle(ZEND_MODULE_INFO_FUNC_ARGS);
extern int php3_rinit_oracle(INIT_FUNC_ARGS);

#else
Expand Down
2 changes: 1 addition & 1 deletion ext/pdf/pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int php3_minit_pdf(INIT_FUNC_ARGS)
return SUCCESS;
}

void php3_info_pdf(void) {
void php3_info_pdf(ZEND_MODULE_INFO_FUNC_ARGS) {
/* need to use a PHPAPI function here because it is external module in windows */
php3_printf("%s. AFM files in %s", PDFLIB_VERSION, PDF_DEFAULT_FONT_PATH);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/pdf/php3_pdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern int le_fp;
extern php3_module_entry pdf_module_entry;
#define pdf_module_ptr &pdf_module_entry

extern void php3_info_pdf(void);
extern void php3_info_pdf(ZEND_MODULE_INFO_FUNC_ARGS);
extern int php3_minit_pdf(INIT_FUNC_ARGS);
extern int php3_mend_pdf(void);
extern void php3_pdf_get_info(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
Loading

0 comments on commit bc415d5

Please sign in to comment.