Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

version.c

00001 /* 
00002 
00003  version.c -- Perl 5 interface to Berkeley DB 
00004 
00005  written by Paul Marquess <[email protected]>
00006  last modified 2nd Jan 2002
00007  version 1.802
00008 
00009  All comments/suggestions/problems are welcome
00010 
00011      Copyright (c) 1995-2002 Paul Marquess. All rights reserved.
00012      This program is free software; you can redistribute it and/or
00013      modify it under the same terms as Perl itself.
00014 
00015  Changes:
00016         1.71 -  Support for Berkeley DB version 3.
00017                 Support for Berkeley DB 2/3's backward compatability mode.
00018         1.72 -  No change.
00019         1.73 -  Added support for threading
00020         1.74 -  Added Perl core patch 7801.
00021 
00022 
00023 */
00024 
00025 #define PERL_NO_GET_CONTEXT
00026 #include "EXTERN.h"  
00027 #include "perl.h"
00028 #include "XSUB.h"
00029 
00030 #include <db.h>
00031 
00032 void
00033 #ifdef CAN_PROTOTYPE
00034 __getBerkeleyDBInfo(void)
00035 #else
00036 __getBerkeleyDBInfo()
00037 #endif
00038 {
00039 #ifdef dTHX     
00040     dTHX;
00041 #endif    
00042     SV * version_sv = perl_get_sv("DB_File::db_version", GV_ADD|GV_ADDMULTI) ;
00043     SV * ver_sv = perl_get_sv("DB_File::db_ver", GV_ADD|GV_ADDMULTI) ;
00044     SV * compat_sv = perl_get_sv("DB_File::db_185_compat", GV_ADD|GV_ADDMULTI) ;
00045 
00046 #ifdef DB_VERSION_MAJOR
00047     int Major, Minor, Patch ;
00048 
00049     (void)db_version(&Major, &Minor, &Patch) ;
00050 
00051     /* Check that the versions of db.h and libdb.a are the same */
00052     if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR 
00053                 || Patch != DB_VERSION_PATCH)
00054         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",  
00055                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, 
00056                 Major, Minor, Patch) ;
00057     
00058     /* check that libdb is recent enough  -- we need 2.3.4 or greater */
00059     if (Major == 2 && (Minor < 3 || (Minor ==  3 && Patch < 4)))
00060         croak("DB_File needs Berkeley DB 2.3.4 or greater, you have %d.%d.%d\n",
00061                  Major, Minor, Patch) ;
00062  
00063     {
00064         char buffer[40] ;
00065         sprintf(buffer, "%d.%d", Major, Minor) ;
00066         sv_setpv(version_sv, buffer) ; 
00067         sprintf(buffer, "%d.%03d%03d", Major, Minor, Patch) ;
00068         sv_setpv(ver_sv, buffer) ; 
00069     }
00070  
00071 #else /* ! DB_VERSION_MAJOR */
00072     sv_setiv(version_sv, 1) ;
00073     sv_setiv(ver_sv, 1) ;
00074 #endif /* ! DB_VERSION_MAJOR */
00075 
00076 #ifdef COMPAT185
00077     sv_setiv(compat_sv, 1) ;
00078 #else /* ! COMPAT185 */
00079     sv_setiv(compat_sv, 0) ;
00080 #endif /* ! COMPAT185 */
00081 
00082 }

Generated on Sun Dec 25 12:14:43 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2