2 * ctx.c: initialization function for client context
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
24 /* ==================================================================== */
31 #include <apr_pools.h>
33 #include "svn_client.h"
34 #include "svn_error.h"
36 #include "private/svn_wc_private.h"
43 /* Call the notify_func of the context provided by BATON, if non-NULL. */
45 call_notify_func(void *baton, const svn_wc_notify_t *n, apr_pool_t *pool)
47 const svn_client_ctx_t *ctx = baton;
50 ctx->notify_func(ctx->notify_baton, n->path, n->action, n->kind,
51 n->mime_type, n->content_state, n->prop_state,
56 call_conflict_func(svn_wc_conflict_result_t **result,
57 const svn_wc_conflict_description2_t *conflict,
59 apr_pool_t *result_pool,
60 apr_pool_t *scratch_pool)
62 svn_client_ctx_t *ctx = baton;
64 if (ctx->conflict_func)
66 const svn_wc_conflict_description_t *cd;
68 cd = svn_wc__cd2_to_cd(conflict, scratch_pool);
69 SVN_ERR(ctx->conflict_func(result, cd, ctx->conflict_baton,
74 /* We have to set a result; so we postpone */
75 *result = svn_wc_create_conflict_result(svn_wc_conflict_choose_postpone,
82 /* The magic number in client_ctx_t.magic_id. */
83 #define CLIENT_CTX_MAGIC APR_UINT64_C(0xDEADBEEF600DF00D)
85 svn_client__private_ctx_t *
86 svn_client__get_private_ctx(svn_client_ctx_t *ctx)
88 svn_client__private_ctx_t *const private_ctx =
89 (void*)((char *)ctx - offsetof(svn_client__private_ctx_t, public_ctx));
90 SVN_ERR_ASSERT_NO_RETURN(&private_ctx->public_ctx == ctx);
91 SVN_ERR_ASSERT_NO_RETURN(0 == private_ctx->magic_null);
92 SVN_ERR_ASSERT_NO_RETURN(CLIENT_CTX_MAGIC == private_ctx->magic_id);
97 svn_client_create_context2(svn_client_ctx_t **ctx,
101 svn_config_t *cfg_config;
103 svn_client__private_ctx_t *const private_ctx =
104 apr_pcalloc(pool, sizeof(*private_ctx));
105 svn_client_ctx_t *const public_ctx = &private_ctx->public_ctx;
107 private_ctx->magic_null = 0;
108 private_ctx->magic_id = CLIENT_CTX_MAGIC;
110 public_ctx->notify_func2 = call_notify_func;
111 public_ctx->notify_baton2 = public_ctx;
113 public_ctx->conflict_func2 = call_conflict_func;
114 public_ctx->conflict_baton2 = public_ctx;
116 public_ctx->config = cfg_hash;
119 cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
123 SVN_ERR(svn_wc_context_create(&public_ctx->wc_ctx, cfg_config,
131 svn_client_create_context(svn_client_ctx_t **ctx,
134 return svn_client_create_context2(ctx, NULL, pool);