diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-04 12:44:38 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-04 12:44:38 +0000 |
commit | 533b568baf9b04a3c364c6550f19db538bc0e4c5 (patch) | |
tree | 88a6cf79a891d479d3d72f66b7176763537d18b4 /lua_preprocess.pl | |
parent | 3cf2f3130034e46ff0224cc576626599422e8401 (diff) | |
download | rspamd-533b568baf9b04a3c364c6550f19db538bc0e4c5.tar.gz rspamd-533b568baf9b04a3c364c6550f19db538bc0e4c5.zip |
[Minor] Remove helper script
Diffstat (limited to 'lua_preprocess.pl')
-rw-r--r-- | lua_preprocess.pl | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/lua_preprocess.pl b/lua_preprocess.pl deleted file mode 100644 index d1e8f4689..000000000 --- a/lua_preprocess.pl +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env perl - -use warnings FATAL => 'all'; -use strict; -use Digest::MD5; - -my ( $in_dir, $out_dir ) = @ARGV; -my @files = <$in_dir/*.lua>; - -sub quote_file { - my ( $in, $out ) = @_; - - while (<$in>) { - if (/^--.USE\s*"(\S+)"$/) { - open( my $inc, '<', "$in_dir/$1.lua.in" ) - or die "missing include $1"; - quote_file( $inc, $out ); - } - else { - s/^\s*//; # remove unnecessary spaces at the beginning - next if /^--/; # skip comments - next if /^\s*$/; # skip empty lines - s/(.)/'$1',/g; # split as 'c', - s/\'\\\'/\'\\\\'/g; # escape backslashes - s/\'\'\'/\'\\\'\'/g; # escape single quotes - print $out "$_'\\n',"; - } - } -} - -sub digest_for_file { - my ($file) = @_; - - open( my $in, '<', $file ) or die "file missing"; - my $digest = Digest::MD5->new->addfile($in)->hexdigest; - - return $digest; -} - -sub changed { - my ( $file, $outfile ) = @_; - - open( my $out, '<', $outfile ) or return 1; - - my $in_checksum = digest_for_file($file); - my $ln = <$out>; - - if ( $ln =~ /^.*id:(\S+)\s.*$/ ) { - if ( $in_checksum ne $1 ) { - return 1; - } - else { - return 0; - } - } - - return 1; -} - -foreach my $file (@files) { - if ( $file =~ /([^\/.]+)(.lua)$/ ) { - my $fname = "$1$2"; - my $varname = "rspamadm_script_$1"; - my $definename = uc $varname; - my $outfile = "$out_dir/$fname.h"; - - if ( changed( $file, $outfile ) ) { - open( my $in, '<', $file ) or die "input missing"; - open( my $out, '>', $outfile ) or die "output missing"; - my $checksum = digest_for_file($file); - print $out <<EOD; -/* id:$checksum */ -#ifndef ${definename}_GUARD_H -#define ${definename}_GUARD_H - -static const char ${varname}\[\] = { -EOD - quote_file( $in, $out ); - - print $out <<EOD; -'\\0'}; -#endif -EOD - } - } -} |