]> git.ipfire.org Git - thirdparty/squid.git/blame - scripts/merge-cf.data.pre.pl
SourceFormat Enforcement
[thirdparty/squid.git] / scripts / merge-cf.data.pre.pl
CommitLineData
ffd3e510 1#!/usr/bin/perl
2#
ef57eb7b 3## Copyright (C) 1996-2016 The Squid Software Foundation and contributors
a151895d
AJ
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
ffd3e510 10# This script reassembles a split configuration file back into a cf.data.pre
11# file.
12
13use strict;
14use IO::File;
15use File::Basename;
16
17my ($path) = ".";
18
19if (defined $ARGV[0]) {
20 $path = dirname($ARGV[0]);
21}
22
23sub filename($)
24{
25 my ($name) = @_;
26 return $path . "/" . $name . ".txt";
27}
28
29my ($in) = new IO::File;
30while(<>) {
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}
43undef $in;