repl5_ruv.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /* repl5_ruv.h - interface for replica update vector */
  42. #ifndef REPL5_RUV
  43. #define REPL5_RUV
  44. #include "slapi-private.h"
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. typedef struct _ruv RUV;
  49. enum
  50. {
  51. RUV_SUCCESS=0,
  52. RUV_BAD_DATA,
  53. RUV_NOTFOUND,
  54. RUV_MEMORY_ERROR,
  55. RUV_NSPR_ERROR,
  56. RUV_BAD_FORMAT,
  57. RUV_UNKNOWN_ERROR,
  58. RUV_ALREADY_EXIST,
  59. RUV_CSNPL_ERROR,
  60. RUV_COVERS_CSN
  61. };
  62. typedef struct ruv_enum_data
  63. {
  64. CSN *csn;
  65. CSN *min_csn;
  66. } ruv_enum_data;
  67. typedef int (*FNEnumRUV) (const ruv_enum_data *element, void *arg);
  68. int ruv_init_new (const char *replGen, ReplicaId rid, const char *purl, RUV **ruv);
  69. int ruv_init_from_bervals(struct berval** vals, RUV **ruv);
  70. int ruv_init_from_slapi_attr(Slapi_Attr *attr, RUV **ruv);
  71. int ruv_init_from_slapi_attr_and_check_purl(Slapi_Attr *attr, RUV **ruv, ReplicaId *rid);
  72. RUV* ruv_dup (const RUV *ruv);
  73. void ruv_destroy (RUV **ruv);
  74. void ruv_copy_and_destroy (RUV **srcruv, RUV **destruv);
  75. int ruv_replace_replica_purl (RUV *ruv, ReplicaId rid, const char *replica_purl);
  76. int ruv_delete_replica (RUV *ruv, ReplicaId rid);
  77. int ruv_add_replica (RUV *ruv, ReplicaId rid, const char *replica_purl);
  78. int ruv_add_index_replica (RUV *ruv, ReplicaId rid, const char *replica_purl, int index);
  79. PRBool ruv_contains_replica (const RUV *ruv, ReplicaId rid);
  80. int ruv_get_largest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  81. int ruv_get_smallest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  82. int ruv_set_csns(RUV *ruv, const CSN *csn, const char *replica_purl);
  83. int ruv_set_csns_keep_smallest(RUV *ruv, const CSN *csn);
  84. int ruv_set_max_csn(RUV *ruv, const CSN *max_csn, const char *replica_purl);
  85. int ruv_set_min_csn(RUV *ruv, const CSN *min_csn, const char *replica_purl);
  86. const char *ruv_get_purl_for_replica(const RUV *ruv, ReplicaId rid);
  87. char *ruv_get_replica_generation (const RUV *ruv);
  88. void ruv_set_replica_generation (RUV *ruv, const char *generation);
  89. PRBool ruv_covers_ruv(const RUV *covering_ruv, const RUV *covered_ruv);
  90. PRBool ruv_covers_csn(const RUV *ruv, const CSN *csn);
  91. PRBool ruv_covers_csn_strict(const RUV *ruv, const CSN *csn);
  92. int ruv_get_min_csn(const RUV *ruv, CSN **csn);
  93. int ruv_get_max_csn(const RUV *ruv, CSN **csn);
  94. int ruv_enumerate_elements (const RUV *ruv, FNEnumRUV fn, void *arg);
  95. int ruv_to_smod(const RUV *ruv, Slapi_Mod *smod);
  96. int ruv_last_modified_to_smod(const RUV *ruv, Slapi_Mod *smod);
  97. int ruv_to_bervals(const RUV *ruv, struct berval ***bvals);
  98. PRInt32 ruv_replica_count (const RUV *ruv);
  99. char **ruv_get_referrals(const RUV *ruv);
  100. void ruv_dump(const RUV *ruv, char *ruv_name, PRFileDesc *prFile);
  101. int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn);
  102. int ruv_cancel_csn_inprogress (RUV *ruv, const CSN *csn);
  103. int ruv_update_ruv (RUV *ruv, const CSN *csn, const char *replica_purl, PRBool isLocal);
  104. int ruv_move_local_supplier_to_first(RUV *ruv, ReplicaId rid);
  105. int ruv_get_first_id_and_purl(RUV *ruv, ReplicaId *rid, char **replica_purl );
  106. int ruv_local_contains_supplier(RUV *ruv, ReplicaId rid);
  107. /* returns true if the ruv has any csns, false otherwise - used for testing
  108. whether or not an RUV is empty */
  109. PRBool ruv_has_csns(const RUV *ruv);
  110. PRBool ruv_has_both_csns(const RUV *ruv);
  111. PRBool ruv_is_newer (Object *sruv, Object *cruv);
  112. void ruv_force_csn_update (RUV *ruv, CSN *csn);
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif