Exemple #1
0
/*
 * Serializes/deserializes a ypresp_key_val structure.
 */
bool
xdr_ypresp_key_val(XDR *xdrs, struct ypresp_key_val *ps)
{
	return ((bool)(xdr_u_int(xdrs, &ps->status) &&
	    xdr_datum(xdrs, &ps->valdat) &&
	    xdr_datum(xdrs, &ps->keydat)));
}
Exemple #2
0
/*
 * Serializes/deserializes a ypreq_key structure.
 */
bool
xdr_ypreq_key(XDR *xdrs, struct ypreq_key *ps)
{
	return ((bool)(xdr_ypdomain_wrap_string(xdrs, &ps->domain) &&
		    xdr_ypmap_wrap_string(xdrs, &ps->map) &&
		    xdr_datum(xdrs, &ps->keydat)));
}
Exemple #3
0
static bool_t xdr_slice(XDR* xdrs, lstring* slice, /*USHORT sdl_length,*/ const UCHAR* sdl)
{
/**************************************
 *
 *	x d r _ s l i c e
 *
 **************************************
 *
 * Functional description
 *	Move a slice of an array under
 *
 **************************************/
	if (!xdr_long(xdrs, reinterpret_cast<SLONG*>(&slice->lstr_length)))
		  return FALSE;

	// Handle operation specific stuff, particularly memory allocation/deallocation

	switch (xdrs->x_op)
	{
	case XDR_ENCODE:
		break;

	case XDR_DECODE:
		if (!slice->lstr_length)
			return TRUE;
		if (slice->lstr_length > slice->lstr_allocated && slice->lstr_allocated)
		{
			BURP_free(slice->lstr_address);
			slice->lstr_address = NULL;
		}
		if (!slice->lstr_address)
		{
			slice->lstr_address = BURP_alloc((SLONG) slice->lstr_length);
			if (!slice->lstr_address) {
				return FALSE;
			}
			slice->lstr_allocated = slice->lstr_length;
		}
		break;

	case XDR_FREE:
		if (slice->lstr_allocated)
			BURP_free(slice->lstr_address);
		slice->lstr_address = NULL;
		slice->lstr_allocated = 0;
		return TRUE;

	default:
		fb_assert(FALSE);
		return FALSE;
	}

	// Get descriptor of array element

	sdl_info info;
	{
		Firebird::LocalStatus ls;
		Firebird::CheckStatusWrapper s(&ls);
		if (SDL_info(&s, sdl, &info, 0))
			return FALSE;
	}

	dsc* desc = &info.sdl_info_element;
	const ULONG n = slice->lstr_length / desc->dsc_length;
	UCHAR* p = slice->lstr_address;

	for (UCHAR* const end = p + n * desc->dsc_length; p < end; p += desc->dsc_length)
	{
		if (!xdr_datum(xdrs, desc, p)) {
			return FALSE;
		}
	}

	return TRUE;
}