summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/err/err_code.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/err/err_code.pl')
-rw-r--r--src/lib/libcrypto/err/err_code.pl105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/lib/libcrypto/err/err_code.pl b/src/lib/libcrypto/err/err_code.pl
new file mode 100644
index 0000000000..ebc8eef913
--- /dev/null
+++ b/src/lib/libcrypto/err/err_code.pl
@@ -0,0 +1,105 @@
1#!/usr/bin/perl
2
3while (@ARGV)
4 {
5 $in=shift(@ARGV);
6 if ($in =~ /^-conf$/)
7 {
8 $in=shift(@ARGV);
9 open(IN,"<$in") || die "unable to open '$in'\n";
10 while (<IN>)
11 {
12 s/#.*$//;
13 s/\s+$//;
14 next if (/^$/);
15 if (/^L\s+(\S+)\s+(\S+)$/)
16 { $errfile{$1}=$2; }
17 elsif (/^F\s+(\S+)$/)
18 { $function{$1}=1; }
19 elsif (/^R\s+(\S+)\s+(\S+)$/)
20 { $r_value{$1}=$2; }
21 else { die "bad input line: $in:$.\n"; }
22 }
23 close(IN);
24 next;
25 }
26
27 open(IN,"<$in") || die "unable to open '$in'\n";
28 $last="";
29 while (<IN>)
30 {
31 if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/)
32 {
33 if ($1 != $last)
34 {
35 if ($function{$1} == 0)
36 {
37 printf STDERR "$. $1 is bad\n";
38 }
39 }
40 $function{$1}++;
41 $last=$1;
42 $reason{$2}++;
43 }
44 }
45 close(IN);
46 }
47
48foreach (keys %function,keys %reason)
49 {
50 /^([A-Z0-9]+)_/;
51 $prefix{$1}++;
52 }
53
54@F=sort keys %function;
55@R=sort keys %reason;
56foreach $j (sort keys %prefix)
57 {
58 next if $errfile{$j} eq "NONE";
59 printf STDERR "doing %-6s - ",$j;
60 if (defined($errfile{$j}))
61 {
62 open(OUT,">$errfile{$j}") ||
63 die "unable to open '$errfile{$j}':$!\n";
64 $close_file=1;
65 }
66 else
67 {
68 *OUT=*STDOUT;
69 $close=0;
70 }
71 @f=grep(/^${j}_/,@F);
72 @r=grep(/^${j}_/,@R);
73 $num=100;
74 print OUT "/* Error codes for the $j functions. */\n\n";
75 print OUT "/* Function codes. */\n";
76 $f_count=0;
77 foreach $i (@f)
78 {
79 $z=6-int(length($i)/8);
80 printf OUT "#define $i%s $num\n","\t" x $z;
81 $num++;
82 $f_count++;
83 }
84 $num=100;
85 print OUT "\n/* Reason codes. */\n";
86 $r_count=0;
87 foreach $i (@r)
88 {
89 $z=6-int(length($i)/8);
90 if (defined($r_value{$i}))
91 {
92 printf OUT "#define $i%s $r_value{$i}\n","\t" x $z;
93 }
94 else
95 {
96 printf OUT "#define $i%s $num\n","\t" x $z;
97 $num++;
98 }
99 $r_count++;
100 }
101 close(OUT) if $close_file;
102
103 printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count;
104 }
105