]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - mkobj.pl
Don't forget to remove some temporary files
[openssl-gost/engine.git] / mkobj.pl
1 #!/usr/bin/perl
2
3 open F,"<","gost_obj.txt" or die "Cannot open gost_obj.txt:$!";
4
5 open H,">","newnids.h" or die "Cannot open newnids.h:$!";
6 open C,">","newnids.c" or die "Cannot open newnids.c:$!";
7
8 print H <<EOHH;
9
10 #ifndef NEWNIDS_H
11 #define NEWNIDS_H
12 /* This file declare variables for  NIDs of new OIDs they are not already
13  * definded as preprocessor symbols in openss core
14  */
15
16 #include <openssl/objects.h>
17
18 EOHH
19
20 print C <<EOCH;
21 #include <openssl/objects.h>
22 #include "gost_lcl.h"
23
24 EOCH
25
26 $defn = "";
27
28 while (<F>)  {
29         chomp;
30         next if /^\s*#/;
31         s/^\s*//;
32         s/\s*#.*$//;
33         ($oid,$sn,$ln) = split(/\s*:\s*/);
34         die "Empty short name in line $." unless $sn;
35         $nid = "NID_" . $sn;
36         $nid =~ tr/-/_/;
37         
38         if (!$oid ) {
39                 $oid = 'NULL';
40     } else {
41                 $oid = '"'.$oid.'"';
42         }
43         $ln ||= $sn;
44         print H "#ifndef $nid\nextern int $nid;\n#endif\n";
45         print C "#ifndef $nid\nint $nid = NID_undef;\n#endif\n";
46         $defn  .= "#ifndef $nid\n    $nid = gost_add_obj($oid,\"$sn\",\"$ln\");\n    if ($nid == NID_undef) return 0;\n#endif\n";
47 }
48         print H "#endif\n";
49         print C "\nint gost_define_nids()\n{\n$defn;    return 1;\n}\n";