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 |
Dave Rodgman | 7ff7965 | 2023-11-03 12:04:52 +0000 | [diff] [blame] | 5 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 9 | #include "mbedtls/config.h" |
| 10 | #else |
| 11 | #include MBEDTLS_CONFIG_FILE |
| 12 | #endif |
| 13 | |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 14 | #include "mbedtls/platform.h" |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 15 | |
| 16 | #define USAGE \ |
Jerry Yu | 47569e0 | 2021-12-10 23:38:57 +0800 | [diff] [blame] | 17 | "usage: %s [ <MBEDTLS_CONFIG> | -l ]\n\n" \ |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 18 | "This program takes one command line argument which corresponds to\n" \ |
| 19 | "the string representation of a Mbed TLS compile time configuration.\n" \ |
| 20 | "The value 0 will be returned if this configuration is defined in the\n" \ |
| 21 | "Mbed TLS build and the macro expansion of that configuration will be\n" \ |
Jerry Yu | 4f2dff4 | 2021-12-06 13:44:39 +0800 | [diff] [blame] | 22 | "printed (if any). Otherwise, 1 will be returned.\n" \ |
Jerry Yu | 47569e0 | 2021-12-10 23:38:57 +0800 | [diff] [blame] | 23 | "-l\tPrint all available configuration.\n" |
Jerry Yu | 4f2dff4 | 2021-12-06 13:44:39 +0800 | [diff] [blame] | 24 | #include <string.h> |
Gilles Peskine | c772b18 | 2021-01-12 15:55:10 +0100 | [diff] [blame] | 25 | #include "query_config.h" |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 26 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 27 | int main(int argc, char *argv[]) |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 28 | { |
Aditya Deshpande | 56d9003 | 2023-02-03 16:15:30 +0000 | [diff] [blame] | 29 | if (argc < 2 || strcmp(argv[1], "-h") == 0) { |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 30 | mbedtls_printf(USAGE, argv[0]); |
| 31 | return MBEDTLS_EXIT_FAILURE; |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 32 | } |
| 33 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 34 | if (strcmp(argv[1], "-l") == 0) { |
Jerry Yu | 4f2dff4 | 2021-12-06 13:44:39 +0800 | [diff] [blame] | 35 | list_config(); |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 36 | return 0; |
Jerry Yu | 4f2dff4 | 2021-12-06 13:44:39 +0800 | [diff] [blame] | 37 | } |
| 38 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 39 | return query_config(argv[1]); |
Andres AG | 509ba69 | 2018-10-26 18:41:08 +0100 | [diff] [blame] | 40 | } |