Fix compiler warning due to missing function prototype.
[svn.git] / subversion / libsvn_fs_base / uuid.c
blob2e489d0e053c5aa084c644e920566ad568bd2db3
1 /* uuid.c : operations on repository uuids
3 * ====================================================================
4 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #include <assert.h>
20 #include "fs.h"
21 #include "trail.h"
22 #include "err.h"
23 #include "uuid.h"
24 #include "bdb/uuids-table.h"
25 #include "../libsvn_fs/fs-loader.h"
27 #include "private/svn_fs_util.h"
30 struct get_uuid_args
32 int idx;
33 const char **uuid;
37 static svn_error_t *
38 txn_body_get_uuid(void *baton, trail_t *trail)
40 struct get_uuid_args *args = baton;
41 return svn_fs_bdb__get_uuid(trail->fs, args->idx, args->uuid,
42 trail, trail->pool);
46 svn_error_t *
47 svn_fs_base__get_uuid(svn_fs_t *fs,
48 const char **uuid,
49 apr_pool_t *pool)
51 base_fs_data_t *bfd = fs->fsap_data;
53 SVN_ERR(svn_fs__check_fs(fs, TRUE));
55 /* Check for a cached UUID first. Failing that, we hit the
56 database. */
57 if (bfd->uuid)
59 *uuid = apr_pstrdup(pool, bfd->uuid);
61 else
63 struct get_uuid_args args;
64 args.idx = 1;
65 args.uuid = uuid;
66 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_get_uuid, &args, pool));
68 /* Toss what we find into the cache. */
69 if (*uuid)
70 bfd->uuid = apr_pstrdup(fs->pool, *uuid);
73 return SVN_NO_ERROR;
77 struct set_uuid_args
79 int idx;
80 const char *uuid;
84 static svn_error_t *
85 txn_body_set_uuid(void *baton, trail_t *trail)
87 struct set_uuid_args *args = baton;
88 return svn_fs_bdb__set_uuid(trail->fs, args->idx, args->uuid,
89 trail, trail->pool);
93 svn_error_t *
94 svn_fs_base__set_uuid(svn_fs_t *fs,
95 const char *uuid,
96 apr_pool_t *pool)
98 struct set_uuid_args args;
99 base_fs_data_t *bfd = fs->fsap_data;
101 SVN_ERR(svn_fs__check_fs(fs, TRUE));
103 if (! uuid)
104 uuid = svn_uuid_generate(pool);
106 args.idx = 1;
107 args.uuid = uuid;
108 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_set_uuid, &args, pool));
110 /* Toss our value into the cache. */
111 if (uuid)
112 bfd->uuid = apr_pstrdup(fs->pool, uuid);
114 return SVN_NO_ERROR;