Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / mbedtls / repo / tests / data_files / print_c.pl
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 if (!@ARGV || $ARGV[0] == '--help') {
6     print <<EOF;
7 Usage: $0 mbedtls_test_foo <file.pem
8        $0 TEST_FOO mbedtls_test_foo <file.pem
9 Print out a PEM file as C code defining a string constant.
10
11 Used to include some of the test data in /library/certs.c for
12 self-tests and sample programs.
13 EOF
14     exit;
15 }
16
17 my $pp_name = @ARGV > 1 ? shift @ARGV : undef;
18 my $name = shift @ARGV;
19
20 my @lines = map {chomp; s/([\\"])/\\$1/g; "\"$_\\r\\n\""} <STDIN>;
21
22 if (defined $pp_name) {
23     foreach ("#define $pp_name", @lines[0..@lines-2]) {
24         printf "%-72s\\\n", $_;
25     }
26     print "$lines[@lines-1]\n";
27     print "const char $name\[\] = $pp_name;\n";
28 } else {
29     print "const char $name\[\] =";
30     foreach (@lines) {
31         print "\n$_";
32     }
33     print ";\n";
34 }