]>
git.saurik.com Git - apple/security.git/blob - Keychain/generateErrStrings.pl
3 # generatorX.pl - create error strings files from the Security header files
5 # John Hurley, Summer 2003. Based on generator.pl, Perry The Cynic, Fall 1999.
8 # perl generatorX.pl input-directory output-directory <files>
10 # Currently supported files are SecBase.h, SecureTransport.h and Authorization.h
12 # perl generatorX.pl `pwd` `pwd` SecBase2.h SecureTransport2.h Authorization.h
16 # errSSLProtocol = -9800, /* SSL protocol error */
17 # errSSLNegotiation = -9801, /* Cipher Suite negotiation failure */
19 # Output should be like (in Unicode):
21 # /* errSSLProtocol */
22 # "-9800" = "SSL protocol error";
24 # /* errSSLNegotiation */
25 # "-9801" = "Cipher Suite negotiation failure";
27 # Note that the list of errors must be numerically unique across all input files, or the strings file
28 # will be invalid.Comments that span multiple lines will be ignored, as will lines with no comment. C++
29 # style comments are not supported.
34 $SOURCEDIR=$ARGV[0]; # directory with error headers
35 $TARGETDIR=$ARGV[1]; # where to put the output file
36 @INPUTFILES=@ARGV[2 .. 9999]; # list of input files
38 $TABLES="$TARGETDIR/SecErrorMessages.strings"; # error strings
40 $tabs = "\t\t\t"; # argument indentation (noncritical)
41 $warning = "This file was automatically generated. Do not edit on penalty of futility!";
44 # Parse error headers and build array of all relevant lines
47 open(ERR
, "cat " . join(" ", @INPUTFILES) . "|") or die "Cannot open error header files";
48 $/=undef; # still gulping
50 @errorlines = m{(?:^\s*)(err[Sec|Authorization|SSL]\w+)(?:\s*=\s*)(-?\d+)(?:\s*,?\s*)(?:/\*\s*)(.*)(?:\*/)(?:$\s*)}gm;
53 $nFull = $#errorlines / 3;
56 # Now we will generate the error name tables.
59 open(OUT
, ">$TABLES") or die "Cannot write $TABLES: $^E";
62 # Print warning comment
63 $msg = "//\n// Security error code tables.\n// $warning\n//\n";
65 # Print the error messages
66 while ($errx = shift @errorlines)
68 $value = shift @errorlines; # or die;
69 $str = shift @errorlines; # or die;
70 $str =~ s/\s*$//; # drop trailing white space
71 if ( $value != 0) # can't output duplicate error codes
73 $msg = $msg . "\n/* $errx */\n\"$value\" = \"$str\";\n";
77 $output = encode
("UTF-16", $msg, Encode
::FB_PERLQQ
);
83 #print "$nFull errors available to error translation functions.\n";