src/Cedar/Remote.c
// Wait for the next RPC call

Wait for the next RPC call
Wait for the next RPC call
bool RpcRecvNextCall(RPC *r)
{
	UINT size;
	void *tmp;
	SOCK *s;
	BUF *b;
	PACK *p;
	PACK *ret;
	if (r == NULL)
	{
		return false;
	}
	s = r->Sock;
	if (RecvAll(s, &size, sizeof(UINT), s->SecureMode) == false)
	{
		return false;
	}
	size = Endian32(size);
	if (size > MAX_PACK_SIZE)
	{
		return false;
	}
	tmp = MallocEx(size, true);
	if (RecvAll(s, tmp, size, s->SecureMode) == false)
	{
		Free(tmp);
		return false;
	}
	b = NewBuf();
	WriteBuf(b, tmp, size);
	SeekBuf(b, 0, 0);
	Free(tmp);
	p = BufToPack(b);
	FreeBuf(b);
	if (p == NULL)
	{
		return false;
	}
	ret = CallRpcDispatcher(r, p);
	FreePack(p);
	if (ret == NULL)
	{
		ret = PackError(ERR_NOT_SUPPORTED);
	}
	b = PackToBuf(ret);
	FreePack(ret);
	size = Endian32(b->Size);
	SendAdd(s, &size, sizeof(UINT));
	SendAdd(s, b->Buf, b->Size);
	if (SendNow(s, s->SecureMode) == false)
	{
		FreeBuf(b);
		return false;
	}
	FreeBuf(b);
	return true;
}
bool RpcRecvNextCall ( RPC * r ) { UINT size ; void * tmp ; SOCK * s ; BUF * b ; PACK * p ; PACK * ret ; if ( r == NULL ) { return false ; } s = r -> Sock ; if ( RecvAll ( s , & size , sizeof ( UINT ) , s -> SecureMode ) == false ) { return false ; } size = Endian32 ( size ) ; if ( size > MAX_PACK_SIZE ) { return false ; } tmp = MallocEx ( size , true ) ; if ( RecvAll ( s , tmp , size , s -> SecureMode ) == false ) { Free ( tmp ) ; return false ; } b = NewBuf ( ) ; WriteBuf ( b , tmp , size ) ; SeekBuf ( b , 0 , 0 ) ; Free ( tmp ) ; p = BufToPack ( b ) ; FreeBuf ( b ) ; if ( p == NULL ) { return false ; } ret = CallRpcDispatcher ( r , p ) ; FreePack ( p ) ; if ( ret == NULL ) { ret = PackError ( ERR_NOT_SUPPORTED ) ; } b = PackToBuf ( ret ) ; FreePack ( ret ) ; size = Endian32 ( b -> Size ) ; SendAdd ( s , & size , sizeof ( UINT ) ) ; SendAdd ( s , b -> Buf , b -> Size ) ; if ( SendNow ( s , s -> SecureMode ) == false ) { FreeBuf ( b ) ; return false ; } FreeBuf ( b ) ; return true ; }
Wait for the next RPC call
Wait for the next RPC call
// Validate arguments
