2 * compat.c : Wrappers and callbacks for compatibility.
4 * ====================================================================
5 * Copyright (c) 2005 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #include <apr_pools.h>
20 #include <apr_strings.h>
22 #include "svn_types.h"
23 #include "svn_error.h"
24 #include "svn_compat.h"
27 /* Baton for use with svn_compat_wrap_commit_callback */
28 struct commit_wrapper_baton
{
30 svn_commit_callback_t callback
;
33 /* This implements svn_commit_callback2_t. */
35 commit_wrapper_callback(const svn_commit_info_t
*commit_info
,
36 void *baton
, apr_pool_t
*pool
)
38 struct commit_wrapper_baton
*cwb
= baton
;
41 return cwb
->callback(commit_info
->revision
,
50 svn_compat_wrap_commit_callback(svn_commit_callback2_t
*callback2
,
51 void **callback2_baton
,
52 svn_commit_callback_t callback
,
56 struct commit_wrapper_baton
*cwb
= apr_palloc(pool
, sizeof(*cwb
));
58 /* Set the user provided old format callback in the baton */
59 cwb
->baton
= callback_baton
;
60 cwb
->callback
= callback
;
62 *callback2_baton
= cwb
;
63 *callback2
= commit_wrapper_callback
;
68 svn_compat_log_revprops_clear(apr_hash_t
*revprops
)
72 apr_hash_set(revprops
, SVN_PROP_REVISION_AUTHOR
,
73 APR_HASH_KEY_STRING
, NULL
);
74 apr_hash_set(revprops
, SVN_PROP_REVISION_DATE
,
75 APR_HASH_KEY_STRING
, NULL
);
76 apr_hash_set(revprops
, SVN_PROP_REVISION_LOG
,
77 APR_HASH_KEY_STRING
, NULL
);
82 svn_compat_log_revprops_in(apr_pool_t
*pool
)
84 apr_array_header_t
*revprops
= apr_array_make(pool
, 3, sizeof(char *));
86 APR_ARRAY_PUSH(revprops
, const char *) = SVN_PROP_REVISION_AUTHOR
;
87 APR_ARRAY_PUSH(revprops
, const char *) = SVN_PROP_REVISION_DATE
;
88 APR_ARRAY_PUSH(revprops
, const char *) = SVN_PROP_REVISION_LOG
;
94 svn_compat_log_revprops_out(const char **author
, const char **date
,
95 const char **message
, apr_hash_t
*revprops
)
97 svn_string_t
*author_s
, *date_s
, *message_s
;
99 *author
= *date
= *message
= NULL
;
102 if ((author_s
= apr_hash_get(revprops
, SVN_PROP_REVISION_AUTHOR
,
103 APR_HASH_KEY_STRING
)))
104 *author
= author_s
->data
;
105 if ((date_s
= apr_hash_get(revprops
, SVN_PROP_REVISION_DATE
,
106 APR_HASH_KEY_STRING
)))
107 *date
= date_s
->data
;
108 if ((message_s
= apr_hash_get(revprops
, SVN_PROP_REVISION_LOG
,
109 APR_HASH_KEY_STRING
)))
110 *message
= message_s
->data
;
114 /* Baton for use with svn_compat_wrap_log_receiver */
115 struct log_wrapper_baton
{
117 svn_log_message_receiver_t receiver
;
120 /* This implements svn_log_entry_receiver_t. */
122 log_wrapper_callback(void *baton
,
123 svn_log_entry_t
*log_entry
,
126 struct log_wrapper_baton
*lwb
= baton
;
128 if (lwb
->receiver
&& SVN_IS_VALID_REVNUM(log_entry
->revision
))
130 const char *author
, *date
, *message
;
131 svn_compat_log_revprops_out(&author
, &date
, &message
,
132 log_entry
->revprops
);
133 return lwb
->receiver(lwb
->baton
,
134 log_entry
->changed_paths
,
136 author
, date
, message
,
144 svn_compat_wrap_log_receiver(svn_log_entry_receiver_t
*receiver2
,
145 void **receiver2_baton
,
146 svn_log_message_receiver_t receiver
,
147 void *receiver_baton
,
150 struct log_wrapper_baton
*lwb
= apr_palloc(pool
, sizeof(*lwb
));
152 /* Set the user provided old format callback in the baton. */
153 lwb
->baton
= receiver_baton
;
154 lwb
->receiver
= receiver
;
156 *receiver2_baton
= lwb
;
157 *receiver2
= log_wrapper_callback
;