1
0

retrocl.h 6.1 KB

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