1 /* id.h : interface to FSX-internal ID functions 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23 #ifndef SVN_LIBSVN_FS_X_ID_H 24 #define SVN_LIBSVN_FS_X_ID_H 25 26 #include "svn_fs.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif /* __cplusplus */ 31 32 /* Unique identifier for a transaction within the given repository. */ 33 typedef apr_int64_t svn_fs_x__txn_id_t; 34 35 /* svn_fs_x__txn_id_t value for everything that is not a transaction. */ 36 #define SVN_FS_X__INVALID_TXN_ID ((svn_fs_x__txn_id_t)(-1)) 37 38 /* Change set is the umbrella term for transaction and revision in FSX. 39 * Revision numbers (>=0) map 1:1 onto change sets while txns are mapped 40 * onto the negatve value range. */ 41 typedef apr_int64_t svn_fs_x__change_set_t; 42 43 /* Invalid / unused change set number. */ 44 #define SVN_FS_X__INVALID_CHANGE_SET ((svn_fs_x__change_set_t)(-1)) 45 46 /* Return TRUE iff the CHANGE_SET refers to a revision 47 (will return FALSE for SVN_INVALID_REVNUM). */ 48 svn_boolean_t 49 svn_fs_x__is_revision(svn_fs_x__change_set_t change_set); 50 51 /* Return TRUE iff the CHANGE_SET refers to a transaction 52 (will return FALSE for SVN_FS_X__INVALID_TXN_ID). */ 53 svn_boolean_t 54 svn_fs_x__is_txn(svn_fs_x__change_set_t change_set); 55 56 /* Return the revision number that corresponds to CHANGE_SET. 57 Will SVN_INVALID_REVNUM for transactions. */ 58 svn_revnum_t 59 svn_fs_x__get_revnum(svn_fs_x__change_set_t change_set); 60 61 /* Return the transaction ID that corresponds to CHANGE_SET. 62 Will SVN_FS_X__INVALID_TXN_ID for revisions. */ 63 svn_fs_x__txn_id_t 64 svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set); 65 66 /* Convert REVNUM into a change set number */ 67 svn_fs_x__change_set_t 68 svn_fs_x__change_set_by_rev(svn_revnum_t revnum); 69 70 /* Convert TXN_ID into a change set number */ 71 svn_fs_x__change_set_t 72 svn_fs_x__change_set_by_txn(svn_fs_x__txn_id_t txn_id); 73 74 /* An ID in FSX consists of a creation CHANGE_SET number and some changeset- 75 * local counter value (NUMBER). 76 */ 77 typedef struct svn_fs_x__id_t 78 { 79 svn_fs_x__change_set_t change_set; 80 81 apr_uint64_t number; 82 } svn_fs_x__id_t; 83 84 85 /*** Operations on ID parts. ***/ 86 87 /* Return TRUE, if both elements of the PART is 0, i.e. this is the default 88 * value if e.g. no copies were made of this node. */ 89 svn_boolean_t 90 svn_fs_x__id_is_root(const svn_fs_x__id_t *part); 91 92 /* Return TRUE, if all element values of *LHS and *RHS match. */ 93 svn_boolean_t 94 svn_fs_x__id_eq(const svn_fs_x__id_t *lhs, 95 const svn_fs_x__id_t *rhs); 96 97 /* Parse the NUL-terminated ID part at DATA and write the result into *PART. 98 */ 99 svn_error_t * 100 svn_fs_x__id_parse(svn_fs_x__id_t *part, 101 const char *data); 102 103 /* Convert ID into string form, allocated in RESULT_POOL. */ 104 svn_string_t * 105 svn_fs_x__id_unparse(const svn_fs_x__id_t*id, 106 apr_pool_t *result_pool); 107 108 /* Set *PART to "unused". */ 109 void 110 svn_fs_x__id_reset(svn_fs_x__id_t *part); 111 112 /* Return TRUE if *PART is belongs to either a revision or transaction. */ 113 svn_boolean_t 114 svn_fs_x__id_used(const svn_fs_x__id_t *part); 115 116 /* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */ 117 int 118 svn_fs_x__id_compare(const svn_fs_x__id_t *a, 119 const svn_fs_x__id_t *b); 120 121 /* Set *NODEREV_ID to the root node ID of transaction TXN_ID. */ 122 void 123 svn_fs_x__init_txn_root(svn_fs_x__id_t *noderev_id, 124 svn_fs_x__txn_id_t txn_id); 125 126 /* Set *NODEREV_ID to the root node ID of revision REV. */ 127 void 128 svn_fs_x__init_rev_root(svn_fs_x__id_t *noderev_id, 129 svn_revnum_t rev); 130 131 #ifdef __cplusplus 132 } 133 #endif /* __cplusplus */ 134 135 #endif /* SVN_LIBSVN_FS_X_ID_H */ 136