Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Query the Mbed TLS compile time configuration |
| 3 | * |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 4 | * Copyright The Mbed TLS Contributors |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 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. |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 18 | */ |
| 19 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 20 | #include "mbedtls/build_info.h" |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 21 | |
| 22 | #if defined(MBEDTLS_PLATFORM_C) |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 23 | # include "mbedtls/platform.h" |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 24 | #else |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 25 | # include <stdio.h> |
| 26 | # include <stdlib.h> |
| 27 | # define mbedtls_printf printf |
| 28 | # define MBEDTLS_EXIT_FAILURE EXIT_FAILURE |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 29 | #endif |
| 30 | |
| 31 | #define USAGE \ |
Andres AG | 08457ce | 2018-10-26 18:45:45 +0100 | [diff] [blame] | 32 | "usage: %s <MBEDTLS_CONFIG>\n\n" \ |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 33 | "This program takes one command line argument which corresponds to\n" \ |
| 34 | "the string representation of a Mbed TLS compile time configuration.\n" \ |
| 35 | "The value 0 will be returned if this configuration is defined in the\n" \ |
| 36 | "Mbed TLS build and the macro expansion of that configuration will be\n" \ |
| 37 | "printed (if any). Otherwise, 1 will be returned.\n" |
| 38 | |
Gilles Peskine | c772b18 | 2021-01-12 15:55:10 +0100 | [diff] [blame] | 39 | #include "query_config.h" |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 40 | |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 41 | int main(int argc, char *argv[]) |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 42 | { |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 43 | if (argc != 2) { |
| 44 | mbedtls_printf(USAGE, argv[0]); |
| 45 | return MBEDTLS_EXIT_FAILURE; |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 46 | } |
| 47 | |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 48 | return query_config(argv[1]); |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 49 | } |