Changeset 937 for trunk/utils.c


Ignore:
Timestamp:
2012-06-28T11:38:30+02:00 (22 months ago)
Author:
moo
Message:

still WIP: rewrite sandbox to use callback

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r935 r937  
    582582/* }}} */ 
    583583 
    584 /* sandbox {{{ */ 
     584typedef struct { /* sandbox {{{ */ 
     585    ZEND_24(NOTHING, const) char *filename; 
     586 
     587    HashTable orig_included_files; 
     588    HashTable *tmp_included_files; 
     589 
     590#ifdef HAVE_XCACHE_CONSTANT 
     591    HashTable *orig_zend_constants; 
     592    HashTable tmp_zend_constants; 
     593#endif 
     594    HashTable *orig_function_table; 
     595    HashTable *orig_class_table; 
     596    HashTable *orig_auto_globals; 
     597    HashTable tmp_function_table; 
     598    HashTable tmp_class_table; 
     599    HashTable tmp_auto_globals; 
     600#ifdef HAVE_XCACHE_CONSTANT 
     601    Bucket    *tmp_internal_constant_tail; 
     602#endif 
     603    Bucket    *tmp_internal_function_tail; 
     604    Bucket    *tmp_internal_class_tail; 
     605 
     606#ifdef XCACHE_ERROR_CACHING 
     607    int orig_user_error_handler_error_reporting; 
     608    zend_uint compilererror_cnt; 
     609    zend_uint compilererror_size; 
     610    xc_compilererror_t *compilererrors; 
     611#endif 
     612 
     613#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES 
     614    zend_uint orig_compiler_options; 
     615#endif 
     616} xc_sandbox_t; 
     617 
    585618#undef TG 
    586619#undef OG 
     
    731764/* }}} */ 
    732765#endif 
     766 
    733767xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */ 
    734768{ 
     
    825859/* }}} */ 
    826860#endif 
    827 static void xc_sandbox_install(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC) /* {{{ */ 
     861static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */ 
    828862{ 
    829863    zend_uint i; 
     
    874908#endif 
    875909 
    876     if (install != XC_InstallNoBinding) { 
    877910#ifdef ZEND_COMPILE_DELAYED_BINDING 
    878         zend_do_delayed_early_binding(CG(active_op_array) TSRMLS_CC); 
    879 #else 
    880         xc_undo_pass_two(CG(active_op_array) TSRMLS_CC); 
    881         xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC); 
    882         xc_redo_pass_two(CG(active_op_array) TSRMLS_CC); 
    883 #endif 
    884     } 
     911    zend_do_delayed_early_binding(CG(active_op_array) TSRMLS_CC); 
     912#else 
     913    xc_undo_pass_two(CG(active_op_array) TSRMLS_CC); 
     914    xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC); 
     915    xc_redo_pass_two(CG(active_op_array) TSRMLS_CC); 
     916#endif 
    885917 
    886918#ifdef XCACHE_ERROR_CACHING 
     
    898930} 
    899931/* }}} */ 
    900 void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC) /* {{{ */ 
     932void xc_sandbox_free(xc_sandbox_t *sandbox, zend_op_array *op_array TSRMLS_DC) /* {{{ */ 
    901933{ 
    902934    XG(sandbox) = NULL; 
     
    916948#endif 
    917949 
    918     if (install != XC_NoInstall) { 
     950    if (op_array) { 
     951        zend_op_array *old_active_op_array = CG(active_op_array); 
    919952        CG(in_compilation)    = 1; 
    920953        CG(compiled_filename) = ZEND_24(NOTHING, (char *)) sandbox->filename; 
    921954        CG(zend_lineno)       = 0; 
    922         xc_sandbox_install(sandbox, install TSRMLS_CC); 
     955 
     956        CG(active_op_array) = op_array; 
     957        xc_sandbox_install(sandbox TSRMLS_CC); 
     958        CG(active_op_array) = old_active_op_array; 
     959 
    923960        CG(in_compilation)    = 0; 
    924961        CG(compiled_filename) = NULL; 
     
    961998} 
    962999/* }}} */ 
     1000const Bucket *xc_sandbox_user_function_begin() /* {{{ */ 
     1001{ 
     1002    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox); 
     1003    assert(sandbox); 
     1004    return TG(internal_function_tail) ? TG(internal_function_tail)->pListNext : TG(function_table).pListHead; 
     1005} /* {{{ */ 
     1006const Bucket *xc_sandbox_user_class_begin() /* {{{ */ 
     1007{ 
     1008    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox); 
     1009    assert(sandbox); 
     1010    return TG(internal_class_tail) ? TG(internal_class_tail)->pListNext : TG(class_table).pListHead; 
     1011} /* {{{ */ 
     1012#ifdef XCACHE_ERROR_CACHING 
     1013xc_compilererror_t *xc_sandbox_compilererrors() /* {{{ */ 
     1014{ 
     1015    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox); 
     1016    assert(sandbox); 
     1017    return sandbox->compilererrors; 
     1018} /* }}} */ 
     1019zend_uint xc_sandbox_compilererror_cnt() /* {{{ */ 
     1020{ 
     1021    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox); 
     1022    assert(sandbox); 
     1023    return sandbox->compilererror_cnt; 
     1024} /* }}} */ 
     1025#endif 
     1026 
     1027 
    9631028int xc_vtrace(const char *fmt, va_list args) /* {{{ */ 
    9641029{ 
Note: See TracChangeset for help on using the changeset viewer.