profile.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "slapi-plugin.h"
  13. /* module: provide an interface to the profile file */
  14. static FILE *profile_fd = NULL;
  15. /* JCMREPL - Could build up in an AVL tree and dump out to disk at the end... */
  16. void
  17. profile_log(char *file, int line)
  18. {
  19. if (profile_fd == NULL)
  20. slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "profile_log: profile file not open.");
  21. else {
  22. /* JCMREPL - Probably need a lock around here */
  23. fprintf(profile_fd, "%s %d\n", file, line);
  24. }
  25. }
  26. void
  27. profile_open()
  28. {
  29. char filename[MAX_FILENAME];
  30. PR_snprintf(filename, MAX_FILENAME, "%s%s", CFG_rootpath, CFG_profilefile);
  31. profile_fd = textfile_open(filename, "a");
  32. }
  33. void
  34. profile_close()
  35. {
  36. if (profile_fd == NULL)
  37. slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "profile_close: profile file not open.");
  38. else
  39. textfile_close(profile_fd);
  40. }