version_features.fmt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Version feature information
  3. *
  4. * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * This file is part of mbed TLS (https://tls.mbed.org)
  20. */
  21. #if !defined(MBEDTLS_CONFIG_FILE)
  22. #include "mbedtls/config.h"
  23. #else
  24. #include MBEDTLS_CONFIG_FILE
  25. #endif
  26. #if defined(MBEDTLS_VERSION_C)
  27. #include "mbedtls/version.h"
  28. #include <string.h>
  29. static const char *features[] = {
  30. #if defined(MBEDTLS_VERSION_FEATURES)
  31. FEATURE_DEFINES
  32. #endif /* MBEDTLS_VERSION_FEATURES */
  33. NULL
  34. };
  35. int mbedtls_version_check_feature( const char *feature )
  36. {
  37. const char **idx = features;
  38. if( *idx == NULL )
  39. return( -2 );
  40. if( feature == NULL )
  41. return( -1 );
  42. while( *idx != NULL )
  43. {
  44. if( !strcmp( *idx, feature ) )
  45. return( 0 );
  46. idx++;
  47. }
  48. return( -1 );
  49. }
  50. #endif /* MBEDTLS_VERSION_C */