version.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

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