retrocl.h 6.1 KB

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