Back to index

php5  5.3.10
Functions | Variables
php_embed.c File Reference
#include "php_embed.h"
#include "ext/standard/php_standard.h"

Go to the source code of this file.

Functions

static char * php_embed_read_cookies (TSRMLS_D)
static int php_embed_deactivate (TSRMLS_D)
static size_t php_embed_single_write (const char *str, uint str_length)
static int php_embed_ub_write (const char *str, uint str_length TSRMLS_DC)
static void php_embed_flush (void *server_context)
static void php_embed_send_header (sapi_header_struct *sapi_header, void *server_context TSRMLS_DC)
static void php_embed_log_message (char *message)
static void php_embed_register_variables (zval *track_vars_array TSRMLS_DC)
static int php_embed_startup (sapi_module_struct *sapi_module)
EMBED_SAPI_API int php_embed_init (int argc, char **argv PTSRMLS_DC)
EMBED_SAPI_API void php_embed_shutdown (TSRMLS_D)

Variables

const char HARDCODED_INI [] = "max_input_time=-1\n\0"
EMBED_SAPI_API sapi_module_struct php_embed_module
static const zend_function_entry additional_functions []

Function Documentation

static int php_embed_deactivate ( TSRMLS_D  ) [static]

Definition at line 41 of file php_embed.c.

{
       fflush(stdout);
       return SUCCESS;
}
static void php_embed_flush ( void *  server_context) [static]

Definition at line 82 of file php_embed.c.

{
       if (fflush(stdout)==EOF) {
              php_handle_aborted_connection();
       }
}

Here is the call graph for this function:

EMBED_SAPI_API int php_embed_init ( int  argc,
char **argv  PTSRMLS_DC 
)

Definition at line 155 of file php_embed.c.

{
       zend_llist global_vars;
#ifdef ZTS
       void ***tsrm_ls = NULL;
#endif

#ifdef HAVE_SIGNAL_H
#if defined(SIGPIPE) && defined(SIG_IGN)
       signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
                                                         that sockets created via fsockopen()
                                                         don't kill PHP if the remote site
                                                         closes it.  in apache|apxs mode apache
                                                         does that for us!  thies@thieso.net
                                                         20000419 */
#endif
#endif

#ifdef ZTS
  tsrm_startup(1, 1, 0, NULL);
  tsrm_ls = ts_resource(0);
  *ptsrm_ls = tsrm_ls;
#endif

  sapi_startup(&php_embed_module);

#ifdef PHP_WIN32
  _fmode = _O_BINARY;                     /*sets default for file streams to binary */
  setmode(_fileno(stdin), O_BINARY);             /* make the stdio mode be binary */
  setmode(_fileno(stdout), O_BINARY);            /* make the stdio mode be binary */
  setmode(_fileno(stderr), O_BINARY);            /* make the stdio mode be binary */
#endif

  php_embed_module.ini_entries = malloc(sizeof(HARDCODED_INI));
  memcpy(php_embed_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));

  php_embed_module.additional_functions = additional_functions;

  if (argv) {
       php_embed_module.executable_location = argv[0];
  }

  if (php_embed_module.startup(&php_embed_module)==FAILURE) {
         return FAILURE;
  }
 
  zend_llist_init(&global_vars, sizeof(char *), NULL, 0);  

  /* Set some Embedded PHP defaults */
  SG(options) |= SAPI_OPTION_NO_CHDIR;
  SG(request_info).argc=argc;
  SG(request_info).argv=argv;

  if (php_request_startup(TSRMLS_C)==FAILURE) {
         php_module_shutdown(TSRMLS_C);
         return FAILURE;
  }
  
  SG(headers_sent) = 1;
  SG(request_info).no_headers = 1;
  php_register_variable("PHP_SELF", "-", NULL TSRMLS_CC);

  return SUCCESS;
}

Here is the call graph for this function:

static void php_embed_log_message ( char *  message) [static]

Definition at line 93 of file php_embed.c.

{
       fprintf (stderr, "%s\n", message);
}
static char* php_embed_read_cookies ( TSRMLS_D  ) [static]

Definition at line 36 of file php_embed.c.

{
       return NULL;
}
static void php_embed_register_variables ( zval *track_vars_array  TSRMLS_DC) [static]

Definition at line 98 of file php_embed.c.

static void php_embed_send_header ( sapi_header_struct sapi_header,
void *server_context  TSRMLS_DC 
) [static]

Definition at line 89 of file php_embed.c.

{
}

Definition at line 220 of file php_embed.c.

{
       php_request_shutdown((void *) 0);
       php_module_shutdown(TSRMLS_C);
       sapi_shutdown();
#ifdef ZTS
    tsrm_shutdown();
#endif
       if (php_embed_module.ini_entries) {
              free(php_embed_module.ini_entries);
              php_embed_module.ini_entries = NULL;
       }
}

Here is the call graph for this function:

static size_t php_embed_single_write ( const char *  str,
uint  str_length 
) [inline, static]

Definition at line 47 of file php_embed.c.

{
#ifdef PHP_WRITE_STDOUT
       long ret;

       ret = write(STDOUT_FILENO, str, str_length);
       if (ret <= 0) return 0;
       return ret;
#else
       size_t ret;

       ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
       return ret;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int php_embed_startup ( sapi_module_struct *  sapi_module) [static]

Definition at line 103 of file php_embed.c.

{
       if (php_module_startup(sapi_module, NULL, 0)==FAILURE) {
              return FAILURE;
       }
       return SUCCESS;
}

Here is the call graph for this function:

static int php_embed_ub_write ( const char *  str,
uint str_length  TSRMLS_DC 
) [static]

Definition at line 64 of file php_embed.c.

{
       const char *ptr = str;
       uint remaining = str_length;
       size_t ret;

       while (remaining > 0) {
              ret = php_embed_single_write(ptr, remaining);
              if (!ret) {
                     php_handle_aborted_connection();
              }
              ptr += ret;
              remaining -= ret;
       }

       return str_length;
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
       ZEND_FE(dl, arginfo_dl)
       {NULL, NULL, NULL}
}

Definition at line 150 of file php_embed.c.

const char HARDCODED_INI[] = "max_input_time=-1\n\0"

Definition at line 28 of file php_embed.c.

EMBED_SAPI_API sapi_module_struct php_embed_module