This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
DB_File v1.73 update (from Paul Marquess)
[perl5.git] / ext / DB_File / version.c
CommitLineData
039d031f
PM
1/*
2
3 version.c -- Perl 5 interface to Berkeley DB
4
5 written by Paul Marquess <Paul.Marquess@btinternet.com>
b90e71be 6 last modified 16th January 2000
88c74d4b 7 version 1.73
039d031f
PM
8
9 All comments/suggestions/problems are welcome
10
b90e71be 11 Copyright (c) 1995-2000 Paul Marquess. All rights reserved.
039d031f
PM
12 This program is free software; you can redistribute it and/or
13 modify it under the same terms as Perl itself.
14
15 Changes:
16 1.71 - Support for Berkeley DB version 3.
17 Support for Berkeley DB 2/3's backward compatability mode.
b90e71be 18 1.72 - No change.
88c74d4b 19 1.73 - Added support for threading
039d031f
PM
20
21*/
22
23#include "EXTERN.h"
24#include "perl.h"
25#include "XSUB.h"
26
27#include <db.h>
28
29void
30__getBerkeleyDBInfo()
31{
88c74d4b
GS
32#ifdef dTHX
33 dTHX;
34#endif
039d031f
PM
35 SV * version_sv = perl_get_sv("DB_File::db_version", GV_ADD|GV_ADDMULTI) ;
36 SV * ver_sv = perl_get_sv("DB_File::db_ver", GV_ADD|GV_ADDMULTI) ;
37 SV * compat_sv = perl_get_sv("DB_File::db_185_compat", GV_ADD|GV_ADDMULTI) ;
38
39#ifdef DB_VERSION_MAJOR
40 int Major, Minor, Patch ;
41
42 (void)db_version(&Major, &Minor, &Patch) ;
43
44 /* Check that the versions of db.h and libdb.a are the same */
45 if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR
46 || Patch != DB_VERSION_PATCH)
47 croak("\nDB_File needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d.%d and libdb version %d.%d.%d\n",
48 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
49 Major, Minor, Patch) ;
50
51 /* check that libdb is recent enough -- we need 2.3.4 or greater */
52 if (Major == 2 && (Minor < 3 || (Minor == 3 && Patch < 4)))
53 croak("DB_File needs Berkeley DB 2.3.4 or greater, you have %d.%d.%d\n",
54 Major, Minor, Patch) ;
55
56 {
57 char buffer[40] ;
58 sprintf(buffer, "%d.%d", Major, Minor) ;
59 sv_setpv(version_sv, buffer) ;
60 sprintf(buffer, "%d.%03d%03d", Major, Minor, Patch) ;
61 sv_setpv(ver_sv, buffer) ;
62 }
63
64#else /* ! DB_VERSION_MAJOR */
65 sv_setiv(version_sv, 1) ;
66 sv_setiv(ver_sv, 1) ;
67#endif /* ! DB_VERSION_MAJOR */
68
69#ifdef COMPAT185
70 sv_setiv(compat_sv, 1) ;
71#else /* ! COMPAT185 */
72 sv_setiv(compat_sv, 0) ;
73#endif /* ! COMPAT185 */
74
75}