CONDITION MSG_BuildReferencedItemSequence(MSG_REFERENCED_ITEM * item, LST_HEAD ** list) { CONDITION cond; DCM_SEQUENCE_ITEM * sq; if (*list == NULL) { *list = LST_Create(); if (*list == NULL) return COND_PushCondition(MSG_LISTFAILURE, MSG_Message(MSG_LISTFAILURE), "MSG_BuildReferencedItemSequence"); } sq = CTN_MALLOC(sizeof(*sq)); if (sq == NULL) return COND_PushCondition(MSG_MALLOCFAILURE, MSG_Message(MSG_MALLOCFAILURE), sizeof(*sq), "MSG_BuildReferencedItemSequence"); cond = MSG_BuildCommand(item, &sq->object); if (cond != MSG_NORMAL) return cond; cond = LST_Enqueue(list, item); if (cond != LST_NORMAL) return COND_PushCondition(MSG_LISTFAILURE, MSG_Message(MSG_LISTFAILURE), "MSG_BuildReferencedItemSequence"); return MSG_NORMAL; }
CONDITION MSG_ParseCEchoRequest(DCM_OBJECT ** object, MSG_C_ECHO_REQ * echoRequest) { static MSG_C_ECHO_REQ request; static unsigned short command, type; static DCM_ELEMENT elementList[] = { {DCM_GROUPCOMMAND, DCM_CMDCOMMANDFIELD, DCM_US, "", 1, sizeof(command), (void *) &command}, {DCM_GROUPCOMMAND, DCM_CMDDATASETTYPE, DCM_US, "", 1, sizeof(type), (void *) &type}, {DCM_GROUPCOMMAND, DCM_CMDMSGID, DCM_US, "", 1, sizeof(request.messageID), (void *) &request.messageID}, {DCM_GROUPCOMMAND, DCM_CMDCLASSUID, DCM_UI, "", 1, sizeof(request.UID), (void *) request.UID} }; void *ctx; int index; unsigned long rtnLength; CONDITION cond; for (index = 0; index < (int) DIM_OF(elementList); index++) { ctx = NULL; cond = DCM_GetElementValue(object, &elementList[index], &rtnLength, &ctx); if (cond != DCM_NORMAL) return COND_PushCondition(MSG_PARSEFAILED, MSG_Message(MSG_PARSEFAILED)); } request.type = MSG_K_C_ECHO_REQ; *echoRequest = request; return MSG_NORMAL; }
CONDITION MSG_ParseCFindResponse(DCM_OBJECT ** object, MSG_C_FIND_RESP * findResponse) { static MSG_C_FIND_RESP response; static unsigned short command, type; static DCM_ELEMENT elementList[] = { {DCM_GROUPCOMMAND, DCM_CMDCOMMANDFIELD, DCM_US, "", 1, sizeof(command), (void *) &command}, {DCM_GROUPCOMMAND, DCM_CMDCLASSUID, DCM_UI, "", 1, sizeof(response.classUID), (void *) response.classUID}, {DCM_GROUPCOMMAND, DCM_CMDMSGIDRESPOND, DCM_US, "", 1, sizeof(response.messageIDRespondedTo), (void *) &response.messageIDRespondedTo}, {DCM_GROUPCOMMAND, DCM_CMDDATASETTYPE, DCM_US, "", 1, sizeof(type), (void *) &type}, {DCM_GROUPCOMMAND, DCM_CMDSTATUS, DCM_US, "", 1, sizeof(response.status), (void *) &response.status}, }; void *ctx; int index; unsigned long rtnLength; CONDITION cond; for (index = 0; index < (int) DIM_OF(elementList); index++) { ctx = NULL; cond = DCM_GetElementValue(object, &elementList[index], &rtnLength, &ctx); if (cond != DCM_NORMAL) return COND_PushCondition(MSG_PARSEFAILED, MSG_Message(MSG_PARSEFAILED)); } response.type = MSG_K_C_FIND_RESP; *findResponse = response; return MSG_NORMAL; }
CONDITION MSG_ParseCStoreRequest(DCM_OBJECT ** object, MSG_C_STORE_REQ * storeRequest) { static MSG_C_STORE_REQ request; static unsigned short command; static DCM_ELEMENT elementList[] = { {DCM_GROUPCOMMAND, DCM_CMDCOMMANDFIELD, DCM_US, "", 1, sizeof(command), (void *) &command}, {DCM_GROUPCOMMAND, DCM_CMDCLASSUID, DCM_UI, "", 1, sizeof(request.classUID), (void *) request.classUID}, {DCM_GROUPCOMMAND, DCM_CMDMSGID, DCM_US, "", 1, sizeof(request.messageID), (void *) &request.messageID}, {DCM_GROUPCOMMAND, DCM_CMDPRIORITY, DCM_US, "", 1, sizeof(request.priority), (void *) &request.priority}, {DCM_GROUPCOMMAND, DCM_CMDDATASETTYPE, DCM_US, "", 1, sizeof(request.dataSetType), (void *) &request.dataSetType}, {DCM_GROUPCOMMAND, DCM_CMDREQUESTEDINSTANCEUID, DCM_UI, "", 1, sizeof(request.instanceUID), (void *) request.instanceUID} }; static MSGPRV_CONDITIONAL conditional[] = { {DCM_GROUPCOMMAND, DCM_CMDMOVEAETITLE, DCM_AE, "", 1, sizeof(request.moveAETitle), (void *) request.moveAETitle, &request.conditionalFields, MSG_K_C_STORE_MOVEAETITLE}, {DCM_GROUPCOMMAND, DCM_CMDMOVEMESSAGEID, DCM_US, "", 1, sizeof(request.moveMessageID), (void *) &request.moveMessageID, &request.conditionalFields, MSG_K_C_STORE_MOVEMESSAGEID}, }; void *ctx; int index; unsigned long rtnLength; CONDITION cond; request.conditionalFields = 0; for (index = 0; index < (int) DIM_OF(elementList); index++) { ctx = NULL; cond = DCM_GetElementValue(object, &elementList[index], &rtnLength, &ctx); if (cond != DCM_NORMAL) return COND_PushCondition(MSG_PARSEFAILED, MSG_Message(MSG_PARSEFAILED)); } for (index = 0; index < (int) DIM_OF(conditional); index++) { ctx = NULL; cond = DCM_GetElementValue(object, &conditional[index].e, &rtnLength, &ctx); if (cond == DCM_NORMAL) { if (DCM_IsString(conditional[index].e.representation)) conditional[index].e.d.string[rtnLength] = '\0'; *conditional[index].flag |= conditional[index].flagBit; }else{ (void) COND_PopCondition(FALSE); } } request.type = MSG_K_C_STORE_REQ; *storeRequest = request; return MSG_NORMAL; }
CONDITION MSG_ParseCMoveResponse(DCM_OBJECT ** object, MSG_C_MOVE_RESP * moveResponse) { static MSG_C_MOVE_RESP response; static unsigned short command, type; static DCM_ELEMENT elementList[] = { {DCM_GROUPCOMMAND, DCM_CMDCOMMANDFIELD, DCM_US, "", 1, sizeof(command), (void *) &command}, {DCM_GROUPCOMMAND, DCM_CMDCLASSUID, DCM_UI, "", 1, sizeof(response.classUID), (void *) response.classUID}, {DCM_GROUPCOMMAND, DCM_CMDMSGIDRESPOND, DCM_US, "", 1, sizeof(response.messageIDRespondedTo), (void *) &response.messageIDRespondedTo}, {DCM_GROUPCOMMAND, DCM_CMDDATASETTYPE, DCM_US, "", 1, sizeof(type), (void *) &type}, {DCM_GROUPCOMMAND, DCM_CMDSTATUS, DCM_US, "", 1, sizeof(response.status), (void *) &response.status}, }; DCM_ELEMENT e; /* Used for conditional elements */ static MSGPRV_CONDITIONAL conditionalList[] = { {DCM_GROUPCOMMAND, DCM_CMDSUCCESSINSTANCEUIDLIST, DCM_UI, "", 1, 0, (void *) &response.successUIDs, &response.conditionalFields, MSG_K_C_MOVE_SUCCESSUID}, {DCM_GROUPCOMMAND, DCM_CMDFAILEDINSTANCEUIDLIST, DCM_UI, "", 1, 0, (void *) &response.failedUIDs, &response.conditionalFields, MSG_K_C_MOVE_FAILEDUID}, {DCM_GROUPCOMMAND, DCM_CMDWARNINGINSTANCEUIDLIST, DCM_UI, "", 1, 0, (void *) &response.warningUIDs, &response.conditionalFields, MSG_K_C_MOVE_WARNINGUID}, {DCM_GROUPCOMMAND, DCM_CMDREMAININGSUBOPERATIONS, DCM_US, "", 1, sizeof(response.remainingSubOperations), (void *) &response.remainingSubOperations, &response.conditionalFields, MSG_K_C_MOVE_REMAINING}, {DCM_GROUPCOMMAND, DCM_CMDCOMPLETEDSUBOPERATIONS, DCM_US, "", 1, sizeof(response.completedSubOperations), (void *) &response.completedSubOperations, &response.conditionalFields, MSG_K_C_MOVE_COMPLETED}, {DCM_GROUPCOMMAND, DCM_CMDFAILEDSUBOPERATIONS, DCM_US, "", 1, sizeof(response.failedSubOperations), (void *) &response.failedSubOperations, &response.conditionalFields, MSG_K_C_MOVE_FAILED}, {DCM_GROUPCOMMAND, DCM_CMDWARNINGSUBOPERATIONS, DCM_US, "", 1, sizeof(response.warningSubOperations), (void *) &response.warningSubOperations, &response.conditionalFields, MSG_K_C_MOVE_WARNING}, }; void *ctx; int index; unsigned long rtnLength; CONDITION cond; for (index = 0; index < (int) DIM_OF(elementList); index++) { ctx = NULL; cond = DCM_GetElementValue(object, &elementList[index], &rtnLength, &ctx); if (cond != DCM_NORMAL) return COND_PushCondition(MSG_PARSEFAILED, MSG_Message(MSG_PARSEFAILED)); } response.type = MSG_K_C_MOVE_RESP; for (index = 0; index < (int) DIM_OF(conditionalList); index++) { cond = DCM_NORMAL; e = conditionalList[index].e; if (e.length == 0) { cond = DCM_GetElementSize(object, DCM_MAKETAG(e.group, e.element), &rtnLength); if (cond == DCM_NORMAL) { e.length = rtnLength; e.d.string = malloc(rtnLength + 1); if (e.d.string == NULL) return 0; /* repair */ *conditionalList[index].e.d.stringArray = e.d.string; }else{ (void) COND_PopCondition(FALSE); } } if (cond == DCM_NORMAL) { ctx = NULL; cond = DCM_GetElementValue(object, &e, &rtnLength, &ctx); if (cond == DCM_NORMAL) { *conditionalList[index].flag |= conditionalList[index].flagBit; e.d.string[rtnLength] = '\0'; } } } *moveResponse = response; return MSG_NORMAL; }