ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/BDB/BDB.xs
(Generate patch)

Comparing BDB/BDB.xs (file contents):
Revision 1.13 by root, Sun Jul 8 11:12:12 2007 UTC vs.
Revision 1.15 by root, Mon Aug 13 11:16:22 2007 UTC

44 44
45typedef SV SV8; /* byte-sv, used for argument-checking */ 45typedef SV SV8; /* byte-sv, used for argument-checking */
46typedef char *octetstring; 46typedef char *octetstring;
47 47
48static SV *prepare_cb; 48static SV *prepare_cb;
49
50static void
51debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg)
52{
53 printf ("err[%s]\n", msg);
54}
55
56static void
57debug_msgcall (const DB_ENV *dbenv, const char *msg)
58{
59 printf ("msg[%s]\n", msg);
60}
49 61
50static char * 62static char *
51strdup_ornull (const char *s) 63strdup_ornull (const char *s)
52{ 64{
53 return s ? strdup (s) : 0; 65 return s ? strdup (s) : 0;
1018 const_iv (LOCK_YOUNGEST) 1030 const_iv (LOCK_YOUNGEST)
1019 1031
1020 const_iv (SEQ_DEC) 1032 const_iv (SEQ_DEC)
1021 const_iv (SEQ_INC) 1033 const_iv (SEQ_INC)
1022 const_iv (SEQ_WRAP) 1034 const_iv (SEQ_WRAP)
1035
1036 const_iv (BUFFER_SMALL)
1037 const_iv (DONOTINDEX)
1038 const_iv (KEYEMPTY )
1039 const_iv (KEYEXIST )
1040 const_iv (LOCK_DEADLOCK)
1041 const_iv (LOCK_NOTGRANTED)
1042 const_iv (LOG_BUFFER_FULL)
1043 const_iv (NOSERVER)
1044 const_iv (NOSERVER_HOME)
1045 const_iv (NOSERVER_ID)
1046 const_iv (NOTFOUND)
1047 const_iv (OLD_VERSION)
1048 const_iv (PAGE_NOTFOUND)
1049 const_iv (REP_DUPMASTER)
1050 const_iv (REP_HANDLE_DEAD)
1051 const_iv (REP_HOLDELECTION)
1052 const_iv (REP_IGNORE)
1053 const_iv (REP_ISPERM)
1054 const_iv (REP_JOIN_FAILURE)
1055 const_iv (REP_LOCKOUT)
1056 const_iv (REP_NEWMASTER)
1057 const_iv (REP_NEWSITE)
1058 const_iv (REP_NOTPERM)
1059 const_iv (REP_UNAVAIL)
1060 const_iv (RUNRECOVERY)
1061 const_iv (SECONDARY_BAD)
1062 const_iv (VERIFY_BAD)
1063 const_iv (VERSION_MISMATCH)
1064
1065 const_iv (VERB_DEADLOCK)
1066 const_iv (VERB_RECOVERY)
1067 const_iv (VERB_REGISTER)
1068 const_iv (VERB_REPLICATION)
1069 const_iv (VERB_WAITSFOR)
1070
1071 const_iv (VERSION_MAJOR)
1072 const_iv (VERSION_MINOR)
1073 const_iv (VERSION_PATCH)
1023#if DB_VERSION_MINOR >= 5 1074#if DB_VERSION_MINOR >= 5
1024 const_iv (MULTIVERSION) 1075 const_iv (MULTIVERSION)
1025 const_iv (TXN_SNAPSHOT) 1076 const_iv (TXN_SNAPSHOT)
1026#endif 1077#endif
1078#if DB_VERSION_MINOR >= 6
1079 const_iv (DB_PREV_DUP)
1080#endif
1027 }; 1081 };
1028 1082
1029 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1083 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1030 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1084 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1085
1086 newCONSTSUB (stash, "DB_VERSION", newSVnv (DB_VERSION_MAJOR + DB_VERSION_MINOR * .1));
1087 newCONSTSUB (stash, "DB_VERSION_STRING", newSVpv (DB_VERSION_STRING, 0));
1031 1088
1032 create_pipe (respipe); 1089 create_pipe (respipe);
1033 1090
1034 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1091 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1035#ifdef _WIN32 1092#ifdef _WIN32
1178 PROTOTYPE: & 1235 PROTOTYPE: &
1179 CODE: 1236 CODE:
1180 SvREFCNT_dec (prepare_cb); 1237 SvREFCNT_dec (prepare_cb);
1181 prepare_cb = newSVsv (cb); 1238 prepare_cb = newSVsv (cb);
1182 1239
1240char *
1241strerror (int errorno = errno)
1242 PROTOTYPE: ;$
1243 CODE:
1244 RETVAL = db_strerror (errorno);
1245 OUTPUT:
1246 RETVAL
1183 1247
1184DB_ENV * 1248DB_ENV *
1185db_env_create (U32 env_flags = 0) 1249db_env_create (U32 env_flags = 0)
1186 CODE: 1250 CODE:
1187{ 1251{
1188 errno = db_env_create (&RETVAL, env_flags); 1252 errno = db_env_create (&RETVAL, env_flags);
1189 if (errno) 1253 if (errno)
1190 croak ("db_env_create: %s", db_strerror (errno)); 1254 croak ("db_env_create: %s", db_strerror (errno));
1255
1256 if (0)
1257 {
1258 RETVAL->set_errcall (RETVAL, debug_errcall);
1259 RETVAL->set_msgcall (RETVAL, debug_msgcall);
1260 }
1191} 1261}
1192 OUTPUT: 1262 OUTPUT:
1193 RETVAL 1263 RETVAL
1194 1264
1195void 1265void
1196db_env_open (DB_ENV *env, octetstring db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef) 1266db_env_open (DB_ENV *env, octetstring db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef)
1197 CODE: 1267 CODE:
1198{ 1268{
1199 dREQ (REQ_ENV_OPEN); 1269 dREQ (REQ_ENV_OPEN);
1200 1270
1201 env->set_thread_count (env, get_nthreads ()); 1271 env->set_thread_count (env, wanted + 2);
1202 1272
1203 req->env = env; 1273 req->env = env;
1204 req->uint1 = open_flags | DB_THREAD; 1274 req->uint1 = open_flags | DB_THREAD;
1205 req->int1 = mode; 1275 req->int1 = mode;
1206 req->buf1 = strdup_ornull (db_home); 1276 req->buf1 = strdup_ornull (db_home);
1599 CODE: 1669 CODE:
1600 RETVAL = env->set_flags (env, flags, onoff); 1670 RETVAL = env->set_flags (env, flags, onoff);
1601 OUTPUT: 1671 OUTPUT:
1602 RETVAL 1672 RETVAL
1603 1673
1674void set_errfile (DB_ENV *env, FILE *errfile)
1675 CODE:
1676 env->set_errfile (env, errfile);
1677
1678void set_msgfile (DB_ENV *env, FILE *msgfile)
1679 CODE:
1680 env->set_msgfile (env, msgfile);
1681
1682int set_verbose (DB_ENV *env, U32 which, int onoff = 1)
1683 CODE:
1684 RETVAL = env->set_verbose (env, which, onoff);
1685 OUTPUT:
1686 RETVAL
1687
1604int set_encrypt (DB_ENV *env, const char *password, U32 flags = 0) 1688int set_encrypt (DB_ENV *env, const char *password, U32 flags = 0)
1605 CODE: 1689 CODE:
1606 RETVAL = env->set_encrypt (env, password, flags); 1690 RETVAL = env->set_encrypt (env, password, flags);
1607 OUTPUT: 1691 OUTPUT:
1608 RETVAL 1692 RETVAL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines