xref: /freebsd-src/crypto/openssl/VMS/VMSify-conf.pl (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#! /usr/bin/env perl
2*e0c4386eSCy Schubert# Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert
9*e0c4386eSCy Schubert
10*e0c4386eSCy Schubertuse strict;
11*e0c4386eSCy Schubertuse warnings;
12*e0c4386eSCy Schubert
13*e0c4386eSCy Schubertmy @directory_vars = ( "dir", "certs", "crl_dir", "new_certs_dir" );
14*e0c4386eSCy Schubertmy @file_vars = ( "database", "certificate", "serial", "crlnumber",
15*e0c4386eSCy Schubert		  "crl", "private_key", "RANDFILE" );
16*e0c4386eSCy Schubertwhile(<STDIN>) {
17*e0c4386eSCy Schubert    s|\R$||;
18*e0c4386eSCy Schubert    foreach my $d (@directory_vars) {
19*e0c4386eSCy Schubert	if (/^(\s*\#?\s*${d}\s*=\s*)\.\/([^\s\#]*)([\s\#].*)$/) {
20*e0c4386eSCy Schubert	    $_ = "$1sys\\\$disk:\[.$2$3";
21*e0c4386eSCy Schubert	} elsif (/^(\s*\#?\s*${d}\s*=\s*)(\w[^\s\#]*)([\s\#].*)$/) {
22*e0c4386eSCy Schubert	    $_ = "$1sys\\\$disk:\[.$2$3";
23*e0c4386eSCy Schubert	}
24*e0c4386eSCy Schubert	s/^(\s*\#?\s*${d}\s*=\s*\$\w+)\/([^\s\#]*)([\s\#].*)$/$1.$2\]$3/;
25*e0c4386eSCy Schubert	while(/^(\s*\#?\s*${d}\s*=\s*(\$\w+\.|sys\\\$disk:\[\.)[\w\.]+)\/([^\]]*)\](.*)$/) {
26*e0c4386eSCy Schubert	    $_ = "$1.$3]$4";
27*e0c4386eSCy Schubert	}
28*e0c4386eSCy Schubert    }
29*e0c4386eSCy Schubert    foreach my $f (@file_vars) {
30*e0c4386eSCy Schubert	s/^(\s*\#?\s*${f}\s*=\s*)\.\/(.*)$/$1sys\\\$disk:\[\/$2/;
31*e0c4386eSCy Schubert	while(/^(\s*\#?\s*${f}\s*=\s*(\$\w+|sys\\\$disk:\[)[^\/]*)\/(\w+\/[^\s\#]*)([\s\#].*)$/) {
32*e0c4386eSCy Schubert	    $_ = "$1.$3$4";
33*e0c4386eSCy Schubert	}
34*e0c4386eSCy Schubert	if (/^(\s*\#?\s*${f}\s*=\s*(\$\w+|sys\\\$disk:\[)[^\/]*)\/(\w+)([\s\#].*)$/) {
35*e0c4386eSCy Schubert	    $_ = "$1]$3.$4";
36*e0c4386eSCy Schubert	} elsif  (/^(\s*\#?\s*${f}\s*=\s*(\$\w+|sys\\\$disk:\[)[^\/]*)\/([^\s\#]*)([\s\#].*)$/) {
37*e0c4386eSCy Schubert	    $_ = "$1]$3$4";
38*e0c4386eSCy Schubert	}
39*e0c4386eSCy Schubert   }
40*e0c4386eSCy Schubert    print $_,"\n";
41*e0c4386eSCy Schubert}
42