This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
system('VAR123=foo cmd') wasn't invoking shell (de-locale-ized patch
[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>
6 last modified 7th September 1999
7 version 1.71
8
9 All comments/suggestions/problems are welcome
10
11 Copyright (c) 1995-9 Paul Marquess. All rights reserved.
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.
18
19*/
20
21#include "EXTERN.h"
22#include "perl.h"
23#include "XSUB.h"
24
25#include <db.h>
26
27void
28__getBerkeleyDBInfo()
29{
30 SV * version_sv = perl_get_sv("DB_File::db_version", GV_ADD|GV_ADDMULTI) ;
31 SV * ver_sv = perl_get_sv("DB_File::db_ver", GV_ADD|GV_ADDMULTI) ;
32 SV * compat_sv = perl_get_sv("DB_File::db_185_compat", GV_ADD|GV_ADDMULTI) ;
33
34#ifdef DB_VERSION_MAJOR
35 int Major, Minor, Patch ;
36
37 (void)db_version(&Major, &Minor, &Patch) ;
38
39 /* Check that the versions of db.h and libdb.a are the same */
40 if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR
41 || Patch != DB_VERSION_PATCH)
42 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",
43 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
44 Major, Minor, Patch) ;
45
46 /* check that libdb is recent enough -- we need 2.3.4 or greater */
47 if (Major == 2 && (Minor < 3 || (Minor == 3 && Patch < 4)))
48 croak("DB_File needs Berkeley DB 2.3.4 or greater, you have %d.%d.%d\n",
49 Major, Minor, Patch) ;
50
51 {
52 char buffer[40] ;
53 sprintf(buffer, "%d.%d", Major, Minor) ;
54 sv_setpv(version_sv, buffer) ;
55 sprintf(buffer, "%d.%03d%03d", Major, Minor, Patch) ;
56 sv_setpv(ver_sv, buffer) ;
57 }
58
59#else /* ! DB_VERSION_MAJOR */
60 sv_setiv(version_sv, 1) ;
61 sv_setiv(ver_sv, 1) ;
62#endif /* ! DB_VERSION_MAJOR */
63
64#ifdef COMPAT185
65 sv_setiv(compat_sv, 1) ;
66#else /* ! COMPAT185 */
67 sv_setiv(compat_sv, 0) ;
68#endif /* ! COMPAT185 */
69
70}