/* Function: int msgqueue_addmsg(MsgQueue_t *msgq, int length, ...) Purpose : add a message onto a message queue Params : msgq - queue to add message on length - length of message ... - message bytes Returns : != 0 if successful  */
int msgqueue_addmsg(MsgQueue_t *msgq, int length,...)
/* Function: int msgqueue_addmsg(MsgQueue_t *msgq, int length, ...) Purpose : add a message onto a message queue Params : msgq - queue to add message on length - length of message ... - message bytes Returns : != 0 if successful  */
int msgqueue_addmsg(MsgQueue_t *msgq, int length,...)
{
	struct msgqueue_entry *mq = mqe_alloc(msgq);
	va_list ap;
	if (mq) {
		struct msgqueue_entry **mqp;
		int i;
		va_start(ap, length);
		for (i = 0; i < length; i++)
			mq->msg.msg[i] = va_arg(ap, unsigned int);
		va_end(ap);
		mq->msg.length = length;
		mq->msg.fifo = 0;
		mq->next = NULL;
		mqp = &msgq->qe;
		while (*mqp)
			mqp = &(*mqp)->next;
		*mqp = mq;
	}
	return mq != NULL;
}