blob: d3f4e7893a12557d6e9ae31b90341143be6c531a [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
Andres AG509ba692018-10-26 18:41:08 +01005 * 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 AG509ba692018-10-26 18:41:08 +010018 */
19
20#if !defined(MBEDTLS_CONFIG_FILE)
21#include "mbedtls/config.h"
22#else
23#include MBEDTLS_CONFIG_FILE
24#endif
25
Andres AG509ba692018-10-26 18:41:08 +010026#include "mbedtls/platform.h"
Andres AG509ba692018-10-26 18:41:08 +010027
28#define USAGE \
Jerry Yu47569e02021-12-10 23:38:57 +080029 "usage: %s [ <MBEDTLS_CONFIG> | -l ]\n\n" \
Andres AG509ba692018-10-26 18:41:08 +010030 "This program takes one command line argument which corresponds to\n" \
31 "the string representation of a Mbed TLS compile time configuration.\n" \
32 "The value 0 will be returned if this configuration is defined in the\n" \
33 "Mbed TLS build and the macro expansion of that configuration will be\n" \
Jerry Yu4f2dff42021-12-06 13:44:39 +080034 "printed (if any). Otherwise, 1 will be returned.\n" \
Jerry Yu47569e02021-12-10 23:38:57 +080035 "-l\tPrint all available configuration.\n"
Jerry Yu4f2dff42021-12-06 13:44:39 +080036#include <string.h>
Gilles Peskinec772b182021-01-12 15:55:10 +010037#include "query_config.h"
Andres AG509ba692018-10-26 18:41:08 +010038
39int main( int argc, char *argv[] )
40{
41 if ( argc != 2 )
42 {
43 mbedtls_printf( USAGE, argv[0] );
44 return( MBEDTLS_EXIT_FAILURE );
45 }
46
Jerry Yu4f2dff42021-12-06 13:44:39 +080047 if( strcmp( argv[1], "-l" ) == 0 )
48 {
49 list_config();
50 return( 0 );
51 }
52
Andres AG509ba692018-10-26 18:41:08 +010053 return( query_config( argv[1] ) );
54}