Back to index

php5  5.3.10
Functions | Variables
zend_extensions.c File Reference
#include "zend_extensions.h"

Go to the source code of this file.

Functions

int zend_load_extension (const char *path)
int zend_register_extension (zend_extension *new_extension, DL_HANDLE handle)
static void zend_extension_shutdown (zend_extension *extension TSRMLS_DC)
static int zend_extension_startup (zend_extension *extension)
int zend_startup_extensions_mechanism ()
int zend_startup_extensions ()
void zend_shutdown_extensions (TSRMLS_D)
void zend_extension_dtor (zend_extension *extension)
static void zend_extension_message_dispatcher (const zend_extension *extension, int num_args, va_list args TSRMLS_DC)
ZEND_API void zend_extension_dispatch_message (int message, void *arg)
ZEND_API int zend_get_resource_handle (zend_extension *extension)
ZEND_API zend_extension * zend_get_extension (const char *extension_name)

Variables

ZEND_API zend_llist zend_extensions
static int last_resource_number

Function Documentation

ZEND_API void zend_extension_dispatch_message ( int  message,
void *  arg 
)

Definition at line 211 of file zend_extensions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void zend_extension_dtor ( zend_extension *  extension)

Definition at line 187 of file zend_extensions.c.

{
#if ZEND_EXTENSIONS_SUPPORT && !ZEND_DEBUG
       if (extension->handle) {
              DL_UNLOAD(extension->handle);
       }
#endif
}

Here is the caller graph for this function:

static void zend_extension_message_dispatcher ( const zend_extension *  extension,
int  num_args,
va_list args  TSRMLS_DC 
) [static]

Definition at line 197 of file zend_extensions.c.

{
       int message;
       void *arg;

       if (!extension->message_handler || num_args!=2) {
              return;
       }
       message = va_arg(args, int);
       arg = va_arg(args, void *);
       extension->message_handler(message, arg);
}

Here is the caller graph for this function:

static void zend_extension_shutdown ( zend_extension *extension  TSRMLS_DC) [static]

Definition at line 141 of file zend_extensions.c.

{
#if ZEND_EXTENSIONS_SUPPORT
       if (extension->shutdown) {
              extension->shutdown(extension);
       }
#endif
}

Here is the caller graph for this function:

static int zend_extension_startup ( zend_extension *  extension) [static]

Definition at line 150 of file zend_extensions.c.

{
#if ZEND_EXTENSIONS_SUPPORT
       if (extension->startup) {
              if (extension->startup(extension)!=SUCCESS) {
                     return 1;
              }
              zend_append_version_info(extension);
       }
#endif
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zend_extension* zend_get_extension ( const char *  extension_name)

Definition at line 230 of file zend_extensions.c.

{
       zend_llist_element *element;

       for (element = zend_extensions.head; element; element = element->next) {
              zend_extension *extension = (zend_extension *) element->data;

              if (!strcmp(extension->name, extension_name)) {
                     return extension;
              }
       }
       return NULL;
}
ZEND_API int zend_get_resource_handle ( zend_extension *  extension)

Definition at line 219 of file zend_extensions.c.

{
       if (last_resource_number<ZEND_MAX_RESERVED_RESOURCES) {
              extension->resource_number = last_resource_number;
              return last_resource_number++;
       } else {
              return -1;
       }
}
int zend_load_extension ( const char *  path)

Definition at line 27 of file zend_extensions.c.

{
#if ZEND_EXTENSIONS_SUPPORT
       DL_HANDLE handle;
       zend_extension *new_extension;
       zend_extension_version_info *extension_version_info;

       handle = DL_LOAD(path);
       if (!handle) {
#ifndef ZEND_WIN32
              fprintf(stderr, "Failed loading %s:  %s\n", path, DL_ERROR());
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
              fflush(stderr);
#endif
#else
              fprintf(stderr, "Failed loading %s\n", path);
#endif
              return FAILURE;
       }

       extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "extension_version_info");
       if (!extension_version_info) {
              extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "_extension_version_info");
       }
       new_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, "zend_extension_entry");
       if (!new_extension) {
              new_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, "_zend_extension_entry");
       }
       if (!extension_version_info || !new_extension) {
              fprintf(stderr, "%s doesn't appear to be a valid Zend extension\n", path);
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
              fflush(stderr);
#endif
              DL_UNLOAD(handle);
              return FAILURE;
       }


       /* allow extension to proclaim compatibility with any Zend version */
       if (extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) {
              if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) {
                     fprintf(stderr, "%s requires Zend Engine API version %d.\n"
                                   "The Zend Engine API version %d which is installed, is outdated.\n\n",
                                   new_extension->name,
                                   extension_version_info->zend_extension_api_no,
                                   ZEND_EXTENSION_API_NO);
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
                     fflush(stderr);
#endif
                     DL_UNLOAD(handle);
                     return FAILURE;
              } else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {
                     fprintf(stderr, "%s requires Zend Engine API version %d.\n"
                                   "The Zend Engine API version %d which is installed, is newer.\n"
                                   "Contact %s at %s for a later version of %s.\n\n",
                                   new_extension->name,
                                   extension_version_info->zend_extension_api_no,
                                   ZEND_EXTENSION_API_NO,
                                   new_extension->author,
                                   new_extension->URL,
                                   new_extension->name);
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
                     fflush(stderr);
#endif
                     DL_UNLOAD(handle);
                     return FAILURE;
              }
       } else if (strcmp(ZEND_EXTENSION_BUILD_ID, extension_version_info->build_id) &&
                  (!new_extension->build_id_check || new_extension->build_id_check(ZEND_EXTENSION_BUILD_ID) != SUCCESS)) {
              fprintf(stderr, "Cannot load %s - it was built with configuration %s, whereas running engine is %s\n",
                                   new_extension->name, extension_version_info->build_id, ZEND_EXTENSION_BUILD_ID);
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
              fflush(stderr);
#endif
              DL_UNLOAD(handle);
              return FAILURE;
       }

       return zend_register_extension(new_extension, handle);
#else
       fprintf(stderr, "Extensions are not supported on this platform.\n");
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
       fflush(stderr);
#endif
       return FAILURE;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

int zend_register_extension ( zend_extension *  new_extension,
DL_HANDLE  handle 
)

Definition at line 122 of file zend_extensions.c.

{
#if ZEND_EXTENSIONS_SUPPORT
       zend_extension extension;

       extension = *new_extension;
       extension.handle = handle;

       zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension);

       zend_llist_add_element(&zend_extensions, &extension);

       /*fprintf(stderr, "Loaded %s, version %s\n", extension.name, extension.version);*/
#endif

       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 180 of file zend_extensions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file zend_extensions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file zend_extensions.c.

{
       /* Startup extensions mechanism */
       zend_llist_init(&zend_extensions, sizeof(zend_extension), (void (*)(void *)) zend_extension_dtor, 1);
       last_resource_number = 0;
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 25 of file zend_extensions.c.

Definition at line 24 of file zend_extensions.c.