diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/regress/lib/libcrypto/man/check_complete.pl | 266 |
1 files changed, 266 insertions, 0 deletions
diff --git a/src/regress/lib/libcrypto/man/check_complete.pl b/src/regress/lib/libcrypto/man/check_complete.pl new file mode 100755 index 0000000000..1086fd8627 --- /dev/null +++ b/src/regress/lib/libcrypto/man/check_complete.pl | |||
| @@ -0,0 +1,266 @@ | |||
| 1 | #!/usr/bin/perl | ||
| 2 | # | ||
| 3 | # Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> | ||
| 4 | # | ||
| 5 | # Permission to use, copy, modify, and distribute this software for any | ||
| 6 | # purpose with or without fee is hereby granted, provided that the above | ||
| 7 | # copyright notice and this permission notice appear in all copies. | ||
| 8 | # | ||
| 9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | use warnings; | ||
| 19 | |||
| 20 | my @obsolete = qw( | ||
| 21 | d2i_PBEPARAM d2i_PBE2PARAM d2i_PBKDF2PARAM | ||
| 22 | i2d_PBEPARAM i2d_PBE2PARAM i2d_PBKDF2PARAM | ||
| 23 | PBEPARAM PBEPARAM_free PBEPARAM_new | ||
| 24 | PBE2PARAM PBE2PARAM_free PBE2PARAM_new | ||
| 25 | PBKDF2PARAM PBKDF2PARAM_free PBKDF2PARAM_new | ||
| 26 | PKCS5_pbe_set PKCS5_pbe_set0_algor | ||
| 27 | PKCS5_pbe2_set PKCS5_pbe2_set_iv | ||
| 28 | PKCS5_pbkdf2_set | ||
| 29 | X509_EX_V_INIT | ||
| 30 | X509_EXT_PACK_STRING X509_EXT_PACK_UNKNOWN | ||
| 31 | ); | ||
| 32 | |||
| 33 | my $MANW = 'man -M /usr/share/man -w'; | ||
| 34 | my $srcdir = '/usr/src/lib/libcrypto/man'; | ||
| 35 | my $hfile = '/usr/include/openssl'; | ||
| 36 | |||
| 37 | my $in_cplusplus = 0; | ||
| 38 | my $in_comment = 0; | ||
| 39 | my $in_define = 0; | ||
| 40 | my $in_function = 0; | ||
| 41 | my $in_struct = 0; | ||
| 42 | my $in_typedef_struct = 0; | ||
| 43 | my $verbose = 0; | ||
| 44 | |||
| 45 | if (defined $ARGV[0] && $ARGV[0] eq '-v') { | ||
| 46 | $verbose = 1; | ||
| 47 | shift @ARGV; | ||
| 48 | } | ||
| 49 | $#ARGV == 0 or die "usage: $0 [-v] headername"; | ||
| 50 | $hfile .= "/$ARGV[0].h"; | ||
| 51 | open my $in_fh, '<', $hfile or die "$hfile: $!"; | ||
| 52 | |||
| 53 | while (<$in_fh>) { | ||
| 54 | try_again: | ||
| 55 | chomp; | ||
| 56 | my $line = $_; | ||
| 57 | |||
| 58 | # C language comments. | ||
| 59 | |||
| 60 | if ($in_comment) { | ||
| 61 | unless (s/.*?\*\///) { | ||
| 62 | print "-- $line\n" if $verbose; | ||
| 63 | next; | ||
| 64 | } | ||
| 65 | $in_comment = 0; | ||
| 66 | } | ||
| 67 | while (/\/\*/) { | ||
| 68 | s/\/\*.*?\*\/// and next; | ||
| 69 | s/\/\*.*// and $in_comment = 1; | ||
| 70 | } | ||
| 71 | |||
| 72 | # End C++ stuff. | ||
| 73 | |||
| 74 | if ($in_cplusplus) { | ||
| 75 | /^#endif$/ and $in_cplusplus = 0; | ||
| 76 | print "-- $line\n" if $verbose; | ||
| 77 | next; | ||
| 78 | } | ||
| 79 | |||
| 80 | # End declarations of structs. | ||
| 81 | |||
| 82 | if ($in_struct) { | ||
| 83 | unless (s/^\s*\}//) { | ||
| 84 | print "-s $line\n" if $verbose; | ||
| 85 | next; | ||
| 86 | } | ||
| 87 | $in_struct = 0; | ||
| 88 | unless ($in_typedef_struct) { | ||
| 89 | /^\s*;$/ or die "at end of struct: $_"; | ||
| 90 | print "-s $line\n" if $verbose; | ||
| 91 | next; | ||
| 92 | } | ||
| 93 | $in_typedef_struct = 0; | ||
| 94 | my ($id) = /^\s*(\w+);$/ | ||
| 95 | or die "at end of typedef struct: $_"; | ||
| 96 | unless (system "$MANW -k Vt=$id > /dev/null 2>&1") { | ||
| 97 | print "Vt $line\n" if $verbose; | ||
| 98 | next; | ||
| 99 | } | ||
| 100 | if ($id =~ /NETSCAPE/) { | ||
| 101 | print "V- $line\n" if $verbose; | ||
| 102 | next; | ||
| 103 | } | ||
| 104 | if (grep { $_ eq $id } @obsolete) { | ||
| 105 | print "V- $line\n" if $verbose; | ||
| 106 | next; | ||
| 107 | } | ||
| 108 | if ($verbose) { | ||
| 109 | print "XX $line\n"; | ||
| 110 | } else { | ||
| 111 | warn "not found: typedef struct $id"; | ||
| 112 | } | ||
| 113 | next; | ||
| 114 | } | ||
| 115 | |||
| 116 | # End macro definitions. | ||
| 117 | |||
| 118 | if ($in_define) { | ||
| 119 | /\\$/ or $in_define = 0; | ||
| 120 | print "-d $line\n" if $verbose; | ||
| 121 | next; | ||
| 122 | } | ||
| 123 | |||
| 124 | # End function declarations. | ||
| 125 | |||
| 126 | if ($in_function) { | ||
| 127 | /^\s/ or die "function arguments not indented: $_"; | ||
| 128 | /\);$/ and $in_function = 0; | ||
| 129 | print "-f $line\n" if $verbose; | ||
| 130 | next; | ||
| 131 | } | ||
| 132 | |||
| 133 | # Begin C++ stuff. | ||
| 134 | |||
| 135 | if (/^#ifdef\s+__cplusplus$/) { | ||
| 136 | $in_cplusplus = 1; | ||
| 137 | print "-- $line\n" if $verbose; | ||
| 138 | next; | ||
| 139 | } | ||
| 140 | |||
| 141 | # Uninteresting lines. | ||
| 142 | |||
| 143 | if (/^\s*$/ || | ||
| 144 | /^DECLARE_STACK_OF\(\w+\)$/ || | ||
| 145 | /^#define HEADER_\w+_H$/ || | ||
| 146 | /^#endif$/ || | ||
| 147 | /^extern\s+const\s+ASN1_ITEM\s+\w+_it;$/ || | ||
| 148 | /^#include\s/ || | ||
| 149 | /^#ifn?def\s/) { | ||
| 150 | print "-- $line\n" if $verbose; | ||
| 151 | next; | ||
| 152 | } | ||
| 153 | |||
| 154 | # Begin declarations of structs. | ||
| 155 | |||
| 156 | if (/^(typedef )?(?:struct|enum)(?: \w+)? \{$/) { | ||
| 157 | $in_struct = 1; | ||
| 158 | $1 and $in_typedef_struct = 1; | ||
| 159 | print "-s $line\n" if $verbose; | ||
| 160 | next; | ||
| 161 | } | ||
| 162 | |||
| 163 | if (my ($id) = /^#define\s+(\w+)\s+\S/) { | ||
| 164 | /\\$/ and $in_define = 1; | ||
| 165 | unless (system "$MANW -k Dv=$id > /dev/null 2>&1") { | ||
| 166 | print "Dv $line\n" if $verbose; | ||
| 167 | next; | ||
| 168 | } | ||
| 169 | unless (system "$MANW $id > /dev/null 2>&1") { | ||
| 170 | print "Fn $line\n" if $verbose; | ||
| 171 | next; | ||
| 172 | } | ||
| 173 | unless (system qw/grep -qR/, '^\.\\\\" ' . $id . '\>', | ||
| 174 | "$srcdir/") { | ||
| 175 | print "D- $line\n" if $verbose; | ||
| 176 | next; | ||
| 177 | } | ||
| 178 | if ($id =~ /NETSCAPE/) { | ||
| 179 | print "D- $line\n" if $verbose; | ||
| 180 | next; | ||
| 181 | } | ||
| 182 | if ($id =~ /^X509_[FR]_\w+$/) { | ||
| 183 | print "D- $line\n" if $verbose; | ||
| 184 | next; | ||
| 185 | } | ||
| 186 | if ($id =~ /^X509_V_ERR_\w+$/) { | ||
| 187 | print "D- $line\n" if $verbose; | ||
| 188 | next; | ||
| 189 | } | ||
| 190 | if (grep { $_ eq $id } @obsolete) { | ||
| 191 | print "D- $line\n" if $verbose; | ||
| 192 | next; | ||
| 193 | } | ||
| 194 | if ($verbose) { | ||
| 195 | print "XX $line\n"; | ||
| 196 | } else { | ||
| 197 | warn "not found: #define $id"; | ||
| 198 | } | ||
| 199 | next; | ||
| 200 | } | ||
| 201 | if (my ($id) = /^#define\s+(\w+)\(/) { | ||
| 202 | /\\$/ and $in_define = 1; | ||
| 203 | unless (system "$MANW $id > /dev/null 2>&1") { | ||
| 204 | print "Fn $line\n" if $verbose; | ||
| 205 | next; | ||
| 206 | } | ||
| 207 | unless (system qw/grep -qR/, '^\.\\\\" .*' . $id . '(3)', | ||
| 208 | "$srcdir/") { | ||
| 209 | print "F- $line\n" if $verbose; | ||
| 210 | next; | ||
| 211 | } | ||
| 212 | if ($verbose) { | ||
| 213 | print "XX $line\n"; | ||
| 214 | } else { | ||
| 215 | warn "not found: #define $id()"; | ||
| 216 | } | ||
| 217 | next; | ||
| 218 | } | ||
| 219 | if (/^typedef\s+(?:struct\s+)?\S+\s+(\w+);$/) { | ||
| 220 | unless (system "$MANW -k Vt=$1 > /dev/null 2>&1") { | ||
| 221 | print "Vt $line\n" if $verbose; | ||
| 222 | next; | ||
| 223 | } | ||
| 224 | if ($verbose) { | ||
| 225 | print "XX $line\n"; | ||
| 226 | } else { | ||
| 227 | warn "not found: typedef $1"; | ||
| 228 | } | ||
| 229 | next; | ||
| 230 | } | ||
| 231 | if (/^\w+(?:\(\w+\))?(?:\s+\w+)?(?:\s+|\s*\(?\*\s*)(\w+)\s*\(/) { | ||
| 232 | my $id = $1; | ||
| 233 | /\);$/ or $in_function = 1; | ||
| 234 | unless (system "$MANW $id > /dev/null 2>&1") { | ||
| 235 | print "Fn $line\n" if $verbose; | ||
| 236 | next; | ||
| 237 | } | ||
| 238 | if ($id =~ /NETSCAPE/) { | ||
| 239 | print "F- $line\n" if $verbose; | ||
| 240 | next; | ||
| 241 | } | ||
| 242 | unless (system qw/grep -qR/, '^\.\\\\" .*' . $id . '\>', | ||
| 243 | "$srcdir/") { | ||
| 244 | print "F- $line\n" if $verbose; | ||
| 245 | next; | ||
| 246 | } | ||
| 247 | if (grep { $_ eq $id } @obsolete) { | ||
| 248 | print "F- $line\n" if $verbose; | ||
| 249 | next; | ||
| 250 | } | ||
| 251 | if ($verbose) { | ||
| 252 | print "XX $line\n"; | ||
| 253 | } else { | ||
| 254 | warn "not found: function $id()"; | ||
| 255 | } | ||
| 256 | next; | ||
| 257 | } | ||
| 258 | if (/ \*$/) { | ||
| 259 | $_ .= <$in_fh>; | ||
| 260 | goto try_again; | ||
| 261 | } | ||
| 262 | die "parse error: $_"; | ||
| 263 | } | ||
| 264 | |||
| 265 | close $in_fh; | ||
| 266 | exit 0; | ||
