blob: cb3714658f14bb7e1fa99f70562ee3fbbd8606b2 [file] [log] [blame]
Andres AG509ba692018-10-26 18:41:08 +01001/*
2 * Query the Mbed TLS compile time configuration
3 *
Bence Szépkúti1e148272020-08-07 13:07:28 +02004 * Copyright The Mbed TLS Contributors
Dave Rodgman7ff79652023-11-03 12:04:52 +00005 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Andres AG509ba692018-10-26 18:41:08 +01006 */
7
8#if !defined(MBEDTLS_CONFIG_FILE)
9#include "mbedtls/config.h"
10#else
11#include MBEDTLS_CONFIG_FILE
12#endif
13
Andres AG509ba692018-10-26 18:41:08 +010014#include "mbedtls/platform.h"
Andres AG509ba692018-10-26 18:41:08 +010015
16#define USAGE \
Jerry Yu47569e02021-12-10 23:38:57 +080017 "usage: %s [ <MBEDTLS_CONFIG> | -l ]\n\n" \
Andres AG509ba692018-10-26 18:41:08 +010018 "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 Yu4f2dff42021-12-06 13:44:39 +080022 "printed (if any). Otherwise, 1 will be returned.\n" \
Jerry Yu47569e02021-12-10 23:38:57 +080023 "-l\tPrint all available configuration.\n"
Jerry Yu4f2dff42021-12-06 13:44:39 +080024#include <string.h>
Gilles Peskinec772b182021-01-12 15:55:10 +010025#include "query_config.h"
Andres AG509ba692018-10-26 18:41:08 +010026
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010027int main(int argc, char *argv[])
Andres AG509ba692018-10-26 18:41:08 +010028{
Aditya Deshpande56d90032023-02-03 16:15:30 +000029 if (argc < 2 || strcmp(argv[1], "-h") == 0) {
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010030 mbedtls_printf(USAGE, argv[0]);
31 return MBEDTLS_EXIT_FAILURE;
Andres AG509ba692018-10-26 18:41:08 +010032 }
33
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010034 if (strcmp(argv[1], "-l") == 0) {
Jerry Yu4f2dff42021-12-06 13:44:39 +080035 list_config();
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010036 return 0;
Jerry Yu4f2dff42021-12-06 13:44:39 +080037 }
38
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010039 return query_config(argv[1]);
Andres AG509ba692018-10-26 18:41:08 +010040}