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