1
1
# ! /usr/bin/env perl
2
+ #
3
+ # Script to generate module `deimos.openssl.object_mac`
4
+ #
5
+ # Upstream uses a script to generate `<openssl/object_mac.h>`.
6
+ # Instead of porting the header, we can simply modify this script
7
+ # to output D code. This script was first copied from openssl-3.0.3 tag,
8
+ # then modified. If it needs updating, check git history for required changes.
9
+ #
10
+ # Since the object definitions are just values, versioning for old versions
11
+ # is not required. Hence one can just update the definitions on a new release
12
+ # using the following commands (assuming CWD is the root of this repository):
13
+ # ````
14
+ # export OSSL_COPYRIGHT_YEAR=2022 # Or later
15
+ # perl -I $PTOR/util/perl/ scripts/objects.pl \
16
+ # $PTOR/crypto/objects.txt $PTOR/crypto/obj_mac.num \
17
+ # > source/deimos/openssl/obj_mac.d
18
+ # ```
19
+ # Where $PTOR is the 'path to OpenSSL repository'.
20
+ #
2
21
# Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
3
22
#
4
23
# Licensed under the Apache License 2.0 (the "License"). You may not use
136
155
}
137
156
138
157
print <<"EOF" ;
139
- /*
158
+ /**
159
+ * Bindings for `<openssl/obj_mac.h>`
160
+ *
140
161
* WARNING: do not edit!
141
- * Generated by crypto/objects/objects.pl
162
+ * Generated by `scripts/objects.pl`, copied and modified from the upstream
163
+ * script `crypto/objects/objects.pl`.
142
164
*
143
165
* Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
144
166
* Licensed under the Apache License 2.0 (the "License"). You may not use
145
167
* this file except in compliance with the License. You can obtain a copy
146
168
* in the file LICENSE in the source distribution or at
147
169
* https://www.openssl.org/source/license.html
148
170
*/
171
+ module deimos.openssl.obj_mac;
149
172
150
- #ifndef OPENSSL_OBJ_MAC_H
151
- # define OPENSSL_OBJ_MAC_H
152
- # pragma once
153
-
154
- #define SN_undef "UNDEF"
155
- #define LN_undef "undefined"
156
- #define NID_undef 0
157
- #define OBJ_undef 0L
173
+ enum SN_undef = "UNDEF";
174
+ enum LN_undef = "undefined";
175
+ enum NID_undef = 0;
176
+ enum OBJ_undef = "0L";
158
177
EOF
159
178
160
179
sub expand
@@ -170,17 +189,12 @@ sub expand
170
189
{
171
190
$Cname =$ordern {$_ };
172
191
print " \n " ;
173
- print expand(" #define SN_$Cname \t\t\ "$sn {$Cname }\"\n " ) if $sn {$Cname } ne " " ;
174
- print expand(" #define LN_$Cname \t\t\ "$ln {$Cname }\"\n " ) if $ln {$Cname } ne " " ;
175
- print expand(" #define NID_$Cname \t\t $nid {$Cname }\n " ) if $nid {$Cname } ne " " ;
176
- print expand(" #define OBJ_$Cname \t\t $obj {$Cname }\n " ) if $obj {$Cname } ne " " ;
192
+ print expand(" enum SN_$Cname = \ "$sn {$Cname }\" ; \n " ) if $sn {$Cname } ne " " ;
193
+ print expand(" enum LN_$Cname = \ "$ln {$Cname }\" ; \n " ) if $ln {$Cname } ne " " ;
194
+ print expand(" enum NID_$Cname = $nid {$Cname }; \n " ) if $nid {$Cname } ne " " ;
195
+ print expand(" enum OBJ_$Cname = \" $obj {$Cname }\" ; \n " ) if $obj {$Cname } ne " " ;
177
196
}
178
197
179
- print <<EOF ;
180
-
181
- #endif /* OPENSSL_OBJ_MAC_H */
182
- EOF
183
-
184
198
sub process_oid
185
199
{
186
200
local ($oid )=@_ ;
0 commit comments