CONDITION DUL_AddSinglePresentationCtx(DUL_ASSOCIATESERVICEPARAMETERS* params, DUL_SC_ROLE proposedRole, DUL_SC_ROLE acceptedRole, DUL_PRESENTATIONCONTEXTID contextID, unsigned char result, const char* abstractSyntax, const char** xferSyntaxes, int xferSyntaxCount) { LST_HEAD* lst; DUL_TRANSFERSYNTAX* transfer; DUL_PRESENTATIONCONTEXT* ctx; CONDITION cond; ctx = (DUL_PRESENTATIONCONTEXT *) CTN_MALLOC(sizeof(*ctx)); if (ctx == NULL) return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR), "DUL_AddSinglePresentationCtx", sizeof(*ctx)); (void) memset(ctx, 0, sizeof(*ctx)); lst = LST_Create(); if (lst == NULL) return COND_PushCondition(DUL_LISTCREATEFAILED, DUL_Message(DUL_LISTCREATEFAILED), "DUL_AddSinglePresentationCtx"); (ctx)->presentationContextID = contextID; (ctx)->result = result; (ctx)->proposedSCRole = proposedRole; (ctx)->acceptedSCRole = acceptedRole; strcpy((ctx)->abstractSyntax, abstractSyntax); strcpy((ctx)->acceptedTransferSyntax, ""); for (; xferSyntaxCount-- > 0; xferSyntaxes++) { if (strlen(*xferSyntaxes) != 0) { transfer = CTN_MALLOC(sizeof(*transfer)); if (transfer == NULL) return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR), "DUL_AddSinglePresentationCtx", sizeof(*transfer)); strcpy(transfer->transferSyntax, *xferSyntaxes); if (LST_Enqueue(&lst, transfer) != LST_NORMAL) return COND_PushCondition(DUL_LISTERROR, DUL_Message(DUL_LISTERROR), "DUL_AddSinglePresentationCtx"); } } (ctx)->proposedTransferSyntax = lst; cond = LST_Enqueue(¶ms->requestedPresentationContext,ctx); if (cond != LST_NORMAL) { return COND_PushCondition(DUL_LISTERROR, DUL_Message(DUL_LISTERROR), "DUL_AddSinglePresentationCtx"); /* Memory Leak here */ } return DUL_NORMAL; }
CONDITION DUL_MakePresentationCtx(DUL_PRESENTATIONCONTEXT ** ctx, DUL_SC_ROLE proposedSCRole, DUL_SC_ROLE acceptedSCRole, DUL_PRESENTATIONCONTEXTID ctxID, unsigned char result, const char *abstractSyntax, const char *transferSyntax,...) { va_list args; LST_HEAD * lst; DUL_TRANSFERSYNTAX * transfer; #ifdef lint char __builtin_va_alist; #endif *ctx = (DUL_PRESENTATIONCONTEXT *) CTN_MALLOC(sizeof(**ctx)); if (*ctx == NULL) return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR), "DUL_MakePresentationCtx", sizeof(**ctx)); (void) memset(*ctx, 0, sizeof(**ctx)); lst = LST_Create(); if (lst == NULL) return COND_PushCondition(DUL_LISTCREATEFAILED, DUL_Message(DUL_LISTCREATEFAILED), "DUL_MakePresentationCtx"); (*ctx)->presentationContextID = ctxID; (*ctx)->result = result; (*ctx)->proposedSCRole = proposedSCRole; (*ctx)->acceptedSCRole = acceptedSCRole; strcpy((*ctx)->abstractSyntax, abstractSyntax); va_start(args, transferSyntax); strcpy((*ctx)->acceptedTransferSyntax, transferSyntax); while ((transferSyntax = va_arg(args, char *)) != NULL) { if (strlen(transferSyntax) != 0) { transfer = CTN_MALLOC(sizeof(*transfer)); if (transfer == NULL) return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR), "DUL_MakePresentationCtx", sizeof(*transfer)); strcpy(transfer->transferSyntax, transferSyntax); if (LST_Enqueue(&lst, transfer) != LST_NORMAL) return COND_PushCondition(DUL_LISTERROR, DUL_Message(DUL_LISTERROR), "DUL_MakePresentationCtx"); } } va_end(args); (*ctx)->proposedTransferSyntax = lst; return DUL_NORMAL; }
static void directoryToHTML(const char* path) { LST_HEAD* l; #if 0 char topDirectory[1024]; char currentDirectory[1024]; char key[1024]; #endif FILE_ENTRY* f; char parentPath[1024]; char *c; strcpy(parentPath, path); c = parentPath + strlen(parentPath); while (*(--c) != '/') ; *c = '\0'; l = LST_Create(); listDirectory(path, &l); html_header(); html_begin_body_options("File View", "bgcolor=#ffffff"); while ((f = LST_Dequeue(&l)) != NULL) { if (strcmp(f->fileName, "..") == 0) { printf("<br><a href=""/cgi-bin/fileview.cgi" "?submitSearch=FileSelect" "&Key=%s" "&CurrentDirectory=%s" "&>%s</a>\n", ".", parentPath, f->fileName); } else { printf("<br><a href=""/cgi-bin/fileview.cgi" "?submitSearch=FileSelect" "&Key=%s" "&CurrentDirectory=%s" "&>%s</a>\n", f->fileName, path, f->fileName); } free(f); } html_end(); LST_Destroy(&l); }
CONDITION SRV_RegisterSOPClassXfer(const char *SOPClass, const char* xferSyntax, DUL_SC_ROLE role, DUL_ASSOCIATESERVICEPARAMETERS * params) { DUL_PRESENTATIONCONTEXTID contextID = 1; CTNBOOLEAN found = FALSE; CONDITION cond; DUL_PRESENTATIONCONTEXT* ctx; if (params->requestedPresentationContext == NULL) { params->requestedPresentationContext = LST_Create(); if (params->requestedPresentationContext == NULL) { return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_RegisterSOPClassXfer"); } } ctx = LST_Head(¶ms->requestedPresentationContext); if (ctx != NULL) (void) LST_Position(¶ms->requestedPresentationContext, ctx); while (ctx != NULL) { DUL_TRANSFERSYNTAX* xferItem; contextID += 2; xferItem = (DUL_TRANSFERSYNTAX*) LST_Head(&ctx->proposedTransferSyntax); if ((strcmp(SOPClass, ctx->abstractSyntax) == 0) && (strcmp(xferSyntax, xferItem->transferSyntax) == 0) && (role == ctx->proposedSCRole) ) return SRV_NORMAL; ctx = LST_Next(¶ms->requestedPresentationContext); } cond = DUL_MakePresentationCtx(&ctx, role, DUL_SC_ROLE_DEFAULT, contextID, 0, SOPClass, "", xferSyntax, NULL); if (cond != DUL_NORMAL) { return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_RegisterSOPClassXfer"); } cond = LST_Enqueue(¶ms->requestedPresentationContext, ctx); if (cond != LST_NORMAL) { return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_RegisterSOPClassXfer"); } return SRV_NORMAL; }
CONDITION IAP_InstanceArraytoElement(char *SOPArray, size_t SOPSpacing, char *UIDArray, size_t UIDSpacing, int count, DCM_ELEMENT * e) { CONDITION cond; DCM_ELEMENT classElement = { DCM_IDREFERENCEDSOPCLASSUID, DCM_UI, "", 1, 0, NULL }, uidElement = { DCM_IDREFERENCEDSOPINSTUID, DCM_UI, "", 1, 0, NULL }; DCM_OBJECT * object; DCM_SEQUENCE_ITEM * item; e->d.sq = LST_Create(); if (e->d.sq == NULL) return 0; /* repair */ while (count-- > 0) { item = malloc(sizeof(*item)); if (item == NULL) return 0; /* repair */ cond = DCM_CreateObject(&item->object); if (cond != DCM_NORMAL) return 0; /* repair */ classElement.d.string = SOPArray; classElement.length = strlen(SOPArray); cond = DCM_AddElement(&item->object, &classElement); if (cond != DCM_NORMAL) return 0; /* repair */ uidElement.d.string = UIDArray; uidElement.length = strlen(UIDArray); cond = DCM_AddElement(&item->object, &uidElement); if (cond != DCM_NORMAL) return 0; /* repair */ cond = LST_Enqueue(&e->d.sq, item); if (cond != LST_NORMAL) return 0; /* repair */ SOPArray += SOPSpacing; UIDArray += UIDSpacing; } return HAP_NORMAL; }
static void dumpCommitRequests(FIS_HANDLE ** fisHandle) { LST_HEAD *requestList; FIS_STORAGECOMMITREQRECORD *commitReq; CONDITION cond; requestList = LST_Create(); if (requestList == NULL) { fprintf(stderr, "Could not create an initial request list. Exiting now.\n"); return; } cond = FIS_Get(fisHandle, FIS_K_STORAGECOMMITREQ, FIS_K_STORAGECOMMITREQ, NULL, 0, requestList); if (cond != FIS_NORMAL) { COND_DumpConditions(); return; } printf("%64s %16s %16s %12s %14s %12s %14s\n", "Transaction UID", "Requesting App", "Responding App", "Request Date", "Request Time", "Response Date", "Response Time"); while ((commitReq = LST_Dequeue(&requestList)) != NULL) { if (!(commitReq->Flag & FIS_K_SCOMMIT_REQDAT)) commitReq->ReqDat[0] = '\0'; if (!(commitReq->Flag & FIS_K_SCOMMIT_REQTIM)) commitReq->ReqTim[0] = '\0'; if (!(commitReq->Flag & FIS_K_SCOMMIT_RESDAT)) commitReq->ResDat[0] = '\0'; if (!(commitReq->Flag & FIS_K_SCOMMIT_RESTIM)) commitReq->ResTim[0] = '\0'; printf("%64s %16s %16s %12s %14s %12s %14s\n", commitReq->TraUID, commitReq->ReqAE, commitReq->ResAE, commitReq->ReqDat, commitReq->ReqTim, commitReq->ResDat, commitReq->ResTim); free(commitReq); } LST_Destroy(&requestList); }
CONDITION UTL_ReadConfigFile( ) { FILE* f; char buf[1024]; if (UTL_configList != 0) return UTL_NORMAL; UTL_configList = LST_Create(); if (UTL_configList == NULL) return 0; if (UTL_configFile == 0) return UTL_NORMAL; if (UTL_configFile[0] == '\0') return UTL_NORMAL; f = fopen(UTL_configFile, "r"); if (f == NULL) return 0; while (fgets(buf, sizeof(buf), f) != NULL) { char* token1; char* token2; CONFIG_ITEM* item; if (buf[0] == '#') continue; if (buf[0] == '\n') continue; token1 = strtok(buf, " \t\n"); token2 = strtok(0, " \t\n"); if (token2 == NULL) continue; item = (CONFIG_ITEM*)malloc(sizeof(*item) + strlen(token1) + strlen(token2) + 2); item->pName = ((char*)item) + sizeof(*item); strcpy(item->pName, token1); item->pValue = item->pName + strlen(token1) + 1; strcpy(item->pValue, token2); LST_Enqueue(&UTL_configList, item); } fclose(f); return UTL_NORMAL; }
CONDITION DDR_GetStudyList(DCM_OBJECT ** object, const char *patientID, LST_HEAD ** lst) { LST_HEAD *patientList; DDR_PATIENT *pPtr; CONDITION cond; U32 offset; DCM_OBJECT *studyObject; /* * Create a patient list and get all of the patients in the DICOMDIR * object */ patientList = LST_Create(); cond = DDR_GetPatientList(object, &patientList); pPtr = LST_Dequeue(&patientList); /* * Scan through the patient list for a patient whose patient ID matches * that passed * by the caller. When we find that, walk through the * study list for that patient * and fill the caller's list with * DDR_STUDY records. */ while (pPtr != NULL) { if (strcmp(pPtr->PatientID, patientID) == 0) { offset = pPtr->StudyLinkOffset; while (offset != 0) { cond = DCM_GetSequenceByOffset(object, DCM_DIRRECORDSEQUENCE, offset, &studyObject); if (cond != DCM_NORMAL) { exit(1); /* repair */ } addStudyRecord(&studyObject, lst); offset = offsetNextRecord(&studyObject); } } free(pPtr); pPtr = LST_Dequeue(&patientList); } LST_Destroy(&patientList); return DDR_NORMAL; }
CONDITION SRV_RegisterSOPClass(const char *SOPClass, DUL_SC_ROLE role, DUL_ASSOCIATESERVICEPARAMETERS * params) { DUL_PRESENTATIONCONTEXTID contextID = 1; CTNBOOLEAN found = FALSE; CONDITION cond; DUL_PRESENTATIONCONTEXT* ctx; if (params->requestedPresentationContext == NULL) { params->requestedPresentationContext = LST_Create(); if (params->requestedPresentationContext == NULL) { return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_RegisterSOPClass"); } } ctx = LST_Head(¶ms->requestedPresentationContext); if (ctx != NULL) (void) LST_Position(¶ms->requestedPresentationContext, ctx); while (ctx != NULL) { contextID += 2; if (strcmp(SOPClass, ctx->abstractSyntax) == 0) return SRV_NORMAL; ctx = LST_Next(¶ms->requestedPresentationContext); } cond = DUL_MakePresentationCtx(&ctx, role, DUL_SC_ROLE_DEFAULT, contextID, 0, SOPClass, "", DICOM_TRANSFERLITTLEENDIAN, NULL); if (cond != DUL_NORMAL) { return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_RegisterSOPClass"); } cond = LST_Enqueue(¶ms->requestedPresentationContext, ctx); if (cond != LST_NORMAL) { return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_RegisterSOPClass"); } return SRV_NORMAL; }
/* ICON_GetStudyIconLst ** ** Purpose: ** Reads the file and returns a list of STUDYICON records corresponding ** to a study identified by an accession number. ** ** Parameter Dictionary: ** file Pathname of the file. ** studyiconlist List of STUDYICON records. ** ** Return Values: ** ICON_NORMAL Sucess ** ICON_FILEOPENFAILED Failed to open file. ** ICON_LISTFAILURE Failed to create/enqueue list. ** ICON_OFFSETERROR Failed to search file. ** ICON_MALLOCFAILURE Failed to malloc memory space. ** ICON_INCORRECTFILESIZE Failed to parse file properly. ** ** Notes: ** ** Algorithm: ** Description of the algorithm (optional) and any other notes. */ CONDITION ICON_GetStudyIconLst(char *file, ICON_STUDYOFFSET * studyoffset, LST_HEAD ** studyiconlist) { int fd, fdcond; LIST_ICON_STUDYICON * listitem; ICON_STUDYICON temp; CONDITION cond; fd = open(file, O_RDONLY); if (fd < 0) return COND_PushCondition(ICON_FILEOPENFAILED, ICON_Message(ICON_FILEOPENFAILED), file, "ICON_GetStudyIconLst"); *studyiconlist = LST_Create(); if (*studyiconlist == NULL) return COND_PushCondition(ICON_LISTFAILURE, ICON_Message(ICON_LISTFAILURE), "ICON_GetStudyIconLst"); if (lseek(fd, studyoffset->Offset, SEEK_SET) < 0) return COND_PushCondition(ICON_OFFSETERROR, ICON_Message(ICON_OFFSETERROR), "ICON_GetStudyIconLst"); while (((fdcond = read(fd, (char *) &temp, sizeof(ICON_STUDYICON))) == sizeof(ICON_STUDYICON)) && (!strcmp(temp.accessionNumber, studyoffset->accessionNumber))) { listitem = (LIST_ICON_STUDYICON *) malloc(sizeof(LIST_ICON_STUDYICON)); if (listitem == NULL) return COND_PushCondition(ICON_MALLOCFAILURE, ICON_Message(ICON_MALLOCFAILURE), "ICON_GetStudyIconLst"); listitem->studyicon = temp; cond = LST_Enqueue(studyiconlist, listitem); if (cond != LST_NORMAL) return COND_PushCondition(ICON_LISTFAILURE, ICON_Message(ICON_LISTFAILURE), "ICON_GetStudyIconLst"); } if ((fdcond != sizeof(ICON_STUDYICON)) && (fdcond != 0)) return COND_PushCondition(ICON_INCORRECTFILESIZE, ICON_Message(ICON_INCORRECTFILESIZE), "ICON_GetStudyIconLst"); close(fd); return (ICON_NORMAL); }
static void localDirectory(llist entries) { LST_HEAD *patientList; DCM_OBJECT *dirFile; DDR_PATIENT *patientNode; CONDITION cond; cond = DCM_OpenFile("/tmp/dicomdir", DCM_ORDERLITTLEENDIAN | DCM_PART10FILE, &dirFile); patientList = LST_Create(); cond = DDR_GetPatientList(&dirFile, &patientList); html_header(); html_begin_body_options("DICOM Patient Search", "bgcolor=#ffffff"); printf("Please select one patient to see a list of studies<p>\n"); printf("<form method=GET action=""/cgi-bin/acc_agent.cgi"">\n"); patientNode = LST_Dequeue(&patientList); printf("<select name=patientID size=10>\n"); while(patientNode != NULL) { printf("<option value=""%s"">%s %s %s\n", patientNode->PatientID, patientNode->PatientID, patientNode->PatientName, patientNode->BirthDate); free(patientNode); patientNode = LST_Dequeue(&patientList); } printf("</select>\n"); printf("<br>\n"); printf("<input type=submit value=""LocalPatientSelect"" name=submitSearch>\n"); printf("<input type=submit value=""Retrieve All Studies from Archive"" name=submitSearch>\n"); printf("</form>\n"); html_end(); LST_Destroy(&patientList); DCM_CloseObject(&dirFile); }
CONDITION SRV_ProposeSOPClassWithXfer(const char*SOPClass, DUL_SC_ROLE role, char** xferSyntaxes, int xferSyntaxCount, int isStorageClass, DUL_ASSOCIATESERVICEPARAMETERS* params) { DUL_PRESENTATIONCONTEXTID contextID = 1; CONDITION cond; DUL_PRESENTATIONCONTEXT* ctx; char** xferSyntaxesLocal = 0; char* prefix = "PROPOSE/XFER"; int singleMode = 1; if (params->requestedPresentationContext == NULL) { params->requestedPresentationContext = LST_Create(); if (params->requestedPresentationContext == NULL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_ProposeSOPClassWithXfer"); } ctx = LST_Head(¶ms->requestedPresentationContext); if (ctx != NULL) (void) LST_Position(¶ms->requestedPresentationContext, ctx); while (ctx != NULL) { contextID += 2; if (strcmp(SOPClass, ctx->abstractSyntax) == 0) return SRV_NORMAL; ctx = LST_Next(¶ms->requestedPresentationContext); } if (xferSyntaxCount == 0) { if (isStorageClass) prefix = "PROPOSE/XFER/STORAGE"; xferSyntaxesLocal = mapProposedSOPToXferSyntax(SOPClass, prefix, &xferSyntaxCount, &singleMode); }else{ xferSyntaxesLocal = xferSyntaxes; singleMode = 1; } if (singleMode == 1) { cond = DUL_AddSinglePresentationCtx(params, role, DUL_SC_ROLE_DEFAULT, contextID, 0, SOPClass, xferSyntaxesLocal, xferSyntaxCount); }else{ cond = DUL_AddMultiplePresentationCtx(params, role, DUL_SC_ROLE_DEFAULT, contextID, 0, SOPClass, xferSyntaxesLocal, xferSyntaxCount); } if (xferSyntaxesLocal != xferSyntaxes) CTN_FREE(xferSyntaxesLocal); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_ProposeSOPClassWithXfer"); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_ProposeSOPClassWithXfer"); return SRV_NORMAL; }
CONDITION SRV_RejectServiceClass(DUL_PRESENTATIONCONTEXT * requestedCtx, unsigned short result, DUL_ASSOCIATESERVICEPARAMETERS * params) { CONDITION cond; DUL_PRESENTATIONCONTEXT * ctx; if (params->acceptedPresentationContext == NULL) { params->acceptedPresentationContext = LST_Create(); if (params->acceptedPresentationContext == NULL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_RejectServiceClass"); } cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, DUL_SC_ROLE_DEFAULT, requestedCtx->presentationContextID, (unsigned char)result, requestedCtx->abstractSyntax, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIAN, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_RejectServiceClass"); cond = LST_Enqueue(¶ms->acceptedPresentationContext, ctx); if (cond != LST_NORMAL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_RejectServiceClass"); return SRV_NORMAL; }
/* ICON_GetStudyOffsetList ** ** Purpose: ** Returns a list of STUDYOFFSET records contained in the file. ** ** Parameter Dictionary: ** file Pathname of the file. ** studyoffsetlist List of STUDYOFFSET records. ** ** Return Values: ** ICON_NORMAL Sucess ** ICON_FILEOPENFAILED Failed to open file. ** ICON_LISTFAILURE Failed to create/enqueue list. ** ICON_MALLOCFAILURE Failed to malloc memory space. ** ICON_INCORRECTFILESIZE Failed to parse file properly. ** ** Notes: ** ** Algorithm: ** Description of the algorithm (optional) and any other notes. */ CONDITION ICON_GetStudyOffsetLst(char *file, LST_HEAD ** studyoffsetlist) { int fd, fdcond; LIST_ICON_STUDYOFFSET * listitem; ICON_STUDYOFFSET temp; CONDITION cond; fd = open(file, O_RDONLY); if (fd < 0) return COND_PushCondition(ICON_FILEOPENFAILED, ICON_Message(ICON_FILEOPENFAILED), file, "ICON_GetStudyOffsetList"); *studyoffsetlist = LST_Create(); if (*studyoffsetlist == NULL) return COND_PushCondition(ICON_LISTFAILURE, ICON_Message(ICON_LISTFAILURE), "ICON_GetStudyOffsetList"); while ((fdcond = read(fd, (char *) &temp, sizeof(ICON_STUDYOFFSET))) == sizeof(ICON_STUDYOFFSET)) { listitem = (LIST_ICON_STUDYOFFSET *) malloc(sizeof(LIST_ICON_STUDYOFFSET)); if (listitem == NULL) return COND_PushCondition(ICON_MALLOCFAILURE, ICON_Message(ICON_MALLOCFAILURE), "ICON_GetStudyOffsetList"); listitem->studyoffset = temp; cond = LST_Enqueue(studyoffsetlist, listitem); if (cond != LST_NORMAL) return COND_PushCondition(ICON_LISTFAILURE, ICON_Message(ICON_LISTFAILURE), "ICON_GetStudyOffsetList"); } if ((fdcond != sizeof(ICON_STUDYOFFSET)) && (fdcond != 0)) return COND_PushCondition(ICON_INCORRECTFILESIZE, ICON_Message(ICON_INCORRECTFILESIZE), file, "ICON_GetStudyOffsetList"); close(fd); return (ICON_NORMAL); }
CONDITION SRV_AcceptSOPClass(DUL_PRESENTATIONCONTEXT * requestedCtx, DUL_SC_ROLE role, DUL_ASSOCIATESERVICEPARAMETERS * params, char** xferSyntaxes, int xferSyntaxCount, int isStorageClass) { CONDITION cond, rtnCond = SRV_NORMAL; DUL_PRESENTATIONCONTEXT* ctx; DUL_TRANSFERSYNTAX* transfer; char* prefix = "ACCEPT/XFER"; if (params->acceptedPresentationContext == NULL) { params->acceptedPresentationContext = LST_Create(); if (params->acceptedPresentationContext == NULL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_AcceptServiceClass"); } if (isStorageClass) prefix = "ACCEPT/XFER/STORAGE"; transfer = matchProposedXferSyntax(requestedCtx, prefix, xferSyntaxes, xferSyntaxCount); if (transfer == NULL) { DUL_TRANSFERSYNTAX* proposedXfer; proposedXfer = (DUL_TRANSFERSYNTAX*)LST_Head(&requestedCtx->proposedTransferSyntax); cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, DUL_SC_ROLE_DEFAULT, requestedCtx->presentationContextID, DUL_PRESENTATION_REJECT_ABSTRACT_SYNTAX, requestedCtx->abstractSyntax, proposedXfer->transferSyntax, proposedXfer->transferSyntax, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptSOPClass"); (void) COND_PushCondition(SRV_UNSUPPORTEDSERVICE, SRV_Message(SRV_UNSUPPORTEDSERVICE), requestedCtx->abstractSyntax, "SRV_AcceptSOPClass"); rtnCond = COND_PushCondition(SRV_PRESENTATIONCTXREJECTED, SRV_Message(SRV_PRESENTATIONCTXREJECTED), requestedCtx->abstractSyntax, "SRV_AcceptSOPClass"); }else{ cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, role, requestedCtx->presentationContextID, DUL_PRESENTATION_ACCEPT, requestedCtx->abstractSyntax, transfer->transferSyntax, transfer->transferSyntax, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptSOPClass"); } cond = LST_Enqueue(¶ms->acceptedPresentationContext, ctx); if (cond != LST_NORMAL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_AcceptSOPClass"); return rtnCond; }
CONDITION DDR_GetSeriesLeafList(DCM_OBJECT ** object, const char *patientID, const char *studyInstanceUID, const char *seriesInstanceUID, LST_HEAD ** leafList) { LST_HEAD *seriesList; DDR_SERIES *sPtr; CONDITION cond; U32 offset; DCM_OBJECT *leafObject; seriesList = LST_Create(); cond = DDR_GetSeriesList(object, patientID, studyInstanceUID, &seriesList); if (cond != DDR_NORMAL) return cond; sPtr = LST_Dequeue(&seriesList); while (sPtr != NULL) { if (strcmp(sPtr->SeriesInstanceUID, seriesInstanceUID) == 0) { offset = sPtr->LeafLinkOffset; while (offset != 0) { cond = DCM_GetSequenceByOffset(object, DCM_DIRRECORDSEQUENCE, offset, &leafObject); if (cond != DCM_NORMAL) { return DDR_ERROR; } addLeafRecord(&leafObject, leafList); offset = offsetNextRecord(&leafObject); } } free(sPtr); sPtr = LST_Dequeue(&seriesList); } LST_Destroy(&seriesList); return DDR_NORMAL; }
/* * ======== CreateChirpList ======== * Purpose: * Initialize a queue of channel I/O Request/Completion packets. * Parameters: * uChirps: Number of Chirps to allocate. * Returns: * Pointer to queue of IRPs, or NULL. * Requires: * Ensures: */ static struct LST_LIST *CreateChirpList(u32 uChirps) { struct LST_LIST *pChirpList; struct CHNL_IRP *pChirp; u32 i; pChirpList = LST_Create(); if (pChirpList) { /* Make N chirps and place on queue. */ for (i = 0; (i < uChirps) && ((pChirp = MakeNewChirp()) != NULL); i++) { LST_PutTail(pChirpList, (struct LST_ELEM *)pChirp); } /* If we couldn't allocate all chirps, free those allocated: */ if (i != uChirps) { FreeChirpList(pChirpList); pChirpList = NULL; } } return pChirpList; }
static void localPatientSelect(llist entries) { LST_HEAD *studyList; DCM_OBJECT *dirFile; DDR_STUDY *studyNode; CONDITION cond; cond = DCM_OpenFile("/tmp/dicomdir", DCM_ORDERLITTLEENDIAN | DCM_PART10FILE, &dirFile); studyList = LST_Create(); cond = DDR_GetStudyList(&dirFile, cgi_val(entries, "patientID"), &studyList); html_header(); html_begin_body_options("DICOM Study Search", "bgcolor=#ffffff"); studyNode = LST_Dequeue(&studyList); printf("<tt>\n"); while(studyNode != NULL) { printf("%s %s %s %s <br>\n", studyNode->StudyDate, studyNode->AccessionNumber, studyNode->StudyID, studyNode->StudyDescription); free(studyNode); studyNode = LST_Dequeue(&studyList); } printf("</tt>\n"); html_end(); DCM_CloseObject(&dirFile); }
void main(int argc, char *argv[]) { int height, width, temp; Boolean GOT_QID = False; CONDITION cond; toplevel = XtAppInitialize( /* create application context */ &app_ctx, "print_server_display", NULL, 0, #ifdef SOLARIS (Cardinal *) & argc, #else &argc, #endif argv, NULL, NULL, 0); width = MAX_WIDTH - 10; height = MAX_HEIGHT - 10; argc--; argv++; while (argc > 0) { if (strcmp(*argv, "-w") == 0) { argc--; argv++; temp = atoi(*argv); if (temp < MIN_WIDTH) { fprintf(stderr, "Height must be > %d\n", MIN_WIDTH); UsageError(); exit(0); } if (temp > MAX_WIDTH) { fprintf(stderr, "Height must be < %d\n", MAX_WIDTH); UsageError(); exit(0); } width = temp; argc--; argv++; } else if (strcmp(*argv, "-h") == 0) { argc--; argv++; temp = atoi(*argv); if (temp < MIN_HEIGHT) { fprintf(stderr, "Height must be > %d\n", MIN_HEIGHT); UsageError(); exit(0); } if (temp > MAX_HEIGHT) { fprintf(stderr, "Height must be < %d\n", MAX_HEIGHT); UsageError(); exit(0); } height = temp; argc--; argv++; } else if (strcmp(*argv, "-v") == 0) { argc--; argv++; (void) COND_EstablishCallback(cond_CB); } else { if (argc != 1) { fprintf(stderr, "Only the last parameter is a none switch\n"); UsageError(); exit(0); } queue_id = atoi(*argv); if (queue_id == 0) { fprintf(stderr, "Invalid queueu ID\n"); UsageError(); exit(0); } argc--; argv++; GOT_QID = True; } } if (GOT_QID == False) { fprintf(stderr, "Error: Missing QID\n"); UsageError(); exit(0); } THR_Init(); /* The print_server_display creates a GQ with the specified ID */ cond = GQ_InitQueue(queue_id, 128, sizeof(GQ_ELEM)); if (cond != GQ_NORMAL) { fprintf(stderr, "GQ_InitQueue failed to create GQ with ID : %d\n", queue_id); COND_DumpConditions(); exit(1); } /* now get hold of the just created GQ */ cond = GQ_GetQueue(queue_id, sizeof(GQ_ELEM)); switch (cond) { case GQ_SHAREDMEMORYFAIL: fprintf(stderr, "GQ Shared Memory failed\n"); exit(0); case GQ_FILEACCESSFAIL: fprintf(stderr, "GQ File Access failed\n"); exit(0); case GQ_BADELEMSIZE: fprintf(stderr, "GQ Bad Element Size\n"); exit(0); case GQ_UNIMPLEMENTED: fprintf(stderr, "GQ Unimplemented\n"); exit(0); case GQ_NORMAL: break; } session_list = LST_Create(); printf("width = %d, height = %d\n", width, height); createMainWin(); XtRealizeWidget(toplevel); DISP_Initialize(toplevel, width, height); /* DISP_CreateSession("1.2.840.113654.2.3.1993.9.123.9.3221", "test", &session_list); DISP_AddBox("test", "PRN_13674.2", &session_list); DISP_AddBox("test2", "PRN_13674.2", &session_list); DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.5", &session_list); DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3225", "PRN_13674.4", &session_list); DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.3", &session_list); */ /*lint -e64*/ XtAppAddTimeOut(app_ctx, TIMEOUT, pollQueue, NULL); /*lint +e64*/ XtAppMainLoop(app_ctx); THR_Shutdown(); }
static CONDITION getResultsRecord(PRIVATE_HANDLE * h, FIS_DATA_TYPE criteriaType, char *uid, long listFlag, LST_HEAD * getList, FIS_RESULTSRECORD * r, long *count) { CONDITION cond; TBL_CRITERIA criteria[2]; FIS_RESULTSRECORD *p; static TBL_FIELD fields[] = { {"ResUID", TBL_STRING, sizeof(results.ResUID), sizeof(results.ResUID), 0, (void *) &results.ResUID[0]}, {"StuInsUID", TBL_STRING, sizeof(results.StuInsUID), sizeof(results.StuInsUID), 0, (void *) &results.StuInsUID[0]}, {"ResID", TBL_STRING, sizeof(results.ResID), sizeof(results.ResID), 0, (void *) &results.ResID[0]}, {"Imp", TBL_TEXT, sizeof(results.Imp), sizeof(results.Imp), 0, (void *) &results.Imp[0]}, {"InsCreDat", TBL_STRING, sizeof(results.InsCreDat), sizeof(results.InsCreDat), 0, (void *) &results.InsCreDat[0]}, {"InsCreTim", TBL_STRING, sizeof(results.InsCreTim), sizeof(results.InsCreTim), 0, (void *) &results.InsCreTim[0]}, {"InsCreUID", TBL_STRING, sizeof(results.InsCreUID), sizeof(results.InsCreUID), 0, (void *) &results.InsCreUID}, {NULL} }; criteria[0].FieldName = criteria[1].FieldName = NULL; if (uid != NULL) { if (uid[0] != '\0') { if (criteriaType == FIS_K_STUDY) { TBL_CRITERIA_LOAD_BYTE(criteria[0], "StuInsUID", uid, TBL_STRING, TBL_EQUAL); } else { TBL_CRITERIA_LOAD_BYTE(criteria[0], "ResUID", uid, TBL_STRING, TBL_EQUAL); } } } (void) memset(&results, 0, sizeof(results)); results.Type = FIS_K_RESULTS; cond = TBL_Select(&h->resultsHandle, criteria, fields, count, resultsCallback, getList); if (cond != TBL_NORMAL) return FIS_GETFAILED; if (r != NULL) *r = results; if (listFlag & FIS_K_RESULTS_INTERPRETATIONLIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->InterpretationList = LST_Create(); p->Flag |= FIS_K_RESULTS_INTERPRETATIONLIST; cond = getInterpretationRecord(h, FIS_K_RESULTS, p->ResUID, 0, p->InterpretationList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } return FIS_NORMAL; }
static CONDITION getSCSeriesRecord(PRIVATE_HANDLE * h, FIS_DATA_TYPE criteriaType, char *uid, long listFlag, LST_HEAD * getList, FIS_SCSERIESRECORD * r, long *count) { CONDITION cond; TBL_CRITERIA criteria[2]; FIS_SCSERIESRECORD *p; static TBL_FIELD fields[] = { {TBL_FIELD_STRING("SerInsUID", scSeries.SerInsUID)}, {TBL_FIELD_STRING("StuComUID", scSeries.StuComUID)}, {TBL_FIELD_STRING("SerDat", scSeries.SerDat)}, {TBL_FIELD_STRING("SerTim", scSeries.SerTim)}, {TBL_FIELD_STRING("RetAETit", scSeries.RetAETit)}, {TBL_FIELD_STRING("StoMedFilSetID", scSeries.StoMedFilSetID)}, {TBL_FIELD_STRING("StoMedFilSetUID", scSeries.StoMedFilSetUID)}, {NULL}, }; criteria[0].FieldName = criteria[1].FieldName = NULL; if (uid != NULL) { if (uid[0] != '\0') { if (criteriaType == FIS_K_STUDYCOMPONENT) { TBL_CRITERIA_LOAD_BYTE(criteria[0], "StuComUID", uid, TBL_STRING, TBL_EQUAL); } else { TBL_CRITERIA_LOAD_BYTE(criteria[0], "SerInsUID", uid, TBL_STRING, TBL_EQUAL); } } } (void) memset(&scSeries, 0, sizeof(scSeries)); scSeries.Type = FIS_K_SCSERIES; cond = TBL_Select(&h->studyComponentSeriesHandle, criteria, fields, count, scSeriesCallback, getList); if (cond != TBL_NORMAL) return COND_PushCondition(FIS_COND(FIS_STUDYGETFAILED), "(FIS)getSCSeriesRecord"); if (r != NULL) *r = scSeries; if (listFlag & FIS_K_SCSERIES_IMAGELIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->ImageList = LST_Create(); cond = getSCImageRecord(h, FIS_K_SCSERIES, p->SerInsUID, 0, p->ImageList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } return FIS_NORMAL; }
static CONDITION getStudyComponentRecord(PRIVATE_HANDLE * h, FIS_DATA_TYPE criteriaType, char *uid, long listFlag, LST_HEAD * getList, FIS_STUDYCOMPONENTRECORD * r, long *count) { CONDITION cond; TBL_CRITERIA criteria[2]; FIS_STUDYCOMPONENTRECORD *p; static TBL_FIELD fields[] = { {TBL_FIELD_STRING("StuComUID", studyComponent.StuComUID)}, {TBL_FIELD_STRING("StuInsUID", studyComponent.StuInsUID)}, {TBL_FIELD_STRING("Mod", studyComponent.Mod)}, {TBL_FIELD_STRING("StuDes", studyComponent.StuDes)}, {TBL_FIELD_STRING("ProCodVal", studyComponent.ProCodVal)}, {TBL_FIELD_STRING("ProCodSchDes", studyComponent.ProCodSchDes)}, {TBL_FIELD_STRING("ProCodMea", studyComponent.ProCodMea)}, {TBL_FIELD_STRING("StuComStaID", studyComponent.StuComStaID)}, {TBL_FIELD_STRING("StuID", studyComponent.StuID)}, {NULL}, }; criteria[0].FieldName = criteria[1].FieldName = NULL; if (uid != NULL) { if (uid[0] != '\0') { if (criteriaType == FIS_K_STUDY) { TBL_CRITERIA_LOAD_BYTE(criteria[0], "StuInsUID", uid, TBL_STRING, TBL_EQUAL); } else { TBL_CRITERIA_LOAD_BYTE(criteria[0], "StuComUID", uid, TBL_STRING, TBL_EQUAL); } } } (void) memset(&studyComponent, 0, sizeof(studyComponent)); studyComponent.Type = FIS_K_STUDYCOMPONENT; cond = TBL_Select(&h->studyComponentHandle, criteria, fields, count, studyComponentCallback, getList); if (cond != TBL_NORMAL) return COND_PushCondition(FIS_COND(FIS_STUDYGETFAILED), "(FIS)getStudyRecord"); if (r != NULL) *r = studyComponent; if (listFlag & FIS_K_STUDYCOMP_SERIESLIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->SeriesList = LST_Create(); p->Flag |= FIS_K_STUDYCOMP_SERIESLIST; cond = getSCSeriesRecord(h, FIS_K_STUDYCOMPONENT, p->StuComUID, FIS_K_SCSERIES_IMAGELIST, p->SeriesList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } return FIS_NORMAL; }
static CONDITION selectStudyRecord(PRIVATE_HANDLE * h, FIS_CRITERIA_TYPE criteriaType, const char *criteriaString, long listFlag, LST_HEAD * getList, FIS_STUDYRECORD * r, long *count) { CONDITION cond = FIS_NORMAL; TBL_CRITERIA criteria[2]; char localString[1024]; FIS_STUDYRECORD *p; static TBL_FIELD fields[] = { {TBL_FIELD_STRING("PatUID", study.PatUID)}, {TBL_FIELD_STRING("StuInsUID", study.StuInsUID)}, {TBL_FIELD_STRING("VisUID", study.VisUID)}, {TBL_FIELD_STRING("AccNum", study.AccNum)}, {TBL_FIELD_STRING("StuID", study.StuID)}, {"SchStuStaDat", TBL_SIGNED4, sizeof(studyDate), sizeof(studyDate), 0, (void *) &studyDate}, {"SchStuStaTim", TBL_FLOAT4, sizeof(studyTime), sizeof(studyTime), 0, (void *) &studyTime}, {TBL_FIELD_STRING("SchStuLoc", study.SchStuLoc)}, {TBL_FIELD_STRING("ProDes", study.ProDes)}, {TBL_FIELD_STRING("StuStaID", study.StuStaID)}, {NULL}, }; criteria[0].FieldName = criteria[1].FieldName = NULL; strcpy(localString, criteriaString); switch (criteriaType) { case FIS_K_ACCESSION: TBL_CRITERIA_LOAD_BYTE(criteria[0], "AccNum", localString, TBL_STRING, TBL_EQUAL); break; default: cond = 0; /* Repair */ } if (cond != FIS_NORMAL) return cond; (void) memset(&study, 0, sizeof(study)); study.Type = FIS_K_STUDY; cond = TBL_Select(&h->studyHandle, criteria, fields, count, studyCallback, getList); if (cond != TBL_NORMAL) return COND_PushCondition(FIS_COND(FIS_STUDYGETFAILED), "(FIS)getStudyRecord"); if (r != NULL) *r = study; if (listFlag & FIS_K_STU_STUDYCOMPONENTLIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->StudyComponentList = LST_Create(); p->Flag |= FIS_K_STU_STUDYCOMPONENTLIST; cond = getStudyComponentRecord(h, FIS_K_STUDY, p->StuInsUID, 0, p->StudyComponentList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } if (listFlag & FIS_K_STU_RESULTSLIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->ResultsList = LST_Create(); p->Flag |= FIS_K_STU_RESULTSLIST; cond = getResultsRecord(h, FIS_K_STUDY, p->StuInsUID, 0, p->ResultsList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } return FIS_NORMAL; }
static CONDITION getPatientRecord(PRIVATE_HANDLE * h, FIS_DATA_TYPE criteriaType, char *uid, long listFlag, LST_HEAD * getList, FIS_PATIENTRECORD * r, long *count) { CONDITION cond; TBL_CRITERIA criteria[2]; FIS_PATIENTRECORD * p; static TBL_FIELD fields[] = { {"PatID", TBL_STRING, sizeof(patient.PatID), sizeof(patient.PatID), 0, (void *) &patient.PatID[0]}, {"PatUID", TBL_STRING, sizeof(patient.PatUID), sizeof(patient.PatUID), 0, (void *) &patient.PatUID[0]}, {"PatNam", TBL_STRING, sizeof(patient.PatNam), sizeof(patient.PatNam), 0, (void *) &patient.PatNam[0]}, {"PatSex", TBL_STRING, sizeof(patient.PatSex), sizeof(patient.PatSex), 0, (void *) &patient.PatSex[0]}, {"PatBirDat", TBL_SIGNED4, sizeof(patientBD), sizeof(patientBD), 0, (void *) &patientBD}, {NULL}, }; criteria[0].FieldName = criteria[1].FieldName = NULL; if (uid != NULL) { if (uid[0] != '\0') { TBL_CRITERIA_LOAD_BYTE(criteria[0], "PatUID", uid, TBL_STRING, TBL_EQUAL); } } memset(&patient, 0, sizeof(patient)); patient.Type = FIS_K_PATIENT; cond = TBL_Select(&h->patientHandle, criteria, fields, count, patientCallback, getList); if (cond != TBL_NORMAL) return COND_PushCondition(FIS_COND(FIS_PATIENTGETFAILED), "(FIS)getPatientRecord"); if (r != NULL) *r = patient; if (listFlag & FIS_K_PAT_STUDYLIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->StudyList = LST_Create(); p->Flag |= FIS_K_PAT_STUDYLIST; cond = getStudyRecord(h, FIS_K_PATIENT, p->PatUID, 0, p->StudyList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } /* if (listFlag & FIS_K_PAT_VISITLIST) { if (getList != NULL) { p = LST_Head(&getList); (void) LST_Position(&getList, p); } else p = r; while (p != NULL) { p->VisitList = LST_Create(); p->Flag |= FIS_K_PAT_VISITLIST; cond = getVisitRecord(h, FIS_K_PATIENT, p->PatUID, 0, p->VisitList, NULL, NULL); if (cond != FIS_NORMAL) return cond; if (getList != NULL) p = LST_Next(&getList); else p = NULL; } } */ return FIS_NORMAL; }
CONDITION SRV_AcceptServiceClass(DUL_PRESENTATIONCONTEXT * requestedCtx, DUL_SC_ROLE role, DUL_ASSOCIATESERVICEPARAMETERS * params) { int index; CTNBOOLEAN abstractFound = FALSE; CONDITION cond, rtnCond = SRV_NORMAL; DUL_PRESENTATIONCONTEXT * ctx; DUL_TRANSFERSYNTAX * transfer; if (params->acceptedPresentationContext == NULL) { params->acceptedPresentationContext = LST_Create(); if (params->acceptedPresentationContext == NULL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_AcceptServiceClass"); } for (index = 0; index < (int) DIM_OF(syntaxList) && !abstractFound; index++) { if (strcmp(requestedCtx->abstractSyntax, syntaxList[index]) == 0) abstractFound = TRUE; } if (abstractFound){ char* xferSyntaxes[] = { DICOM_TRANSFERLITTLEENDIAN }; transfer = matchProposedXferSyntax(requestedCtx, "ACCEPT/XFER", xferSyntaxes, 1); if (transfer == NULL) { cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, DUL_SC_ROLE_DEFAULT, requestedCtx->presentationContextID, DUL_PRESENTATION_REJECT_TRANSFER_SYNTAX, requestedCtx->abstractSyntax, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIAN, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptServiceClass"); (void) COND_PushCondition(SRV_UNSUPPORTEDSERVICE, SRV_Message(SRV_UNSUPPORTEDSERVICE), requestedCtx->abstractSyntax, "SRV_AcceptServiceClass"); rtnCond = COND_PushCondition(SRV_PRESENTATIONCTXREJECTED, SRV_Message(SRV_PRESENTATIONCTXREJECTED), requestedCtx->abstractSyntax, "SRV_AcceptServiceClass"); } else { cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, role, requestedCtx->presentationContextID, DUL_PRESENTATION_ACCEPT, requestedCtx->abstractSyntax, transfer->transferSyntax, transfer->transferSyntax, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptServiceClass"); } #if 0 if ((transfer = LST_Head(&requestedCtx->proposedTransferSyntax)) == NULL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_AcceptServiceClass"); (void) LST_Position(&requestedCtx->proposedTransferSyntax, transfer); while (!transferFound && (transfer != NULL)) { if (strcmp(transfer->transferSyntax, DICOM_TRANSFERLITTLEENDIAN) == 0){ transferFound = TRUE; }else{ transfer = LST_Next(&requestedCtx->proposedTransferSyntax); } } if (transferFound) { cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, role, requestedCtx->presentationContextID, DUL_PRESENTATION_ACCEPT, requestedCtx->abstractSyntax, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIAN, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptServiceClass"); }else{ cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, DUL_SC_ROLE_DEFAULT, requestedCtx->presentationContextID, DUL_PRESENTATION_REJECT_TRANSFER_SYNTAX, requestedCtx->abstractSyntax, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIAN, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptServiceClass"); (void) COND_PushCondition(SRV_UNSUPPORTEDTRANSFERSYNTAX, SRV_Message(SRV_UNSUPPORTEDTRANSFERSYNTAX), requestedCtx->abstractSyntax, "SRV_AcceptServiceClass"); rtnCond = COND_PushCondition(SRV_PRESENTATIONCTXREJECTED, SRV_Message(SRV_PRESENTATIONCTXREJECTED), requestedCtx->abstractSyntax, "SRV_AcceptServiceClass"); } #endif }else{ cond = DUL_MakePresentationCtx(&ctx, requestedCtx->proposedSCRole, DUL_SC_ROLE_DEFAULT, requestedCtx->presentationContextID, DUL_PRESENTATION_REJECT_ABSTRACT_SYNTAX, requestedCtx->abstractSyntax, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIAN, NULL); if (cond != DUL_NORMAL) return COND_PushCondition(SRV_PRESENTATIONCONTEXTERROR, SRV_Message(SRV_PRESENTATIONCONTEXTERROR), "SRV_AcceptServiceClass"); (void) COND_PushCondition(SRV_UNSUPPORTEDSERVICE, SRV_Message(SRV_UNSUPPORTEDSERVICE), requestedCtx->abstractSyntax, "SRV_AcceptServiceClass"); rtnCond = COND_PushCondition(SRV_PRESENTATIONCTXREJECTED, SRV_Message(SRV_PRESENTATIONCTXREJECTED), requestedCtx->abstractSyntax, "SRV_AcceptServiceClass"); } cond = LST_Enqueue(¶ms->acceptedPresentationContext, ctx); if (cond != LST_NORMAL) return COND_PushCondition(SRV_LISTFAILURE, SRV_Message(SRV_LISTFAILURE), "SRV_AcceptServiceClass"); /* pdvList.count = 0; */ return rtnCond; }
static void selectSeries(llist entries) { CONDITION cond; char dbKey[64]; char studyUID[65]; char seriesUID[65]; IDB_Query series; QUERY_LIST_ITEM *item; IDB_InstanceListElement *instancePtr; unsigned long byteCount = 0; char password[64]; DMAN_HANDLE *controlHandle; LST_HEAD *destinationList; openCTN(&controlHandle); strcpy(dbKey, cgi_val(entries, "DBKey")); strcpy(studyUID, cgi_val(entries, "StudyUID")); strcpy(seriesUID, cgi_val(entries, "SeriesUID")); strcpy(password, cgi_val(entries, "password")); TBL_SetOption("OPEN_SPEEDUP"); cond = searchOneSeries(dbKey, studyUID, seriesUID, &series); html_header(); html_begin_body_options("CTN Archive: Series Management", "bgcolor=#ffffff"); printf("<table>\n"); printf("<TR><TH align=right>Name: <TH align=left>%s</TR>\n", series.patient.PatNam); printf("<TR><TH align=right>Date of Birth: <TH align=left>%s</TR>\n", series.patient.PatBirDat); printf("<TR><TH align=right>Series Number: <TH align=left>%s</TR>\n", series.series.SerNum); printf("<TR><TH align=right>Image Count: <TH align=left>%d</TR>\n", series.series.NumSerRelIma); printf("</table>\n"); printf("<form method=GET action=""archive_agent.cgi"">\n"); printf("<input type=hidden name=DBKey value=%s>\n", dbKey); printf("<input type=hidden name=StudyUID value=%s>\n", studyUID); printf("<input type=hidden name=SeriesUID value=%s>\n", seriesUID); printf("<input type=hidden name=password value=%s>\n", password); { DMAN_VIDEOIMAGEDEST *video; destinationList = LST_Create(); cond = listOfDestinations(&controlHandle, destinationList); printf("<select name=DestinationApplication size=10>\n"); video = LST_Dequeue(&destinationList); while (video != NULL) { /*char tmp[1024];*/ DMAN_APPLICATIONENTITY ae; memset(&ae, 0, sizeof(ae)); ae.Type = DMAN_K_APPLICATIONENTITY; DMAN_LookupApplication(&controlHandle, video->RespondingTitle, &ae); /*sprintf(tmp, "%17s %s", ae.Title, ae.Title, ae.Node, ae.Comment);*/ printf("<option value=""%s"">%16s %15s %d %s\n", /* ae.Title,*/ video->RespondingTitle, ae.Title, ae.Node, ae.Port, ae.Comment); free(video); video = LST_Dequeue(&destinationList); } printf("</select>\n"); } LST_Destroy(&destinationList); printf("<br>\n"); printf("<input type=submit value=""MoveSeries"" name=submitSearch>\n"); printf("</form>\n"); html_end(); }
int v_buildSequence(DCM_OBJECT ** object, SQ_TYPE type) { int index = 0; int i; LST_HEAD *l; DCM_ELEMENT *e; CONDITION cond; SQ_REFPATIENTSOPINSTANCEUID *patient; SQ_REFSTUDYSOPINSTANCEUID *study; SQ_REQPROCEDURECODE *code; void *pointer; static SQ_MAP_SOP sops[] = { {SQ_K_REFPATIENTSOPINSTANCEUID, DICOM_SOPCLASSDETACHEDPATIENTMGMT, &(p.RPSequenceCount), sizeof(SQ_REFPATIENTSOPINSTANCEUID)}, {SQ_K_REFSTUDYSOPINSTANCEUID, DICOM_SOPCLASSDETACHEDSTUDYMGMT, &(p.RSSequenceCount), sizeof(SQ_REFSTUDYSOPINSTANCEUID)}, {SQ_K_ADMITDIAGNOSISCODE, "", &(p.ADCSequenceCount), sizeof(SQ_REQPROCEDURECODE)}, {SQ_K_DISCHARGEDIAGNOSISCODE, "", &(p.DDCSequenceCount), sizeof(SQ_REQPROCEDURECODE)}, }; l = LST_Create(); if (l == NULL) return -1; for (i = 0; i < (int) DIM_OF(sops) && sops[i].type != type; i++); if (i >= (int) DIM_OF(sops)) return -1; while (index < *(sops[i].counter)) { if ((pointer = malloc(sops[i].size)) == NULL) return -1; switch (type) { case SQ_K_REFPATIENTSOPINSTANCEUID: patient = (SQ_REFPATIENTSOPINSTANCEUID *) pointer; patient->type = type; sprintf(patient->referencedSOPClassUID, "%s", sops[i].sopclass); sprintf(patient->referencedSOPInstanceUID, "%s", p.RPSequence[index]); break; case SQ_K_REFSTUDYSOPINSTANCEUID: study = (SQ_REFSTUDYSOPINSTANCEUID *) pointer; study->type = type; sprintf(study->referencedSOPClassUID, "%s", sops[i].sopclass); sprintf(study->referencedSOPInstanceUID, "%s", p.RSSequence[index]); break; case SQ_K_ADMITDIAGNOSISCODE: code = (SQ_REQPROCEDURECODE *) pointer; code->type = type; strcpy(code->codeValue, p.ADCSequence[index].CodeValue); strcpy(code->codingSchemeDesignator, p.ADCSequence[index].CodingSchemeDesignator); strcpy(code->codeMeaning, p.ADCSequence[index].CodeMeaning); break; case SQ_K_DISCHARGEDIAGNOSISCODE: code = (SQ_REQPROCEDURECODE *) pointer; code->type = type; strcpy(code->codeValue, p.DDCSequence[index].CodeValue); strcpy(code->codingSchemeDesignator, p.DDCSequence[index].CodingSchemeDesignator); strcpy(code->codeMeaning, p.DDCSequence[index].CodeMeaning); break; } if (LST_Enqueue(&l, pointer) != LST_NORMAL) return -2; index++; } cond = SQ_BuildSequence(&l, sops[i].type, &e); if (cond != SQ_NORMAL) { COND_DumpConditions(); fprintf(stderr, "SQ_BuildSequence failed \n"); return -1; } cond = DCM_AddElement(object, e); if (cond != DCM_NORMAL) { COND_DumpConditions(); fprintf(stderr, "DCM_AddElement failed \n"); return -1; } return 0; /* if (type == REFPATIENTSQ) { while (index < p.RPSequenceCount) { patient = malloc(sizeof(*patient)); if (patient == NULL) return -1; patient->type = SQ_K_REFPATIENTSOPINSTANCEUID; sprintf(patient->referencedSOPClassUID, "%s", DICOM_SOPCLASSDETACHEDPATIENTMGMT); sprintf(patient->referencedSOPInstanceUID, "%s", p.RPSequence[index]); LST_Enqueue(&l, patient); index++; } cond = SQ_BuildSequence(&l, SQ_K_REFPATIENTSOPINSTANCEUID, &e); if (cond != SQ_NORMAL) { COND_DumpConditions(); fprintf(stderr, "SQ_BuildSequence failed \n"); return -1; } cond = DCM_AddElement(object, e); if (cond != DCM_NORMAL) { COND_DumpConditions(); fprintf(stderr, "DCM_AddElement failed \n"); return -1; } return 0; } if (type == REFSTUDYSQ) { while (index < p.RSSequenceCount) { study = malloc(sizeof(*study)); if (study == NULL) return -1; study->type = SQ_K_REFSTUDYSOPINSTANCEUID; sprintf(study->referencedSOPClassUID, "%s", DICOM_SOPCLASSDETACHEDSTUDYMGMT); sprintf(study->referencedSOPInstanceUID, "%s", p.RSSequence[index]); LST_Enqueue(&l, study); index++; } cond = SQ_BuildSequence(&l, SQ_K_REFSTUDYSOPINSTANCEUID, &e); if (cond != SQ_NORMAL) { COND_DumpConditions(); fprintf(stderr, "SQ_BuildSequence failed \n"); return -1; } cond = DCM_AddElement(object, e); if (cond != DCM_NORMAL) { COND_DumpConditions(); fprintf(stderr, "DCM_AddElement failed \n"); return -1; } return 1; } */ }
main(int argc, char **argv) { CONDITION cond; LST_HEAD *l, *elementList; DCM_ELEMENT_NODE *n, *elementNode; unsigned short group; CTNBOOLEAN uidDictionary = FALSE; while (--argc > 0 && (*++argv)[0] == '-') { switch (*(argv[0] + 1)) { case 'u': uidDictionary = TRUE; break; default: fprintf(stderr, "Unrecognized option: %s\n", *argv); exit(1); break; } } THR_Init(); if (uidDictionary) { UID_ScanDictionary(uidCallback, 0); THR_Shutdown(); return 0; } l = LST_Create(); if (l == NULL) { THR_Shutdown(); return 1; } elementList = LST_Create(); if (elementList == NULL) { THR_Shutdown(); return 1; } cond = DCM_GroupDictionary(0xffff, &l, groupCallback); if (cond != DCM_NORMAL) { COND_DumpConditions(); THR_Shutdown(); exit(1); } n = LST_Dequeue(&l); while (n != NULL) { group = DCM_TAG_GROUP(n->e.tag); printf("%04x %s\n", group, n->e.description); cond = DCM_ElementDictionary(DCM_MAKETAG(group, 0xffff), &elementList, elementCallback); if (cond != DCM_NORMAL) { COND_DumpConditions(); THR_Shutdown(); exit(1); } elementNode = LST_Dequeue(&elementList); while (elementNode != NULL) { printf(" %04x %04x %s %s\n", DCM_TAG_GROUP(elementNode->e.tag), DCM_TAG_ELEMENT(elementNode->e.tag), translate(elementNode->e.representation), elementNode->e.description); free(elementNode); elementNode = LST_Dequeue(&elementList); } free(n); n = LST_Dequeue(&l); } THR_Shutdown(); return 0; }
int r_buildSequence(DCM_OBJECT ** object, SQ_TYPE type) { int index = 0; int i; LST_HEAD *l; DCM_ELEMENT *e; CONDITION cond; SQ_REFINTERPRETATIONSOPINSTANCEUID *interp; SQ_REFSTUDYSOPINSTANCEUID *study; void *pointer; static SQ_MAP_SOP sops[] = { {SQ_K_REFINTERPRETATIONSOPINSTANCEUID, DICOM_SOPCLASSDETACHEDINTERPRETMGMT, &(p.RISequenceCount), sizeof(SQ_REFINTERPRETATIONSOPINSTANCEUID)}, {SQ_K_REFSTUDYSOPINSTANCEUID, DICOM_SOPCLASSDETACHEDSTUDYMGMT, &(p.RSSequenceCount), sizeof(SQ_REFSTUDYSOPINSTANCEUID)}, }; l = LST_Create(); if (l == NULL) return -1; for (i = 0; i < (int) DIM_OF(sops) && sops[i].type != type; i++); if (i >= (int) DIM_OF(sops)) return -1; while (index < *(sops[i].counter)) { if ((pointer = malloc(sops[i].size)) == NULL) return -1; switch (type) { case SQ_K_REFINTERPRETATIONSOPINSTANCEUID: interp = (SQ_REFINTERPRETATIONSOPINSTANCEUID *) pointer; interp->type = SQ_K_REFINTERPRETATIONSOPINSTANCEUID; sprintf(interp->referencedSOPClassUID, "%s", sops[i].sopclass); sprintf(interp->referencedSOPInstanceUID, "%s", p.RISequence[index]); break; case SQ_K_REFSTUDYSOPINSTANCEUID: study = (SQ_REFSTUDYSOPINSTANCEUID *) pointer; study->type = SQ_K_REFSTUDYSOPINSTANCEUID; sprintf(study->referencedSOPClassUID, "%s", sops[i].sopclass); sprintf(study->referencedSOPInstanceUID, "%s", p.RSSequence[index]); break; } if (LST_Enqueue(&l, pointer) != LST_NORMAL) return -2; index++; } cond = SQ_BuildSequence(&l, sops[i].type, &e); if (cond != SQ_NORMAL) { COND_DumpConditions(); fprintf(stderr, "SQ_BuildSequence failed \n"); return -1; } cond = DCM_AddElement(object, e); if (cond != DCM_NORMAL) { COND_DumpConditions(); fprintf(stderr, "DCM_AddElement failed \n"); return -1; } return 0; /* if (!strcmp(DICOM_SOPCLASSDETACHEDINTERPRETMGMT, sopclass)) { while (index < p.RISequenceCount) { interp = malloc(sizeof(*interp)); if (interp == NULL) return -1; interp->type = SQ_K_REFINTERPRETATIONSOPINSTANCEUID; sprintf(interp->referencedSOPClassUID, "%s", sopclass); sprintf(interp->referencedSOPInstanceUID, "%s", p.RISequence[index]); LST_Enqueue(&l, interp); index++; } cond = SQ_BuildSequence(&l, SQ_K_REFINTERPRETATIONSOPINSTANCEUID, &e); if (cond != SQ_NORMAL) { COND_DumpConditions(); fprintf(stderr, "SQ_BuildSequence failed \n"); return -1; } cond = DCM_AddElement(object, e); if (cond != DCM_NORMAL) { COND_DumpConditions(); fprintf(stderr, "DCM_AddElement failed \n"); return -1; } return 0; } if (!strcmp(DICOM_SOPCLASSDETACHEDSTUDYMGMT, sopclass)) { while (index < p.RSSequenceCount) { study = malloc(sizeof(*study)); if (study == NULL) return -1; study->type = SQ_K_REFSTUDYSOPINSTANCEUID; sprintf(study->referencedSOPClassUID, "%s", sopclass); sprintf(study->referencedSOPInstanceUID, "%s", p.RSSequence[index]); LST_Enqueue(&l, study); index++; } cond = SQ_BuildSequence(&l, SQ_K_REFSTUDYSOPINSTANCEUID, &e); if (cond != SQ_NORMAL) { COND_DumpConditions(); fprintf(stderr, "SQ_BuildSequence failed \n"); return -1; } cond = DCM_AddElement(object, e); if (cond != DCM_NORMAL) { COND_DumpConditions(); fprintf(stderr, "DCM_AddElement failed \n"); return -1; } return 1; } */ }
/* * ======== RMM_create ======== */ DSP_STATUS RMM_create(struct RMM_TargetObj **pTarget, struct RMM_Segment segTab[], u32 numSegs) { struct RMM_Header *hptr; struct RMM_Segment *sptr, *tmp; struct RMM_TargetObj *target; s32 i; DSP_STATUS status = DSP_SOK; DBC_Require(pTarget != NULL); DBC_Require(numSegs == 0 || segTab != NULL); GT_3trace(RMM_debugMask, GT_ENTER, "RMM_create(0x%lx, 0x%lx, 0x%lx)\n", pTarget, segTab, numSegs); /* Allocate DBL target object */ MEM_AllocObject(target, struct RMM_TargetObj, RMM_TARGSIGNATURE); if (target == NULL) { GT_0trace(RMM_debugMask, GT_6CLASS, "RMM_create: Memory allocation failed\n"); status = DSP_EMEMORY; } if (DSP_FAILED(status)) goto func_cont; target->numSegs = numSegs; if (!(numSegs > 0)) goto func_cont; /* Allocate the memory for freelist from host's memory */ target->freeList = MEM_Calloc(numSegs * sizeof(struct RMM_Header *), MEM_PAGED); if (target->freeList == NULL) { GT_0trace(RMM_debugMask, GT_6CLASS, "RMM_create: Memory allocation failed\n"); status = DSP_EMEMORY; } else { /* Allocate headers for each element on the free list */ for (i = 0; i < (s32) numSegs; i++) { target->freeList[i] = MEM_Calloc(sizeof(struct RMM_Header), MEM_PAGED); if (target->freeList[i] == NULL) { GT_0trace(RMM_debugMask, GT_6CLASS, "RMM_create: Memory " "allocation failed\n"); status = DSP_EMEMORY; break; } } /* Allocate memory for initial segment table */ target->segTab = MEM_Calloc(numSegs * sizeof(struct RMM_Segment), MEM_PAGED); if (target->segTab == NULL) { GT_0trace(RMM_debugMask, GT_6CLASS, "RMM_create: Memory allocation failed\n"); status = DSP_EMEMORY; } else { /* Initialize segment table and free list */ sptr = target->segTab; for (i = 0, tmp = segTab; numSegs > 0; numSegs--, i++) { *sptr = *tmp; hptr = target->freeList[i]; hptr->addr = tmp->base; hptr->size = tmp->length; hptr->next = NULL; tmp++; sptr++; } } } func_cont: /* Initialize overlay memory list */ if (DSP_SUCCEEDED(status)) { target->ovlyList = LST_Create(); if (target->ovlyList == NULL) { GT_0trace(RMM_debugMask, GT_6CLASS, "RMM_create: Memory allocation failed\n"); status = DSP_EMEMORY; } } if (DSP_SUCCEEDED(status)) { *pTarget = target; } else { *pTarget = NULL; if (target) RMM_delete(target); } DBC_Ensure((DSP_SUCCEEDED(status) && MEM_IsValidHandle((*pTarget), RMM_TARGSIGNATURE)) || (DSP_FAILED(status) && *pTarget == NULL)); return status; }