GH355: Implement HKDF
[openssl.git] / util / mkerr.pl
index 95f288304ec9e63ac6da084bbcf000c26ea77b6a..4fd5520d87cb851746e76a9bf534f44ebf49d958 100644 (file)
@@ -3,6 +3,7 @@
 my $config = "crypto/err/openssl.ec";
 my $hprefix = "openssl/";
 my $debug = 0;
+my $unref = 0;
 my $rebuild = 0;
 my $static = 1;
 my $recurse = 0;
@@ -26,6 +27,7 @@ while (@ARGV) {
                $hprefix = shift @ARGV;
        } elsif($arg eq "-debug") {
                $debug = 1;
+               $unref = 1;
                shift @ARGV;
        } elsif($arg eq "-rebuild") {
                $rebuild = 1;
@@ -42,6 +44,9 @@ while (@ARGV) {
        } elsif($arg eq "-staticloader") {
                $staticloader = "static ";
                shift @ARGV;
+       } elsif($arg eq "-unref") {
+               $unref = 1;
+               shift @ARGV;
        } elsif($arg eq "-write") {
                $dowrite = 1;
                shift @ARGV;
@@ -89,7 +94,7 @@ Options:
                   void ERR_load_<LIB>_strings(void);
                   void ERR_unload_<LIB>_strings(void);
                   void ERR_<LIB>_error(int f, int r, char *fn, int ln);
-                  #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__)
+                  #define <LIB>err(f,r) ERR_<LIB>_error(f,r,OPENSSL_FILE,OPENSSL_LINE)
                 while the code facilitates the use of these in an environment
                 where the error support routines are dynamically loaded at 
                 runtime.
@@ -98,6 +103,8 @@ Options:
   -staticloader Prefix generated functions with the 'static' scope modifier.
                 Default: don't write any scope modifier prefix.
 
+  -unref        Print out unreferenced function and reason codes.
+
   -write        Actually (over)write the generated code to the header and C 
                 source files as assigned to each library through the config 
                 file.
@@ -116,7 +123,7 @@ EOF
 }
 
 if($recurse) {
-       @source = ( <crypto/*.c>, <crypto/*/*.c>, <ssl/*.c> )
+       @source = ( <crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>, <ssl/*/*.c> )
 } else {
        @source = @ARGV;
 }
@@ -377,7 +384,6 @@ foreach $lib (keys %csrc)
        my $hfile = $hinc{$lib};
        my $cfile = $csrc{$lib};
        if(!$fnew{$lib} && !$rnew{$lib}) {
-               print STDERR "$lib:\t\tNo new error codes\n";
                next unless $rebuild;
        } else {
                print STDERR "$lib:\t\t$fnew{$lib} New Functions,";
@@ -487,7 +493,7 @@ EOF
 ${staticloader}void ERR_load_${lib}_strings(void);
 ${staticloader}void ERR_unload_${lib}_strings(void);
 ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
-# define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
+# define ${lib}err(f,r) ERR_${lib}_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
 
 EOF
        }
@@ -550,7 +556,7 @@ EOF
        if (open(IN,"<$cfile")) {
                my $line = "";
                while (<IN>) {
-                       chomp;
+                       s|\R$||; # Better chomp
                        $_ = $line . $_;
                        $line = "";
                        if (/{ERR_(FUNC|REASON)\(/) {
@@ -596,7 +602,6 @@ EOF
        open (OUT,">$cfile") || die "Can't open $cfile for writing";
 
        print OUT <<"EOF";
-/* $cfile */
 /* ====================================================================
  * Copyright (c) 1999-$year The OpenSSL Project.  All rights reserved.
  *
@@ -808,7 +813,7 @@ foreach (keys %rcodes) {
        push (@runref, $_) unless exists $urcodes{$_};
 }
 
-if($debug && @funref) {
+if($unref && @funref) {
        print STDERR "The following function codes were not referenced:\n";
        foreach(sort @funref)
        {
@@ -816,7 +821,7 @@ if($debug && @funref) {
        }
 }
 
-if($debug && @runref) {
+if($unref && @runref) {
        print STDERR "The following reason codes were not referenced:\n";
        foreach(sort @runref)
        {