geoip2_c 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/ext/geoip2/libmaxminddb/.gitignore +35 -0
  3. data/ext/geoip2/libmaxminddb/.gitmodules +9 -0
  4. data/ext/geoip2/libmaxminddb/.perltidyrc +11 -0
  5. data/ext/geoip2/libmaxminddb/.travis.yml +48 -0
  6. data/ext/geoip2/libmaxminddb/.uncrustify.cfg +78 -0
  7. data/ext/geoip2/libmaxminddb/AUTHORS +0 -0
  8. data/ext/geoip2/libmaxminddb/Changes.md +238 -0
  9. data/ext/geoip2/libmaxminddb/LICENSE +202 -0
  10. data/ext/geoip2/libmaxminddb/Makefile.am +41 -0
  11. data/ext/geoip2/libmaxminddb/NOTICE +13 -0
  12. data/ext/geoip2/libmaxminddb/README.dev.md +58 -0
  13. data/ext/geoip2/libmaxminddb/README.md +122 -0
  14. data/ext/geoip2/libmaxminddb/appveyor.yml +33 -0
  15. data/ext/geoip2/libmaxminddb/bin/Makefile.am +5 -0
  16. data/ext/geoip2/libmaxminddb/bin/mmdblookup.c +397 -0
  17. data/ext/geoip2/libmaxminddb/bootstrap +21 -0
  18. data/ext/geoip2/libmaxminddb/common.mk +7 -0
  19. data/ext/geoip2/libmaxminddb/configure.ac +132 -0
  20. data/ext/geoip2/libmaxminddb/dev-bin/make-man-pages.pl +76 -0
  21. data/ext/geoip2/libmaxminddb/dev-bin/ppa-release.sh +50 -0
  22. data/ext/geoip2/libmaxminddb/dev-bin/regen-prototypes.pl +136 -0
  23. data/ext/geoip2/libmaxminddb/dev-bin/regen-win32-test-projs.pl +54 -0
  24. data/ext/geoip2/libmaxminddb/dev-bin/release.sh +106 -0
  25. data/ext/geoip2/libmaxminddb/dev-bin/uncrustify-all.sh +21 -0
  26. data/ext/geoip2/libmaxminddb/dev-bin/valgrind-all.pl +46 -0
  27. data/ext/geoip2/libmaxminddb/doc/libmaxminddb.md +889 -0
  28. data/ext/geoip2/libmaxminddb/doc/mmdblookup.md +103 -0
  29. data/ext/geoip2/libmaxminddb/include/maxminddb.h +232 -0
  30. data/ext/geoip2/libmaxminddb/include/maxminddb_config.h.in +14 -0
  31. data/ext/geoip2/libmaxminddb/projects/VS12/README.md +59 -0
  32. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-release.props +32 -0
  33. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-x64.props +14 -0
  34. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.props +32 -0
  35. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.sln +150 -0
  36. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj +141 -0
  37. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj.filters +26 -0
  38. data/ext/geoip2/libmaxminddb/projects/VS12/maxminddb_config.h +14 -0
  39. data/ext/geoip2/libmaxminddb/projects/VS12-tests/bad_pointers.vcxproj +105 -0
  40. data/ext/geoip2/libmaxminddb/projects/VS12-tests/basic_lookup.vcxproj +105 -0
  41. data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_entry_list.vcxproj +105 -0
  42. data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_types.vcxproj +105 -0
  43. data/ext/geoip2/libmaxminddb/projects/VS12-tests/dump.vcxproj +105 -0
  44. data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value.vcxproj +105 -0
  45. data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value_pointer_bug.vcxproj +105 -0
  46. data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv4_start_cache.vcxproj +105 -0
  47. data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv6_lookup_in_ipv4.vcxproj +105 -0
  48. data/ext/geoip2/libmaxminddb/projects/VS12-tests/libtap.vcxproj +85 -0
  49. data/ext/geoip2/libmaxminddb/projects/VS12-tests/maxminddb_test_helper.vcxproj +107 -0
  50. data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata.vcxproj +105 -0
  51. data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata_pointers.vcxproj +105 -0
  52. data/ext/geoip2/libmaxminddb/projects/VS12-tests/no_map_get_value.vcxproj +105 -0
  53. data/ext/geoip2/libmaxminddb/projects/VS12-tests/read_node.vcxproj +105 -0
  54. data/ext/geoip2/libmaxminddb/projects/VS12-tests/shared.vcxproj +104 -0
  55. data/ext/geoip2/libmaxminddb/projects/VS12-tests/threads.vcxproj +103 -0
  56. data/ext/geoip2/libmaxminddb/projects/VS12-tests/version.vcxproj +105 -0
  57. data/ext/geoip2/libmaxminddb/projects/test.vcxproj.template +105 -0
  58. data/ext/geoip2/libmaxminddb/src/Makefile.am +9 -0
  59. data/ext/geoip2/libmaxminddb/src/libmaxminddb.pc.in +11 -0
  60. data/ext/geoip2/libmaxminddb/src/maxminddb-compat-util.h +167 -0
  61. data/ext/geoip2/libmaxminddb/src/maxminddb.c +2171 -0
  62. data/ext/geoip2/libmaxminddb/t/Makefile.am +23 -0
  63. data/ext/geoip2/libmaxminddb/t/bad_databases_t.c +66 -0
  64. data/ext/geoip2/libmaxminddb/t/bad_pointers_t.c +53 -0
  65. data/ext/geoip2/libmaxminddb/t/basic_lookup_t.c +172 -0
  66. data/ext/geoip2/libmaxminddb/t/compile_c++_t.pl +107 -0
  67. data/ext/geoip2/libmaxminddb/t/data_entry_list_t.c +353 -0
  68. data/ext/geoip2/libmaxminddb/t/data_types_t.c +439 -0
  69. data/ext/geoip2/libmaxminddb/t/dump_t.c +103 -0
  70. data/ext/geoip2/libmaxminddb/t/get_value_pointer_bug_t.c +66 -0
  71. data/ext/geoip2/libmaxminddb/t/get_value_t.c +249 -0
  72. data/ext/geoip2/libmaxminddb/t/ipv4_start_cache_t.c +36 -0
  73. data/ext/geoip2/libmaxminddb/t/ipv6_lookup_in_ipv4_t.c +48 -0
  74. data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.c +255 -0
  75. data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.h +69 -0
  76. data/ext/geoip2/libmaxminddb/t/metadata_pointers_t.c +32 -0
  77. data/ext/geoip2/libmaxminddb/t/metadata_t.c +226 -0
  78. data/ext/geoip2/libmaxminddb/t/mmdblookup_t.pl +158 -0
  79. data/ext/geoip2/libmaxminddb/t/no_map_get_value_t.c +32 -0
  80. data/ext/geoip2/libmaxminddb/t/read_node_t.c +157 -0
  81. data/ext/geoip2/libmaxminddb/t/threads_t.c +196 -0
  82. data/ext/geoip2/libmaxminddb/t/version_t.c +10 -0
  83. data/geoip2_c.gemspec +1 -1
  84. data/lib/geoip2/version.rb +1 -1
  85. metadata +82 -1
