cdb_next_item() now returns both key and value
[citadel.git] / citadel / server / backends / berkeley_db / berkeley_db.c
index 2c118ce2ba00cf57e872d4ec9645823fee41fcc2..a55c6113a2df523a69ccaf8be1edc855e98f53cb 100644 (file)
@@ -599,11 +599,11 @@ void bdb_rewind(int cdb) {
 
 // Fetch the next item in a sequential search.  Returns a pointer to a 
 // cdbdata structure, or NULL if we've hit the end.
-struct cdbdata bdb_next_item(int cdb) {
-       struct cdbdata cdbret;
+struct cdbkeyval bdb_next_item(int cdb) {
+       struct cdbkeyval kv;
        int ret = 0;
 
-       memset(&cdbret, 0, sizeof(struct cdbdata));
+       memset(&kv, 0, sizeof(struct cdbkeyval));
 
        // reuse memory from the previous call.
        TSD->dbkey[cdb].flags = DB_DBT_MALLOC;
@@ -617,15 +617,16 @@ struct cdbdata bdb_next_item(int cdb) {
                        bdb_abort();
                }
                bdb_close_cursor(cdb);
-               return(cdbret);         // presumably, we are at the end
+               return(kv);             // presumably, we are at the end
        }
 
        bdb_decompress_if_necessary(&TSD->dbdata[cdb]);
 
-       cdbret.len = TSD->dbdata[cdb].size;
-       cdbret.ptr = TSD->dbdata[cdb].data;
-
-       return (cdbret);
+       kv.key.len = TSD->dbkey[cdb].size;
+       kv.key.ptr = TSD->dbkey[cdb].data;
+       kv.val.len = TSD->dbdata[cdb].size;
+       kv.val.ptr = TSD->dbdata[cdb].data;
+       return (kv);
 }