summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2021-11-19 09:15:35 +0000
committerschwarze <>2021-11-19 09:15:35 +0000
commitca49b82866e22619b5b7a9bdbef2328b7adeff11 (patch)
treebb411277191f47bed246002786aa44f0f55d8c47 /src
parent37e49cc98d663f90282949c6b5c281cf7f838399 (diff)
downloadopenbsd-ca49b82866e22619b5b7a9bdbef2328b7adeff11.tar.gz
openbsd-ca49b82866e22619b5b7a9bdbef2328b7adeff11.tar.bz2
openbsd-ca49b82866e22619b5b7a9bdbef2328b7adeff11.zip
Very quick and dirty script to help me check that the symbols
in one of the public openssl/ header files are all documented. Before attempting to read this code, make sure that you are fully vaccinated against leaning toothpick syndrome. Example usage: ./check_complete.pl x509_vfy ./check_complete.pl -v x509 | less Intentionally not linked to the build. jsing@ agrees with the general direction.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/regress/lib/libcrypto/man/check_complete.pl266
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
17use strict;
18use warnings;
19
20my @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
33my $MANW = 'man -M /usr/share/man -w';
34my $srcdir = '/usr/src/lib/libcrypto/man';
35my $hfile = '/usr/include/openssl';
36
37my $in_cplusplus = 0;
38my $in_comment = 0;
39my $in_define = 0;
40my $in_function = 0;
41my $in_struct = 0;
42my $in_typedef_struct = 0;
43my $verbose = 0;
44
45if (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";
51open my $in_fh, '<', $hfile or die "$hfile: $!";
52
53while (<$in_fh>) {
54try_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
265close $in_fh;
266exit 0;