summaryrefslogtreecommitdiff
path: root/sapi/activescript/php4activescript.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-05-20 01:35:29 +0000
committerWez Furlong <wez@php.net>2002-05-20 01:35:29 +0000
commite754361405395908abd687b1403215da2bd98b92 (patch)
treee695f256b31e3a721667dba65199d34869455948 /sapi/activescript/php4activescript.c
parent50f7427e69741acf9094a0f63c35503bfa4afca6 (diff)
downloadphp-git-e754361405395908abd687b1403215da2bd98b92.tar.gz
Implement ActiveScript interfaces.
This allows use of PHP in: Client-side script in Internet Explorer Windows Scripting Host ASP and ASP.NET pages It's mostly working... give it a go. You will need to regsvr32 the php4activescript.dll manually.
Diffstat (limited to 'sapi/activescript/php4activescript.c')
-rw-r--r--sapi/activescript/php4activescript.c156
1 files changed, 156 insertions, 0 deletions
diff --git a/sapi/activescript/php4activescript.c b/sapi/activescript/php4activescript.c
new file mode 100644
index 0000000000..eed1d7e52e
--- /dev/null
+++ b/sapi/activescript/php4activescript.c
@@ -0,0 +1,156 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2002 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | 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. |
+ | 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: Wez Furlong <wez@thebrainroom.com> |
+ +----------------------------------------------------------------------+
+ */
+/* $Id$ */
+
+#include "php.h"
+#include "php_main.h"
+#include "SAPI.h"
+#include "php_globals.h"
+#include "ext/standard/info.h"
+#include "php_variables.h"
+#include "php_ini.h"
+#include "php4activescript.h"
+
+/* SAPI definitions and DllMain */
+
+static int php_activescript_startup(sapi_module_struct *sapi_module)
+{
+ if (php_module_startup(sapi_module) == FAILURE ||
+ zend_startup_module(&php_activescript_module) == FAILURE) {
+ return FAILURE;
+ } else {
+ return SUCCESS;
+ }
+}
+
+static int sapi_activescript_ub_write(const char *str, uint str_length TSRMLS_DC)
+{
+ /* In theory, this is a blackhole. In practice, I wan't to see the output
+ * in the debugger! */
+
+ char buf[1024];
+ uint l, a = str_length;
+
+ while(a) {
+ l = a;
+ if (l > sizeof(buf) - 1)
+ l = sizeof(buf) - 1;
+ memcpy(buf, str, l);
+ buf[l] = 0;
+ OutputDebugString(buf);
+ a -= l;
+ }
+
+ return str_length;
+}
+
+static void sapi_activescript_register_server_variables(zval *track_vars_array TSRMLS_DC)
+{
+}
+
+static char *sapi_activescript_read_cookies(TSRMLS_D)
+{
+ return NULL;
+}
+
+static int sapi_activescript_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
+{
+ return SAPI_HEADER_ADD;
+}
+
+static int sapi_activescript_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
+{
+ return SAPI_HEADER_SENT_SUCCESSFULLY;
+}
+
+zend_module_entry php_activescript_module = {
+ STANDARD_MODULE_HEADER,
+ "ActiveScript",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ STANDARD_MODULE_PROPERTIES
+};
+
+
+sapi_module_struct activescript_sapi_module = {
+ "activescript", /* name */
+ "Active Script", /* pretty name */
+
+ php_activescript_startup, /* startup */
+ php_module_shutdown_wrapper, /* shutdown */
+
+ NULL, /* activate */
+ NULL, /* deactivate */
+
+ sapi_activescript_ub_write, /* unbuffered write */
+ NULL, /* flush */
+ NULL, /* get uid */
+ NULL, /* getenv */
+
+ zend_error, /* error handler */
+
+ sapi_activescript_header_handler, /* header handler */
+ sapi_activescript_send_headers, /* send headers handler */
+ NULL, /* send header handler */
+
+ NULL, /* read POST data */
+ sapi_activescript_read_cookies, /* read Cookies */
+
+ sapi_activescript_register_server_variables, /* register server variables */
+ NULL, /* Log message */
+
+ NULL, /* Block interruptions */
+ NULL, /* Unblock interruptions */
+
+ STANDARD_SAPI_MODULE_PROPERTIES
+};
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ module_handle = hinstDLL;
+
+ tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log");
+
+ sapi_startup(&activescript_sapi_module);
+ if (activescript_sapi_module.startup) {
+ activescript_sapi_module.startup(&sapi_module);
+ }
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ ts_free_thread();
+ break;
+ case DLL_PROCESS_DETACH:
+ if (activescript_sapi_module.shutdown) {
+ activescript_sapi_module.shutdown(&sapi_module);
+ }
+ tsrm_shutdown();
+ break;
+ }
+ return TRUE;
+}
+
+