Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Query the Mbed TLS compile time configuration |
| 3 | * |
| 4 | * Copyright (C) 2018, 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 | |
| 22 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 23 | #include "mbedtls/config.h" |
| 24 | #else |
| 25 | #include MBEDTLS_CONFIG_FILE |
| 26 | #endif |
| 27 | |
| 28 | #if defined(MBEDTLS_PLATFORM_C) |
| 29 | #include "mbedtls/platform.h" |
| 30 | #else |
| 31 | #include <stdio.h> |
| 32 | #include <stdlib.h> |
| 33 | #define mbedtls_printf printf |
| 34 | #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE |
| 35 | #endif |
| 36 | |
| 37 | #define USAGE \ |
| 38 | "usage: %s <MBEDTLS_CONFIG>\n\n" \ |
| 39 | "This program takes one command line argument which corresponds to\n" \ |
| 40 | "the string representation of a Mbed TLS compile time configuration.\n" \ |
| 41 | "The value 0 will be returned if this configuration is defined in the\n" \ |
| 42 | "Mbed TLS build and the macro expansion of that configuration will be\n" \ |
| 43 | "printed (if any). Otherwise, 1 will be returned.\n" |
| 44 | |
| 45 | int query_config( const char *config ); |
| 46 | |
| 47 | int main( int argc, char *argv[] ) |
| 48 | { |
| 49 | if ( argc != 2 ) |
| 50 | { |
| 51 | mbedtls_printf( USAGE, argv[0] ); |
| 52 | return( MBEDTLS_EXIT_FAILURE ); |
| 53 | } |
| 54 | |
| 55 | return( query_config( argv[1] ) ); |
| 56 | } |