static pANTLR3_COMMON_TOKEN pythonbriefLexer_nextTokenImpl( pANTLR3_TOKEN_SOURCE toksource ) { pANTLR3_LEXER lexer = (pANTLR3_LEXER)( toksource->super ); ppythonbriefLexer ctx = (ppythonbriefLexer) lexer->ctx; for ( ; ; ) { if ( ctx->tokens->count > 0 ) { return (pANTLR3_COMMON_TOKEN) vectorRemove( ctx->tokens, 0 ); } pythonbriefLexer_insertImaginaryIndentDedentTokens( ctx, toksource ); } assert( 0 == 1 ); // This part of code should be never reached }
void lmHandlerReceiveLargeMessage(NodeManagerInterface nmi, JausMessage message) { LargeMessageList msgList; JausMessage tempMessage; JausMessage outMessage; int i; unsigned long sequenceNumber; unsigned long index; JausUnsignedInteger newDataSize = 0; JausUnsignedInteger bufferIndex = 0; char address[128] = {0}; switch(message->dataFlag) { case JAUS_FIRST_DATA_PACKET: // Check for valid SeqNumber(0), else Error if(message->sequenceNumber) { cError("LargeMessageHandler: Received First Data Packet with invalid Sequence Number(%d)\n", message->sequenceNumber); jausMessageDestroy(message); return; } // Check if LargeMessageList exists (same CC & Source) msgList = lmHandlerGetMessageList(nmi->lmh, message); if(msgList) { // Destroy the list and all messages vectorRemove(nmi->lmh->messageLists, msgList, (void *)lmHandlerMessageListEqual); lmListDestroy(msgList); } // create LargeMessageList msgList = lmListCreate(); vectorAdd(nmi->lmh->messageLists, msgList); // add message to LargeMessageList at first position msgList->commandCode = message->commandCode; msgList->source->id = message->source->id; vectorAdd(msgList->messages, message); break; case JAUS_NORMAL_DATA_PACKET: // Check if LargeMessageList exists, error if not msgList = lmHandlerGetMessageList(nmi->lmh, message); if(msgList) { // Check if item exists in LargeMessageList with seqNumber if(vectorContains(msgList->messages, message, (void *)lmHandlerLargeMessageCheck) != -1) { cError("LargeMessageHandler: Received duplicate NORMAL_DATA_PACKET\n"); jausMessageDestroy(message); } else { // insert to Vector vectorAdd(msgList->messages, message); } } else { // Destroy Message cError("LargeMessageHandler: Received NORMAL_DATA_PACKET (0x%4X) for unknown Large Message Set (never received JAUS_FIRST_DATA_PACKET)\n", message->commandCode); jausMessageDestroy(message); } break; case JAUS_RETRANSMITTED_DATA_PACKET: // Check if LargeMessageList exists, error if not msgList = lmHandlerGetMessageList(nmi->lmh, message); if(msgList) { // Check if item exists in LargeMessageList with seqNumber if(vectorContains(msgList->messages, message, (void *)lmHandlerLargeMessageCheck) != -1) { tempMessage = (JausMessage) vectorRemove(msgList->messages, message, (void *)lmHandlerLargeMessageCheck); jausMessageDestroy(tempMessage); } // insert to Vector vectorAdd(msgList->messages, message); } else { cError("LargeMessageHandler: Received RETRANSMITTED_DATA_PACKET for unknown Large Message Set (never received JAUS_FIRST_DATA_PACKET)\n"); jausMessageDestroy(message); } break; case JAUS_LAST_DATA_PACKET: // Check if LargeMessageList exists, error if not msgList = lmHandlerGetMessageList(nmi->lmh, message); if(msgList) { // insert message to end of list vectorAdd(msgList->messages, message); // Create JausMessage object outMessage = jausMessageCreate(); // Calculate new message size newDataSize = 0; for(i = 0; i < msgList->messages->elementCount; i++) { tempMessage = (JausMessage)msgList->messages->elementData[i]; newDataSize += tempMessage->dataSize; } // Setup Header and Data Buffer outMessage->properties = tempMessage->properties; outMessage->commandCode = tempMessage->commandCode; outMessage->destination->id = tempMessage->destination->id; outMessage->source->id = tempMessage->source->id; outMessage->dataControl = tempMessage->dataControl; outMessage->sequenceNumber = tempMessage->sequenceNumber; outMessage->data = (unsigned char *) malloc(newDataSize); // Populate new message sequenceNumber = 0; bufferIndex = 0; while(sequenceNumber <= message->sequenceNumber) { index = 0; do { tempMessage = (JausMessage)msgList->messages->elementData[index]; index++; if(index > msgList->messages->elementCount) { // Invalid set of messages //TODO: Here is when you would request a retransmittal if ACK/NAK is set and ask the sending component to resend some packets // Received LAST_DATA_PACKET, but do not have proper sequence of messages // Destroy the list and all messages vectorRemove(nmi->lmh->messageLists, msgList, (void *)lmHandlerMessageListEqual); lmListDestroy(msgList); cError("LargeMessageHandler: Received LAST_DATA_PACKET, but do not have proper sequence of messages\n"); jausMessageDestroy(outMessage); return; } } while(tempMessage->sequenceNumber != sequenceNumber); // Move data from tempMessage to outMessage memcpy(outMessage->data + bufferIndex, tempMessage->data, tempMessage->dataSize); bufferIndex += tempMessage->dataSize; sequenceNumber++; // TOM: switched from i++ } // Set DataSize // Set proper header flags (dataFlag JAUS_SINGLE_DATA_PACKET) outMessage->dataSize = newDataSize; outMessage->dataFlag = JAUS_SINGLE_DATA_PACKET; if(outMessage->scFlag) { scManagerReceiveMessage(nmi, outMessage); } else { queuePush(nmi->receiveQueue, (void *)outMessage); } // Destroy LargeMessageList vectorRemove(nmi->lmh->messageLists, msgList, (void *)lmHandlerMessageListEqual); lmListDestroy(msgList); } else { cError("LargeMessageHandler: Received LAST_DATA_PACKET for unknown Large Message Set (never received JAUS_FIRST_DATA_PACKET)\n"); jausMessageDestroy(message); } break; default: jausAddressToString(message->source, address); cError("lmHandler: Received (%s) with improper dataFlag (%d) from %s\n", jausMessageCommandCodeString(message), message->dataFlag, address); jausMessageDestroy(message); break; } }