Changeset 938 in svn for trunk/utils.c


Ignore:
Timestamp:
2012-06-28T10:17:58Z (3 years ago)
Author:
Xuefer
Message:

finished sandbox rewrite

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r937 r938  
    765765#endif
    766766
    767 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */
     767static xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */
    768768{
    769769    HashTable *h;
     
    930930}
    931931/* }}} */
    932 void xc_sandbox_free(xc_sandbox_t *sandbox, zend_op_array *op_array TSRMLS_DC) /* {{{ */
     932static void xc_sandbox_free(xc_sandbox_t *sandbox, zend_op_array *op_array TSRMLS_DC) /* {{{ */
    933933{
    934934    XG(sandbox) = NULL;
     
    998998}
    999999/* }}} */
    1000 const Bucket *xc_sandbox_user_function_begin() /* {{{ */
     1000zend_op_array *xc_sandbox(xc_sandboxed_func_t sandboxed_func, void *data, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */
     1001{
     1002    xc_sandbox_t sandbox;
     1003    zend_op_array *op_array = NULL;
     1004    zend_bool catched = 0;
     1005
     1006    memset(&sandbox, 0, sizeof(sandbox));
     1007    zend_try {
     1008        xc_sandbox_init(&sandbox, filename TSRMLS_CC);
     1009        op_array = sandboxed_func(data TSRMLS_CC);
     1010    } zend_catch {
     1011        catched = 1;
     1012    } zend_end_try();
     1013
     1014    xc_sandbox_free(&sandbox, op_array TSRMLS_CC);
     1015    if (catched) {
     1016        zend_bailout();
     1017    }
     1018    return op_array;
     1019}
     1020/* {{{ */
     1021const Bucket *xc_sandbox_user_function_begin(TSRMLS_D) /* {{{ */
    10011022{
    10021023    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
    10031024    assert(sandbox);
    10041025    return TG(internal_function_tail) ? TG(internal_function_tail)->pListNext : TG(function_table).pListHead;
    1005 } /* {{{ */
    1006 const Bucket *xc_sandbox_user_class_begin() /* {{{ */
     1026}
     1027/* {{{ */
     1028const Bucket *xc_sandbox_user_class_begin(TSRMLS_D) /* {{{ */
    10071029{
    10081030    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
    10091031    assert(sandbox);
    10101032    return TG(internal_class_tail) ? TG(internal_class_tail)->pListNext : TG(class_table).pListHead;
    1011 } /* {{{ */
     1033}
     1034/* {{{ */
    10121035#ifdef XCACHE_ERROR_CACHING
    1013 xc_compilererror_t *xc_sandbox_compilererrors() /* {{{ */
     1036xc_compilererror_t *xc_sandbox_compilererrors(TSRMLS_D) /* {{{ */
    10141037{
    10151038    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
    10161039    assert(sandbox);
    10171040    return sandbox->compilererrors;
    1018 } /* }}} */
    1019 zend_uint xc_sandbox_compilererror_cnt() /* {{{ */
     1041}
     1042/* }}} */
     1043zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D) /* {{{ */
    10201044{
    10211045    xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
    10221046    assert(sandbox);
    10231047    return sandbox->compilererror_cnt;
    1024 } /* }}} */
    1025 #endif
    1026 
     1048}
     1049/* }}} */
     1050#endif
    10271051
    10281052int xc_vtrace(const char *fmt, va_list args) /* {{{ */
Note: See TracChangeset for help on using the changeset viewer.