@@ -0,0 +1,7 @@
1
+ if DEBUG
2
+ AM_CFLAGS=-O0 -g -Wall -Wextra
3
+ else
4
+ AM_CFLAGS=-O2 -g
5
+ endif
6
+
7
+ AM_CPPFLAGS = -I$(top_srcdir)/include
@@ -0,0 +1,132 @@
1
+ # -*- Autoconf -*-
2
+ # Process this file with autoconf to produce a configure script.
3
+
4
+ AC_PREREQ([2.63])
5
+ AC_INIT([libmaxminddb], [1.2.1], [support@maxmind.com])
6
+ AC_CONFIG_SRCDIR([include/maxminddb.h])
7
+ AC_CONFIG_HEADERS([config.h include/maxminddb_config.h])
8
+
9
+ PKG_PROG_PKG_CONFIG
10
+ m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], [${libdir}/pkgconfig])])
11
+ AC_CONFIG_FILES([src/libmaxminddb.pc])
12
+
13
+ LT_INIT
14
+ AM_INIT_AUTOMAKE(foreign m4_esyscmd([case `automake --version | head -n 1` in
15
+ *1.14*) echo subdir-objects;;
16
+ *1.11*);;
17
+ *) echo serial-tests;;
18
+ esac]))
19
+ AC_PROG_LIBTOOL
20
+ # Checks for programs.
21
+ AC_PROG_CC_C99
22
+
23
+ # Copied from http://stackoverflow.com/a/10682813/9832 and tweaked for C (as
24
+ # opposed to C++)
25
+ #
26
+ # AX_CHECK_CFLAGS(ADDITIONAL-CFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
27
+ #
28
+ # checks whether the $(CC) compiler accepts the ADDITIONAL-CFLAGS
29
+ # if so, they are added to the CXXFLAGS
30
+ AC_DEFUN([AX_CHECK_CFLAGS],
31
+ [
32
+ AC_MSG_CHECKING([whether compiler accepts "$1"])
33
+ cat > conftest.c << EOF
34
+ int main(){
35
+ return 0;
36
+ }
37
+ EOF
38
+ if $CC $CFLAGS -o conftest.o conftest.c [$1] > /dev/null 2>&1
39
+ then
40
+ AC_MSG_RESULT([yes])
41
+ CFLAGS="${CFLAGS} [$1]"
42
+ [$2]
43
+ else
44
+ AC_MSG_RESULT([no])
45
+ [$3]
46
+ fi
47
+ ])dnl AX_CHECK_CFLAGS
48
+
49
+ AX_CHECK_CFLAGS([-fms-extensions])
50
+
51
+ # We will add this back for non-debug builds in the common.mk file
52
+ CFLAGS=`echo ${CFLAGS} | sed 's/-O2//'`
53
+ CXXFLAGS=`echo ${CXXFLAGS} | sed 's/-O2//'`
54
+
55
+ # autoconf insists on giving us gnu99 if it's available
56
+ CC=`echo ${CC} | sed 's/-std=gnu99/-std=c99/'`
57
+
58
+ AC_C_RESTRICT
59
+
60
+ AC_CHECK_HEADERS([arpa/inet.h assert.h fcntl.h inttypes.h libgen.h math.h netdb.h netinet/in.h stdarg.h stdbool.h stdint.h stdio.h stdlib.h string.h sys/mman.h sys/socket.h sys/stat.h sys/time.h sys/types.h unistd.h])
61
+
62
+ # configure generates an invalid config for MinGW because of the type checks
63
+ # so we only run them on non MinGW-Systems. For MinGW we also need to link
64
+ # against ws2_32.
65
+ AC_CANONICAL_HOST
66
+ case $host_os in
67
+ mingw*)
68
+ LDFLAGS="-lws2_32"
69
+ ;;
70
+ *)
71
+ AC_TYPE_OFF_T
72
+ AC_TYPE_SIZE_T
73
+ AC_TYPE_SSIZE_T
74
+ AC_TYPE_UINT8_T
75
+ AC_TYPE_UINT32_T
76
+ AC_TYPE_UINT64_T
77
+ ;;
78
+ esac
79
+
80
+
81
+ # This check is backwards in order to make life easier for people writing
82
+ # extensions in other languages that link to this library. If they want to
83
+ # simply assume that they are using a newish compiler, they don't need to
84
+ # check for this type nor do they need to define anything on the CLI. They'll
85
+ # just get code that assumes this type exists.
86
+ AC_CHECK_TYPE(
87
+ [unsigned __int128],
88
+ [AC_DEFINE([MMDB_UINT128_IS_BYTE_ARRAY], [0], [Missing the unsigned __int128 type])],
89
+ [AC_CHECK_TYPE(
90
+ [unsigned int __attribute__((mode(TI)))],
91
+ [AC_DEFINE([MMDB_UINT128_IS_BYTE_ARRAY], [0], [Missing the unsigned __int128 type])
92
+ AC_DEFINE([MMDB_UINT128_USING_MODE], [1], [int128 types are available with __attribute__((mode(TI)))])],
93
+ [AC_DEFINE([MMDB_UINT128_IS_BYTE_ARRAY], [1], [Missing the unsigned __int128 type])])])
94
+
95
+ AC_CHECK_TYPES([boolean])
96
+
97
+ AC_CHECK_FUNC(
98
+ [open_memstream],
99
+ [AC_DEFINE([HAVE_OPEN_MEMSTREAM], [1], [Has an open_memstream() function])])
100
+
101
+ AC_C_BIGENDIAN(
102
+ [AC_DEFINE([MMDB_LITTLE_ENDIAN], [0], [System is big-endian])],
103
+ [AC_DEFINE([MMDB_LITTLE_ENDIAN], [1], [System is little-endian])])
104
+
105
+ AC_FUNC_MALLOC
106
+ AC_FUNC_MMAP
107
+
108
+ AC_SEARCH_LIBS([fabs], [m])
109
+ AC_SEARCH_LIBS([fabsf], [m])
110
+ AC_SEARCH_LIBS([getaddrinfo], [socket])
111
+
112
+ AC_ARG_ENABLE(
113
+ [debug],
114
+ [ --enable-debug Turn on debugging],
115
+ [case "${enableval}" in
116
+ yes) debug=true ;;
117
+ no) debug=false ;;
118
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
119
+ esac],[debug=false])
120
+ AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
121
+
122
+ AC_ARG_ENABLE([tests],
123
+ AS_HELP_STRING([--enable-tests], [Compilation of tests code]),
124
+ [enable_tests=${enableval}],
125
+ [enable_tests=yes])
126
+ AM_CONDITIONAL([TESTS], [test "${enable_tests}" = "yes"])
127
+
128
+ AC_CONFIG_FILES([Makefile
129
+ src/Makefile
130
+ bin/Makefile
131
+ t/Makefile])
132
+ AC_OUTPUT
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env perl
2
+
3
+ use strict;
4
+ use warnings;
5
+ use autodie qw( :all );
6
+
7
+ use FindBin qw( $Bin );
8
+
9
+ use File::Path qw( mkpath );
10
+ use File::Slurp qw( edit_file read_file write_file );
11
+ use File::Temp qw( tempdir );
12
+ use File::Which qw( which );
13
+
14
+ sub main {
15
+ my $target = shift || "$Bin/..";
16
+
17
+ my $pandoc = which('pandoc')
18
+ or die
19
+ "\n You must install pandoc in order to generate the man pages.\n\n";
20
+
21
+ _make_man( $target, 'libmaxminddb', 3 );
22
+ _make_lib_man_links($target);
23
+
24
+ _make_man( $target, 'mmdblookup', 1 );
25
+ }
26
+
27
+ sub _make_man {
28
+ my $target = shift;
29
+ my $name = shift;
30
+ my $section = shift;
31
+
32
+ my $man_dir = "$target/man/man$section";
33
+ mkpath($man_dir);
34
+
35
+ my $tempdir = tempdir( CLEANUP => 1 );
36
+
37
+ my $markdown = <<"EOF";
38
+ % $name($section)
39
+
40
+ EOF
41
+ $markdown .= read_file("$Bin/../doc/$name.md");
42
+
43
+ my $tempfile = "$tempdir/$name.$section.md";
44
+ write_file( $tempfile, $markdown );
45
+
46
+ my $man_file = "$man_dir/$name.$section";
47
+ system( qw( pandoc -s -t man ), $tempfile, '-o', $man_file );
48
+
49
+ _fix_indentation($man_file);
50
+ }
51
+
52
+ sub _make_lib_man_links {
53
+ my $target = shift;
54
+
55
+ my $header = read_file("$Bin/../include/maxminddb.h");
56
+ for my $proto ( $header =~ /^ +extern.+?(\w+)\(/gsm ) {
57
+ open my $fh, '>', "$target/man/man3/$proto.3";
58
+ print {$fh} ".so man3/libmaxminddb.3\n";
59
+ close $fh;
60
+ }
61
+ }
62
+
63
+ # AFAICT there's no way to control the indentation depth for code blocks with
64
+ # Pandoc.
65
+ sub _fix_indentation {
66
+ my $file = shift;
67
+
68
+ edit_file(
69
+ sub {
70
+ s/^\.IP\n\.nf/.IP "" 4\n.nf/gm;
71
+ },
72
+ $file
73
+ );
74
+ }
75
+
76
+ main(shift);
@@ -0,0 +1,50 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ set -x
5
+ set -u
6
+
7
+ DISTS=( wily trusty precise )
8
+
9
+ VERSION=$(perl -MFile::Slurp::Tiny=read_file -MDateTime <<EOF
10
+ use v5.16;
11
+ my \$log = read_file(q{Changes.md});
12
+ \$log =~ /^## (\d+\.\d+\.\d+) - (\d{4}-\d{2}-\d{2})/;
13
+ die 'Release time is not today!' unless DateTime->now->ymd eq \$2;
14
+ say \$1;
15
+ EOF
16
+ )
17
+
18
+ RESULTS=/tmp/build-libmaxminddb-results/
19
+ SRCDIR="$RESULTS/libmaxminddb"
20
+
21
+ mkdir -p "$SRCDIR"
22
+
23
+ # gbp does weird things without a pristine checkout
24
+ git clone git@github.com:maxmind/libmaxminddb.git -b ubuntu-ppa $SRCDIR
25
+
26
+ pushd "$SRCDIR"
27
+ git merge "$VERSION"
28
+
29
+ for dist in "${DISTS[@]}"; do
30
+ git clean -xfd
31
+ git reset HEAD --hard
32
+
33
+ dch -v "$VERSION-0+maxmind1~$dist" -D "$dist" -u low "New upstream release."
34
+ gbp buildpackage -S --git-ignore-new
35
+ done
36
+
37
+ read -e -p "Release to PPA? (y/n)" SHOULD_RELEASE
38
+
39
+ if [ "$SHOULD_RELEASE" != "y" ]; then
40
+ echo "Aborting"
41
+ exit 1
42
+ fi
43
+
44
+ dput ppa:maxmind/ppa ../*source.changes
45
+
46
+ popd
47
+
48
+ git add debian/changelog
49
+ git commit -m "Update debian/changelog for $VERSION"
50
+ git push
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env perl
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use FindBin qw( $Bin );
7
+
8
+ use File::Basename qw( basename dirname );
9
+ use File::Slurp qw( read_file write_file );
10
+ use List::MoreUtils qw( uniq );
11
+
12
+ sub main {
13
+ _regen_prototypes(
14
+ "$Bin/../src/maxminddb.c",
15
+ "$Bin/../include/maxminddb.h"
16
+ );
17
+
18
+ _regen_prototypes(
19
+ "$Bin/../bin/mmdblookup.c",
20
+ );
21
+
22
+ _regen_prototypes(
23
+ "$Bin/../t/maxminddb_test_helper.c",
24
+ "$Bin/../t/maxminddb_test_helper.h",
25
+ );
26
+ }
27
+
28
+ sub _regen_prototypes {
29
+ my $c_file = shift;
30
+ my $h_file = shift;
31
+
32
+ my $c_code = read_file($c_file);
33
+ my $h_code = $h_file ? read_file($h_file) : q{};
34
+ my $orig_c_code = $c_code;
35
+ my $orig_h_code = $h_code;
36
+
37
+ my $script_name = basename($0);
38
+ my $dir = basename($Bin);
39
+
40
+ my $indent_off = '/* *INDENT-OFF* */';
41
+ my $indent_on = '/* *INDENT-ON* */';
42
+ my $prototypes_start
43
+ = "/* --prototypes automatically generated by $dir/$script_name - don't remove this comment */";
44
+ my $prototypes_end
45
+ = q{/* --prototypes end - don't remove this comment-- */};
46
+
47
+ ( my $prototypes_start_re = $prototypes_start ) =~ s/ \n /\n */g;
48
+ ( my $prototypes_end_re = $prototypes_end ) =~ s/\n/\n */g;
49
+
50
+ for my $content ( $c_code, $h_code ) {
51
+ $content =~ s{
52
+ [ ]*
53
+ \Q$indent_off\E
54
+ \n
55
+ [ ]*
56
+ \Q$prototypes_start\E
57
+ .+?
58
+ [ ]*
59
+ \Q$prototypes_end\E
60
+ \n
61
+ [ ]*
62
+ \Q$indent_on\E
63
+ \n
64
+ }{__PROTOTYPES__}sx;
65
+ }
66
+
67
+ my @prototypes = parse_prototypes($c_code);
68
+
69
+ if ($h_file) {
70
+ my $external_prototypes = join q{}, map {
71
+ my $p = 'extern ' . $_->{prototype};
72
+ $p =~ s/^/ /; # first line
73
+ $p =~ s/\n/\n /gm; # the rest
74
+ $p . ";\n"
75
+ }
76
+ grep { $_->{external} } @prototypes;
77
+ $h_code
78
+ =~ s/__PROTOTYPES__/ $indent_off\n $prototypes_start\n$external_prototypes $prototypes_end\n $indent_on\n/;
79
+ $h_code =~ s{\n *(/\* \*INDENT)}{\n $1}g;
80
+ }
81
+
82
+ my $internal_prototypes = join q{}, uniq
83
+ map { $_->{prototype} . ";\n" } grep { !$_->{external} } @prototypes;
84
+ $c_code
85
+ =~ s/__PROTOTYPES__/$indent_off\n$prototypes_start\n$internal_prototypes$prototypes_end\n$indent_on\n/;
86
+
87
+ write_file( $c_file, $c_code ) if $c_code ne $orig_c_code;
88
+ write_file( $h_file, $h_code ) if $h_file && $h_code ne $orig_h_code;
89
+ }
90
+
91
+ my $return_type_re = qr/(?:\w+\s+)+?\**?/;
92
+ my $signature_re = qr/\([^\(\)]+?\)/;
93
+
94
+ # Shamelessly stolen from Inline::C::ParseRegExp
95
+ my $sp = qr{[ \t]|\n(?![ \t]*\n)};
96
+
97
+ my $re_type = qr {
98
+ (?: (?: const $sp*)? \w+ $sp* )+? # words
99
+ (?: (?: const $sp*)? \* $sp* )* # stars
100
+ (?: const $sp*)? # optional const
101
+ }x;
102
+
103
+ my $re_identifier = qr{ \w+ $sp* }x;
104
+
105
+ my $re_args = qr/\(.*?\)/s;
106
+
107
+ # and again from Inline::C::ParseRegExp
108
+ my $re_signature = qr/^($re_type ($re_identifier) $re_args) (?>[\ \t\n]*?{)/x;
109
+
110
+ {
111
+ my %skip = map { $_ => 1 } qw( memmem );
112
+
113
+ sub parse_prototypes {
114
+ my $c_code = shift;
115
+
116
+ my @protos;
117
+
118
+ for my $chunk ( $c_code =~ /^(\w+.+?[;{])/gsm ) {
119
+ my ( $prototype, $name ) = $chunk =~ /^$re_signature/ms
120
+ or next;
121
+
122
+ next if $prototype =~ /^(?:DEBUG_FUNC|NO_PROTO)/;
123
+
124
+ push @protos,
125
+ {
126
+ name => $name,
127
+ prototype => $prototype,
128
+ external => $prototype =~ /^LOCAL/ ? 0 : 1,
129
+ };
130
+ }
131
+
132
+ return grep { !$skip{ $_->{name} } } @protos;
133
+ }
134
+ }
135
+
136
+ main();
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env perl
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use FindBin qw( $Bin );
7
+
8
+ use Data::UUID;
9
+ use File::Slurp qw( read_file write_file );
10
+ use Path::Iterator::Rule;
11
+
12
+ sub main {
13
+ my $rule = Path::Iterator::Rule->new;
14
+ $rule->file->name(qr/_t.c$/);
15
+
16
+ my $ug = Data::UUID->new;
17
+
18
+ my $template = read_file("$Bin/../projects/test.vcxproj.template");
19
+
20
+ my @names;
21
+ for my $file ( $rule->all("$Bin/../t/") ) {
22
+ my ($name) = $file =~ /(\w*)_t.c$/;
23
+
24
+ next unless $name;
25
+ next if $name eq 'threads';
26
+
27
+ push @names, $name;
28
+
29
+ my $project = $template;
30
+
31
+ $project =~ s/%TESTNAME%/$name/g;
32
+
33
+ my $uuid = $ug->to_string( $ug->create );
34
+ $project =~ s/%UUID%/$uuid/g;
35
+
36
+ write_file( "$Bin/../projects/VS12-tests/$name.vcxproj", $project );
37
+ }
38
+
39
+ _modify_yml(@names);
40
+ }
41
+
42
+ sub _modify_yml {
43
+ my @names = @_;
44
+
45
+ my $exe_block = join "\n",
46
+ map { " - .\\projects\\VS12\\Debug\\test_${_}.exe" } @names;
47
+
48
+ my $file = "$Bin/../appveyor.yml";
49
+ my $config = read_file($file);
50
+ $config =~ s/(#EXES).*?(#ENDEXES)/$1\n$exe_block\n $2/s;
51
+ write_file( $file, $config );
52
+ }
53
+
54
+ main();
@@ -0,0 +1,106 @@
1
+ #!/bin/bash
2
+
3
+ set -eu -o pipefail
4
+
5
+ changelog=$(cat Changes.md)
6
+
7
+ regex='## ([0-9]+\.[0-9]+\.[0-9]+) - ([0-9]{4}-[0-9]{2}-[0-9]{2})
8
+
9
+ ((.|
10
+ )*)
11
+ '
12
+
13
+ if [[ ! $changelog =~ $regex ]]; then
14
+ echo "Could not find date line in change log!"
15
+ exit 1
16
+ fi
17
+
18
+ version="${BASH_REMATCH[1]}"
19
+ date="${BASH_REMATCH[2]}"
20
+ notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^## [0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')"
21
+
22
+ dist="libmaxminddb-$version.tar.gz"
23
+
24
+ if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
25
+ echo "$date is not today!"
26
+ exit 1
27
+ fi
28
+
29
+ if [ -n "$(git status --porcelain)" ]; then
30
+ echo ". is not clean." >&2
31
+ exit 1
32
+ fi
33
+
34
+ old_version=$(perl -MFile::Slurp=read_file <<EOF
35
+ use v5.16;
36
+ my \$conf = read_file(q{configure.ac});
37
+ \$conf =~ /AC_INIT.+\[(\d+\.\d+\.\d+)\]/;
38
+ say \$1;
39
+ EOF
40
+ )
41
+
42
+ perl -MFile::Slurp=edit_file -e \
43
+ "edit_file { s/\Q$old_version/$version/g } \$_ for qw( configure.ac include/maxminddb.h )"
44
+
45
+ if [ -n "$(git status --porcelain)" ]; then
46
+ git add configure.ac include/maxminddb.h
47
+ git commit -m "Bumped version to $version"
48
+ fi
49
+
50
+ if [ ! -d .gh-pages ]; then
51
+ echo "Checking out gh-pages in .gh-pages"
52
+ git clone -b gh-pages git@github.com:maxmind/libmaxminddb.git .gh-pages
53
+ pushd .gh-pages
54
+ else
55
+ echo "Updating .gh-pages"
56
+ pushd .gh-pages
57
+ git pull
58
+ fi
59
+
60
+ if [ -n "$(git status --porcelain)" ]; then
61
+ echo ".gh-pages is not clean" >&2
62
+ exit 1
63
+ fi
64
+
65
+ index=index.md
66
+ cat <<EOF > $index
67
+ ---
68
+ layout: default
69
+ title: libmaxminddb - a library for working with MaxMind DB files
70
+ version: $version
71
+ ---
72
+ EOF
73
+
74
+ cat ../doc/libmaxminddb.md >> $index
75
+
76
+ mmdblookup=mmdblookup.md
77
+ cat <<EOF > $mmdblookup
78
+ ---
79
+ layout: default
80
+ title: mmdblookup - a utility to look up an IP address in a MaxMind DB file
81
+ version: $version
82
+ ---
83
+ EOF
84
+
85
+ cat ../doc/mmdblookup.md >> $mmdblookup
86
+
87
+ git commit -m "Updated for $version" -a
88
+
89
+ read -p "Push to origin? (y/n) " should_push
90
+
91
+ if [ "$should_push" != "y" ]; then
92
+ echo "Aborting"
93
+ exit 1
94
+ fi
95
+
96
+ git push
97
+
98
+ popd
99
+
100
+ git push
101
+
102
+ message="$version
103
+
104
+ $notes"
105
+
106
+ hub release create -a "$dist" -m "$message" "$version"
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+
3
+ uncrustify="uncrustify -c .uncrustify.cfg --replace --no-backup"
4
+
5
+ # We indent each thing twice because uncrustify is not idempotent - in some
6
+ # cases it will flip-flop between two indentation styles.
7
+ for dir in bin include src t; do
8
+ c_files=`find $dir -maxdepth 1 -name '*.c'`
9
+ if [ "$c_files" != "" ]; then
10
+ $uncrustify $dir/*.c;
11
+ $uncrustify $dir/*.c;
12
+ fi
13
+
14
+ h_files=`find $dir -maxdepth 1 -name '*.h'`
15
+ if [ "$h_files" != "" ]; then
16
+ $uncrustify $dir/*.h;
17
+ $uncrustify $dir/*.h;
18
+ fi
19
+ done
20
+
21
+ ./dev-bin/regen-prototypes.pl
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env perl
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use File::Basename qw( basename );
7
+ use FindBin qw( $Bin );
8
+ use IPC::Run3;
9
+
10
+ my $top_dir = "$Bin/..";
11
+
12
+ my $output;
13
+
14
+ my @tests = glob "$top_dir/t/.libs/lt-*_t";
15
+
16
+ my @mmdblookup = (
17
+ "$top_dir/bin/mmdblookup",
18
+ '--file', "$top_dir/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb",
19
+ '--ip',
20
+ );
21
+
22
+ # We want IPv4 and IPv6 addresses - one of each that exists in the db and one
23
+ # that doesn't
24
+ my @ips = ( '1.1.1.1', '10.0.0.0', 'abcd::', '0900::' );
25
+
26
+ my @cmds = (
27
+ ( map { [ @mmdblookup, $_ ] } @ips ),
28
+ ( map { [$_] } @tests ),
29
+ );
30
+
31
+ for my $cmd (@cmds) {
32
+ my $output;
33
+ run3(
34
+ [ qw( valgrind --leak-check=full -- ), @{$cmd} ],
35
+ \undef,
36
+ \$output,
37
+ \$output,
38
+ );
39
+
40
+ $output =~ s/^(?!=).*\n//mg;
41
+
42
+ my $marker = '-' x 60;
43
+ print $marker, "\n", ( join q{ }, basename( shift @{$cmd} ), @{$cmd} ),
44
+ "\n", $marker, "\n", $output,
45
+ "\n\n";
46
+ }