static void activateCB_menu1_p1_b4( Widget wgt, XtPointer cd, XtPointer cb) { Widget UxWidget = wgt; XtPointer UxClientData = cd; XtPointer UxCallbackArg = cb; /* * activateCP_menu1_p1_b4 * * * Purpose: * This subroutine closes all the open structures and dicom * Object * before quitting the program * * * Parameter Dictinary: * none * Return Value: * none * * * Notes: * * * Algorithm: * Description of the algorithm (optional) and ant other * notes. * * */ if (ieIE != NULL) (void) IE_Free((void **) &ieIE); /** cond = IE_Free(ieIE); if(cond != IE_NORMAL) (void) COND_DumpConditions();**/ if (ieModule != NULL) (void) IE_Free((void **) &ieModule); /** cond = IE_Free(ieModule); if(cond != IE_NORMAL) (void) COND_DumpConditions();**/ if (ieAttr != NULL) (void) IE_Free((void **) &ieAttr); /** cond = IE_Free(ieAttr); if(cond != IE_NORMAL) (void) COND_DumpConditions();**/ if (ieObject != NULL) (void) IE_Free((void **) &ieObject); /** cond = IE_Free(ieObject); if(cond != IE_NORMAL) (void) COND_DumpConditions();**/ (void) DCM_CloseObject(&queryObject); exit(0); }
static CONDITION storageCallback(MSG_C_STORE_REQ * request, MSG_C_STORE_RESP * response, unsigned long received, unsigned long estimate, /* DCM_OBJECT ** object, STORAGE_PARAMS * params, */ DCM_OBJECT ** object, void *paramsPtr, DUL_PRESENTATIONCONTEXT * pc) { CONDITION cond = 0; IE_OBJECT * ieObject; /* The definition and assignment help satisfy prototypes for this callback ** function (defined by dicom_services.h) */ STORAGE_PARAMS *params; params = (STORAGE_PARAMS *) paramsPtr; if (!silent) printf("%8d bytes received of %8d estimated \n", received, estimate); if (!silent && (object != NULL)) (void) DCM_DumpElements(object, 0); if (object != NULL) { if (doVerification) { cond = IE_ExamineObject(object, &ieObject); (void) IE_Free((void **) &ieObject); if (cond != IE_NORMAL) { /* The image does not satisfy */ /* Part 3 requirements */ response->status = MSG_K_C_STORE_DATASETNOTMATCHSOPCLASSERROR; return SRV_NORMAL; } } cond = storeImage(params->handle, params->fileName, params->transferSyntax, request->classUID, params->owner, params->groupName, params->priv, object); } if (response != NULL) { if (cond == APP_NORMAL) response->status = MSG_K_SUCCESS; else response->status = MSG_K_C_STORE_OUTOFRESOURCES; } return SRV_NORMAL; }
int main(int argc, char **argv) { CONDITION cond; /* Return value from DUL and ACR routines */ DCM_OBJECT * object; /* Handle to the information object */ DCM_ELEMENT element; /* Handle to the DCM_ELEMENT */ IE_OBJECT * ieObject; /* Handle to the IE_OBJECT object */ IE_INFORMATIONENTITY * ieIE, *ie_node; /* Handle to IE_INFORMATIONENTITY */ LST_HEAD * ie_head, *mod_head, *attr_head; /* Handle to the LST_HEAD */ IE_MODULE * ieModule, *mod_node; /* Handle to IE_MODULE */ IE_ATTRIBUTE * attr_node; /* Handle to IE_ATTRIBUTE */ CTNBOOLEAN verbose = FALSE; /* For debugging purpose */ CTNBOOLEAN flag; /* Return value from findElement routine */ unsigned long options = DCM_ORDERLITTLEENDIAN; /* Byte order in data streams */ char *file; /* The image file name */ char UID[90]; /* The SOP Class UID of the image file */ U32 length; /* Length of the data field of DCM_ELEMENT */ int ie_loop, mod_loop, attr_loop, j, k, i;/* Iteration variables */ while (--argc > 0 && (*++argv)[0] == '-') { switch (*(argv[0] + 1)) { case 'v': verbose = TRUE; break; case 'b': options &= ~DCM_ORDERMASK; options |= DCM_ORDERBIGENDIAN; break; case 't': options &= ~DCM_FILEFORMATMASK; options |= DCM_PART10FILE; break; default: break; } } if (argc < 1) usageerror(); file = *argv; THR_Init(); DCM_Debug(verbose); /* Open a DICOM object file and put the contents into the memory represented by the information object. */ cond = DCM_OpenFile(file, options, &object); if (cond != DCM_NORMAL && ((options & DCM_PART10FILE) == 0)) { COND_DumpConditions(); (void) DCM_CloseObject(&object); (void) COND_PopCondition(TRUE); fprintf(stderr, "Could not open %s as expected. Trying Part 10 format.\n", file); cond = DCM_OpenFile(file, options | DCM_PART10FILE, &object); } if (cond != DCM_NORMAL) { COND_DumpConditions(); THR_Shutdown(); return 1; }else{ printf("file is successfully opened!\n"); /* Call IE_ExamineObject to examine this DCM object. */ cond = IE_ExamineObject(&object, &ieObject); if (cond == IE_ILLEGALDCMOBJECT || cond == IE_LISTFAILURE || cond == IE_MALLOCFAILURE){ COND_DumpConditions(); }else{ /* Print the IE_OBJECT object. */ strcpy(UID, ieObject->classUID); printObject(ieObject); /* Examine each IE on the list. */ ie_head = ieObject->ieList; ie_loop = LST_Count(&ie_head); for (i = 0; i < ie_loop; i++) { ie_node = LST_Pop(&ie_head); cond = IE_ExamineInformationEntity(&object, ie_node->ieType, &ieIE); /* Print each IE_IE. */ printIE(ieIE); /* Examine each module on the list. */ mod_head = ieIE->moduleList; mod_loop = LST_Count(&mod_head); for (k = 0; k < mod_loop; k++) { mod_node = LST_Pop(&mod_head); cond = IE_ExamineModule(&object, ieIE->ieType, mod_node->moduleType, &ieModule); printModule(ieModule); /* Print each IE_ATTRIBUTE. */ attr_head = ieModule->attributeList; attr_loop = LST_Count(&attr_head); for (j = 0; j < attr_loop; j++) { attr_node = LST_Pop(&attr_head); printIEAttribute(attr_node); free(attr_node); } free(mod_node); cond = IE_Free((void **) &ieModule); } free(ie_node); cond = IE_Free((void **) &ieIE); } cond = IE_Free((void **) &ieObject); /* Check to see the status of the Information Entities. */ cond = IE_ExamineObject(&object, &ieObject); printf("\n%s requirements:\n", ieObject->objectDescription); ie_head = ieObject->ieList; ie_loop = LST_Count(&ie_head); for (i = 0; i < ie_loop; i++) { ie_node = LST_Pop(&ie_head); if (ie_node->requirement == IE_K_REQUIRED) printIE(ie_node); free(ie_node); } cond = IE_Free((void **) &ieObject); /* Check to see the status of the Information Entity and status of the Modules within them. */ cond = IE_ExamineObject(&object, &ieObject); printf("\n%s requirements:\n", ieObject->objectDescription); ie_head = ieObject->ieList; ie_loop = LST_Count(&ie_head); for (i = 0; i < ie_loop; i++) { ie_node = LST_Pop(&ie_head); cond = IE_ExamineInformationEntity(&object, ie_node->ieType, &ieIE); if (ie_node->requirement == IE_K_REQUIRED) { printf("\n"); printIE(ieIE); mod_head = ieIE->moduleList; mod_loop = LST_Count(&mod_head); for (k = 0; k < mod_loop; k++) { mod_node = LST_Pop(&mod_head); if (mod_node->requirement == IE_K_REQUIRED) printModule(mod_node); free(mod_node); } } free(ie_node); cond = IE_Free((void **) &ieIE); } cond = IE_Free((void **) &ieObject); /* Check to see the missing attributes if there is any. */ cond = IE_ObjectRequirements(UID, &ieObject); printf("\n Missing required(type1 and type2) attributes: \n"); ie_head = ieObject->ieList; ie_loop = LST_Count(&ie_head); for (i = 0; i < ie_loop; i++) { ie_node = LST_Pop(&ie_head); cond = IE_IERequirements(UID, ie_node->ieType, &ieIE); mod_head = ieIE->moduleList; mod_loop = LST_Count(&mod_head); for (k = 0; k < mod_loop; k++) { mod_node = LST_Pop(&mod_head); cond = IE_ModuleRequirements(UID, ie_node->ieType, mod_node->moduleType, &ieModule); printf(" %s\n", ieModule->moduleDescription); attr_head = ieModule->attributeList; attr_loop = LST_Count(&attr_head); for (j = 0; j < attr_loop; j++) { attr_node = LST_Pop(&attr_head); flag = findElement(object, attr_node->element.tag, &element); cond = DCM_LookupElement(&element); if (cond != DCM_NORMAL) cond = COND_PopCondition(FALSE); if (!flag) { if (attr_node->requirement == IE_K_TYPE1){ printf(" %08x, %s\n", element.tag, element.description); }else if (attr_node->requirement == IE_K_TYPE2){ cond = DCM_GetElementSize(&object, attr_node->element.tag, &length); if (cond != DCM_NORMAL){ cond = COND_PopCondition(FALSE); printf(" %08x, %s\n", element.tag, element.description); } } } } /* finish one module */ free(mod_node); cond = IE_Free((void **) &ieModule); } free(ie_node); cond = IE_Free((void **) &ieIE); } cond = IE_Free((void **) &ieObject); } } /* Free the memory and remove the object handle. */ cond = DCM_CloseObject(&object); if (cond != DCM_NORMAL){ COND_DumpConditions(); }else{ printf("The object is closed successfully.\n"); } THR_Shutdown(); return 0; }
int main(int argc, char **argv) { CONDITION /* Return value from DUL and ACR routines */ cond; IE_OBJECT /* Handle to the IE_OBJECT object */ * ieObject; IE_INFORMATIONENTITY /* Handle to IE_INFORMATIONENTITY */ * ieIE, *ie_node; LST_HEAD /* Handle to the LST_HEAD */ * ie_head, *mod_head, *attr_head; IE_MODULE /* Handle to IE_MODULE */ * ieModule, *mod_node; IE_ATTRIBUTE /* Handle to IE_ATTRIBUTE */ * attr_node; CTNBOOLEAN /* For debugging purpose */ verbose = FALSE; char /* The UID of the image file */ *UID, *SOPClassName; int /* Iteration variables */ ie_loop, mod_loop, attr_loop, i, k, j; if (argc < 1) usageerror(); THR_Init(); DCM_Debug(verbose); while (--argc > 0 && (*++argv)[0] == '-') { switch (*(argv[0] + 1)) { case 'v': verbose = TRUE; break; default: break; } } while (argc-- > 0) { SOPClassName = *argv; (void) *argv++; /* * Find the SOP Class UID according to the SOP Class name. */ UID = lookupUID(SOPClassName); if (UID != NULL) { /* The SOP Class name is legal */ printf("\nRequired IEs and Modules for %s image file:\n", SOPClassName); /* * Find the required IEs. */ cond = IE_ObjectRequirements(UID, &ieObject); if (cond == IE_LISTFAILURE || cond == IE_MALLOCFAILURE || cond == IE_ILLEGALDCMOBJECT) { COND_DumpConditions(); THR_Shutdown(); return (2); } ie_head = ieObject->ieList; ie_loop = LST_Count(&ie_head); for (i = 0; i < ie_loop; i++) { /* * Find all the required Modules. */ ie_node = LST_Pop(&ie_head); printf("%s\n", ie_node->ieDescription); cond = IE_IERequirements(UID, ie_node->ieType, &ieIE); mod_head = ieIE->moduleList; mod_loop = LST_Count(&mod_head); for (k = 0; k < mod_loop; k++) { mod_node = LST_Pop(&mod_head); printf(" %s\n", mod_node->moduleDescription); } cond = IE_Free((void **) &ieIE); } cond = IE_Free((void **) &ieObject); printf("\n"); printf("Required Modules and Attributes for %s image file:\n", SOPClassName); /* * Find all the required IEs. */ cond = IE_ObjectRequirements(UID, &ieObject); if (cond == IE_LISTFAILURE || cond == IE_MALLOCFAILURE || cond == IE_ILLEGALDCMOBJECT) { COND_DumpConditions(); THR_Shutdown(); return (2); } ie_head = ieObject->ieList; ie_loop = LST_Count(&ie_head); for (i = 0; i < ie_loop; i++) { /* * Find all the required Modules. */ ie_node = LST_Pop(&ie_head); cond = IE_IERequirements(UID, ie_node->ieType, &ieIE); mod_head = ieIE->moduleList; mod_loop = LST_Count(&mod_head); for (k = 0; k < mod_loop; k++) { mod_node = LST_Pop(&mod_head); cond = IE_ModuleRequirements(UID, ie_node->ieType, mod_node->moduleType, &ieModule); printf("%s\n", mod_node->moduleDescription); attr_head = ieModule->attributeList; attr_loop = LST_Count(&attr_head); for (j = 0; j < attr_loop; j++) { /* * Find all the mandatory attributes. */ attr_node = LST_Pop(&attr_head); cond = DCM_LookupElement (&(attr_node->element)); printf(" %s\n", attr_node->element.description); } } } } else /* Illegal SOP Class entered by the user */ printf("Illegal SOP Class.\n"); } THR_Shutdown(); return (0); }
static void browseSelectionCB_scrolledList2( Widget wgt, XtPointer cd, XtPointer cb) { Widget UxWidget = wgt; XtPointer UxClientData = cd; XtPointer UxCallbackArg = cb; { /* * scrolledList2 * * * Purpose: * This subroutine examines the selected module, finds a * pointer * to the atrribute-list structure and loads the list of * attributes * in scrolledList3(window) * * * Parameter Dictinary: * cbs input, pointer to the * selected module structure * * * Return Value: * list of attributes loaded in scrolledList3 * * * Notes: * * * Algorithm: * Description of the algorithm (optional) and any * other notes. * * */ XmListCallbackStruct *cbs; char *modname; char buff[80]; int i; int cnt = 0; XmString *strlist; CONDITION cond; cbs = (XmListCallbackStruct *) UxCallbackArg; /* clear scrolledlist3 */ XtVaGetValues(scrolledList3, XmNitemCount, &cnt, XmNitems, &strlist, NULL); if (cnt != 0) { XmListDeleteAllItems(scrolledList3); /* lint -e64 */ XtFree(strlist); /* lint +e64 */ } if (strlen(XmTextGetString(text1)) != 0) XmTextSetString(text1, NULL); if (strlen(XmTextGetString(text2)) != 0) XmTextSetString(text2, NULL); /* if any previous module structure is open, free it */ if (ieModule != NULL) { cond = IE_Free((void **) &ieModule); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(ieModule); /* load scrolledList3 with attributeList */ ieModule = LST_Head(&mod_head); (void) LST_Position(&mod_head, ieModule); for (i = 2; i <= cbs->item_position; i++) ieModule = LST_Next(&mod_head); cond = IE_ExamineModule(&queryObject, ieIE->ieType, ieModule->moduleType, &ieModule); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } attr_head = ieModule->attributeList; MUT_LoadList(scrolledList3, ieModule->attributeList, formatattrieList, buff); } }
static void browseSelectionCB_scrolledList1( Widget wgt, XtPointer cd, XtPointer cb) { Widget UxWidget = wgt; XtPointer UxClientData = cd; XtPointer UxCallbackArg = cb; { /* * scrolledList1 * * * Purpose: * This subrouitne examines the selected information * entity(IE), * finds a pointer to module-list structure and loads * the list of * modules in scrolledList2(window). * * * Parameter Dictionary: * cbs input, pointer to the * selected IE structure * * * Return Value: * list of modules loaded in the scrolledList2 * * * Notes: * * * Algorithm: * Description of the algorithm (optional) and any * other notes. * * */ XmListCallbackStruct *cbs; char *iename; int i; char buff[80]; CONDITION cond; int cnt3 = 0; XmString *strlist3; cbs = (XmListCallbackStruct *) UxCallbackArg; /* if selected a new item from List1(IE), then clear list3 */ XtVaGetValues(scrolledList2, XmNitemCount, &cnt3, XmNitems, &strlist3, NULL); if (cnt3 != 0) { XmListDeleteAllItems(scrolledList2); /* lint -e64 */ XtFree(strlist3); /* lint +e64 */ } XtVaGetValues(scrolledList3, XmNitemCount, &cnt3, XmNitems, &strlist3, NULL); if (cnt3 != 0) { XmListDeleteAllItems(scrolledList3); /* lint -e64 */ XtFree(strlist3); /* lint +e64 */ } /* clear any previosly open structure IE */ if (ieIE != NULL) { cond = IE_Free((void **) &ieIE); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(ieIE); /* clear text widgets */ if (strlen(XmTextGetString(text1)) != 0) XmTextSetString(text1, NULL); if (strlen(XmTextGetString(text2)) != 0) XmTextSetString(text2, NULL); /* pointer to the head-end of the list, ieList */ ieIE = LST_Head(&ie_head); /* makes current the node */ (void) LST_Position(&ie_head, ieIE); /* pointer to the next item */ for (i = 2; i <= cbs->item_position; i++) ieIE = LST_Next(&ie_head); cond = IE_ExamineInformationEntity(&queryObject, ieIE->ieType, &ieIE); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } mod_head = ieIE->moduleList; MUT_LoadList(scrolledList2, ieIE->moduleList, formatmodieList, buff); } }
void openfile(char *filename) { char buff[80], bname[80]; int nitems; int cnt = 0; XmString *strlist; CONDITION cond; /**memset(info, 0 ,sizeof(info)); copyWtext(info);**/ /* show selected patient filename in text widget */ sprintf(bname, "File Selected: %s", filename); XmTextSetString(text3, bname); /* clear the scrolledlist windows, befor opening a new file*/ XtVaGetValues(scrolledList1, XmNitemCount, &cnt, XmNitems, &strlist, NULL); if (cnt != 0) { XmListDeleteAllItems(scrolledList1); /*lint -e64*/ XtFree(strlist); /*lint +e64*/ } XtVaGetValues(scrolledList2, XmNitemCount, &cnt, XmNitems, &strlist, NULL); if (cnt != 0) { XmListDeleteAllItems(scrolledList2); /*lint -e64*/ XtFree(strlist); /*lint +e64*/ } XtVaGetValues(scrolledList3, XmNitemCount, &cnt, XmNitems, &strlist, NULL); if (cnt != 0) { XmListDeleteAllItems(scrolledList3); /*lint -e64*/ XtFree(strlist); /*lint +e64*/ } /* Clear text widgets */ if (strlen(XmTextGetString(text1)) != 0) XmTextSetString(text1, NULL); if (strlen(XmTextGetString(text2)) != 0) XmTextSetString(text2, NULL); if (strlen(XmTextGetString(scrolledText1)) != 0) XmTextSetString(scrolledText1, NULL); if (ieObject != NULL) { cond = IE_Free((void **) &ieObject); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(ieObject); if (ieIE != NULL) { cond = IE_Free((void **) &ieIE); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(ieIE); if (ieModule != NULL) { cond = IE_Free((void **) &ieModule); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(ieModule); if (ieAttr != NULL) { cond = IE_Free((void **) &ieAttr); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(ieAttr); if (queryObject != NULL) { cond = DCM_CloseObject(&queryObject); if (cond != DCM_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } } free(queryObject); kount = kount + 1; printf(" %d, %s\n", kount, filename); cond = DCM_OpenFile(filename, options, &queryObject); if (cond != DCM_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } else { cond = IE_ExamineObject(&queryObject, &ieObject); if (cond != IE_NORMAL) { (void) COND_ExtractConditions(errorstackP); copyWtext(info); (void) COND_PopCondition(clearStack); free(info); } ie_head = ieObject->ieList; MUT_LoadList(scrolledList1, ie_head, formatieList, buff); } free(filename); }