]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/Security/generateErrStrings.pl
3 # Copyright (c) 2003-2004,2011,2014 Apple Inc. All Rights Reserved.
5 # @APPLE_LICENSE_HEADER_START@
7 # This file contains Original Code and/or Modifications of Original Code
8 # as defined in and that are subject to the Apple Public Source License
9 # Version 2.0 (the 'License'). You may not use this file except in
10 # compliance with the License. Please obtain a copy of the License at
11 # http://www.opensource.apple.com/apsl/ and read it before using this
14 # The Original Code and all software distributed under the License are
15 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 # Please see the License for the specific language governing rights and
20 # limitations under the License.
22 # @APPLE_LICENSE_HEADER_END@
24 # generatorX.pl - create error strings files from the Security header files
27 # perl generatorX.pl input-directory output-directory <files>
29 # Currently supported files are SecBase.h, SecureTransport.h and Authorization.h
31 # perl generatorX.pl `pwd` `pwd` SecBase2.h SecureTransport2.h Authorization.h
35 # errSSLProtocol = -9800, /* SSL protocol error */
36 # errSSLNegotiation = -9801, /* Cipher Suite negotiation failure */
38 # Output should be like (in Unicode):
40 # /* errSSLProtocol */
41 # "-9800" = "SSL protocol error";
43 # /* errSSLNegotiation */
44 # "-9801" = "Cipher Suite negotiation failure";
46 # Note that the list of errors must be numerically unique across all input files, or the strings file
47 # will be invalid.Comments that span multiple lines will be ignored, as will lines with no comment. C++
48 # style comments are not supported.
53 $SOURCEDIR=$ARGV[0]; # directory with error headers
54 $TARGETDIR=$ARGV[1]; # where to put the output file
55 @INPUTFILES=@ARGV[2 .. 9999]; # list of input files
57 $TABLES="$TARGETDIR/SecErrorMessages.strings"; # error strings
59 $tabs = "\t\t\t"; # argument indentation (noncritical)
60 $warning = "This file was automatically generated. Do not edit on penalty of futility!";
63 # Parse error headers and build array of all relevant lines
66 open(ERR
, "cat " . join(" ", @INPUTFILES) . "|") or die "Cannot open error header files";
67 $/=undef; # big gulp mode
69 @errorlines = m{(?:^\s*)(err[Sec|Authorization|SSL]\w+)(?:\s*=\s*)(-?\d+)(?:\s*,?\s*)(?:/\*\s*)(.*)(?:\*/)(?:$\s*)}gm;
72 $nFull = $#errorlines / 3;
75 # Now we will generate the error name tables.
77 open(OUT
, ">$TABLES") or die "Cannot write $TABLES: $^E";
79 # Print warning comment
80 $msg = "//\n// Security error code tables.\n// $warning\n//\n";
82 # Print the error messages
83 while ($errx = shift @errorlines)
85 $value = shift @errorlines; # or die;
86 $str = shift @errorlines; # or die;
87 $str =~ s/\s*$//; # drop trailing white space
88 if ( $value != 0) # can't output duplicate error codes
90 $msg = $msg . "\n/* $errx */\n\"$value\" = \"$str\";\n";
94 $output = encode
("UTF-16", $msg, Encode
::FB_PERLQQ
);