bdb 0.2.6 → 0.2.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +1 -0
  2. data/VERSION +1 -1
  3. data/ext/bdb.c +51 -0
  4. data/ext/extconf.rb +1 -1
  5. metadata +3 -3
data/README.md CHANGED
@@ -46,6 +46,7 @@ Sample Usage
46
46
  Bdb::DB_INIT_LOCK | # Initialize locking.
47
47
  Bdb::DB_INIT_LOG | # Initialize logging
48
48
  Bdb::DB_INIT_MPOOL # Initialize the in-memory cache.
49
+ # env.encrypt = 'yourpassword' # If you need it.
49
50
  env.open(File.join(File.dirname(__FILE__), 'tmp'), env_flags, 0);
50
51
 
51
52
  db = env.db
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.2.6.2
data/ext/bdb.c CHANGED
@@ -1058,6 +1058,28 @@ VALUE db_truncate(VALUE obj, VALUE vtxn)
1058
1058
  return INT2FIX(count);
1059
1059
  }
1060
1060
 
1061
+ /**
1062
+ * call-seq:
1063
+ * db.set_encrypt(db, passwd)
1064
+ *
1065
+ * Set encrypt
1066
+ */
1067
+ VALUE db_set_encrypt(VALUE obj, VALUE vpasswd) {
1068
+ int rv;
1069
+ t_dbh *dbh;
1070
+ const char *passwd;
1071
+
1072
+ passwd = StringValueCStr(vpasswd);
1073
+ Data_Get_Struct(obj,t_dbh,dbh);
1074
+ u_int32_t flags=0x00000001; //DB_ENCRYPT_AES
1075
+
1076
+ rv = dbh->db->set_encrypt(dbh->db, passwd, flags);
1077
+
1078
+ if ( rv != 0 )
1079
+ raise_error(rv, "set_encrypt failure: %s",db_strerror(rv));
1080
+ return vpasswd;
1081
+ }
1082
+
1061
1083
  /*
1062
1084
  * call-seq:
1063
1085
  * db.key_range(txn,vkey,flags) -> [#less,#same,#greater]
@@ -2873,6 +2895,30 @@ VALUE env_set_verbose(VALUE obj, VALUE which, VALUE onoff)
2873
2895
  return Qtrue;
2874
2896
  }
2875
2897
 
2898
+ /*
2899
+ * call-seq:
2900
+ * env.set_encrypt(passwd)
2901
+ *
2902
+ * set encrypt
2903
+ */
2904
+ VALUE env_set_encrypt(VALUE obj, VALUE vpasswd)
2905
+ {
2906
+ t_envh *eh;
2907
+ const char *passwd;
2908
+ int rv;
2909
+
2910
+ passwd = StringValueCStr(vpasswd);
2911
+ Data_Get_Struct(obj, t_envh, eh);
2912
+ u_int32_t flags=0x00000001; //DB_ENCRYPT_AES
2913
+
2914
+ rv = eh->env->set_encrypt(eh->env, passwd, flags);
2915
+ if ( rv != 0 ) {
2916
+ raise_error(rv, "env_set_encrypt: %s",db_strerror(rv));
2917
+ }
2918
+
2919
+ return vpasswd;
2920
+ }
2921
+
2876
2922
  /*
2877
2923
  * call-seq:
2878
2924
  * env.rep_priority = int
@@ -3331,6 +3377,8 @@ EXCEPTIONS_CREATE
3331
3377
  rb_define_method(cDb,"sync",db_sync,0);
3332
3378
  rb_define_method(cDb,"truncate",db_truncate,1);
3333
3379
 
3380
+ rb_define_method(cDb,"encrypt=",db_set_encrypt,1);
3381
+
3334
3382
  #if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR > 3
3335
3383
  rb_define_method(cDb,"compact",db_compact,5);
3336
3384
  #endif
@@ -3387,6 +3435,9 @@ EXCEPTIONS_CREATE
3387
3435
  rb_define_method(cEnv,"home",env_get_home,0);
3388
3436
  rb_define_method(cEnv,"set_verbose",env_set_verbose,2);
3389
3437
 
3438
+ rb_define_method(cEnv,"encrypt=",env_set_encrypt,1);
3439
+ //rb_define_method(cEnv,"encrypt",env_get_encrypt,0);
3440
+
3390
3441
  rb_define_method(cEnv,"rep_priority=", env_rep_set_priority, 1);
3391
3442
  rb_define_method(cEnv,"rep_priority", env_rep_get_priority, 0);
3392
3443
  rb_define_method(cEnv,"rep_nsites=", env_rep_set_nsites, 1);
@@ -10,7 +10,7 @@ require 'mkmf'
10
10
  end
11
11
 
12
12
  # MacPorts installs the directories "inside-out" compared to the structure expected above
13
- macports_db_versions = Dir["/opt/local/include/db*"].map { |dir| /\d\d$/.match(dir)[0] }
13
+ macports_db_versions = Dir["/opt/local/include/db*"].map { |dir| %r|db(\d\d)$|.match(dir) }.compact.map { |match| match[1] }
14
14
  macports_db_versions.each do |version|
15
15
  dir_config('db', "/opt/local/include/db#{version}", "/opt/local/lib/db#{version}")
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-08-24 00:00:00.000000000Z
14
+ date: 2011-08-25 00:00:00.000000000Z
15
15
  dependencies: []
16
16
  description: Advanced Ruby Berkeley DB library.
17
17
  email:
@@ -49,7 +49,7 @@ files:
49
49
  - test/txn_test.rb
50
50
  - LICENSE
51
51
  - ext/extconf.rb
52
- homepage: http://github.com/ninjudd/bdb
52
+ homepage: http://github.com/ruby-bdb/bdb
53
53
  licenses: []
54
54
  post_install_message:
55
55
  rdoc_options: []