repl_ext.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. /* repl_ext.c - manages operation extensions created by the
  7. * replication system
  8. */
  9. #include "repl.h"
  10. /* structure with information for each extension */
  11. typedef struct repl_ext
  12. {
  13. char *object_name; /* name of the object extended */
  14. int object_type; /* handle to the extended object */
  15. int handle; /* extension handle */
  16. } repl_ext;
  17. /* ----------------------------- Supplier ----------------------------- */
  18. static repl_ext repl_sup_ext_list [REPL_EXT_ALL];
  19. /* initializes replication extensions */
  20. void repl_sup_init_ext ()
  21. {
  22. int rc;
  23. /* populate the extension list */
  24. repl_sup_ext_list[REPL_SUP_EXT_OP].object_name = SLAPI_EXT_OPERATION;
  25. rc = slapi_register_object_extension(repl_plugin_name,
  26. SLAPI_EXT_OPERATION,
  27. supplier_operation_extension_constructor,
  28. supplier_operation_extension_destructor,
  29. &repl_sup_ext_list[REPL_SUP_EXT_OP].object_type,
  30. &repl_sup_ext_list[REPL_SUP_EXT_OP].handle);
  31. if(rc!=0)
  32. {
  33. PR_ASSERT(0); /* JCMREPL Argh */
  34. }
  35. }
  36. void* repl_sup_get_ext (ext_type type, void *object)
  37. {
  38. /* find the requested extension */
  39. repl_ext ext = repl_sup_ext_list [type];
  40. void* data = slapi_get_object_extension(ext.object_type, object, ext.handle);
  41. return data;
  42. }
  43. /* ----------------------------- Consumer ----------------------------- */
  44. static repl_ext repl_con_ext_list [REPL_EXT_ALL];
  45. /* initializes replication extensions */
  46. void repl_con_init_ext ()
  47. {
  48. int rc;
  49. /* populate the extension list */
  50. repl_con_ext_list[REPL_CON_EXT_OP].object_name = SLAPI_EXT_OPERATION;
  51. rc = slapi_register_object_extension(repl_plugin_name,
  52. SLAPI_EXT_OPERATION,
  53. consumer_operation_extension_constructor,
  54. consumer_operation_extension_destructor,
  55. &repl_con_ext_list[REPL_CON_EXT_OP].object_type,
  56. &repl_con_ext_list[REPL_CON_EXT_OP].handle);
  57. if(rc!=0)
  58. {
  59. PR_ASSERT(0); /* JCMREPL Argh */
  60. }
  61. repl_con_ext_list[REPL_CON_EXT_CONN].object_name = SLAPI_EXT_CONNECTION;
  62. rc = slapi_register_object_extension(repl_plugin_name,
  63. SLAPI_EXT_CONNECTION,
  64. consumer_connection_extension_constructor,
  65. consumer_connection_extension_destructor,
  66. &repl_con_ext_list[REPL_CON_EXT_CONN].object_type,
  67. &repl_con_ext_list[REPL_CON_EXT_CONN].handle);
  68. if(rc!=0)
  69. {
  70. PR_ASSERT(0); /* JCMREPL Argh */
  71. }
  72. repl_con_ext_list[REPL_CON_EXT_MTNODE].object_name = SLAPI_EXT_MTNODE;
  73. rc = slapi_register_object_extension(repl_plugin_name,
  74. SLAPI_EXT_MTNODE,
  75. multimaster_mtnode_extension_constructor,
  76. multimaster_mtnode_extension_destructor,
  77. &repl_con_ext_list[REPL_CON_EXT_MTNODE].object_type,
  78. &repl_con_ext_list[REPL_CON_EXT_MTNODE].handle);
  79. if(rc!=0)
  80. {
  81. PR_ASSERT(0); /* JCMREPL Argh */
  82. }
  83. }
  84. void* repl_con_get_ext (ext_type type, void *object)
  85. {
  86. /* find the requested extension */
  87. repl_ext ext = repl_con_ext_list [type];
  88. void* data = slapi_get_object_extension(ext.object_type, object, ext.handle);
  89. return data;
  90. }