1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 15:17:13 +02:00

Update MaxmindDB to current git.

This commit is contained in:
Sandu Liviu Catalin
2021-08-22 20:15:19 +03:00
parent 0008869ddd
commit 69a4d305a5
40 changed files with 2291 additions and 1912 deletions

View File

@ -0,0 +1,15 @@
#!/bin/sh
format="clang-format -i -style=file"
for dir in bin include src t; do
c_files=`find $dir -maxdepth 1 -name '*.c'`
if [ "$c_files" != "" ]; then
$format $dir/*.c;
fi
h_files=`find $dir -maxdepth 1 -name '*.h'`
if [ "$h_files" != "" ]; then
$format $dir/*.h;
fi
done

View File

@ -7,53 +7,75 @@ use autodie qw( :all );
use FindBin qw( $Bin );
use File::Path qw( mkpath );
use File::Slurp qw( edit_file read_file write_file );
use File::Temp qw( tempdir );
use File::Slurp qw( edit_file read_file );
use File::Which qw( which );
sub main {
my $target = shift || "$Bin/..";
my $pandoc = which('pandoc')
or die
"\n You must install pandoc in order to generate the man pages.\n\n";
my @translators = qw ( lowdown pandoc );
my $translator;
foreach my $p (@translators) {
if ( defined which($p) ) {
$translator = $p;
last;
}
}
unless ( defined $translator ) {
die "\n You must install one of "
. join( ', ', @translators )
. " in order to generate the man pages.\n\n";
}
_make_man( $target, 'libmaxminddb', 3 );
_make_man( $translator, $target, 'libmaxminddb', 3 );
_make_lib_man_links($target);
_make_man( $target, 'mmdblookup', 1 );
_make_man( $translator, $target, 'mmdblookup', 1 );
}
sub _make_man {
my $target = shift;
my $name = shift;
my $section = shift;
my $translator = shift;
my $target = shift;
my $name = shift;
my $section = shift;
my $input = "$Bin/../doc/$name.md";
my $man_dir = "$target/man/man$section";
mkpath($man_dir);
my $output = "$man_dir/$name.$section";
my $tempdir = tempdir( CLEANUP => 1 );
my $markdown = <<"EOF";
% $name($section)
EOF
$markdown .= read_file("$Bin/../doc/$name.md");
my $tempfile = "$tempdir/$name.$section.md";
write_file( $tempfile, $markdown );
my $man_file = "$man_dir/$name.$section";
system( qw( pandoc -s -t man ), $tempfile, '-o', $man_file );
_fix_indentation($man_file);
if ( $translator eq 'pandoc' ) {
system(
'pandoc',
'-s',
'-f', 'markdown_mmd+backtick_code_blocks',
'-t', 'man',
'-M', "title:$name",
'-M', "section:$section",
$input,
'-o', $output,
);
_pandoc_postprocess($output);
}
elsif ( $translator eq 'lowdown' ) {
system(
'lowdown',
'-s',
'--out-no-smarty',
'-Tman',
'-M', "title:$name",
'-M', "section:$section",
$input,
'-o', $output,
);
}
}
sub _make_lib_man_links {
my $target = shift;
my $header = read_file("$Bin/../include/maxminddb.h");
for my $proto ( $header =~ /^ *extern.+?(\w+)\(/gsm ) {
for my $proto ( $header =~ /^ *extern.+?(MMDB_\w+)\(/gsm ) {
open my $fh, '>', "$target/man/man3/$proto.3";
print {$fh} ".so man3/libmaxminddb.3\n";
close $fh;
@ -62,12 +84,13 @@ sub _make_lib_man_links {
# AFAICT there's no way to control the indentation depth for code blocks with
# Pandoc.
sub _fix_indentation {
sub _pandoc_postprocess {
my $file = shift;
edit_file(
sub {
s/^\.IP\n\.nf/.IP "" 4\n.nf/gm;
s/(Automatically generated by Pandoc)(.+)$/$1/m;
},
$file
);

View File

@ -4,7 +4,7 @@ set -e
set -x
set -u
DISTS=( artful zesty xenial trusty precise )
DISTS=( groovy focal bionic xenial trusty )
VERSION=$(perl -MFile::Slurp::Tiny=read_file -MDateTime <<EOF
use v5.16;

View File

@ -1,19 +0,0 @@
#!/bin/sh
uncrustify="uncrustify -c .uncrustify.cfg --replace --no-backup"
# We indent each thing twice because uncrustify is not idempotent - in some
# cases it will flip-flop between two indentation styles.
for dir in bin include src t; do
c_files=`find $dir -maxdepth 1 -name '*.c'`
if [ "$c_files" != "" ]; then
$uncrustify $dir/*.c;
$uncrustify $dir/*.c;
fi
h_files=`find $dir -maxdepth 1 -name '*.h'`
if [ "$h_files" != "" ]; then
$uncrustify $dir/*.h;
$uncrustify $dir/*.h;
fi
done