5 if (!@ARGV || $ARGV[0] == '--help') {
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.
11 Used to include some of the test data in /library/certs.c for
12 self-tests and sample programs.
17 my $pp_name = @ARGV > 1 ? shift @ARGV : undef;
18 my $name = shift @ARGV;
20 my @lines = map {chomp; s/([\\"])/\\$1/g; "\"$_\\r\\n\""} <STDIN>;
22 if (defined $pp_name) {
23 foreach ("#define $pp_name", @lines[0..@lines-2]) {
24 printf "%-72s\\\n", $_;
26 print "$lines[@lines-1]\n";
27 print "const char $name\[\] = $pp_name;\n";
29 print "const char $name\[\] =";