📄 mkerr.pl
字号:
print OUT @out; undef @out; print OUT <<"EOF";/* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. */EOF if($static) { print OUT <<"EOF";${staticloader}void ERR_load_${lib}_strings(void);EOF } else { print OUT <<"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__)EOF } print OUT <<"EOF";/* Error codes for the $lib functions. *//* Function codes. */EOF foreach $i (@function) { $z=6-int(length($i)/8); if($fcodes{$i} eq "X") { $fcodes{$i} = ++$fmax{$lib}; print STDERR "New Function code $i\n" if $debug; } printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z; } print OUT "\n/* Reason codes. */\n"; foreach $i (@reasons) { $z=6-int(length($i)/8); if($rcodes{$i} eq "X") { $rcodes{$i} = ++$rmax{$lib}; print STDERR "New Reason code $i\n" if $debug; } printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z; } print OUT <<"EOF";#ifdef __cplusplus}#endif#endifEOF close OUT; # Rewrite the C source file containing the error details. # First, read any existing reason string definitions: my %err_reason_strings; if (open(IN,"<$cfile")) { while (<IN>) { if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) { $err_reason_strings{$1} = $2; } } close(IN); } my $hincf; if($static) { $hfile =~ /([^\/]+)$/; $hincf = "<openssl/$1>"; } else { $hincf = "\"$hfile\""; } # If static we know the error code at compile time so use it # in error definitions. if ($static) { $pack_errcode = "ERR_LIB_${lib}"; $load_errcode = "0"; } else { $pack_errcode = "0"; $load_errcode = "ERR_LIB_${lib}"; } open (OUT,">$cfile") || die "Can't open $cfile for writing"; print OUT <<"EOF";/* $cfile *//* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core\@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay\@cryptsoft.com). This product includes software written by Tim * Hudson (tjh\@cryptsoft.com). * *//* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */#include <stdio.h>#include <openssl/err.h>#include $hincf/* BEGIN ERROR CODES */#ifndef OPENSSL_NO_ERR#define ERR_FUNC(func) ERR_PACK($pack_errcode,func,0)#define ERR_REASON(reason) ERR_PACK($pack_errcode,0,reason)static ERR_STRING_DATA ${lib}_str_functs[]= {EOF # Add each function code: if a function name is found then use it. foreach $i (@function) { my $fn; $i =~ /^${lib}_F_(\S+)$/; $fn = $1; if(exists $ftrans{$fn}) { $fn = $ftrans{$fn}; }# print OUT "{ERR_PACK($pack_errcode,$i,0),\t\"$fn\"},\n"; print OUT "{ERR_FUNC($i),\t\"$fn\"},\n"; } print OUT <<"EOF";{0,NULL} };static ERR_STRING_DATA ${lib}_str_reasons[]= {EOF # Add each reason code. foreach $i (@reasons) { my $rn; my $rstr = "ERR_REASON($i)"; my $nspc = 0; if (exists $err_reason_strings{$i}) { $rn = $err_reason_strings{$i}; } else { $i =~ /^${lib}_R_(\S+)$/; $rn = $1; $rn =~ tr/_[A-Z]/ [a-z]/; } $nspc = 40 - length($rstr) unless length($rstr) > 40; $nspc = " " x $nspc; print OUT "{${rstr}${nspc},\"$rn\"},\n"; }if($static) { print OUT <<"EOF";{0,NULL} };#endif${staticloader}void ERR_load_${lib}_strings(void) { static int init=1; if (init) { init=0;#ifndef OPENSSL_NO_ERR ERR_load_strings($load_errcode,${lib}_str_functs); ERR_load_strings($load_errcode,${lib}_str_reasons);#endif } }EOF} else { print OUT <<"EOF";{0,NULL} };#endif#ifdef ${lib}_LIB_NAMEstatic ERR_STRING_DATA ${lib}_lib_name[]= {{0 ,${lib}_LIB_NAME},{0,NULL} };#endifstatic int ${lib}_lib_error_code=0;static int ${lib}_error_init=1;${staticloader}void ERR_load_${lib}_strings(void) { if (${lib}_lib_error_code == 0) ${lib}_lib_error_code=ERR_get_next_error_library(); if (${lib}_error_init) { ${lib}_error_init=0;#ifndef OPENSSL_NO_ERR ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs); ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons);#endif#ifdef ${lib}_LIB_NAME ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0); ERR_load_strings(0,${lib}_lib_name);#endif } }${staticloader}void ERR_unload_${lib}_strings(void) { if (${lib}_error_init == 0) {#ifndef OPENSSL_NO_ERR ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs); ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons);#endif#ifdef ${lib}_LIB_NAME ERR_unload_strings(0,${lib}_lib_name);#endif ${lib}_error_init=1; } }${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line) { if (${lib}_lib_error_code == 0) ${lib}_lib_error_code=ERR_get_next_error_library(); ERR_PUT_error(${lib}_lib_error_code,function,reason,file,line); }EOF} close OUT; undef %err_reason_strings;}if($debug && defined(%notrans)) { print STDERR "The following function codes were not translated:\n"; foreach(sort keys %notrans) { print STDERR "$_\n"; }}# Make a list of unreferenced function and reason codesforeach (keys %fcodes) { push (@funref, $_) unless exists $ufcodes{$_};}foreach (keys %rcodes) { push (@runref, $_) unless exists $urcodes{$_};}if($debug && defined(@funref) ) { print STDERR "The following function codes were not referenced:\n"; foreach(sort @funref) { print STDERR "$_\n"; }}if($debug && defined(@runref) ) { print STDERR "The following reason codes were not referenced:\n"; foreach(sort @runref) { print STDERR "$_\n"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -