⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swigutil_pl.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* Be nice and allocate the memory for the cred structure before passing it     * off to the perl space */  *cred = apr_pcalloc(pool, sizeof(**cred));    if (!*cred) {      croak("Could not allocate memory for cred structure");    }    svn_swig_pl_callback_thunk(CALL_SV,                               baton, NULL,                               "SsiSbS", *cred, _SWIG_TYPE("svn_auth_cred_ssl_server_trust_t *"),                               realm, failures,                                cert_info, _SWIG_TYPE("svn_auth_ssl_server_cert_info_t *"),                               may_save, pool, POOLINFO);    /* Allow the perl callback to indicate failure by setting all vars to 0      * or by simply doing nothing.  While still allowing them to indicate     * failure by setting the cred strucutre's pointer to 0 via $$cred = 0 */    if (*cred) {        if ((*cred)->may_save == 0 && (*cred)->accepted_failures == 0) {            *cred = NULL;        }    }    return SVN_NO_ERROR;}svn_error_t *svn_swig_pl_thunk_ssl_client_cert_prompt(                svn_auth_cred_ssl_client_cert_t **cred,                void *baton,                const char * realm,                svn_boolean_t may_save,                apr_pool_t *pool){    /* Be nice and allocate the memory for the cred structure before passing it     * off to the perl space */  *cred = apr_pcalloc(pool, sizeof(**cred));    if (!*cred) {      croak("Could not allocate memory for cred structure");    }    svn_swig_pl_callback_thunk(CALL_SV,                               baton, NULL,                               "SsbS", *cred, _SWIG_TYPE("svn_auth_cred_ssl_client_cert_t *"),                               realm, may_save, pool, POOLINFO);    return SVN_NO_ERROR;}svn_error_t *svn_swig_pl_thunk_ssl_client_cert_pw_prompt(                                     svn_auth_cred_ssl_client_cert_pw_t **cred,                                     void *baton,                                     const char *realm,                                     svn_boolean_t may_save,                                     apr_pool_t *pool){    /* Be nice and allocate the memory for the cred structure before passing it     * off to the perl space */  *cred = apr_pcalloc(pool, sizeof(**cred));    if (!*cred) {      croak("Could not allocate memory for cred structure");    }    svn_swig_pl_callback_thunk(CALL_SV,                               baton, NULL,                               "SsbS", *cred, _SWIG_TYPE("svn_auth_cred_ssl_client_cert_pw_t *"),                               realm, may_save, pool, POOLINFO);    return SVN_NO_ERROR;}/* Thunked version of svn_wc_notify_func_t callback type */void svn_swig_pl_notify_func(void * baton,		             const char *path,			     svn_wc_notify_action_t action,			     svn_node_kind_t kind,			     const char *mime_type,			     svn_wc_notify_state_t content_state,			     svn_wc_notify_state_t prop_state,			     svn_revnum_t revision){    if (!SvOK((SV *)baton)) {        return;     }    svn_swig_pl_callback_thunk(CALL_SV,                               baton, NULL,                               "siisiir", path, action, kind, mime_type,                               content_state, prop_state, revision);    }/* Thunked version of svn_client_get_commit_log_t callback type. */svn_error_t *svn_swig_pl_get_commit_log_func(const char **log_msg,                                             const char **tmp_file,                                             apr_array_header_t *commit_items,                                             void *baton,                                             apr_pool_t *pool){    SV *result;    svn_error_t *ret_val = SVN_NO_ERROR;    SV *log_msg_sv;    SV *tmp_file_sv;    SV *commit_items_sv;    if (!SvOK((SV *)baton)) {      *log_msg = apr_pstrdup(pool, "");	*tmp_file = NULL;        return SVN_NO_ERROR;    }        log_msg_sv = newRV_noinc(sv_newmortal());    tmp_file_sv = newRV_noinc(sv_newmortal());    commit_items_sv = svn_swig_pl_convert_array      (commit_items, _SWIG_TYPE("svn_client_commit_item_t *"));    svn_swig_pl_callback_thunk(CALL_SV,                               baton, &result,                               "OOOS", log_msg_sv, tmp_file_sv,                               commit_items_sv, pool, POOLINFO);    if (!SvOK(SvRV(log_msg_sv))) {        /* client returned undef to us */        *log_msg = NULL;    } else if (SvPOK(SvRV(log_msg_sv))) {	/* client returned string so get the string and then duplicate	 * it using pool memory */        *log_msg = apr_pstrdup(pool, SvPV_nolen(SvRV(log_msg_sv)));    } else {        croak("Invalid value in log_msg reference, must be undef or a string");    }    if (!SvOK(SvRV(tmp_file_sv))) {	*tmp_file = NULL;    } else if (SvPOK(SvRV(tmp_file_sv))) {	*tmp_file = apr_pstrdup(pool, SvPV_nolen(SvRV(tmp_file_sv)));    } else {        croak("Invalid value in tmp_file reference, "              "must be undef or a string");        }    if (sv_derived_from(result, "_p_svn_error_t")) {        swig_type_info *errorinfo = _SWIG_TYPE("svn_error_t *");	if (SWIG_ConvertPtr(result, (void *)&ret_val, errorinfo, 0) < 0) {            SvREFCNT_dec(result);	    croak("Unable to convert from SWIG Type");        }    }    SvREFCNT_dec(result);    return ret_val;}/* Thunked version of svn_client_info_t callback type. */svn_error_t *svn_swig_pl_info_receiver(void *baton,                                       const char *path,                                       const svn_info_t *info,                                       apr_pool_t *pool){    SV *result;    svn_error_t *ret_val;    swig_type_info *infoinfo = _SWIG_TYPE("svn_info_t *");    if (!SvOK((SV *)baton))        return;       svn_swig_pl_callback_thunk(CALL_SV, baton, &result, "sSS", path, info,                               infoinfo, pool, POOLINFO);     if (sv_derived_from(result, "_p_svn_error_t")) {        swig_type_info *errorinfo = _SWIG_TYPE("svn_error_t *");        if (SWIG_ConvertPtr(result, (void *)&ret_val, errorinfo, 0) < 0) {            SvREFCNT_dec(result);            croak("Unable to convert from SWIG Type");        }    }    else        ret_val = SVN_NO_ERROR;        SvREFCNT_dec(result);    return ret_val;}/* Thunked version of svn_wc_cancel_func_t callback type. */svn_error_t *svn_swig_pl_cancel_func(void *cancel_baton) {    SV *result;    svn_error_t *ret_val;    if (!SvOK((SV *)cancel_baton)) {        return SVN_NO_ERROR;    }    svn_swig_pl_callback_thunk(CALL_SV, cancel_baton, &result, "");    if (sv_derived_from(result,"_p_svn_error_t")) {         swig_type_info *errorinfo = _SWIG_TYPE("svn_error_t *");	if (SWIG_ConvertPtr(result, (void *)&ret_val, errorinfo, 0) < 0) {	    SvREFCNT_dec(result);	    croak("Unable to convert from SWIG Type");	}    } else if (SvIOK(result) && SvIV(result)) {        ret_val = svn_error_create(SVN_ERR_CANCELLED, NULL,                                   "By cancel callback");    } else if (SvTRUE(result) && SvPOK(result)) {        ret_val = svn_error_create(SVN_ERR_CANCELLED, NULL,                                    SvPV_nolen(result));    } else {        ret_val = SVN_NO_ERROR;    }    SvREFCNT_dec(result);    return ret_val;}/* Thunked version of svn_wc_status_func_t callback type. */void svn_swig_pl_status_func(void *baton,                             const char *path,                             svn_wc_status_t *status){  swig_type_info *statusinfo = _SWIG_TYPE("svn_wc_status_t *");  if (!SvOK((SV *)baton)) {    return;  }     svn_swig_pl_callback_thunk(CALL_SV, baton, NULL, "sS",                             path, status, statusinfo); }/* Thunked version of svn_client_blame_receiver_t callback type. */svn_error_t *svn_swig_pl_blame_func(void *baton,                                    apr_int64_t line_no,                                    svn_revnum_t revision,                                    const char *author,                                    const char *date,                                    const char *line,                                    apr_pool_t *pool){    SV *result;    svn_error_t *ret_val = SVN_NO_ERROR;     svn_swig_pl_callback_thunk(CALL_SV, baton, &result, "LrsssS",                               line_no, revision, author, date, line,                               pool, POOLINFO);    if (sv_derived_from(result, "_p_svn_error_t")) {        swig_type_info *errorinfo = _SWIG_TYPE("svn_error_t *");	if (SWIG_ConvertPtr(result, (void *)&ret_val, errorinfo, 0) < 0) {            SvREFCNT_dec(result);	    croak("Unable to convert from SWIG Type");        }    }        SvREFCNT_dec(result);    return ret_val;}/* Thunked config enumerator */svn_boolean_t svn_swig_pl_thunk_config_enumerator(const char *name, const char *value, void *baton){    SV *result;    if (!SvOK((SV *)baton))	return 0;    svn_swig_pl_callback_thunk(CALL_SV, baton, &result,                               "ss", name, value);    return SvOK(result);}/* default pool support */#if defined(SVN_AVOID_CIRCULAR_LINKAGE_AT_ALL_COSTS_HACK)static svn_swig_pl_get_current_pool_t svn_swig_pl_get_current_pool = NULL;static svn_swig_pl_set_current_pool_t svn_swig_pl_set_current_pool = NULL;void svn_swig_pl_bind_current_pool_fns(svn_swig_pl_get_current_pool_t get,                                       svn_swig_pl_set_current_pool_t set){  svn_swig_pl_get_current_pool = get;  svn_swig_pl_set_current_pool = set;}#elseapr_pool_t *svn_swig_pl_get_current_pool(void);void svn_swig_pl_set_current_pool(apr_pool_t *pool);#endifapr_pool_t *svn_swig_pl_make_pool(SV *obj){    apr_pool_t *pool;    if (obj && sv_isobject(obj)) {      if (sv_derived_from(obj, "SVN::Pool")) {	    obj = SvRV(obj);	}	if (sv_derived_from(obj, "_p_apr_pool_t")) {	    SWIG_ConvertPtr(obj, (void **)&pool, POOLINFO, 0);	    return pool;	}    }    if (!svn_swig_pl_get_current_pool())      svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"new_default",                                 &obj, "s", "SVN::Pool");    return svn_swig_pl_get_current_pool();}/* stream interpolability with io::handle */typedef struct  {    SV *obj;    IO *io;} io_baton_t;static svn_error_t *io_handle_read(void *baton,                                   char *buffer,                                   apr_size_t *len){    io_baton_t *io = baton;    MAGIC *mg;    if ((mg = SvTIED_mg((SV*)io->io, PERL_MAGIC_tiedscalar))) {	SV *ret;	SV *buf = sv_newmortal();	svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"READ", &ret, "OOz",                                   SvTIED_obj((SV*)io->io, mg),                                   buf, *len);	*len = SvIV(ret);	SvREFCNT_dec(ret);	memmove(buffer, SvPV_nolen(buf), *len);    }    else      *len = PerlIO_read(IoIFP(io->io), buffer, *len);    return SVN_NO_ERROR;}static svn_error_t *io_handle_write(void *baton,                                    const char *data,                                    apr_size_t *len){    io_baton_t *io = baton;    MAGIC *mg;    if ((mg = SvTIED_mg((SV*)io->io, PERL_MAGIC_tiedscalar))) {	SV *ret, *pv;        pv = sv_2mortal(newSVpvn(data, *len));	svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"WRITE", &ret, "OOz",                                   SvTIED_obj((SV*)io->io, mg), pv, *len);	*len = SvIV(ret);	SvREFCNT_dec(ret);    }    else      *len = PerlIO_write(IoIFP(io->io), data, *len);    return SVN_NO_ERROR;}static svn_error_t *io_handle_close(void *baton){    io_baton_t *io = baton;    MAGIC *mg;    if ((mg = SvTIED_mg((SV*)io->io, PERL_MAGIC_tiedscalar))) {      svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"CLOSE", NULL, "O",                                 SvTIED_obj((SV*)io->io, mg));    }    else {      PerlIO_close(IoIFP(io->io));    }    return SVN_NO_ERROR;}static apr_status_t io_handle_cleanup(void *baton){    io_baton_t *io = baton;    SvREFCNT_dec(io->obj);    return APR_SUCCESS;}svn_error_t *svn_swig_pl_make_stream(svn_stream_t **stream, SV *obj){    IO *io;    int simple_type = 1;    if (!SvOK(obj)) {        *stream = NULL;        return SVN_NO_ERROR;    }    if (obj && sv_isobject(obj)) {      if (sv_derived_from(obj, "SVN::Stream"))        svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"svn_stream",                                   &obj, "O", obj);	else if (!sv_derived_from(obj, "_p_svn_stream_t"))            simple_type = 0;        if (simple_type) {            SWIG_ConvertPtr(obj, (void **)stream, _SWIG_TYPE("svn_stream_t *"), 0);            return SVN_NO_ERROR;        }    }    if (obj && SvROK(obj) && SvTYPE(SvRV(obj)) == SVt_PVGV &&	(io = GvIO(SvRV(obj)))) {	apr_pool_t *pool = svn_swig_pl_get_current_pool();	io_baton_t *iob = apr_palloc(pool, sizeof(io_baton_t));	SvREFCNT_inc(obj);	iob->obj = obj;	iob->io = io;	*stream = svn_stream_create(iob, pool);	svn_stream_set_read(*stream, io_handle_read);	svn_stream_set_write(*stream, io_handle_write);	svn_stream_set_close(*stream, io_handle_close);	apr_pool_cleanup_register(pool, iob, io_handle_cleanup,                                  io_handle_cleanup);    }    else      croak("unknown type for svn_stream_t");    return SVN_NO_ERROR;}SV *svn_swig_pl_from_stream(svn_stream_t *stream){    SV *ret;    svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"new", &ret, "sS",                               "SVN::Stream", stream, _SWIG_TYPE("svn_stream_t *"));    return sv_2mortal(ret);}apr_file_t *svn_swig_pl_make_file(SV *file, apr_pool_t *pool){    apr_file_t *apr_file = NULL;    if (!SvOK(file) || file == &PL_sv_undef)	return NULL;    if (SvPOKp(file)) {      apr_file_open(&apr_file, SvPV_nolen(file),                    APR_CREATE | APR_READ | APR_WRITE,                    APR_OS_DEFAULT,                    pool);    } else if (SvROK(file) && SvTYPE(SvRV(file)) == SVt_PVGV) {        apr_status_t status;#ifdef WIN32        apr_os_file_t osfile = (apr_os_file_t)          _get_osfhandle(PerlIO_fileno(IoIFP(sv_2io(file))));#else        apr_os_file_t osfile = PerlIO_fileno(IoIFP(sv_2io(file)));#endif        status = apr_os_file_put(&apr_file, &osfile,                                  O_CREAT | O_WRONLY, pool);        if (status)            return NULL;    }    return apr_file;}static apr_status_t cleanup_refcnt(void *data){    SV *sv = data;    SvREFCNT_dec(sv);    return APR_SUCCESS;}void svn_swig_pl_hold_ref_in_pool(apr_pool_t *pool, SV *sv){    SvREFCNT_inc(sv);    apr_pool_cleanup_register(pool, sv, cleanup_refcnt, apr_pool_cleanup_null);}SV *svn_swig_pl_from_md5(unsigned char *digest){    SV *ret;    svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"new", &ret, "sS",                               "SVN::MD5", digest,                               _SWIG_TYPE("unsigned char *"));    return sv_2mortal(ret);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -