retrocl.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. #ifndef _H_RETROCL
  42. #define _H_RETROCL 1
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45. #include <string.h>
  46. #include "slapi-private.h"
  47. #include "slapi-plugin.h"
  48. /* #include "portable.h" */
  49. #include "ldaplog.h"
  50. #include "ldif.h"
  51. #include "slap.h"
  52. /* max len of a long (2^64), represented as a string, including null byte */
  53. #define CNUMSTR_LEN 21
  54. typedef unsigned long changeNumber;
  55. typedef struct _cnum_result_t {
  56. int crt_nentries; /* number of entries returned from search */
  57. int crt_err; /* err returned from backend */
  58. Slapi_Entry *crt_entry; /* The entry returned from the backend */
  59. } cnum_result_t;
  60. typedef struct _cnumRet {
  61. changeNumber cr_cnum;
  62. char *cr_time;
  63. int cr_lderr;
  64. } cnumRet;
  65. /* Operation types */
  66. #define OP_MODIFY 1
  67. #define OP_ADD 2
  68. #define OP_DELETE 3
  69. #define OP_MODRDN 4
  70. /*
  71. * How often the changelog trimming thread runs. This is the minimum trim age.
  72. */
  73. #define CHANGELOGDB_TRIM_INTERVAL 300*1000 /* 5 minutes in milliseconds */
  74. #if defined(__hpux) && defined(__ia64)
  75. #define RETROCL_DLL_DEFAULT_THREAD_STACKSIZE 524288L
  76. #else
  77. #define RETROCL_DLL_DEFAULT_THREAD_STACKSIZE 131072L
  78. #endif
  79. #define RETROCL_BE_CACHEMEMSIZE "2097152"
  80. #define RETROCL_BE_CACHESIZE "-1"
  81. #define RETROCL_PLUGIN_NAME "DSRetroclPlugin"
  82. /* was originally changelogmaximumage */
  83. #define CONFIG_CHANGELOG_MAXAGE_ATTRIBUTE "nsslapd-changelogmaxage"
  84. #define CONFIG_CHANGELOG_DIRECTORY_ATTRIBUTE "nsslapd-changelogdir"
  85. #define RETROCL_CHANGELOG_DN "cn=changelog"
  86. #define RETROCL_MAPPINGTREE_DN "cn=\"cn=changelog\",cn=mapping tree,cn=config"
  87. #define RETROCL_PLUGIN_DN "cn=Retro Changelog Plugin,cn=plugins,cn=config"
  88. #define RETROCL_LDBM_DN "cn=changelog,cn=ldbm database,cn=plugins,cn=config"
  89. #define RETROCL_INDEX_DN "cn=changenumber,cn=index,cn=changelog,cn=ldbm database,cn=plugins,cn=config"
  90. /* Allow anonymous access to the changelog base only, but not to the
  91. * entries in the changelog.
  92. */
  93. #define RETROCL_ACL "(target =\"ldap:///cn=changelog\")(targetattr != \"aci\")(version 3.0; acl \"changelog base\"; allow( read,search, compare ) userdn =\"ldap:///anyone\";)"
  94. enum {
  95. PLUGIN_RETROCL,
  96. PLUGIN_MAX
  97. };
  98. extern void* g_plg_identity [PLUGIN_MAX];
  99. extern Slapi_Backend *retrocl_be_changelog;
  100. extern int retrocl_nattributes;
  101. extern char** retrocl_attributes;
  102. extern char** retrocl_aliases;
  103. extern const char *attr_changenumber;
  104. extern const char *attr_targetdn;
  105. extern const char *attr_changetype;
  106. extern const char *attr_newrdn;
  107. extern const char *attr_newsuperior;
  108. extern const char *attr_deleteoldrdn;
  109. extern const char *attr_changes;
  110. extern const char *attr_changetime;
  111. extern const char *attr_objectclass;
  112. extern const char *attr_nsuniqueid;
  113. extern const char *attr_isreplicated;
  114. extern PRLock *retrocl_internal_lock;
  115. /* Functions */
  116. /* from repl_shared.h: not sure where defined */
  117. unsigned long strntoul( char *from, size_t len, int base );
  118. extern int retrocl_plugin_init(Slapi_PBlock *pb);
  119. extern int retrocl_bepostop_delete (Slapi_PBlock *pb);
  120. extern int retrocl_postop_add (Slapi_PBlock *pb);
  121. extern int retrocl_postop_delete (Slapi_PBlock *pb);
  122. extern int retrocl_postop_modify (Slapi_PBlock *pb);
  123. extern int retrocl_postop_modrdn (Slapi_PBlock *pb);
  124. extern int retrocl_postob(Slapi_PBlock *,int);
  125. extern int retrocl_rootdse_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
  126. extern void retrocl_create_cle(void);
  127. extern int retrocl_create_config(void);
  128. extern changeNumber retrocl_get_first_changenumber(void);
  129. extern void retrocl_set_first_changenumber(changeNumber cn);
  130. extern changeNumber retrocl_get_last_changenumber(void);
  131. extern void retrocl_commit_changenumber(void);
  132. extern void retrocl_release_changenumber(void);
  133. extern changeNumber retrocl_assign_changenumber(void);
  134. extern int retrocl_get_changenumbers(void);
  135. extern void retrocl_forget_changenumbers(void);
  136. extern time_t retrocl_getchangetime( int type, int *err );
  137. extern void retrocl_init_trimming(void);
  138. extern void retrocl_stop_trimming(void);
  139. extern char *retrocl_get_config_str(const char *attrt);
  140. #endif /* _H_RETROCL */