cl5_init.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /* cl5_init.c - implments initialization/cleanup functions for
  13. 4.0 style changelog
  14. */
  15. #include "slapi-plugin.h"
  16. #include "cl5.h"
  17. #include "repl5.h"
  18. /* initializes changelog*/
  19. int changelog5_init()
  20. {
  21. int rc;
  22. changelog5Config config;
  23. rc = cl5Init ();
  24. if (rc != CL5_SUCCESS)
  25. {
  26. slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
  27. "changelog5_init: failed to initialize changelog\n");
  28. return 1;
  29. }
  30. /* read changelog configuration */
  31. changelog5_config_init ();
  32. changelog5_read_config (&config);
  33. if (config.dir == NULL)
  34. {
  35. /* changelog is not configured - bail out */
  36. /* Note: but still changelog needs to be initialized to allow it
  37. * to configure after this point. (don't call cl5Cleanup) */
  38. rc = 0; /* OK */
  39. goto done;
  40. }
  41. /* start changelog */
  42. rc = cl5Open (config.dir, &config.dbconfig);
  43. if (rc != CL5_SUCCESS)
  44. {
  45. slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
  46. "changelog5_init: failed to start changelog at %s\n",
  47. config.dir);
  48. rc = 1;
  49. goto done;
  50. }
  51. /* set trimming parameters */
  52. rc = cl5ConfigTrimming (config.maxEntries, config.maxAge, config.compactInterval, config.trimInterval);
  53. if (rc != CL5_SUCCESS)
  54. {
  55. slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
  56. "changelog5_init: failed to configure changelog trimming\n");
  57. rc = 1;
  58. goto done;
  59. }
  60. rc = 0;
  61. done:
  62. changelog5_config_done (&config);
  63. return rc;
  64. }
  65. /* cleanups changelog data */
  66. void changelog5_cleanup()
  67. {
  68. /* close changelog */
  69. cl5Close ();
  70. cl5Cleanup ();
  71. /* cleanup config */
  72. changelog5_config_cleanup ();
  73. }