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