Beispiel #1
0
/**
 * Sets the COM error given an nsIException
 * @param exception the exception being set
 */
inline
static void SetCOMError(nsIException * exception)
{
    nsCString message;
    BuildMessage(exception, message);
    Error(E_FAIL, message.get());
}
	bool RequestSessionId( unsigned int& id )
	{
		id = 0u;

		bf_write	buf;
		byte		data[ 2048 ];
		
		buf.StartWriting( data, sizeof( data ) );

		BuildMessage( buf, PHONE_MSG_ENGINESTART, NULL, id );

		struct sockaddr_in sa;

		m_cserIP.ToSockadr( (struct sockaddr *)&sa );

		for ( int retries = 0; retries < PHONE_HOME_RETRIES; ++retries )
		{
			m_pSocket->SendSocketMessage( sa, (const byte *)buf.GetData(), buf.GetNumBytesWritten() ); //lint !e534
			if ( m_pSocket->WaitForMessage( PHONE_HOME_TIMEOUT ) )
			{	
				byte		readbuf[ 128 ];

				bf_read		replybuf( readbuf, sizeof( readbuf ) );

				struct sockaddr_in replyaddress;
				uint bytesReceived = m_pSocket->ReceiveSocketMessage( &replyaddress, (byte *)readbuf, sizeof( readbuf ) );
				if ( bytesReceived > 0 )
				{
					// Fixup actual size
					replybuf.StartReading( readbuf, bytesReceived );

					// Parse out data
					byte responseType = (byte)replybuf.ReadByte();
					if ( M2C_ACKPHONEHOME == responseType  )
					{
						bool allowPlay = replybuf.ReadByte() == 1 ? true : false;
						if ( allowPlay )
						{
							id = replybuf.ReadLong();
							return true;
						}
					}
					break;
				}

			}
		}

		return false;
	}
	void SendSessionMessage( byte msgtype, char const *mapname )
	{
		if ( m_uSessionID == 0 )
			return;

		bf_write	buf;
		byte		data[ 2048 ];
		
		buf.StartWriting( data, sizeof( data ) );

		BuildMessage( buf, msgtype, mapname, m_uSessionID );

		struct sockaddr_in sa;

		m_cserIP.ToSockadr( (struct sockaddr *)&sa );

		m_pSocket->SendSocketMessage( sa, (const byte *)buf.GetData(), buf.GetNumBytesWritten() );

		// If we already have a sessionid, don't wait for the server to give us back a new one...
		if ( m_uSessionID != 0 )
		{
			return;
		}

		if ( m_pSocket->WaitForMessage( PHONE_HOME_TIMEOUT ) )
		{	
			byte		readbuf[ 128 ];

			bf_read		replybuf( readbuf, sizeof( readbuf ) );

			struct sockaddr_in replyaddress;
			uint bytesReceived = m_pSocket->ReceiveSocketMessage( &replyaddress, (byte *)readbuf, sizeof( readbuf ) );
			if ( bytesReceived > 0 )
			{
				// Fixup actual size
				replybuf.StartReading( readbuf, bytesReceived );

				// Parse out data
				byte responseType = (byte)replybuf.ReadByte();
				if ( M2C_ACKPHONEHOME == responseType  )
				{
					bool allowPlay = replybuf.ReadByte() == 1 ? true : false;
					if ( allowPlay )
					{
						m_uSessionID = replybuf.ReadLong();
					}
				}
			}
		}
	}
