/*
* Copyright (c) 2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#include "sm/generic.h"
SM_RCSID("@(#)$Id: rcbpeek2int.c,v 1.1 2005/11/08 18:46:11 ca Exp $")
#include "sm/assert.h"
#include "sm/magic.h"
#include "sm/error.h"
#include "sm/memops.h"
#include "sm/rpool.h"
#include "sm/limits.h"
#include "sm/rcb.h"
#include "sm/reccom.h"
/*
** SM_RCB_PEEK2UINT32 -- "peek" at two ints from the current position in an RCB
**
** Parameters:
** rcb -- sm_rcb_P object to "peek" at.
** pv1 -- pointer to value to return.
** pv2 -- pointer to value to return.
**
** Returns:
** usual sm_error code; SM_E_OVFLW_NS
**
** Last code review:
** Last code change:
*/
sm_ret_T
sm_rcb_peek2uint32(sm_rcb_P rcb, uint32_t *pv1, uint32_t *pv2)
{
uchar *buf;
SM_IS_RCB(rcb);
#if SM_RCB_CHECK
SM_REQUIRE(rcb->sm_rcb_state == SM_RCB_DEC);
#endif
#if PARANOID
SM_REQUIRE(pv1 != NULL);
SM_REQUIRE(pv2 != NULL);
SM_REQUIRE(rcb->sm_rcb_base != NULL);
#endif
if (rcb->sm_rcb_len < rcb->sm_rcb_rw + sizeof(uint32_t) * 2)
return sm_error_perm(SM_EM_RECCOM, SM_E_OVFLW_NS);
buf = rcb->sm_rcb_base + rcb->sm_rcb_rw;
sm_buf2uint32(buf, pv1);
sm_buf2uint32(buf + sizeof(uint32_t), pv2);
return SM_SUCCESS;
}
syntax highlighted by Code2HTML, v. 0.9.1