repl_monitor.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #include <string.h>
  7. #include "repl.h"
  8. #include "slapi-plugin.h"
  9. /* Forward Declartions */
  10. static int repl_monitor_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
  11. int
  12. repl_monitor_init()
  13. {
  14. /* The FE DSE *must* be initialised before we get here */
  15. int return_value= LDAP_SUCCESS;
  16. static int initialized = 0;
  17. if (!initialized)
  18. {
  19. /* ONREPL - this is commented until we implement 4.0 style changelog
  20. slapi_config_register_callback(SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,"cn=monitor",LDAP_SCOPE_BASE,"(objectclass=*)",repl_monitor_search,NULL); */
  21. initialized = 1;
  22. }
  23. return return_value;
  24. }
  25. static int
  26. repl_monitor_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
  27. {
  28. const char *sdv = get_server_dataversion();
  29. if ( sdv != NULL )
  30. {
  31. int port;
  32. char buf[BUFSIZ];
  33. struct berval val;
  34. struct berval *vals[2];
  35. vals[0] = &val;
  36. vals[1] = NULL;
  37. port= config_get_port();
  38. if(port==0)
  39. {
  40. port= config_get_secureport();
  41. }
  42. /* ONREPL - how do we publish changenumbers now with multiple changelogs?
  43. sprintf( buf, "%s:%lu %s% lu", get_localhost_DNS(), port, sdv, ldapi_get_last_changenumber());
  44. */
  45. val.bv_val = buf;
  46. val.bv_len = strlen( buf );
  47. slapi_entry_attr_replace( e, attr_dataversion, vals );
  48. }
  49. return SLAPI_DSE_CALLBACK_OK;
  50. }