📄 property.c
字号:
void **acceptor_baton, serf_response_handler_t *handler, void **handler_baton, apr_pool_t *pool){ svn_ra_serf__propfind_context_t *ctx = setup_baton; svn_ra_serf__xml_parser_t *parser_ctx = ctx->parser_ctx; *req_bkt = svn_ra_serf__bucket_propfind_create(ctx->conn, ctx->path, ctx->label, ctx->depth, ctx->find_props, serf_request_get_alloc(request)); if (ctx->conn->using_ssl) { *req_bkt = serf_bucket_ssl_encrypt_create(*req_bkt, ctx->conn->ssl_context, serf_request_get_alloc(request)); if (!ctx->conn->ssl_context) { ctx->conn->ssl_context = serf_bucket_ssl_encrypt_context_get(*req_bkt); } } parser_ctx->pool = pool; parser_ctx->user_data = ctx; parser_ctx->start = start_propfind; parser_ctx->end = end_propfind; parser_ctx->cdata = cdata_propfind; parser_ctx->status_code = &ctx->status_code; parser_ctx->done = &ctx->done; parser_ctx->done_list = ctx->done_list; parser_ctx->done_item = &ctx->done_item; *handler = svn_ra_serf__handle_xml_parser; *handler_baton = parser_ctx; return APR_SUCCESS;}static svn_boolean_tcheck_cache(apr_hash_t *ret_props, svn_ra_serf__session_t *sess, const char *path, svn_revnum_t rev, const svn_ra_serf__dav_props_t *find_props, apr_pool_t *pool){ svn_boolean_t cache_hit = TRUE; const svn_ra_serf__dav_props_t *prop; /* check to see if we have any of this information cached */ prop = find_props; while (prop && prop->namespace) { const svn_string_t *val; val = svn_ra_serf__get_ver_prop_string(sess->cached_props, path, rev, prop->namespace, prop->name); if (val) { svn_ra_serf__set_ver_prop(ret_props, path, rev, prop->namespace, prop->name, val, pool); } else { cache_hit = FALSE; } prop++; } return cache_hit;}/* * This function will deliver a PROP_CTX PROPFIND request in the SESS * serf context for the properties listed in LOOKUP_PROPS at URL for * DEPTH ("0","1","infinity"). * * This function will not block waiting for the response. Instead, the * caller is expected to call context_run and wait for the PROP_CTX->done * flag to be set. */svn_error_t *svn_ra_serf__deliver_props(svn_ra_serf__propfind_context_t **prop_ctx, apr_hash_t *ret_props, svn_ra_serf__session_t *sess, svn_ra_serf__connection_t *conn, const char *path, svn_revnum_t rev, const char *depth, const svn_ra_serf__dav_props_t *find_props, svn_boolean_t cache_props, svn_ra_serf__list_t **done_list, apr_pool_t *pool){ svn_ra_serf__propfind_context_t *new_prop_ctx; if (!*prop_ctx) { svn_ra_serf__handler_t *handler; if (cache_props == TRUE) { svn_boolean_t cache_satisfy; cache_satisfy = check_cache(ret_props, sess, path, rev, find_props, pool); if (cache_satisfy) { *prop_ctx = NULL; return SVN_NO_ERROR; } } new_prop_ctx = apr_pcalloc(pool, sizeof(*new_prop_ctx)); new_prop_ctx->pool = apr_hash_pool_get(ret_props); new_prop_ctx->path = path; new_prop_ctx->cache_props = cache_props; new_prop_ctx->find_props = find_props; new_prop_ctx->ret_props = ret_props; new_prop_ctx->depth = depth; new_prop_ctx->done = FALSE; new_prop_ctx->sess = sess; new_prop_ctx->conn = conn; new_prop_ctx->rev = rev; new_prop_ctx->done_list = done_list; if (SVN_IS_VALID_REVNUM(rev)) { new_prop_ctx->label = apr_ltoa(pool, rev); } else { new_prop_ctx->label = NULL; } handler = apr_pcalloc(pool, sizeof(*handler)); handler->method = "PROPFIND"; handler->delegate = setup_propfind; handler->delegate_baton = new_prop_ctx; handler->session = new_prop_ctx->sess; handler->conn = new_prop_ctx->conn; new_prop_ctx->handler = handler; new_prop_ctx->parser_ctx = apr_pcalloc(pool, sizeof(*new_prop_ctx->parser_ctx)); *prop_ctx = new_prop_ctx; } /* create request */ svn_ra_serf__request_create((*prop_ctx)->handler); return SVN_NO_ERROR;}svn_boolean_tsvn_ra_serf__propfind_is_done(svn_ra_serf__propfind_context_t *ctx){ return ctx->done;}intsvn_ra_serf__propfind_status_code(svn_ra_serf__propfind_context_t *ctx){ return ctx->status_code;}/* * This helper function will block until the PROP_CTX indicates that is done * or another error is returned. */svn_error_t *svn_ra_serf__wait_for_props(svn_ra_serf__propfind_context_t *prop_ctx, svn_ra_serf__session_t *sess, apr_pool_t *pool){ svn_error_t *err; err = svn_ra_serf__context_run_wait(&prop_ctx->done, sess, pool); SVN_ERR(prop_ctx->parser_ctx->error); return err;}/* * This is a blocking version of deliver_props. */svn_error_t *svn_ra_serf__retrieve_props(apr_hash_t *prop_vals, svn_ra_serf__session_t *sess, svn_ra_serf__connection_t *conn, const char *url, svn_revnum_t rev, const char *depth, const svn_ra_serf__dav_props_t *props, apr_pool_t *pool){ svn_ra_serf__propfind_context_t *prop_ctx = NULL; SVN_ERR(svn_ra_serf__deliver_props(&prop_ctx, prop_vals, sess, conn, url, rev, depth, props, TRUE, NULL, pool)); if (prop_ctx) { SVN_ERR(svn_ra_serf__wait_for_props(prop_ctx, sess, pool)); } return SVN_NO_ERROR;}voidsvn_ra_serf__walk_all_props(apr_hash_t *props, const char *name, svn_revnum_t rev, svn_ra_serf__walker_visitor_t walker, void *baton, apr_pool_t *pool){ apr_hash_index_t *ns_hi; apr_hash_t *ver_props, *path_props; ver_props = apr_hash_get(props, &rev, sizeof(rev)); if (!ver_props) { return; } path_props = apr_hash_get(ver_props, name, strlen(name)); if (!path_props) { return; } for (ns_hi = apr_hash_first(pool, path_props); ns_hi; ns_hi = apr_hash_next(ns_hi)) { void *ns_val; const void *ns_name; apr_ssize_t ns_len; apr_hash_index_t *name_hi; apr_hash_this(ns_hi, &ns_name, &ns_len, &ns_val); for (name_hi = apr_hash_first(pool, ns_val); name_hi; name_hi = apr_hash_next(name_hi)) { void *prop_val; const void *prop_name; apr_ssize_t prop_len; apr_hash_this(name_hi, &prop_name, &prop_len, &prop_val); /* use a subpool? */ walker(baton, ns_name, ns_len, prop_name, prop_len, prop_val, pool); } }}voidsvn_ra_serf__walk_all_paths(apr_hash_t *props, svn_revnum_t rev, svn_ra_serf__path_rev_walker_t walker, void *baton, apr_pool_t *pool){ apr_hash_index_t *path_hi; apr_hash_t *ver_props; ver_props = apr_hash_get(props, &rev, sizeof(rev)); if (!ver_props) { return; } for (path_hi = apr_hash_first(pool, ver_props); path_hi; path_hi = apr_hash_next(path_hi)) { void *path_props; const void *path_name; apr_ssize_t path_len; apr_hash_index_t *ns_hi; apr_hash_this(path_hi, &path_name, &path_len, &path_props); for (ns_hi = apr_hash_first(pool, path_props); ns_hi; ns_hi = apr_hash_next(ns_hi)) { void *ns_val; const void *ns_name; apr_ssize_t ns_len; apr_hash_index_t *name_hi; apr_hash_this(ns_hi, &ns_name, &ns_len, &ns_val); for (name_hi = apr_hash_first(pool, ns_val); name_hi; name_hi = apr_hash_next(name_hi)) { void *prop_val; const void *prop_name; apr_ssize_t prop_len; apr_hash_this(name_hi, &prop_name, &prop_len, &prop_val); /* use a subpool? */ walker(baton, path_name, path_len, ns_name, ns_len, prop_name, prop_len, prop_val, pool); } } }}static svn_error_t *set_bare_props(svn_ra_serf__prop_set_t setprop, void *baton, const char *ns, apr_ssize_t ns_len, const char *name, apr_ssize_t name_len, const svn_string_t *val, apr_pool_t *pool){ const char *prop_name; if (strcmp(ns, SVN_DAV_PROP_NS_CUSTOM) == 0) prop_name = name; else if (strcmp(ns, SVN_DAV_PROP_NS_SVN) == 0) prop_name = apr_pstrcat(pool, SVN_PROP_PREFIX, name, NULL); else if (strcmp(ns, SVN_PROP_PREFIX) == 0) prop_name = apr_pstrcat(pool, SVN_PROP_PREFIX, name, NULL); else if (strcmp(ns, "") == 0) prop_name = name; else { /* do nothing for now? */ return SVN_NO_ERROR; } return setprop(baton, prop_name, val, pool);}svn_error_t *svn_ra_serf__set_baton_props(svn_ra_serf__prop_set_t setprop, void *baton, const char *ns, apr_ssize_t ns_len, const char *name, apr_ssize_t name_len, const svn_string_t *val, apr_pool_t *pool){ const char *prop_name; if (strcmp(ns, SVN_DAV_PROP_NS_CUSTOM) == 0) prop_name = name; else if (strcmp(ns, SVN_DAV_PROP_NS_SVN) == 0) prop_name = apr_pstrcat(pool, SVN_PROP_PREFIX, name, NULL); else if (strcmp(ns, SVN_PROP_PREFIX) == 0) prop_name = apr_pstrcat(pool, SVN_PROP_PREFIX, name, NULL); else if (strcmp(ns, "") == 0) prop_name = name; else if (strcmp(name, "version-name") == 0) prop_name = SVN_PROP_ENTRY_COMMITTED_REV; else if (strcmp(name, "creationdate") == 0) prop_name = SVN_PROP_ENTRY_COMMITTED_DATE; else if (strcmp(name, "creator-displayname") == 0) prop_name = SVN_PROP_ENTRY_LAST_AUTHOR; else if (strcmp(name, "repository-uuid") == 0) prop_name = SVN_PROP_ENTRY_UUID; else if (strcmp(name, "lock-token") == 0) prop_name = SVN_PROP_ENTRY_LOCK_TOKEN; else if (strcmp(name, "checked-in") == 0) prop_name = SVN_RA_SERF__WC_CHECKED_IN_URL; else { /* do nothing for now? */ return SVN_NO_ERROR; } return setprop(baton, prop_name, val, pool);}static svn_error_t *set_hash_props(void *baton, const char *name, const svn_string_t *value, apr_pool_t *pool){ apr_hash_t *props = baton; apr_hash_set(props, name, APR_HASH_KEY_STRING, value); return SVN_NO_ERROR;}svn_error_t *svn_ra_serf__set_flat_props(void *baton, const char *ns, apr_ssize_t ns_len, const char *name, apr_ssize_t name_len, const svn_string_t *val, apr_pool_t *pool){ return svn_ra_serf__set_baton_props(set_hash_props, baton, ns, ns_len, name, name_len, val, pool);}svn_error_t *svn_ra_serf__set_bare_props(void *baton, const char *ns, apr_ssize_t ns_len, const char *name, apr_ssize_t name_len, const svn_string_t *val, apr_pool_t *pool){ return set_bare_props(set_hash_props, baton, ns, ns_len, name, name_len, val, pool);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -