Example #1
0
//static
int Db::_append_recno_intercept(DB *db, DBT *data, db_recno_t recno)
{
	int err;

	if (db == 0) {
		DB_ERROR("Db::append_recno_callback", EINVAL, ON_ERROR_UNKNOWN);
		return (EINVAL);
	}
	Db *cxxdb = (Db *)db->cj_internal;
	if (cxxdb == 0) {
		DB_ERROR("Db::append_recno_callback", EINVAL, ON_ERROR_UNKNOWN);
		return (EINVAL);
	}
	if (cxxdb->append_recno_callback_ == 0) {
		DB_ERROR("Db::append_recno_callback", EINVAL, cxxdb->error_policy());
		return (EINVAL);
	}

	// making these copies is slow but portable.
	// Another alternative is to cast the DBT* manufactured
	// by the C layer to a Dbt*.  It 'should be' safe since
	// Dbt is a thin shell over DBT, adding no extra data,
	// but is nonportable, and could lead to errors if anything
	// were added to the Dbt class.
	//
	Dbt cxxdbt;
	memcpy((DBT *)&cxxdbt, data, sizeof(DBT));
	err = (*cxxdb->append_recno_callback_)(cxxdb, &cxxdbt, recno);
	memcpy(data, (DBT *)&cxxdbt, sizeof(DBT));
	return (err);
}
Example #2
0
//static
void Db::_feedback_intercept(DB *db, int opcode, int pct)
{
	if (db == 0) {
		DB_ERROR("Db::feedback_callback", EINVAL, ON_ERROR_UNKNOWN);
		return;
	}
	Db *cxxdb = (Db *)db->cj_internal;
	if (cxxdb == 0) {
		DB_ERROR("Db::feedback_callback", EINVAL, ON_ERROR_UNKNOWN);
		return;
	}
	if (cxxdb->feedback_callback_ == 0) {
		DB_ERROR("Db::feedback_callback", EINVAL, cxxdb->error_policy());
		return;
	}
	(*cxxdb->feedback_callback_)(cxxdb, opcode, pct);
}