1 |
// Subversion Client |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include <cxx/standard.hh> |
8 |
|
9 |
#include <apr_tables.h> |
10 |
|
11 |
#include "Client.hpp" |
12 |
|
13 |
namespace Subversion |
14 |
{ |
15 |
|
16 |
Client::Client() |
17 |
{ |
18 |
CheckError(::svn_client_create_context(&context, pool)); |
19 |
|
20 |
::apr_array_header_t *providers(::apr_array_make(pool, 5, sizeof (::svn_auth_provider_object_t *))); |
21 |
|
22 |
#ifdef _WIN32 |
23 |
::svn_client_get_windows_simple_provider(reinterpret_cast< ::svn_auth_provider_object_t **>(::apr_array_push(providers)), pool); |
24 |
#endif |
25 |
::svn_client_get_simple_provider(reinterpret_cast< ::svn_auth_provider_object_t **>(::apr_array_push(providers)), pool); |
26 |
::svn_client_get_username_provider(reinterpret_cast< ::svn_auth_provider_object_t **>(::apr_array_push(providers)), pool); |
27 |
::svn_client_get_ssl_server_trust_file_provider(reinterpret_cast< ::svn_auth_provider_object_t **>(::apr_array_push(providers)), pool); |
28 |
::svn_client_get_ssl_client_cert_file_provider(reinterpret_cast< ::svn_auth_provider_object_t **>(::apr_array_push(providers)), pool); |
29 |
::svn_client_get_ssl_client_cert_pw_file_provider(reinterpret_cast< ::svn_auth_provider_object_t **>(::apr_array_push(providers)), pool); |
30 |
::svn_auth_open(&context->auth_baton, providers, pool); |
31 |
} |
32 |
|
33 |
cse::String Client::GetProperty(const cse::String &property, const cse::String &target) const |
34 |
{ |
35 |
api::Apr::Pool pool; |
36 |
::apr_hash_t *hash; |
37 |
::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified }; |
38 |
|
39 |
CheckError(::svn_client_propget2(&hash, property.NullTerminate(), target.NullTerminate(), &revision, &revision, false, context, pool)); |
40 |
|
41 |
if (::apr_hash_index_t *index = ::apr_hash_first(pool, hash)) |
42 |
{ |
43 |
::svn_string_t *string; |
44 |
|
45 |
::apr_hash_this(index, NULL, NULL, reinterpret_cast<void **>(&string)); |
46 |
|
47 |
return cse::String(string->data, string->len); |
48 |
} |
49 |
else |
50 |
return cse::EmptyString; |
51 |
} |
52 |
|
53 |
_L<Entry> Client::GetEntries(const cse::String &target) const |
54 |
{ |
55 |
api::Apr::Pool pool; |
56 |
::apr_hash_t *hash; |
57 |
::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified }; |
58 |
|
59 |
#if (SVN_VER_MAJOR == 1) && (SVN_VER_MINOR == 2) |
60 |
CheckError(::svn_client_ls2(&hash, target.NullTerminate(), &revision, &revision, false, context, pool)); |
61 |
#else |
62 |
CheckError(::svn_client_ls3(&hash, NULL, target.NullTerminate(), &revision, &revision, false, context, pool)); |
63 |
#endif |
64 |
|
65 |
_L<Entry> entries; |
66 |
|
67 |
for (::apr_hash_index_t *index(::apr_hash_first(pool, hash)); index; index = apr_hash_next(index)) |
68 |
{ |
69 |
const char *string; |
70 |
::apr_ssize_t size; |
71 |
::svn_dirent_t *entry; |
72 |
|
73 |
::apr_hash_this(index, reinterpret_cast<const void **>(&string), &size, reinterpret_cast<void **>(&entry)); |
74 |
|
75 |
entries.InsertLast(Entry(cse::String(string, size), entry)); |
76 |
} |
77 |
|
78 |
return entries; |
79 |
} |
80 |
|
81 |
} |