vlv_srch.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. /* vlv_srch.h */
  42. #if !defined(__VLV_SRCH_H)
  43. #define __VLV_SRCH_H
  44. extern char* const type_vlvName;
  45. extern char* const type_vlvBase;
  46. extern char* const type_vlvScope;
  47. extern char* const type_vlvFilter;
  48. extern char* const type_vlvSort;
  49. extern char* const type_vlvFilename;
  50. extern char* const type_vlvEnabled;
  51. extern char* const type_vlvUses;
  52. #if defined(USE_OPENLDAP)
  53. typedef struct LDAPsortkey { /* structure for a sort-key */
  54. char * sk_attrtype;
  55. char * sk_matchruleoid;
  56. int sk_reverseorder;
  57. } LDAPsortkey;
  58. #endif
  59. void internal_ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
  60. int internal_ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, const char *string_rep);
  61. /*
  62. * This structure is the internal representation of a VLV Search.
  63. */
  64. struct vlvSearch
  65. {
  66. /* The VLV Search Specification Entry */
  67. const Slapi_Entry *vlv_e;
  68. /* Extracted from the VLV Search Specification entry */
  69. Slapi_DN *vlv_dn;
  70. char *vlv_name;
  71. Slapi_DN *vlv_base;
  72. int vlv_scope;
  73. char *vlv_filter;
  74. int vlv_initialized;
  75. /* Derived from the VLV Entry */
  76. Slapi_Filter *vlv_slapifilter;
  77. /* List of Indexes for this Search */
  78. struct vlvIndex* vlv_index;
  79. /* The next VLV Search in the list */
  80. struct vlvSearch* vlv_next;
  81. };
  82. struct vlvIndex
  83. {
  84. char *vlv_name;
  85. char *vlv_sortspec;
  86. /* Derived from the VLV Entry */
  87. LDAPsortkey **vlv_sortkey;
  88. /* The Index filename */
  89. char *vlv_filename;
  90. /* Attribute Structure maps filename onto index */
  91. struct attrinfo *vlv_attrinfo;
  92. /* Syntax Plugin. One for each LDAPsortkey */
  93. void **vlv_syntax_plugin;
  94. /* Matching Rule PBlock. One for each LDAPsortkey */
  95. Slapi_PBlock **vlv_mrpb;
  96. /* Keep track of the index length */
  97. PRLock *vlv_indexlength_lock;
  98. int vlv_indexlength_cached;
  99. db_recno_t vlv_indexlength;
  100. int vlv_enabled; /* index file is there & ready */
  101. int vlv_online; /* turned off when generating index */
  102. /* The last time we checked to see if the index file was available */
  103. time_t vlv_lastchecked;
  104. /* The number of uses this search has received since start up */
  105. PRUint32 vlv_uses;
  106. struct backend* vlv_be; /* need backend to remove the index when done */
  107. /* The parent Search Specification for this Index */
  108. struct vlvSearch* vlv_search;
  109. /* The next VLV Index in the list */
  110. struct vlvIndex* vlv_next;
  111. };
  112. struct vlvSearch* vlvSearch_new();
  113. void vlvSearch_init(struct vlvSearch*, Slapi_PBlock *pb, const Slapi_Entry *e, ldbm_instance *inst);
  114. void vlvSearch_reinit(struct vlvSearch* p, const struct backentry *base);
  115. void vlvSearch_delete(struct vlvSearch** ppvs);
  116. void vlvSearch_addtolist(struct vlvSearch* p, struct vlvSearch** pplist);
  117. struct vlvSearch* vlvSearch_find(const struct vlvSearch* plist, const char *base, int scope, const char *filter, const char *sortspec);
  118. struct vlvIndex* vlvSearch_findenabled(backend *be,struct vlvSearch* plist, const Slapi_DN *base, int scope, const char *filter, const sort_spec* sort_control);
  119. struct vlvSearch* vlvSearch_finddn(const struct vlvSearch* plist, const Slapi_DN *dn);
  120. struct vlvIndex* vlvSearch_findname(const struct vlvSearch* plist, const char *name);
  121. struct vlvIndex* vlvSearch_findindexname(const struct vlvSearch* plist, const char *name);
  122. char *vlvSearch_getnames(const struct vlvSearch* plist);
  123. void vlvSearch_removefromlist(struct vlvSearch** pplist, const Slapi_DN *dn);
  124. int vlvSearch_accessallowed(struct vlvSearch *p, Slapi_PBlock *pb);
  125. const Slapi_DN *vlvSearch_getBase(struct vlvSearch* p);
  126. int vlvSearch_getScope(struct vlvSearch* p);
  127. Slapi_Filter *vlvSearch_getFilter(struct vlvSearch* p);
  128. int vlvSearch_isVlvSearchEntry(Slapi_Entry *e);
  129. void vlvSearch_addIndex(struct vlvSearch *pSearch, struct vlvIndex *pIndex);
  130. struct vlvIndex* vlvIndex_new();
  131. void vlvIndex_init(struct vlvIndex* p, backend *be, struct vlvSearch* pSearch, const Slapi_Entry *e);
  132. void vlvIndex_delete(struct vlvIndex** ppvs);
  133. PRUint32 vlvIndex_get_indexlength(struct vlvIndex* p, DB *db, back_txn *txn);
  134. void vlvIndex_increment_indexlength(struct vlvIndex* p, DB *db, back_txn *txn);
  135. void vlvIndex_decrement_indexlength(struct vlvIndex* p, DB *db, back_txn *txn);
  136. void vlvIndex_incrementUsage(struct vlvIndex* p);
  137. const char *vlvIndex_filename(const struct vlvIndex* p);
  138. int vlvIndex_enabled(const struct vlvIndex* p);
  139. int vlvIndex_online(const struct vlvIndex *p);
  140. void vlvIndex_go_offline(struct vlvIndex *p, backend *be);
  141. void vlvIndex_go_online(struct vlvIndex *p, backend *be);
  142. int vlvIndex_accessallowed(struct vlvIndex *p, Slapi_PBlock *pb);
  143. const Slapi_DN *vlvIndex_getBase(struct vlvIndex* p);
  144. int vlvIndex_getScope(struct vlvIndex* p);
  145. Slapi_Filter *vlvIndex_getFilter(struct vlvIndex* p);
  146. const char *vlvIndex_getName(struct vlvIndex* p);
  147. int vlvIndex_isVlvIndexEntry(Slapi_Entry *e);
  148. #define VLV_ACCESS_DENIED -1
  149. #define VLV_BLD_LIST_FAILED -2
  150. #define VLV_FIND_SEARCH_FAILED -3
  151. #endif