features.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2016 Red Hat, Inc.
  3. * All rights reserved.
  4. *
  5. * License: GPL (version 3 or any later version).
  6. * See LICENSE for details.
  7. * END COPYRIGHT BLOCK **/
  8. #ifdef HAVE_CONFIG_H
  9. # include <config.h>
  10. #endif
  11. /* features.c - routines for dealing with supportedFeatures rfc3674 */
  12. #include <stdio.h>
  13. #include "slap.h"
  14. #include "slapi-plugin.h"
  15. int slapi_register_supported_feature( char *featureoid );
  16. static char **supported_features = NULL;
  17. static Slapi_RWLock *supported_features_lock = NULL;
  18. void
  19. init_features( void )
  20. {
  21. supported_features_lock = slapi_new_rwlock();
  22. if (supported_features_lock == NULL) {
  23. slapi_log_error(SLAPI_LOG_FATAL, "startup",
  24. "init_features: failed to create lock.\n");
  25. exit(1);
  26. }
  27. slapi_register_supported_feature( LDAP_FEATURE_ALL_OP_ATTRS );
  28. }
  29. int
  30. slapi_register_supported_feature( char *featureoid )
  31. {
  32. slapi_rwlock_wrlock(supported_features_lock);
  33. charray_add( &supported_features, slapi_ch_strdup( featureoid ));
  34. slapi_rwlock_unlock(supported_features_lock);
  35. return LDAP_SUCCESS;
  36. }
  37. int
  38. slapi_get_supported_features_copy( char ***ftroidsp )
  39. {
  40. slapi_rwlock_unlock(supported_features_lock);
  41. if ( ftroidsp != NULL ) {
  42. *ftroidsp = charray_dup(supported_features);
  43. }
  44. slapi_rwlock_unlock(supported_features_lock);
  45. return LDAP_SUCCESS;
  46. }