Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.79 KB | None | 0 0
  1. static size_t sapi_dp_ub_write(const char *str, size_t str_length) {
  2. }
  3. static int php_dp_startup(sapi_module_struct *sapi_module) {
  4.     if (php_module_startup(sapi_module, NULL, 0) == FAILURE) {
  5.         return FAILURE;
  6.     }
  7.     return SUCCESS;
  8. }
  9. static int sapi_dp_deactivate(void) {
  10.     fflush(stdout);
  11.     if(SG(request_info).argv0) {
  12.         free(SG(request_info).argv0);
  13.         SG(request_info).argv0 = NULL;
  14.     }
  15.     return SUCCESS;
  16. }
  17. static void sapi_dp_flush(void *server_context) {
  18.     if (fflush(stdout)==EOF && errno!=EBADF) {
  19. #ifndef PHP_CLI_WIN32_NO_CONSOLE
  20.         php_handle_aborted_connection();
  21. #endif
  22.     }
  23. }
  24. static int sapi_dp_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s) {
  25.     return 0;
  26. }
  27. static void sapi_dp_log_message(char *message, int syslog_type_int) /* {{{ */
  28. {
  29.     fprintf(stderr, "%s\n", message);
  30. #ifdef PHP_WIN32
  31.     fflush(stderr);
  32. #endif
  33. }
  34. static void sapi_dp_register_variables(zval *track_vars_array) /* {{{ */
  35. {
  36.     size_t len;
  37.     char   *docroot = "";
  38.  
  39.     /* In CGI mode, we consider the environment to be a part of the server
  40.      * variables
  41.      */
  42.     php_import_environment_variables(track_vars_array);
  43.    
  44. }
  45. static char* sapi_dp_read_cookies(void) /* {{{ */
  46. {
  47.     return NULL;
  48. }
  49. static void sapi_dp_send_header(sapi_header_struct *sapi_header, void *server_context) /* {{{ */
  50. {
  51. }
  52. static int sapi_dp_send_headers(sapi_headers_struct *sapi_headers) /* {{{ */
  53. {
  54.     /* We do nothing here, this function is needed to prevent that the fallback
  55.      * header handling is called. */
  56.     return SAPI_HEADER_SENT_SUCCESSFULLY;
  57. }
  58. static int php_cli_startup(sapi_module_struct *sapi_module)
  59. {
  60.     return php_module_startup(sapi_module, NULL, 0) == FAILURE ? FAILURE : SUCCESS;
  61. }
  62. static sapi_module_struct dp_sapi_module = {
  63.     "DPackager Loader",
  64.     "DPackager Loader",
  65.  
  66.     php_dp_startup,
  67.     php_module_shutdown_wrapper,
  68.  
  69.     NULL,                      
  70.     sapi_dp_deactivate,        
  71.  
  72.     sapi_dp_ub_write,              
  73.     sapi_dp_flush,               
  74.     NULL,                          
  75.     NULL,                      
  76.  
  77.     php_error,                 
  78.  
  79.     sapi_dp_header_handler,     /* header handler */
  80.     sapi_dp_send_headers,           /* send headers handler */
  81.     sapi_dp_send_header,            /* send header handler */      
  82.  
  83.     NULL,      
  84.     sapi_dp_read_cookies,        
  85.  
  86.     sapi_dp_register_variables, /* register server variables */
  87.     sapi_dp_log_message,            /* Log message */
  88.     NULL,                           /* Get request time */
  89.     NULL,                           /* Child terminate */
  90.  
  91.     STANDARD_SAPI_MODULE_PROPERTIES
  92. };
  93. ZEND_API int startupDPackagerSAPI(void) {
  94.     sapi_module_struct *sapi_module = &dp_sapi_module;
  95.    
  96.     php_tsrm_startup();
  97.     ZEND_TSRMLS_CACHE_UPDATE();
  98.     zend_signal_startup();
  99.    
  100.     sapi_startup(sapi_module);
  101.    
  102.     sapi_module->startup(sapi_module);
  103.     php_request_startup();
  104.    
  105.     zend_eval_string_ex("$a = 1+1;", NULL, (char *)"", 1 TSRMLS_CC);
  106.    
  107.     zend_ini_deactivate();
  108.     php_module_shutdown();
  109.     tsrm_shutdown();
  110.  
  111.     return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement