(args=None)
| 195 | |
| 196 | |
| 197 | def main(args=None): |
| 198 | args = parser.parse_args(args) |
| 199 | if not os.path.isdir(args.srcdir): |
| 200 | error(f"OpenSSL directory not found: {args.srcdir}") |
| 201 | args.err_h = os.path.join(args.srcdir, "include", "openssl", "err.h") |
| 202 | if not os.path.isfile(args.err_h): |
| 203 | # Fall back to infile for OpenSSL 3.0.0 and later. |
| 204 | args.err_h += ".in" |
| 205 | args.errcodes = os.path.join(args.srcdir, "crypto", "err", "openssl.ec") |
| 206 | if not os.path.isfile(args.errcodes): |
| 207 | error(f"file {args.errcodes} not found in {args.srcdir}") |
| 208 | args.errtxt = os.path.join(args.srcdir, "crypto", "err", "openssl.txt") |
| 209 | if not os.path.isfile(args.errtxt): |
| 210 | error(f"file {args.errtxt} not found in {args.srcdir}") |
| 211 | |
| 212 | # [("ERR_LIB_X509", "X509", 11), ...] |
| 213 | args.lib2errnum = parse_err_h(args) |
| 214 | |
| 215 | # [('X509_R_AKID_MISMATCH', 'X509', 'AKID_MISMATCH', 110), ...] |
| 216 | reasons = [] |
| 217 | reasons.extend(parse_openssl_error_text(args)) |
| 218 | reasons.extend(parse_extra_reasons(args)) |
| 219 | # sort by macro name and numeric error code |
| 220 | args.reasons = sorted(reasons, key=operator.itemgetter(0, 3)) |
| 221 | |
| 222 | commit = get_openssl_git_commit(args) |
| 223 | lines = [ |
| 224 | "/* File generated by Tools/ssl/make_ssl_data.py */", |
| 225 | f"/* Generated on {datetime.datetime.now(datetime.UTC).isoformat()} */", |
| 226 | f"/* Generated from Git commit {commit} */", |
| 227 | "", |
| 228 | ] |
| 229 | lines.extend(gen_library_codes(args)) |
| 230 | lines.append("") |
| 231 | lines.extend(gen_error_codes(args)) |
| 232 | |
| 233 | if args.output is None: |
| 234 | for line in lines: |
| 235 | print(line) |
| 236 | else: |
| 237 | with open(args.output, 'w') as output: |
| 238 | for line in lines: |
| 239 | print(line, file=output) |
| 240 | |
| 241 | |
| 242 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…