repl5_ruv.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
  37. * All rights reserved.
  38. * END COPYRIGHT BLOCK **/
  39. #ifdef HAVE_CONFIG_H
  40. # include <config.h>
  41. #endif
  42. /* repl5_ruv.h - interface for replica update vector */
  43. #ifndef REPL5_RUV
  44. #define REPL5_RUV
  45. #include "slapi-private.h"
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. typedef struct _ruv RUV;
  50. enum
  51. {
  52. RUV_SUCCESS=0,
  53. RUV_BAD_DATA,
  54. RUV_NOTFOUND,
  55. RUV_MEMORY_ERROR,
  56. RUV_NSPR_ERROR,
  57. RUV_BAD_FORMAT,
  58. RUV_UNKNOWN_ERROR,
  59. RUV_ALREADY_EXIST,
  60. RUV_CSNPL_ERROR,
  61. RUV_COVERS_CSN
  62. };
  63. typedef struct ruv_enum_data
  64. {
  65. CSN *csn;
  66. CSN *min_csn;
  67. } ruv_enum_data;
  68. typedef int (*FNEnumRUV) (const ruv_enum_data *element, void *arg);
  69. int ruv_init_new (const char *replGen, ReplicaId rid, const char *purl, RUV **ruv);
  70. int ruv_init_from_bervals(struct berval** vals, RUV **ruv);
  71. int ruv_init_from_slapi_attr(Slapi_Attr *attr, RUV **ruv);
  72. int ruv_init_from_slapi_attr_and_check_purl(Slapi_Attr *attr, RUV **ruv, ReplicaId *rid);
  73. RUV* ruv_dup (const RUV *ruv);
  74. void ruv_destroy (RUV **ruv);
  75. void ruv_copy_and_destroy (RUV **srcruv, RUV **destruv);
  76. int ruv_replace_replica_purl (RUV *ruv, ReplicaId rid, const char *replica_purl);
  77. int ruv_delete_replica (RUV *ruv, ReplicaId rid);
  78. int ruv_add_replica (RUV *ruv, ReplicaId rid, const char *replica_purl);
  79. int ruv_add_index_replica (RUV *ruv, ReplicaId rid, const char *replica_purl, int index);
  80. PRBool ruv_contains_replica (const RUV *ruv, ReplicaId rid);
  81. int ruv_get_largest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  82. int ruv_get_smallest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  83. int ruv_set_csns(RUV *ruv, const CSN *csn, const char *replica_purl);
  84. int ruv_set_csns_keep_smallest(RUV *ruv, const CSN *csn);
  85. int ruv_set_max_csn(RUV *ruv, const CSN *max_csn, const char *replica_purl);
  86. int ruv_set_min_csn(RUV *ruv, const CSN *min_csn, const char *replica_purl);
  87. const char *ruv_get_purl_for_replica(const RUV *ruv, ReplicaId rid);
  88. char *ruv_get_replica_generation (const RUV *ruv);
  89. void ruv_set_replica_generation (RUV *ruv, const char *generation);
  90. PRBool ruv_covers_ruv(const RUV *covering_ruv, const RUV *covered_ruv);
  91. PRBool ruv_covers_csn(const RUV *ruv, const CSN *csn);
  92. PRBool ruv_covers_csn_strict(const RUV *ruv, const CSN *csn);
  93. int ruv_get_min_csn(const RUV *ruv, CSN **csn);
  94. int ruv_get_max_csn(const RUV *ruv, CSN **csn);
  95. int ruv_enumerate_elements (const RUV *ruv, FNEnumRUV fn, void *arg);
  96. int ruv_to_smod(const RUV *ruv, Slapi_Mod *smod);
  97. int ruv_last_modified_to_smod(const RUV *ruv, Slapi_Mod *smod);
  98. int ruv_to_bervals(const RUV *ruv, struct berval ***bvals);
  99. PRInt32 ruv_replica_count (const RUV *ruv);
  100. char **ruv_get_referrals(const RUV *ruv);
  101. void ruv_dump(const RUV *ruv, char *ruv_name, PRFileDesc *prFile);
  102. int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn);
  103. int ruv_cancel_csn_inprogress (RUV *ruv, const CSN *csn);
  104. int ruv_update_ruv (RUV *ruv, const CSN *csn, const char *replica_purl, PRBool isLocal);
  105. int ruv_move_local_supplier_to_first(RUV *ruv, ReplicaId rid);
  106. int ruv_get_first_id_and_purl(RUV *ruv, ReplicaId *rid, char **replica_purl );
  107. int ruv_local_contains_supplier(RUV *ruv, ReplicaId rid);
  108. /* returns true if the ruv has any csns, false otherwise - used for testing
  109. whether or not an RUV is empty */
  110. PRBool ruv_has_csns(const RUV *ruv);
  111. PRBool ruv_has_both_csns(const RUV *ruv);
  112. PRBool ruv_is_newer (Object *sruv, Object *cruv);
  113. void ruv_force_csn_update (RUV *ruv, CSN *csn);
  114. void ruv_insert_dummy_min_csn (RUV *ruv);
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif