blob: 9f826c2a4702a66741f97e523e8c6c29f9666ba5 [file] [log] [blame]
Paul Bakker0f90d7d2014-04-30 11:49:44 +02001/*
2 * Version feature information
3 *
Manuel Pégourié-Gonnard7381ff02015-08-04 11:12:49 +02004 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Paul Bakker0f90d7d2014-04-30 11:49:44 +02005 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00006 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker0f90d7d2014-04-30 11:49:44 +02007 *
Paul Bakker0f90d7d2014-04-30 11:49:44 +02008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000024#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020025#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020027#endif
Paul Bakker0f90d7d2014-04-30 11:49:44 +020028
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#if defined(MBEDTLS_VERSION_C)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020030
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000031#include "mbedtls/version.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020032
33#include <string.h>
34
Manuel Pégourié-Gonnard385069f2015-03-05 15:47:55 +000035static const char *features[] = {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020036#if defined(MBEDTLS_VERSION_FEATURES)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020037FEATURE_DEFINES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020038#endif /* MBEDTLS_VERSION_FEATURES */
Paul Bakker0f90d7d2014-04-30 11:49:44 +020039 NULL
40};
41
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020042int mbedtls_version_check_feature( const char *feature )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020043{
44 const char **idx = features;
45
Paul Bakker790e3952014-04-30 16:48:32 +020046 if( *idx == NULL )
47 return( -2 );
48
Paul Bakker0f90d7d2014-04-30 11:49:44 +020049 if( feature == NULL )
50 return( -1 );
51
52 while( *idx != NULL )
53 {
Manuel Pégourié-Gonnardcb46fd82015-05-28 17:06:07 +020054 if( !strcmp( *idx, feature ) )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020055 return( 0 );
56 idx++;
57 }
58 return( -1 );
59}
60
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020061#endif /* MBEDTLS_VERSION_C */