blob: eefe4c2a9fc7f067ccda6a2e9419cf117aae667d [file] [log] [blame]
Paul Bakker0f90d7d2014-04-30 11:49:44 +02001/*
2 * Version feature information
3 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +00004 * Copyright (C) 2006-2014, 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
Paul Bakker2ca1dc82014-04-30 17:01:25 +020035#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
Paul Bakker0f90d7d2014-04-30 11:49:44 +020036 !defined(EFI32)
Paul Bakker2ca1dc82014-04-30 17:01:25 +020037#define strcasecmp _stricmp
Paul Bakker0f90d7d2014-04-30 11:49:44 +020038#endif
39
Manuel Pégourié-Gonnard385069f2015-03-05 15:47:55 +000040static const char *features[] = {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020041#if defined(MBEDTLS_VERSION_FEATURES)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020042FEATURE_DEFINES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020043#endif /* MBEDTLS_VERSION_FEATURES */
Paul Bakker0f90d7d2014-04-30 11:49:44 +020044 NULL
45};
46
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020047int mbedtls_version_check_feature( const char *feature )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020048{
49 const char **idx = features;
50
Paul Bakker790e3952014-04-30 16:48:32 +020051 if( *idx == NULL )
52 return( -2 );
53
Paul Bakker0f90d7d2014-04-30 11:49:44 +020054 if( feature == NULL )
55 return( -1 );
56
57 while( *idx != NULL )
58 {
59 if( !strcasecmp( *idx, feature ) )
60 return( 0 );
61 idx++;
62 }
63 return( -1 );
64}
65
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020066#endif /* MBEDTLS_VERSION_C */