cl5_init.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* cl5_init.c - implments initialization/cleanup functions for
  7. 4.0 style changelog
  8. */
  9. #include "slapi-plugin.h"
  10. #include "cl5.h"
  11. #include "repl5.h"
  12. /* initializes changelog*/
  13. int changelog5_init()
  14. {
  15. int rc;
  16. changelog5Config config;
  17. rc = cl5Init ();
  18. if (rc != CL5_SUCCESS)
  19. {
  20. slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
  21. "changelog5_init: failed to initialize changelog\n");
  22. return 1;
  23. }
  24. /* read changelog configuration */
  25. changelog5_config_init ();
  26. changelog5_read_config (&config);
  27. if (config.dir == NULL)
  28. {
  29. /* changelog is not configured - bail out */
  30. rc = 0; /* OK */
  31. goto done;
  32. }
  33. /* start changelog */
  34. rc = cl5Open (config.dir, &config.dbconfig);
  35. if (rc != CL5_SUCCESS)
  36. {
  37. slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
  38. "changelog5_init: failed to start changelog at %s\n",
  39. config.dir);
  40. rc = 1;
  41. goto done;
  42. }
  43. /* set trimming parameters */
  44. rc = cl5ConfigTrimming (config.maxEntries, config.maxAge);
  45. if (rc != CL5_SUCCESS)
  46. {
  47. slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
  48. "changelog5_init: failed to configure changelog trimming\n");
  49. rc = 1;
  50. goto done;
  51. }
  52. rc = 0;
  53. done:
  54. changelog5_config_done (&config);
  55. return rc;
  56. }
  57. /* cleanups changelog data */
  58. void changelog5_cleanup()
  59. {
  60. /* close changelog */
  61. cl5Close ();
  62. cl5Cleanup ();
  63. /* cleanup config */
  64. changelog5_config_cleanup ();
  65. }