Beispiel #4
0
DisplayWindow::DisplayWindow(QWidget *parent,ModelVideo model)
	:PostureWindow(parent)
{
	m_mvModel.m_sDate = model.m_sDate;
	m_mvModel.m_sDescribe = model.m_sDescribe;
	m_mvModel.m_sDirectory = model.m_sDirectory;
	m_mvModel.m_sOutLine = model.m_sOutLine;
	m_mvModel.m_sPublisher = model.m_sPublisher;
	m_mvModel.m_sVideoID = model.m_sVideoID;
	m_mvModel.m_vCommendsName = model.m_vCommendsName;
	m_mvModel.m_vComments = model.m_vComments;
	m_mvModel.m_sFavor = model.m_sFavor;
	m_mvModel.m_sMode = model.m_sMode;
	m_qmbMsg = new QMessageBox(this);
	m_qmbMsg->setObjectName("msg");
	m_qmbMsg->hide();
	BuildBottomRight();
	BuildConnections();
	BuildMessage();
}
Beispiel #5
0
// Overridden method for building the data grids - these are substantially different from the CalReview base but the overall appearance and graph presence are the same
void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSizer, bool AO)
{
    wxString raSteps = wxString::Format("%d", m_calDetails.raStepCount);
    wxString decSteps = wxString::Format("%d", m_calDetails.decStepCount);
    wxString oldAngleDelta;
    double newRARate = m_newParams.xRate * 1000;                          // px per sec for UI purposes
    double newDecRate = m_newParams.yRate * 1000;
    double imageScale = m_calDetails.imageScale;
    bool oldValid = m_oldParams.isValid;

    if (!AO)                // AO calibration never triggers sanity check alerts, so don't show that data
    {
        // Compute the orthogonality stuff
        m_newAngleDelta = wxString::Format("%0.1f", m_calDetails.orthoError);
        if (oldValid)
        {
            oldAngleDelta = wxString::Format("%0.1f", m_oldDetails.orthoError);
        }
        else
            oldAngleDelta = NA_STR;

        if (m_newParams.yRate != 0. && m_oldParams.yRate != 0.)
            m_oldNewDifference = wxString::Format("%0.1f", fabs(1.0 - m_newParams.yRate / m_oldParams.yRate) * 100.0);
        else
            m_oldNewDifference = "";

        // Lay out the controls
        wxBoxSizer *pVSizer = new wxBoxSizer(wxVERTICAL);
        wxStaticBoxSizer *pMsgGrp = new wxStaticBoxSizer(wxVERTICAL, parentPanel, _("Explanation"));

        // Explanation area
        wxStaticText *pMsgArea = new wxStaticText(parentPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(450, -1), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
        BuildMessage(pMsgArea, m_issue);
        pMsgArea->SetSizeHints(wxSize(450, MESSAGE_HEIGHT));
        wxFont font = pMsgArea->GetFont();
        font.SetWeight(wxFONTWEIGHT_BOLD);
        pMsgArea->SetFont(font);
        pMsgGrp->Add(pMsgArea, wxSizerFlags().Border(wxALL, 5));
        pVSizer->Add(pMsgGrp, wxSizerFlags().Border(wxALL, 5));

        // Grid control for details
        wxStaticBoxSizer *pGridGrp = new wxStaticBoxSizer(wxVERTICAL, parentPanel, _("Details"));
        wxGrid *pGrid = new wxGrid(parentPanel, wxID_ANY);
        pGrid->CreateGrid(3, 4);
        pGrid->SetRowLabelSize(1);
        pGrid->SetColLabelSize(1);
        pGrid->EnableEditing(false);

        int col = 0;
        int row = 0;
        pGrid->SetCellValue(row, col++, _("Steps, RA:"));
        pGrid->SetCellValue(row, col++, raSteps);
        pGrid->SetCellValue(row, col++, _("Steps, Dec:"));
        pGrid->SetCellValue(row, col++, decSteps);
        if (m_issue == CI_Steps){
            if (raSteps <= decSteps)
                HighlightCell(pGrid, row, 1);
            else
                HighlightCell(pGrid, row, 3);
        }
        row++;
        col = 0;
        pGrid->SetCellValue(row, col++, _("Orthogonality error:"));
        pGrid->SetCellValue(row, col++, m_newAngleDelta);
        pGrid->SetCellValue(row, col++, _("Previous orthogonality error:"));
        pGrid->SetCellValue(row, col++, oldAngleDelta);
        if (m_issue == CI_Angle)
        {
            HighlightCell(pGrid, row, 1);
        }

        row++;
        col = 0;
        // Show either the new RA and Dec rates or the new and old Dec rates depending on the issue
        if (m_issue == CI_Different)
        {
            pGrid->SetCellValue(row, col++, _("This declination rate:"));
            if (newDecRate != CALIBRATION_RATE_UNCALIBRATED)
                pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * imageScale, newDecRate));
            else
                pGrid->SetCellValue(row, col++, NA_STR);
            pGrid->SetCellValue(row, col++, _("Previous declination rate:"));
            if (m_oldParams.yRate != CALIBRATION_RATE_UNCALIBRATED)
                pGrid->SetCellValue(row, col++, wxString::Format(_("\n%0.3f px/sec"), m_oldParams.yRate * 1000));
            else
                pGrid->SetCellValue(row, col++, NA_STR);
            HighlightCell(pGrid, row, 1);
            HighlightCell(pGrid, row, 3);
        }
        else
        {
            pGrid->SetCellValue(row, col++, _("RA rate:"));
            pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newRARate * imageScale, newRARate));
            pGrid->SetCellValue(row, col++, _("Declination rate:"));
            if (newDecRate != CALIBRATION_RATE_UNCALIBRATED)
                pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * imageScale, newDecRate));
            else
                pGrid->SetCellValue(row, col++, NA_STR);
            if (m_issue == CI_Rates)
            {
                HighlightCell(pGrid, row, 1);
                HighlightCell(pGrid, row, 3);
            }
        }

        pGrid->AutoSize();
        pGrid->ClearSelection();
        pGridGrp->Add(pGrid);
        pVSizer->Add(pGridGrp, wxSizerFlags(0).Border(wxALL, 5));

        // Checkboxes for being quiet
        m_pBlockThis = new wxCheckBox(parentPanel, wxID_ANY, _("Don't show calibration alerts of this type"));
        pVSizer->Add(m_pBlockThis, wxSizerFlags(0).Border(wxALL, 15));
        parentHSizer->Add(pVSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
    }

}
Beispiel #6
0
bool NetBase::CheckIn()
{    
    // check for incoming packets
    SOCKADDR_IN addr;
    memset (&addr, 0, sizeof(SOCKADDR_IN));
    socklen_t len = sizeof(SOCKADDR_IN);

    if (!input_buffer)
    {
        input_buffer = (char*) cs_malloc(MAXPACKETSIZE);

        if (!input_buffer)
        {
            Error2("Failed to cs_malloc %d bytes for packet buffer!\n",MAXPACKETSIZE);
            return false;
        }
    }

    // Connection must be initialized!
    CS_ASSERT(ready);
    
    int packetlen = RecvFrom (&addr, &len, (void*) input_buffer, MAXPACKETSIZE);

    if (packetlen <= 0)
    {
        return false;
    }
    // Identify the connection
    Connection* connection = GetConnByIP(&addr);

    // Extract the netpacket from the buffer and prep for use locally.
    psNetPacket *bufpacket = psNetPacket::NetPacketFromBuffer(input_buffer,packetlen);
    if (bufpacket==NULL)
    {
        char addrText[INET_ADDRSTRLEN];

        //for win32 for now only inet_ntoa as inet_ntop wasn't supported till vista.
        //it has the same degree of compatibility of the previous code and it's supported till win2000
        #ifdef WIN32
        strncpy(addrText, inet_ntoa(addr.sin_addr), INET_ADDRSTRLEN);
        #else
        //there was a failure in conversion if null
        if(!inet_ntop(addr.sin_family,&addr.sin_addr, addrText, sizeof(addrText)))
        {
            strncpy(addrText, "UNKNOWN", INET_ADDRSTRLEN);
        }
        #endif

        // The data received was too small to make a full packet.
        if (connection)
        {
            Debug4(LOG_NET, connection->clientnum, "Too short packet received from client %d (IP: %s) (%d bytes)", connection->clientnum, addrText, packetlen);
        }
        else
        {
            Debug3(LOG_NET, 0, "Too short packet received from IP address %s. (%d bytes) No existing connection from this IP.",
                addrText, packetlen);
        }
        return true; // Continue processing more packets if available
    }
    input_buffer = NULL; //input_buffer now hold by the bufpacket pointer.

    // Endian correction
    bufpacket->UnmarshallEndian();

    // Check for too-big packets - no harm in processing them, but probably a bug somewhere
    if (bufpacket->GetPacketSize() < static_cast<unsigned int>(packetlen))
    {
        char addrText[INET_ADDRSTRLEN];

        //for win32 for now only inet_ntoa as inet_ntop wasn't supported till vista.
        //it has the same degree of compatibility of the previous code and it's supported till win2000
        #ifdef WIN32
        strncpy(addrText, inet_ntoa(addr.sin_addr), INET_ADDRSTRLEN);
        #else
        //there was a failure in conversion if null
        if(!inet_ntop(addr.sin_family,&addr.sin_addr, addrText, sizeof(addrText)))
        {
            strncpy(addrText, "UNKNOWN", INET_ADDRSTRLEN);
        }
        #endif
        
        if (connection)
        {
            Debug5(LOG_NET, connection->clientnum, "Too long packet received from client %d (IP: %s) (%d bytes received, header reports %zu bytes)",
                connection->clientnum, addrText, packetlen, bufpacket->GetPacketSize());
        }
        else
        {
            
            Debug4(LOG_NET, 0,"Too long packet received from IP address %s. (%d bytes received, header reports %zu bytes) No existing connection from this IP.",
                   addrText, packetlen, bufpacket->GetPacketSize());
        }
    }

    //Create new net packet entry and transfer ownership of bufpacket to pkt.
    csRef<psNetPacketEntry> pkt;
    pkt.AttachNew(new psNetPacketEntry( bufpacket, 
            connection ? connection->clientnum : 0, packetlen));
    
    if(TEST_PACKETLOSS > 0.0 && randomgen->Get() < TEST_PACKETLOSS)
    {
        psNetPacket* packet = pkt->packet;
        int type = 0;

        if (packet->offset == 0) 
        {
            psMessageBytes* msg = (psMessageBytes*) packet->data;
            type = msg->type;
        }

        Error3("Packet simulated lost. Type %s ID %d.\n", type == 0 ? "Fragment" : (const char *)  GetMsgTypeName(type), pkt->packet->pktid);
        return true;
    }

    // ACK packets can get eaten by HandleAck
    if (HandleAck(pkt, connection, &addr))
    {
        return true;
    }

    // printf("Got packet with sequence %d.\n", pkt->packet->GetSequence());
    //
    // Check for doubled packets and drop them
    if (pkt->packet->pktid != 0)
    {
        if (connection && CheckDoublePackets (connection, pkt))
        {
#ifdef PACKETDEBUG
            Debug2(LOG_NET,0,"Dropping doubled packet (ID %d)\n", pkt->packet->pktid);
#endif
            return true;
        }
    }
    
#ifdef PACKETDEBUG
    Debug7(LOG_NET,0,"Received Pkt, ID: %d, offset %d, from %d size %d (actual %d) flags %d\n", 
        pkt->packet->pktid, pkt->packet->offset, pkt->clientnum, pkt->packet->pktsize,packetlen, pkt->packet->flags);
#endif

    /**
    * Now either send this packet to BuildMessage, or loop through
    * subpackets if they are merged.
    */
    csRef<psNetPacketEntry> splitpacket = pkt;
    psNetPacket      *packetdata = NULL;

    do
    {
        splitpacket = pkt->GetNextPacket(packetdata);
        if (splitpacket)
            BuildMessage(splitpacket, connection, &addr);
    } while (packetdata);
    return true;
}
Beispiel #7
0
Message* Message_recv(int s) {
    char* buf = NULL;
    int bytesrecv;
    int bytesread = 0;
    int msgsize;
    xmlDocPtr doc;
    xmlNodePtr root;
    buildmessage bm;
    initbuildmessage(&bm);

    bytesread = 0;
    while(bytesread < 4) {
        bytesrecv = recv(s, &(((char*)&msgsize)[bytesread]), 4-bytesread, 0);
        if(bytesrecv <= 0) {
            free(delbuildmessage(&bm));
            return NULL;
        }
        bytesread += bytesrecv;
    }
    msgsize = ntohl(msgsize);
    bytesread = 0;
    while(bytesread < msgsize) {
        int buf_size = (102400 < (msgsize - bytesread) ? 102400 : (msgsize - bytesread));
        char* tmp = (char*)malloc(bytesread + buf_size);
        memcpy(tmp, buf, bytesread);
        free(buf);
        buf = tmp;
        bytesrecv = recv(s, &(buf[bytesread]), buf_size, 0);
        if(bytesrecv <= 0) {
            free(buf);
            free(delbuildmessage(&bm));
            return NULL;
        }
        bytesread += bytesrecv;
    }

#ifdef DEBUG
    {
    int i;
    for(i = 0; i < bytesrecv; i++) {
        printf("%c", buf[i]);
    }
    printf("\n---\n");
    }
#endif

    doc = xmlReadMemory(buf, bytesread, NULL, NULL, 0);
    free(buf);
    if(doc == NULL) {
        int i;
        for(i = 0; i < bytesrecv; i++) {
            printf("%c", buf[i]);
        }
        printf("\n");
        fprintf(stderr, "XML Parser Error!\n");
        exit(-1);
    }

    root = xmlDocGetRootElement(doc);

    BuildMessage(&bm, doc, root);

    xmlFreeDoc(doc);

    return delbuildmessage(&bm);
}
Beispiel #8
0
void BuildMessage(buildmessage* bm, xmlDocPtr doc, xmlNodePtr node) {
    if(strcmp((char*)node->name, "linda") == 0) {
        xmlNode* cur_node = node->children;
        while(cur_node) {
            if(cur_node->type == XML_ELEMENT_NODE) {
                BuildMessage(bm, doc, cur_node);
            }
            cur_node = cur_node->next;
        }
        return;
    } else if(strcmp((char*)node->name, "action") == 0) {
        xmlNode* cur_node = node->children;
        char* text = NULL;
        while(cur_node) {
            if(cur_node->type == XML_TEXT_NODE) {
                text = (char*)cur_node->content;
            }
            cur_node = cur_node->next;
        }
        if(text == NULL) {
            fprintf(stderr, "No message type specified.\n");
            exit(-1);
        } else if(strcmp(text, "done") == 0) {
            bm->m->type = L_DONE;
        } else if(strcmp(text, "dont_know") == 0) {
            bm->m->type = L_DONT_KNOW;
        } else if(strcmp(text, "result_string") == 0) {
            bm->m->type = L_RESULT_STRING;
        } else if(strcmp(text, "result_int") == 0) {
            bm->m->type = L_RESULT_INT;
        } else if(strcmp(text, "result_tuple") == 0) {
            bm->m->type = L_RESULT_TUPLE;
        } else if(strcmp(text, "out") == 0) {
            bm->m->type = L_OUT;
            bm->m->out.ts = NULL;
            bm->m->out.t = NULL;
        } else if(strcmp(text, "in") == 0) {
            bm->m->type = L_IN;
            bm->m->in.ts = NULL;
            bm->m->in.t = NULL;
        } else if(strcmp(text, "rd") == 0) {
            bm->m->type = L_RD;
            bm->m->rd.ts = NULL;
            bm->m->rd.t = NULL;
        } else if(strcmp(text, "inp") == 0) {
            bm->m->type = L_INP;
            bm->m->in.ts = NULL;
            bm->m->in.t = NULL;
        } else if(strcmp(text, "rdp") == 0) {
            bm->m->type = L_RDP;
            bm->m->rd.ts = NULL;
            bm->m->rd.t = NULL;
        } else if(strcmp(text, "collect") == 0) {
            bm->m->type = L_COLLECT;
            bm->m->collect.ts1 = NULL;
            bm->m->collect.ts2 = NULL;
            bm->m->collect.t = NULL;
        } else if(strcmp(text, "copy_collect") == 0) {
            bm->m->type = L_COPY_COLLECT;
            bm->m->collect.ts1 = NULL;
            bm->m->collect.ts2 = NULL;
            bm->m->collect.t = NULL;
        } else if(strcmp(text, "unblock") == 0) {
            bm->m->type = L_UNBLOCK;
        } else if(strcmp(text, "create_tuplespace") == 0) {
            bm->m->type = L_CREATE_TUPLESPACE;
        } else if(strcmp(text, "add_reference") == 0) {
            bm->m->type = L_ADD_REFERENCE;
        } else if(strcmp(text, "delete_reference") == 0) {
            bm->m->type = L_DELETE_REFERENCE;
        } else if(strcmp(text, "monitor") == 0) {
            bm->m->type = L_MONITOR;
        } else if(strcmp(text, "list_ts") == 0) {
            bm->m->type = L_LIST_TS;
        } else if(strcmp(text, "inspect") == 0) {
            bm->m->type = L_INSPECT;
        } else if(strcmp(text, "get_routes") == 0) {
            bm->m->type = L_GET_ROUTES;
        } else if(strcmp(text, "register_process") == 0) {
            bm->m->type = L_REGISTER_PROCESS;
        } else if(strcmp(text, "register_thread") == 0) {
            bm->m->type = L_REGISTER_THREAD;
        } else if(strcmp(text, "register_type") == 0) {
            bm->m->type = L_REGISTER_TYPE;
            bm->m->typestruct.type_id = NULL;
        } else if(strcmp(text, "update_type") == 0) {
            bm->m->type = L_UPDATE_TYPE;
            bm->m->typestruct.type_id = NULL;
        } else if(strcmp(text, "my_name_is") == 0) {
            bm->m->type = L_MY_NAME_IS;
        } else if(strcmp(text, "get_node_id") == 0) {
            bm->m->type = L_GET_NODE_ID;
        } else if(strcmp(text, "register_partition") == 0) {
            bm->m->type = L_REGISTER_PARTITION;
        } else if(strcmp(text, "get_partitions") == 0) {
            bm->m->type = L_GET_PARTITIONS;
        } else if(strcmp(text, "deleted_partition") == 0) {
            bm->m->type = L_DELETED_PARTITION;
        } else if(strcmp(text, "get_neighbours") == 0) {
            bm->m->type = L_GET_NEIGHBOURS;
        } else if(strcmp(text, "get_connection_details") == 0) {
            bm->m->type = L_GET_CONNECTION_DETAILS;
        } else if(strcmp(text, "get_requests") == 0) {
            bm->m->type = L_GET_REQUESTS;
        } else if(strcmp(text, "tuple_request") == 0) {
            bm->m->type = L_TUPLE_REQUEST;
        } else if(strcmp(text, "cancel_request") == 0) {
            bm->m->type = L_CANCEL_REQUEST;
        } else if(strcmp(text, "multiple_in") == 0) {
            bm->m->type = L_MULTIPLE_IN;
        } else {
            fprintf(stderr, "Unknown message type '%s'.\n", text);
            exit(-1);
        }
    } else if(strcmp((char*)node->name, "body") == 0) {
        xmlNode* cur_node = node->children;
        while(cur_node) {
            if(cur_node->type == XML_ELEMENT_NODE) {
                BuildMessage(bm, doc, cur_node);
            }
            cur_node = cur_node->next;
        }
        return;
    } else if(strcmp((char*)node->name, "ts") == 0) {
        char* val = (char*)xmlGetProp(node, (xmlChar*)"id");
        switch(bm->m->type) {
        case L_OUT:
            bm->m->out.ts = Minimal_tupleSpace(val);
            break;
        case L_IN:
        case L_INP:
            bm->m->in.ts = Minimal_tupleSpace(val);
            break;
        case L_RD:
        case L_RDP:
            bm->m->rd.ts = Minimal_tupleSpace(val);
            break;
        case L_COLLECT:
        case L_COPY_COLLECT:
            if(bm->m->collect.ts1 == NULL) {
                bm->m->collect.ts1 = Minimal_tupleSpace(val);
            } else {
                bm->m->collect.ts2 = Minimal_tupleSpace(val);
            }
            break;
        case L_ADD_REFERENCE:
        case L_DELETE_REFERENCE:
        case L_REGISTER_PARTITION:
        case L_DELETED_PARTITION:
            bm->m->ref.ts = malloc(strlen(val) + 1);
            strcpy(bm->m->ref.ts, val);
            break;
        case L_INSPECT:
        case L_REGISTER_THREAD:
        case L_GET_PARTITIONS:
        case L_GET_REQUESTS:
            bm->m->ts = Minimal_tupleSpace(val);
            break;
        case L_TUPLE_REQUEST:
        case L_CANCEL_REQUEST:
        case L_MULTIPLE_IN:
            bm->m->tuple_request.ts = Minimal_tupleSpace(val);
            break;
        default:
            fprintf(stderr, "Got unexpected TSID.\n");
        }
        free(val);
    } else if(strcmp((char*)node->name, "tid") == 0) {
        char* val = (char*)xmlGetProp(node, (xmlChar*)"id");
        switch(bm->m->type) {
        case L_IN:
        case L_INP:
            bm->m->in.tid = val;
            break;
        case L_RD:
        case L_RDP:
            bm->m->rd.tid = val;
            break;
        default:
            fprintf(stderr, "Got unexpected TID.\n");
        }
    } else if(strcmp((char*)node->name, "tuple") == 0) {
        LindaValue t = Minimal_xmlToValue(node);

        switch(bm->m->type) {
        case L_RESULT_TUPLE:
            bm->m->tuple = t;
            break;
        case L_OUT:
            bm->m->out.t = t;
            break;
        case L_IN:
        case L_INP:
            bm->m->in.t = t;
            break;
        case L_RD:
        case L_RDP:
            bm->m->rd.t = t;
            break;
        case L_COLLECT:
        case L_COPY_COLLECT:
            bm->m->collect.t = t;
            break;
        case L_TUPLE_REQUEST:
        case L_CANCEL_REQUEST:
        case L_MULTIPLE_IN:
            bm->m->tuple_request.t = t;
            break;
        default:
            fprintf(stderr, "Discarding tuple due to invalid message type.\n");
            Linda_delReference(t);
        }
    } else if(strcmp((char*)node->name, "integer") == 0) {
        LindaValue i = Minimal_xmlToValue(node);
        switch(bm->m->type) {
        case L_RESULT_INT:
            bm->m->i = Linda_getInt(i);
            break;
        default:
            fprintf(stderr, "Discarding int due to invalid message type.\n");
        }
        Linda_delReference(i);
    } else if(strcmp((char*)node->name, "string") == 0) {
        LindaValue sv = Minimal_xmlToValue(node);
        char* s = malloc(strlen(sv->string)+1);
        strcpy(s, sv->string);
        Linda_delReference(sv);

        switch(bm->m->type) {
        case L_RESULT_STRING:
        case L_CREATE_TUPLESPACE:
        case L_REGISTER_THREAD:
        case L_MY_NAME_IS:
        case L_GET_CONNECTION_DETAILS:
            bm->m->string = s;
            break;
        case L_ADD_REFERENCE:
        case L_DELETE_REFERENCE:
        case L_REGISTER_PARTITION:
        case L_DELETED_PARTITION:
            bm->m->ref.tid = s;
            break;
        case L_REGISTER_TYPE:
        case L_UPDATE_TYPE:
            if(bm->m->typestruct.type_id == NULL) {
                bm->m->typestruct.type_id = s;
            } else {
                bm->m->typestruct.pid = s;
            }
            break;
        default:
            fprintf(stderr, "Discarding string due to invalid message type.\n");
        }
    } else if(strcmp((char*)node->name, "element") == 0) {
        LindaValue t = Minimal_xmlToValue(node);

        switch(bm->m->type) {
        case L_REGISTER_TYPE:
        case L_UPDATE_TYPE:
            bm->m->typestruct.typeobj = t;
            break;
        default:
            fprintf(stderr, "Discarding element due to invalid message type.\n");
            Linda_delReference(t);
        }
    } else if(strcmp((char*)node->name, "msgid") == 0) {
        bm->m->msgid = (MsgID*)malloc(sizeof(MsgID));

        bm->m->msgid->dest = malloc(strlen((char*)xmlGetProp(node, (xmlChar*)"dest")) + 1);
        strcpy(bm->m->msgid->dest, (char*)xmlGetProp(node, (xmlChar*)"dest"));

        bm->m->msgid->source = malloc(strlen((char*)xmlGetProp(node, (xmlChar*)"source")) + 1);
        strcpy(bm->m->msgid->source, (char*)xmlGetProp(node, (xmlChar*)"source"));

        bm->m->msgid->count = atoi((char*)xmlGetProp(node, (xmlChar*)"count"));
    } else {
        fprintf(stderr, "Unknown message tag '%s'. Ignoring.\n", node->name);
    }
}