2 * compat.c : Wrappers and callbacks for compatibility.
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 #include <apr_pools.h>
25 #include <apr_strings.h>
28 #include "svn_types.h"
29 #include "svn_error.h"
30 #include "svn_compat.h"
31 #include "svn_props.h"
34 /* Baton for use with svn_compat_wrap_commit_callback */
35 struct commit_wrapper_baton {
37 svn_commit_callback_t callback;
40 /* This implements svn_commit_callback2_t. */
42 commit_wrapper_callback(const svn_commit_info_t *commit_info,
43 void *baton, apr_pool_t *pool)
45 struct commit_wrapper_baton *cwb = baton;
48 return cwb->callback(commit_info->revision,
57 svn_compat_wrap_commit_callback(svn_commit_callback2_t *callback2,
58 void **callback2_baton,
59 svn_commit_callback_t callback,
63 struct commit_wrapper_baton *cwb = apr_palloc(pool, sizeof(*cwb));
65 /* Set the user provided old format callback in the baton */
66 cwb->baton = callback_baton;
67 cwb->callback = callback;
69 *callback2_baton = cwb;
70 *callback2 = commit_wrapper_callback;
75 svn_compat_log_revprops_clear(apr_hash_t *revprops)
79 svn_hash_sets(revprops, SVN_PROP_REVISION_AUTHOR, NULL);
80 svn_hash_sets(revprops, SVN_PROP_REVISION_DATE, NULL);
81 svn_hash_sets(revprops, SVN_PROP_REVISION_LOG, NULL);
86 svn_compat_log_revprops_in(apr_pool_t *pool)
88 apr_array_header_t *revprops = apr_array_make(pool, 3, sizeof(char *));
90 APR_ARRAY_PUSH(revprops, const char *) = SVN_PROP_REVISION_AUTHOR;
91 APR_ARRAY_PUSH(revprops, const char *) = SVN_PROP_REVISION_DATE;
92 APR_ARRAY_PUSH(revprops, const char *) = SVN_PROP_REVISION_LOG;
98 svn_compat_log_revprops_out(const char **author, const char **date,
99 const char **message, apr_hash_t *revprops)
101 svn_string_t *author_s, *date_s, *message_s;
103 *author = *date = *message = NULL;
106 if ((author_s = svn_hash_gets(revprops, SVN_PROP_REVISION_AUTHOR)))
107 *author = author_s->data;
108 if ((date_s = svn_hash_gets(revprops, SVN_PROP_REVISION_DATE)))
109 *date = date_s->data;
110 if ((message_s = svn_hash_gets(revprops, SVN_PROP_REVISION_LOG)))
111 *message = message_s->data;
115 /* Baton for use with svn_compat_wrap_log_receiver */
116 struct log_wrapper_baton {
118 svn_log_message_receiver_t receiver;
121 /* This implements svn_log_entry_receiver_t. */
123 log_wrapper_callback(void *baton,
124 svn_log_entry_t *log_entry,
127 struct log_wrapper_baton *lwb = baton;
129 if (lwb->receiver && SVN_IS_VALID_REVNUM(log_entry->revision))
131 const char *author, *date, *message;
132 svn_compat_log_revprops_out(&author, &date, &message,
133 log_entry->revprops);
134 return lwb->receiver(lwb->baton,
135 log_entry->changed_paths2,
137 author, date, message,
145 svn_compat_wrap_log_receiver(svn_log_entry_receiver_t *receiver2,
146 void **receiver2_baton,
147 svn_log_message_receiver_t receiver,
148 void *receiver_baton,
151 struct log_wrapper_baton *lwb = apr_palloc(pool, sizeof(*lwb));
153 /* Set the user provided old format callback in the baton. */
154 lwb->baton = receiver_baton;
155 lwb->receiver = receiver;
157 *receiver2_baton = lwb;
158 *receiver2 = log_wrapper_callback;