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.

152 lines
4.0 KiB

  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2004 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.0 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_0.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 "php5activescript.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, &php_activescript_module, 1) == FAILURE) {
  31. return FAILURE;
  32. } else {
  33. return SUCCESS;
  34. }
  35. }
  36. static int sapi_activescript_ub_write(const char *str, uint str_length TSRMLS_DC)
  37. {
  38. /* In theory, this is a blackhole. In practice, I want to see the output
  39. * in the debugger! */
  40. char buf[1024];
  41. uint l, a = str_length;
  42. while(a) {
  43. l = a;
  44. if (l > sizeof(buf) - 1)
  45. l = sizeof(buf) - 1;
  46. memcpy(buf, str, l);
  47. buf[l] = 0;
  48. OutputDebugString(buf);
  49. a -= l;
  50. }
  51. return str_length;
  52. }
  53. static void sapi_activescript_register_server_variables(zval *track_vars_array TSRMLS_DC)
  54. {
  55. }
  56. static char *sapi_activescript_read_cookies(TSRMLS_D)
  57. {
  58. return NULL;
  59. }
  60. static int sapi_activescript_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
  61. {
  62. return SAPI_HEADER_ADD;
  63. }
  64. static int sapi_activescript_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
  65. {
  66. return SAPI_HEADER_SENT_SUCCESSFULLY;
  67. }
  68. zend_module_entry php_activescript_module = {
  69. STANDARD_MODULE_HEADER,
  70. "ActiveScript",
  71. NULL,
  72. NULL,
  73. NULL,
  74. NULL,
  75. NULL,
  76. NULL,
  77. NULL,
  78. STANDARD_MODULE_PROPERTIES
  79. };
  80. sapi_module_struct activescript_sapi_module = {
  81. "activescript", /* name */
  82. "Active Script", /* pretty name */
  83. php_activescript_startup, /* startup */
  84. php_module_shutdown_wrapper, /* shutdown */
  85. NULL, /* activate */
  86. NULL, /* deactivate */
  87. sapi_activescript_ub_write, /* unbuffered write */
  88. NULL, /* flush */
  89. NULL, /* get uid */
  90. NULL, /* getenv */
  91. zend_error, /* error handler */
  92. sapi_activescript_header_handler, /* header handler */
  93. sapi_activescript_send_headers, /* send headers handler */
  94. NULL, /* send header handler */
  95. NULL, /* read POST data */
  96. sapi_activescript_read_cookies, /* read Cookies */
  97. sapi_activescript_register_server_variables, /* register server variables */
  98. NULL, /* Log message */
  99. STANDARD_SAPI_MODULE_PROPERTIES
  100. };
  101. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  102. {
  103. switch (fdwReason) {
  104. case DLL_PROCESS_ATTACH:
  105. module_handle = hinstDLL;
  106. tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log");
  107. sapi_startup(&activescript_sapi_module);
  108. if (activescript_sapi_module.startup) {
  109. activescript_sapi_module.startup(&sapi_module);
  110. }
  111. break;
  112. case DLL_THREAD_ATTACH:
  113. break;
  114. case DLL_THREAD_DETACH:
  115. ts_free_thread();
  116. break;
  117. case DLL_PROCESS_DETACH:
  118. if (activescript_sapi_module.shutdown) {
  119. activescript_sapi_module.shutdown(&sapi_module);
  120. }
  121. tsrm_shutdown();
  122. break;
  123. }
  124. return TRUE;
  125. }