You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.1 KiB

  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 4 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2002 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.02 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available at through the world-wide-web at |
  10. | http://www.php.net/license/2_02.txt. |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Wez Furlong <wez@thebrainroom.com> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #include "php.h"
  20. #include "php_main.h"
  21. #include "SAPI.h"
  22. #include "php_globals.h"
  23. #include "ext/standard/info.h"
  24. #include "php_variables.h"
  25. #include "php_ini.h"
  26. #include "php4activescript.h"
  27. /* SAPI definitions and DllMain */
  28. static int php_activescript_startup(sapi_module_struct *sapi_module)
  29. {
  30. if (php_module_startup(sapi_module) == FAILURE ||
  31. zend_startup_module(&php_activescript_module) == FAILURE) {
  32. return FAILURE;
  33. } else {
  34. return SUCCESS;
  35. }
  36. }
  37. static int sapi_activescript_ub_write(const char *str, uint str_length TSRMLS_DC)
  38. {
  39. /* In theory, this is a blackhole. In practice, I wan't to see the output
  40. * in the debugger! */
  41. char buf[1024];
  42. uint l, a = str_length;
  43. while(a) {
  44. l = a;
  45. if (l > sizeof(buf) - 1)
  46. l = sizeof(buf) - 1;
  47. memcpy(buf, str, l);
  48. buf[l] = 0;
  49. OutputDebugString(buf);
  50. a -= l;
  51. }
  52. return str_length;
  53. }
  54. static void sapi_activescript_register_server_variables(zval *track_vars_array TSRMLS_DC)
  55. {
  56. }
  57. static char *sapi_activescript_read_cookies(TSRMLS_D)
  58. {
  59. return NULL;
  60. }
  61. static int sapi_activescript_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
  62. {
  63. return SAPI_HEADER_ADD;
  64. }
  65. static int sapi_activescript_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
  66. {
  67. return SAPI_HEADER_SENT_SUCCESSFULLY;
  68. }
  69. zend_module_entry php_activescript_module = {
  70. STANDARD_MODULE_HEADER,
  71. "ActiveScript",
  72. NULL,
  73. NULL,
  74. NULL,
  75. NULL,
  76. NULL,
  77. NULL,
  78. NULL,
  79. STANDARD_MODULE_PROPERTIES
  80. };
  81. sapi_module_struct activescript_sapi_module = {
  82. "activescript", /* name */
  83. "Active Script", /* pretty name */
  84. php_activescript_startup, /* startup */
  85. php_module_shutdown_wrapper, /* shutdown */
  86. NULL, /* activate */
  87. NULL, /* deactivate */
  88. sapi_activescript_ub_write, /* unbuffered write */
  89. NULL, /* flush */
  90. NULL, /* get uid */
  91. NULL, /* getenv */
  92. zend_error, /* error handler */
  93. sapi_activescript_header_handler, /* header handler */
  94. sapi_activescript_send_headers, /* send headers handler */
  95. NULL, /* send header handler */
  96. NULL, /* read POST data */
  97. sapi_activescript_read_cookies, /* read Cookies */
  98. sapi_activescript_register_server_variables, /* register server variables */
  99. NULL, /* Log message */
  100. NULL, /* Block interruptions */
  101. NULL, /* Unblock interruptions */
  102. STANDARD_SAPI_MODULE_PROPERTIES
  103. };
  104. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  105. {
  106. switch (fdwReason) {
  107. case DLL_PROCESS_ATTACH:
  108. module_handle = hinstDLL;
  109. tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log");
  110. sapi_startup(&activescript_sapi_module);
  111. if (activescript_sapi_module.startup) {
  112. activescript_sapi_module.startup(&sapi_module);
  113. }
  114. break;
  115. case DLL_THREAD_ATTACH:
  116. break;
  117. case DLL_THREAD_DETACH:
  118. ts_free_thread();
  119. break;
  120. case DLL_PROCESS_DETACH:
  121. if (activescript_sapi_module.shutdown) {
  122. activescript_sapi_module.shutdown(&sapi_module);
  123. }
  124. tsrm_shutdown();
  125. break;
  126. }
  127. return TRUE;
  128. }