molten.c
/* {{{ molten reload curl function for performance */
{{{ molten reload curl function for performance
{{{ molten reload curl function for performance
static void molten_reload_curl_function()
{
#if PHP_MAJOR_VERSION < 7
    zend_function *orig, *replace;
    const mo_reload_def *p = &(prd[0]);
    while(p->orig_func != NULL) {
        if (zend_hash_find(CG(function_table), p->save_func, strlen(p->orig_func) + 1, (void **)&orig) != SUCCESS) {
            zend_hash_find(CG(function_table), p->over_func, strlen(p->over_func) + 1, (void **)&replace);
            if (zend_hash_find(CG(function_table), p->orig_func, strlen(p->orig_func) + 1, (void **)&orig) == SUCCESS) {
                zend_hash_add(CG(function_table), p->save_func, strlen(p->save_func)+1, orig, sizeof(zend_function), NULL);
                zend_hash_update(CG(function_table), p->orig_func, strlen(p->orig_func) + 1, replace, sizeof(zend_function), NULL);
            }
        }
        p++;
    }
#else
    zend_function *orig, *replace;
    const mo_reload_def *p = &(prd[0]);
    while(p->orig_func != NULL) {
        if (zend_hash_str_find_ptr(CG(function_table), p->save_func, strlen(p->orig_func)) == NULL) {
            replace = zend_hash_str_find_ptr(CG(function_table), p->over_func, strlen(p->over_func));
            if ((orig = zend_hash_str_find_ptr(CG(function_table), p->orig_func, strlen(p->orig_func))) != NULL) {
                if (orig->type == ZEND_INTERNAL_FUNCTION) {
                     orig->common.fn_flags = ZEND_ACC_PUBLIC;
                    if(!strcmp(p->orig_func,"curl_setopt")) {
                        origin_curl_setopt =  pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT);
                        memcpy(origin_curl_setopt, orig, sizeof(zend_internal_function));
                    } else if (!strcmp(p->orig_func,"curl_exec")) {
                        origin_curl_exec =  pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT);
                        memcpy(origin_curl_exec, orig, sizeof(zend_internal_function));
                    } else if (!strcmp(p->orig_func,"curl_setopt_array")) {
                        origin_curl_setopt_array = pemalloc(sizeof(zend_internal_function) , HASH_FLAG_PERSISTENT);
                        memcpy(origin_curl_setopt_array, orig, sizeof(zend_internal_function));
                    } else if (!strcmp(p->orig_func,"curl_reset")) {
                        origin_curl_reset = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT);
                        memcpy(origin_curl_reset, orig, sizeof(zend_internal_function));
                    }
                    function_add_ref(orig);
                    zend_hash_str_update_mem(CG(function_table), p->orig_func, strlen(p->orig_func), replace, sizeof(zend_internal_function));
                    function_add_ref(replace);
                }
            }
        }
        p++;
    }
#endif
#if PHP_MAJOR_VERSION < 7
    zend_function *orig_func;
    if (zend_hash_find(CG(function_table), "origin_molten_curl_setopt", sizeof("origin_molten_curl_setopt"), (void **)&orig_func) == SUCCESS ) {
        origin_curl_setopt = orig_func;
    }
    if (zend_hash_find(CG(function_table), "origin_molten_curl_exec", sizeof("origin_molten_curl_exec"), (void **)&orig_func) == SUCCESS ) {
        origin_curl_exec = orig_func;
    }
    if (zend_hash_find(CG(function_table), "origin_molten_curl_setopt_array", sizeof("origin_molten_curl_setopt_array"), (void **)&orig_func) == SUCCESS ) {
        origin_curl_setopt_array = orig_func;
    }
    if (zend_hash_find(CG(function_table), "origin_molten_curl_reset", sizeof("origin_molten_curl_reset"), (void **)&orig_func) == SUCCESS ) {
        origin_curl_reset = orig_func;
    }
#endif
}
static void molten_reload_curl_function ( ) { #if PHP_MAJOR_VERSION < 7 zend_function * orig , * replace ; const mo_reload_def * p = & ( prd [ 0 ] ) ; while ( p -> orig_func != NULL ) { if ( zend_hash_find ( CG ( function_table ) , p -> save_func , strlen ( p -> orig_func ) + 1 , ( void * * ) & orig ) != SUCCESS ) { zend_hash_find ( CG ( function_table ) , p -> over_func , strlen ( p -> over_func ) + 1 , ( void * * ) & replace ) ; if ( zend_hash_find ( CG ( function_table ) , p -> orig_func , strlen ( p -> orig_func ) + 1 , ( void * * ) & orig ) == SUCCESS ) { zend_hash_add ( CG ( function_table ) , p -> save_func , strlen ( p -> save_func ) + 1 , orig , sizeof ( zend_function ) , NULL ) ; zend_hash_update ( CG ( function_table ) , p -> orig_func , strlen ( p -> orig_func ) + 1 , replace , sizeof ( zend_function ) , NULL ) ; } } p ++ ; } #else zend_function * orig , * replace ; const mo_reload_def * p = & ( prd [ 0 ] ) ; while ( p -> orig_func != NULL ) { if ( zend_hash_str_find_ptr ( CG ( function_table ) , p -> save_func , strlen ( p -> orig_func ) ) == NULL ) { replace = zend_hash_str_find_ptr ( CG ( function_table ) , p -> over_func , strlen ( p -> over_func ) ) ; if ( ( orig = zend_hash_str_find_ptr ( CG ( function_table ) , p -> orig_func , strlen ( p -> orig_func ) ) ) != NULL ) { if ( orig -> type == ZEND_INTERNAL_FUNCTION ) { orig -> common . fn_flags = ZEND_ACC_PUBLIC ; if ( ! strcmp ( p -> orig_func , " " ) ) { origin_curl_setopt = pemalloc ( sizeof ( zend_internal_function ) , HASH_FLAG_PERSISTENT ) ; memcpy ( origin_curl_setopt , orig , sizeof ( zend_internal_function ) ) ; } else if ( ! strcmp ( p -> orig_func , " " ) ) { origin_curl_exec = pemalloc ( sizeof ( zend_internal_function ) , HASH_FLAG_PERSISTENT ) ; memcpy ( origin_curl_exec , orig , sizeof ( zend_internal_function ) ) ; } else if ( ! strcmp ( p -> orig_func , " " ) ) { origin_curl_setopt_array = pemalloc ( sizeof ( zend_internal_function ) , HASH_FLAG_PERSISTENT ) ; memcpy ( origin_curl_setopt_array , orig , sizeof ( zend_internal_function ) ) ; } else if ( ! strcmp ( p -> orig_func , " " ) ) { origin_curl_reset = pemalloc ( sizeof ( zend_internal_function ) , HASH_FLAG_PERSISTENT ) ; memcpy ( origin_curl_reset , orig , sizeof ( zend_internal_function ) ) ; } function_add_ref ( orig ) ; zend_hash_str_update_mem ( CG ( function_table ) , p -> orig_func , strlen ( p -> orig_func ) , replace , sizeof ( zend_internal_function ) ) ; function_add_ref ( replace ) ; } } } p ++ ; } #endif #if PHP_MAJOR_VERSION < 7 zend_function * orig_func ; if ( zend_hash_find ( CG ( function_table ) , " " , sizeof ( " " ) , ( void * * ) & orig_func ) == SUCCESS ) { origin_curl_setopt = orig_func ; } if ( zend_hash_find ( CG ( function_table ) , " " , sizeof ( " " ) , ( void * * ) & orig_func ) == SUCCESS ) { origin_curl_exec = orig_func ; } if ( zend_hash_find ( CG ( function_table ) , " " , sizeof ( " " ) , ( void * * ) & orig_func ) == SUCCESS ) { origin_curl_setopt_array = orig_func ; } if ( zend_hash_find ( CG ( function_table ) , " " , sizeof ( " " ) , ( void * * ) & orig_func ) == SUCCESS ) { origin_curl_reset = orig_func ; } #endif }
{{{ molten reload curl function for performance
{{{ molten reload curl function for performance
//Not execute arg_info release //Set orig handle /* retrieve function from function table */