Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/conf/keysets.pl

raw
1 #! /usr/bin/env perl
2 # Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9 use strict;
10 use warnings;
11 use FindBin;
12 use lib "$FindBin::Bin/../../util/perl";
13 use OpenSSL::copyright;
14
15 my $NUMBER = 0x0001;
16 my $UPPER = 0x0002;
17 my $LOWER = 0x0004;
18 my $UNDER = 0x0100;
19 my $PUNCTUATION = 0x0200;
20 my $WS = 0x0010;
21 my $ESC = 0x0020;
22 my $QUOTE = 0x0040;
23 my $DQUOTE = 0x0400;
24 my $COMMENT = 0x0080;
25 my $FCOMMENT = 0x0800;
26 my $DOLLAR = 0x1000;
27 my $EOF = 0x0008;
28 my @V_def;
29 my @V_w32;
30
31 my $v;
32 my $c;
33 foreach (0 .. 127) {
34 $c = sprintf("%c", $_);
35 $v = 0;
36 $v |= $NUMBER if $c =~ /[0-9]/;
37 $v |= $UPPER if $c =~ /[A-Z]/;
38 $v |= $LOWER if $c =~ /[a-z]/;
39 $v |= $UNDER if $c =~ /_/;
40 $v |= $PUNCTUATION if $c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/;
41 $v |= $WS if $c =~ /[ \t\r\n]/;
42 $v |= $ESC if $c =~ /\\/;
43 $v |= $QUOTE if $c =~ /['`"]/; # for emacs: "`'
44 $v |= $COMMENT if $c =~ /\#/;
45 $v |= $DOLLAR if $c eq '$';
46 $v |= $EOF if $c =~ /\0/;
47 push(@V_def, $v);
48
49 $v = 0;
50 $v |= $NUMBER if $c =~ /[0-9]/;
51 $v |= $UPPER if $c =~ /[A-Z]/;
52 $v |= $LOWER if $c =~ /[a-z]/;
53 $v |= $UNDER if $c =~ /_/;
54 $v |= $PUNCTUATION if $c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/;
55 $v |= $WS if $c =~ /[ \t\r\n]/;
56 $v |= $DQUOTE if $c =~ /["]/; # for emacs: "
57 $v |= $FCOMMENT if $c =~ /;/;
58 $v |= $DOLLAR if $c eq '$';
59 $v |= $EOF if $c =~ /\0/;
60 push(@V_w32, $v);
61 }
62
63 # The year the output file is generated.
64 my $YEAR = OpenSSL::copyright::year_of($0);
65 print <<"EOF";
66 /*
67 * WARNING: do not edit!
68 * Generated by crypto/conf/keysets.pl
69 *
70 * Copyright 1995-$YEAR The OpenSSL Project Authors. All Rights Reserved.
71 * Licensed under the Apache License 2.0 (the "License"). You may not use
72 * this file except in compliance with the License. You can obtain a copy
73 * in the file LICENSE in the source distribution or at
74 * https://www.openssl.org/source/license.html
75 */
76
77 #define CONF_NUMBER $NUMBER
78 #define CONF_UPPER $UPPER
79 #define CONF_LOWER $LOWER
80 #define CONF_UNDER $UNDER
81 #define CONF_PUNCT $PUNCTUATION
82 #define CONF_WS $WS
83 #define CONF_ESC $ESC
84 #define CONF_QUOTE $QUOTE
85 #define CONF_DQUOTE $DQUOTE
86 #define CONF_COMMENT $COMMENT
87 #define CONF_FCOMMENT $FCOMMENT
88 #define CONF_DOLLAR $DOLLAR
89 #define CONF_EOF $EOF
90 #define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
91 #define CONF_ALNUM (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
92 #define CONF_ALNUM_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER|CONF_PUNCT)
93
94
95 #define IS_COMMENT(conf,c) is_keytype(conf, c, CONF_COMMENT)
96 #define IS_FCOMMENT(conf,c) is_keytype(conf, c, CONF_FCOMMENT)
97 #define IS_EOF(conf,c) is_keytype(conf, c, CONF_EOF)
98 #define IS_ESC(conf,c) is_keytype(conf, c, CONF_ESC)
99 #define IS_NUMBER(conf,c) is_keytype(conf, c, CONF_NUMBER)
100 #define IS_WS(conf,c) is_keytype(conf, c, CONF_WS)
101 #define IS_ALNUM(conf,c) is_keytype(conf, c, CONF_ALNUM)
102 #define IS_ALNUM_PUNCT(conf,c) is_keytype(conf, c, CONF_ALNUM_PUNCT)
103 #define IS_QUOTE(conf,c) is_keytype(conf, c, CONF_QUOTE)
104 #define IS_DQUOTE(conf,c) is_keytype(conf, c, CONF_DQUOTE)
105 #define IS_DOLLAR(conf,c) is_keytype(conf, c, CONF_DOLLAR)
106
107 EOF
108
109 my $i;
110
111 print "static const unsigned short CONF_type_default[128] = {";
112 for ($i = 0; $i < 128; $i++) {
113 print "\n " if ($i % 8) == 0;
114 printf " 0x%04X,", $V_def[$i];
115 }
116 print "\n};\n\n";
117
118 print "#ifndef OPENSSL_NO_DEPRECATED_3_0\n";
119 print "static const unsigned short CONF_type_win32[128] = {";
120 for ($i = 0; $i < 128; $i++) {
121 print "\n " if ($i % 8) == 0;
122 printf " 0x%04X,", $V_w32[$i];
123 }
124 print "\n};\n";
125 print "#endif\n";