]> git.ipfire.org Git - thirdparty/squid.git/blob - scripts/merge-cf.data.pre.pl
SourceFormat Enforcement
[thirdparty/squid.git] / scripts / merge-cf.data.pre.pl
1 #!/usr/bin/perl
2 #
3 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 ##
5 ## Squid software is distributed under GPLv2+ license and includes
6 ## contributions from numerous individuals and organizations.
7 ## Please see the COPYING and CONTRIBUTORS files for details.
8 ##
9
10 # This script reassembles a split configuration file back into a cf.data.pre
11 # file.
12
13 use strict;
14 use IO::File;
15 use File::Basename;
16
17 my ($path) = ".";
18
19 if (defined $ARGV[0]) {
20 $path = dirname($ARGV[0]);
21 }
22
23 sub filename($)
24 {
25 my ($name) = @_;
26 return $path . "/" . $name . ".txt";
27 }
28
29 my ($in) = new IO::File;
30 while(<>) {
31 if (/^NAME: (.*)/) {
32 my (@aliases) = split(/ /, $1);
33 my ($name) = shift @aliases;
34 $in->open(filename($name), "r") || die "Couldn't open ".filename($name).":$!\n";
35 while(<$in>) {
36 print $_;
37 }
38 $in->close();
39 } else {
40 print $_;
41 }
42 }
43 undef $in;