int flags;
u_int32_t flags;
__ham_dup_return(hashp, hcp, val, flags)	HTAB *hashp;	HASH_CURSOR *hcp;	DBT *val;	int flags;{	PAGE *pp;	DBT *myval, tmp_val;	db_indx_t ndx;	db_pgno_t pgno;	u_int8_t *hk, type;	int indx, ret;	db_indx_t len;	/* Check for duplicate and return the first one. */	ndx = H_DATAINDEX(hcp->bndx);	type = HPAGE_TYPE(hcp->pagep, ndx);	pp = hcp->pagep;	myval = val;	/*	 * There are 3 cases:	 * 1. We are not in duplicate, simply call db_ret.	 * 2. We are looking at keys and stumbled onto a duplicate.	 * 3. We are in the middle of a duplicate set. (ISDUP set)	 */	/*	 * Here we check for the case where we just stumbled onto a	 * duplicate.  In this case, we do initialization and then	 * let the normal duplicate code handle it.	 */	if (!F_ISSET(hcp, H_ISDUP))		if (type == H_DUPLICATE) {			F_SET(hcp, H_ISDUP);			hcp->dup_tlen = LEN_HDATA(hcp->pagep,			    hashp->hdr->pagesize, hcp->bndx);			hk = H_PAIRDATA(hcp->pagep, hcp->bndx);			if (flags == DB_LAST || flags == DB_PREV) {				hcp->dndx = 0;				hcp->dup_off = 0;				do {					memcpy(&len,					    HKEYDATA_DATA(hk) + hcp->dup_off,					    sizeof(db_indx_t));					hcp->dup_off += DUP_SIZE(len);					hcp->dndx++;				} while (hcp->dup_off < hcp->dup_tlen);				hcp->dup_off -= DUP_SIZE(len);				hcp->dndx--;			} else {				memcpy(&len,				    HKEYDATA_DATA(hk), sizeof(db_indx_t));				hcp->dup_off = 0;				hcp->dndx = 0;			}			hcp->dup_len = len;		} else if (type == H_OFFDUP) {			F_SET(hcp, H_ISDUP);			memcpy(&pgno, HOFFDUP_PGNO(P_ENTRY(hcp->pagep, ndx)),			    sizeof(db_pgno_t));			if (flags == DB_LAST || flags == DB_PREV) {				indx = (int)hcp->dndx;				if ((ret = __db_dend(hashp->dbp,				    pgno, &hcp->dpagep)) != 0)					return (ret);				hcp->dpgno = PGNO(hcp->dpagep);				hcp->dndx = NUM_ENT(hcp->dpagep) - 1;			} else if ((ret = __ham_next_cpage(hashp,			    hcp, pgno, 0, H_ISDUP)) != 0)				return (ret);		}	/*	 * Now, everything is initialized, grab a duplicate if	 * necessary.	 */	if (F_ISSET(hcp, H_ISDUP))		if (hcp->dpgno != PGNO_INVALID) {			pp = hcp->dpagep;			ndx = hcp->dndx;		} else {			/*			 * Copy the DBT in case we are retrieving into			 * user memory and we need the parameters for			 * it.			 */			memcpy(&tmp_val, val, sizeof(*val));			F_SET(&tmp_val, DB_DBT_PARTIAL);			tmp_val.dlen = hcp->dup_len;			tmp_val.doff = hcp->dup_off + sizeof(db_indx_t);			myval = &tmp_val;		}	/*	 * Finally, if we had a duplicate, pp, ndx, and myval should be	 * set appropriately.	 */	if ((ret = __db_ret(hashp->dbp, pp, ndx, myval, &hcp->big_data,	    &hcp->big_datalen)) != 0)		return (ret);	/*	 * In case we sent a temporary off to db_ret, set the real	 * return values.	 */	val->data = myval->data;	val->size = myval->size;	return (0);}