git://git.jankratochvil.net
/
redirector-ad.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
We now really display the pattern itself, NOT the matched string
[redirector-ad.git]
/
redirector
1
#! /usr/bin/perl
2
#
3
# $Id$
4
5
use strict;
6
use warnings;
7
8
use re 'eval';
9
10
use constant DIR_AD => "/usr/local/squid/etc/ad";
11
12
13
chdir DIR_AD or die "chdir ".DIR_AD.": $!";
14
15
my($patt)="";
16
open(M4,"-|","m4 -P main") or die "m4 run: $!";
17
while (<M4>) {
18
chomp;
19
next if !$_;
20
$patt.="|" if $patt;
21
$patt.=$_."(?{ '";
22
s/'/'."'".'/g;
23
$patt.="$_'; })";
24
}
25
close M4;
26
27
select STDOUT;
28
$|=1;
29
30
while (<>) {
31
s@^http://($patt).*\n$@http://localhost/cgi-bin/redirector-ad.cgi?$^R\n@os;
32
print;
33
}