int MLTestHead(MLINKlink, const char *head, int *n) tests that the next object to be read from link is an expression with head head, and stores the number of arguments of the expression in n.
/* test whether the head of the incoming object is "ReturnPacket" */
void f(MLINK lp) { int args;
if(MLTestHead(lp, "ReturnPacket", &args)) { /* read the contents of the ReturnPacket[] */ } else { /* the head of incoming packet is not "ReturnPacket" */ } }