1*50995Sbostic /*- 2*50995Sbostic * Copyright (c) 1990 The Regents of the University of California. 3*50995Sbostic * All rights reserved. 4*50995Sbostic * 5*50995Sbostic * %sccs.include.redist.c% 6*50995Sbostic */ 7*50995Sbostic 8*50995Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*50995Sbostic static char sccsid[] = "@(#)rec_utils.c 5.1 (Berkeley) 09/04/91"; 10*50995Sbostic #endif /* LIBC_SCCS and not lint */ 11*50995Sbostic 12*50995Sbostic #include <sys/param.h> 13*50995Sbostic #include <db.h> 14*50995Sbostic #include <stdio.h> 15*50995Sbostic #include <stdlib.h> 16*50995Sbostic #include <string.h> 17*50995Sbostic #include "../btree/btree.h" 18*50995Sbostic 19*50995Sbostic /* 20*50995Sbostic * __REC_RET -- Build return data as a result of search or scan. 21*50995Sbostic * 22*50995Sbostic * Parameters: 23*50995Sbostic * t: tree 24*50995Sbostic * d: LEAF to be returned to the user. 25*50995Sbostic * data: user's data structure 26*50995Sbostic * 27*50995Sbostic * Returns: 28*50995Sbostic * RET_SUCCESS, RET_ERROR. 29*50995Sbostic */ 30*50995Sbostic int 31*50995Sbostic __rec_ret(t, e, data) 32*50995Sbostic BTREE *t; 33*50995Sbostic EPG *e; 34*50995Sbostic DBT *data; 35*50995Sbostic { 36*50995Sbostic register RLEAF *rl; 37*50995Sbostic 38*50995Sbostic rl = GETRLEAF(e->page, e->index); 39*50995Sbostic if (rl->flags & P_BIGDATA) { 40*50995Sbostic if (__ovfl_get(t, rl->bytes, 41*50995Sbostic &data->size, &t->bt_dbuf, &t->bt_dbufsz)) 42*50995Sbostic return (RET_ERROR); 43*50995Sbostic } else { 44*50995Sbostic if (rl->dsize > t->bt_dbufsz) { 45*50995Sbostic if ((t->bt_dbuf = 46*50995Sbostic realloc(t->bt_dbuf, rl->dsize)) == NULL) 47*50995Sbostic return (RET_ERROR); 48*50995Sbostic t->bt_dbufsz = rl->dsize; 49*50995Sbostic } 50*50995Sbostic bcopy(rl->bytes, t->bt_dbuf, t->bt_dbufsz); 51*50995Sbostic data->size = rl->dsize; 52*50995Sbostic } 53*50995Sbostic data->data = t->bt_dbuf; 54*50995Sbostic 55*50995Sbostic return (RET_SUCCESS); 56*50995Sbostic } 57