Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / bind / dist / win32utils / setpk11provider.pl
blob4c571aead524953311319d0e8bf4d94c61358a37
1 #!/usr/bin/perl
3 # Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 # Id: setpk11provider.pl,v 1.2 2009/10/12 16:41:13 each Exp
19 # setpk11provider.pl
20 # This script sets the PKCS#11 provider name in the build scripts.
22 # for instance: setpk11provider.pl bp201w32HSM
25 if ($#ARGV != 0) {
26 die "Usage: perl setpk11provider.pl <pkcs11_provider_dll_name>\n"
29 my $provider=$ARGV[0];
31 $provider =~ s|\.[dD][lL][lL]$||;
33 # List of files that need to be updated
34 @filelist = ("../bin/pkcs11/win32//pk11keygen.mak",
35 "../bin/pkcs11/win32//pk11keygen.dsp",
36 "../bin/pkcs11/win32//pk11list.mak",
37 "../bin/pkcs11/win32//pk11list.dsp",
38 "../bin/pkcs11/win32//pk11destroy.mak",
39 "../bin/pkcs11/win32//pk11destroy.dsp");
41 # function to replace the provider define
42 sub updatefile {
43 my($filename, $substr, $line);
44 my(@Lines);
46 $filename = $_[0];
47 $substr = $_[1];
49 open (RFILE, $filename) || die "Can't open file $filename: $!";
50 @Lines = <RFILE>;
51 close (RFILE);
53 # Replace the string
54 foreach $line (@Lines) {
55 $line =~ s/unknown_provider/$substr/gi;
57 #update the file
58 open (RFILE, ">$filename") || die "Can't open file $filename: $!";
59 foreach $line (@Lines) {
60 print RFILE $line;
62 close(RFILE);
65 # update config.h to define or undefine USE_PKCS11
66 sub updateconfig {
67 my($havexml, $substr, $line);
68 my(@Lines);
70 $havexml = $_[0];
72 open (RFILE, "../config.h") || die "Can't open config.h";
73 @Lines = <RFILE>;
74 close (RFILE);
76 foreach $line (@Lines) {
77 if ($havexml) {
78 $line =~ s/^.*#undef USE_PKCS11.*$/define USE_PKCS11 1/;
79 } else {
80 $line =~ s/^#define USE_PKCS11 .*$/\/\* #undef USE_PKCS11 \*\//;
84 open (RFILE, ">../config.h") || die "Can't open config.h";
85 print "Updating file ../config.h\n";
86 foreach $line (@Lines) {
87 print RFILE $line;
89 close(RFILE);
92 #Update the list of files
93 if ($provider ne 0) {
94 $ind = 0;
95 print "Provider is $provider\n";
96 foreach $file (@filelist) {
97 print "Updating file $file\n";
98 updatefile($file, $provider);
99 $ind++;
101 updateconfig(1);
102 } else {
103 updateconfig(0);