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