示例#1
0
main(int argc, char **argv)
{
  DCM_OBJECT
	* object;
    CONDITION
	cond;
		char *
	   fileInput;
    CTNBOOLEAN
	verbose = FALSE,
	exitFlag = FALSE,
	formatFlag = FALSE;
    unsigned long
        options = DCM_ORDERLITTLEENDIAN;
    long vmLimit = 0;
    LST_HEAD* fileNames = 0;
    UTL_FILEITEM* p = NULL;

		if (argc < 2)
			usageerror();
		else {
			argv++;
			fileInput = *argv;
		}

    THR_Init();
    DCM_Debug(verbose);

    cond = DCM_OpenFile(fileInput, 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", p->path);
	    cond = DCM_OpenFile(p->path, options | DCM_PART10FILE, &object);
    }
    if (cond == DCM_NORMAL) {
			printf("<?xml version=\"1.0\" ?>\n");
			printf("<Structured_Report>\n");
	    iterateThroughElements(&object, 1);
			printf("</Structured_Report>\n");
    }
    COND_DumpConditions();
    (void) DCM_CloseObject(&object);
    (void) COND_PopCondition(TRUE);

    if (cond != DCM_NORMAL && exitFlag) {
	    THR_Shutdown();
	    exit(1);
    }

#ifdef MALLOC_DEBUG
    malloc_verify(0);
    malloc_shutdown();
#endif
    THR_Shutdown();
    return 0;
}
示例#2
0
文件: iap.c 项目: bhavik86/Dicom
static CONDITION
parseImageInstanceUID(DCM_OBJECT ** object, int *elementCount)
{
    static DCM_FLAGGED_ELEMENT 		localList[] = {
										{DCM_IDSOPINSTANCEUID, DCM_UI, "", 1, sizeof(q.Image.ImageUID), (void *) &q.Image.ImageUID[0], DB_K_QIMAGEUID, &q.Image.Query_Flag},
									};
    CONDITION						cond;
    DCM_ELEMENT						e;
    U32								l;
    char		    				*c;
    int			    				index;

    cond = DCM_GetElementSize(object, DCM_IDSOPINSTANCEUID, &l);
    if (cond != DCM_NORMAL) {
    	(void) COND_PopCondition(FALSE);
    	return IAP_NORMAL;
    }

    cond = DCM_GetElement(object, DCM_IDSOPINSTANCEUID, &e);
    if (cond != DCM_NORMAL) {
    	(void) COND_PopCondition(FALSE);
    	return IAP_NORMAL;
    }

    if (e.multiplicity == 1) {
    	cond = DCM_ParseObject(object, NULL, 0, localList, (int) DIM_OF(localList), elementCount);
    	if (cond != DCM_NORMAL) return COND_PushCondition(IAP_OBJECTACCESSFAILED, IAP_Message(IAP_OBJECTACCESSFAILED), "parseImageInstanceUID");
    	q.Image.Query_Flag |= DB_K_QIMAGEUID;
    	q.Image.ImageMultUIDCount = 0;
    	q.Image.ImageMultUID = NULL;
    }else{
    	c = malloc((l + 1) + (e.multiplicity * sizeof(char *)));
    	if (c == NULL) return COND_PushCondition(IAP_MALLOCFAILURE, IAP_Message(IAP_MALLOCFAILURE), (l + 1) + (e.multiplicity * sizeof(char *)), "parseImageInstanceUID");

    	q.Image.ImageMultUIDCount = e.multiplicity;
    	q.Image.ImageMultUID = (char **) c;
    	c += e.multiplicity * sizeof(char *);

    	e.d.string = c;

    	cond = DCM_ParseObject(object, &e, 1, NULL, 0, elementCount);
    	if (cond != DCM_NORMAL) return COND_PushCondition(IAP_OBJECTACCESSFAILED, IAP_Message(IAP_OBJECTACCESSFAILED), "parseImageInstanceUID");

    	for (index = 0; (unsigned long) index < e.multiplicity; index++) {
    		q.Image.ImageMultUID[index] = c;
    		while ((*c != '\\') && (*c != '\0')){
    			c++;
    		}
    		*c++ = '\0';
    	}
    	q.Image.Query_Flag |= DB_K_QIMAGEMULTUID;
    }
    return IAP_NORMAL;
}
示例#3
0
文件: iap.c 项目: bhavik86/Dicom
CONDITION
IAP_ObjectToQuery(DCM_OBJECT ** object, char *SOPClass, Query * query, int *elementCount)
{
    CONDITION		cond, returnCondition;
    int         	index;
    void        	*ctx;
    U32				l;
    long        	flag;
    static char     queryLevelString[48] = "";	/* Initialize for AIX compiler bug */
    DCM_ELEMENT		queryLevelElement = {DCM_IDQUERYLEVEL, DCM_CS, "", 1, sizeof(queryLevelString), (void *) &queryLevelString[0]};

    *elementCount = 0;
    q.QueryState = 0;
    q.Patient.Query_Flag = 0;
    q.Study.Query_Flag = 0;
    q.Series.Query_Flag = 0;
    q.Image.Query_Flag = 0;

    ctx = NULL;
    returnCondition = IAP_NORMAL;

    cond = DCM_GetElementValue(object, &queryLevelElement, &l, &ctx);
    if (cond != DCM_NORMAL) {
    	if (cond == DCM_ILLEGALOBJECT){
    		return COND_PushCondition(IAP_ILLEGALOBJECT, "IAP_ObjectToQuery");
    	}else{
    		(void) COND_PopCondition(FALSE);
    		(void) COND_PushCondition(IAP_QUERYLEVELMISSING, "IAP_ObjectToQuery");
    		returnCondition = IAP_INCOMPLETEOBJECT;
    	}
    }else{
    	queryLevelString[l] = '\0';
    	if (queryLevelString[l - 1] == ' ') queryLevelString[l - 1] = '\0';

    	for (index = 0; index < DIM_OF(levelMap); index++) {
    		if (strcmp(levelMap[index].queryLevel, queryLevelString) == 0) q.QueryState |= levelMap[index].flag;
    	}
    }

    flag = 0;
    for (index = 0; index < DIM_OF(classMap); index++) {
    	if (strcmp(classMap[index].SOPClass, SOPClass) == 0) flag |= classMap[index].flag;
    }
    if (flag == 0) {
    	(void) COND_PushCondition(IAP_SOPCLASSMISSING, "");
    	returnCondition = IAP_INCOMPLETEOBJECT;
    }
    q.QueryState |= flag;

    cond = DCM_ParseObject(object, NULL, 0, list, (int) DIM_OF(list), elementCount);
    if (cond != DCM_NORMAL)	return COND_PushCondition(IAP_OBJECTACCESSFAILED, IAP_Message(IAP_OBJECTACCESSFAILED), "IAP_ObjectToQuery");

    cond = parseImageInstanceUID(object, elementCount);
    if (cond != IAP_NORMAL)	return cond;

    *query = q;
    return returnCondition;
}
示例#4
0
static void testSOPClasses(DUL_NETWORKKEY* network, const char* classFile,
	const char* callingTitle, const char* sourceHost,
	const char* calledTitle, const char* targetHost, int port) {

    FILE* f = NULL;
    char line[512] = "";
    CONDITION cond = 0;
   DUL_ASSOCIATIONKEY		/* Describes the Association with the Acceptor */
	* association = NULL;
    f = fopen(classFile, "r");
    if (f == NULL) {
	printf("Could not open %s\n", classFile);
	return;
    }
    
    while (fgets(line, sizeof(line), f) != NULL) {
	char sopClassUID[512] = "";
	DUL_ASSOCIATESERVICEPARAMETERS	/* The items which describe this
					 * Association */
	  params = {
	  DICOM_STDAPPLICATIONCONTEXT, "DICOM_TEST", "DICOM_VERIFY",
	    "", 16384, 0, 0, 0,
	    "calling presentation addr", "called presentation addr",
	    NULL, NULL, 0, 0,
	    MIR_IMPLEMENTATIONCLASSUID, MIR_IMPLEMENTATIONVERSIONNAME,
	    "", ""
	};
	sscanf(line, "%s", sopClassUID);

	sprintf(params.calledPresentationAddress, "%s:%d", targetHost, port);
	strcpy(params.callingPresentationAddress, sourceHost);
	strcpy(params.calledAPTitle,  calledTitle);
	strcpy(params.callingAPTitle, callingTitle);
	cond = SRV_RequestServiceClass(sopClassUID, DUL_SC_ROLE_DEFAULT, &params);
	if (cond != SRV_NORMAL) {
	    COND_DumpConditions();
	    THR_Shutdown();
	    exit(1);
	}
	cond = DUL_RequestAssociation(&network, &params, &association);
	if (cond != DUL_NORMAL) {
	    if (cond == DUL_ASSOCIATIONREJECTED) {
		fprintf(stderr, "Association Rejected\n");
		fprintf(stderr, " Result: %2x Source %2x Reason %2x\n",
			params.result, params.resultSource,
			params.diagnostic);
	    }
	    myExit(&association);
	}
	printf(" Success: %s\n", sopClassUID);
	cond = DUL_ReleaseAssociation(&association);
	(void) DUL_ClearServiceParameters(&params);
	COND_PopCondition(TRUE);

    }
    fclose(f);

}
示例#5
0
文件: cparse.c 项目: bhavik86/Dicom
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;
}
示例#6
0
/* establishAssociation
**
** Purpose:
**	Request for the specific service class and then establish an
**	Association
**
** Parameter Dictionary:
**	networkKey		Key describing the network connection
**	queryList		Handle to list of queries
**	moveDestination		Name of destination where images are to be moved
**	sendAssociation		Key describing the Association
**	params			Service parameters describing the Association
**
** Return Values:
**	DUL_NORMAL	on success
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
CONDITION
establishAssociation(DUL_NETWORKKEY ** networkKey,
		     char *destination,
		     DMAN_HANDLE ** handle,
		     DUL_ASSOCIATIONKEY ** sendAssociation,
		     DUL_ASSOCIATESERVICEPARAMETERS * params)
{
    CONDITION cond;
    DMAN_APPLICATIONENTITY ae;
    DMAN_APPLICATIONENTITY criteria;
    long count;

    memset(&criteria, 0, sizeof(criteria));
    criteria.Type = ae.Type = DMAN_K_APPLICATIONENTITY;
    criteria.Flag = DMAN_K_APPLICATION_TITLE;
    strcpy(criteria.Title, destination);
    cond = DMAN_Select(handle, (DMAN_GENERICRECORD *) & ae,
	       (DMAN_GENERICRECORD *) & criteria, NULL, NULL, &count, NULL);
    if (cond != DMAN_NORMAL)
	return 0;
    if (count != 1)
	return 0;

    sprintf(params->calledPresentationAddress, "%s:%-d", ae.Node, ae.Port);

    cond = SRV_RequestServiceClass(DICOM_SOPCLASSSTORAGECOMMITMENTPUSHMODEL,
				   DUL_SC_ROLE_DEFAULT, params);
    if (CTN_INFORM(cond))
	(void) COND_PopCondition(FALSE);
    else if (cond != SRV_NORMAL)
	return 0;		/* repair */

    cond = DUL_RequestAssociation(networkKey, params, sendAssociation);
    if (cond != DUL_NORMAL) {
	printf("Could not establish Association with %s %s %s\n",
	       params->callingAPTitle,
	       params->calledAPTitle,
	       params->calledPresentationAddress);
	COND_DumpConditions();
	return 0;		/* repair */
    }
    return APP_NORMAL;
}
示例#7
0
static CONDITION
openGQ(int qID)
{
    CONDITION
    cond;

    /* Get a new or existing Queue for the GQ operations */
    if (gqueueFlag) {
#ifdef ASG
	cond = GQ_GetQueue(qID, sizeof(GQ_ELEM));
	if (cond != GQ_NORMAL) {
	    (void) COND_PopCondition(TRUE);	/* necessary to clear the
						 * stack since, this is not
						 * an error and any
						 * conditions dumped later,
						 * unnecessarily displays
						 * this message */
	    /* The Q may not be existing, in which case we create one */
	    cond = GQ_InitQueue(qID, 128, sizeof(GQ_ELEM));
	    if (cond != GQ_NORMAL) {
		return COND_PushCondition(APP_ERROR(APP_FAILURE),
					  "GQ_InitQueue", "main");
	    }
	}
	appHandles.gqID = qID;	/* set the gqID field */

	/* Now again invoke GetQueue */
#endif
	/*
	 * We try to open an existing Queue. It is assumed that an
	 * accompanying program viz. print_server_display will be running
	 * with the desired GQ already created
	 */
	cond = GQ_GetQueue(qID, sizeof(GQ_ELEM));
	if (cond != GQ_NORMAL) {
	    return COND_PushCondition(APP_ERROR(APP_FAILURE),
				      "GQ_GetQueue", "main");
	}
    }
    return APP_NORMAL;
}
示例#8
0
文件: set.c 项目: nagyistge/ctn
/* setRequest
**
** Purpose:
**	To build the N-SET response message and send it back to the
**	requesting SCU.
**
** Parameter Dictionary:
**	association	The key which describes the association
**	ctx		Pointer to the context for this command
**	request		Pointer to the N-SET request message
**
** Return Values:
**	SRV_NORMAL under error free conditions
**
**	SRV_CALLBACKABORTEDSERVICE
**	SRV_ILLEGALPARAMETER
**	SRV_NOCALLBACK
**	SRV_NORMAL
**	SRV_OBJECTBUILDFAILED
**	SRV_RESPONSEFAILED
**
** Algorithm:
**	First determine for which SOP Class, the request has arrived.
**	Accordingly call SRV_NSetResponse with the appropriate
**	call back function.
*/
CONDITION
setRequest(DUL_ASSOCIATIONKEY ** association,
	   DUL_PRESENTATIONCONTEXT * ctx, MSG_N_SET_REQ ** request,
	   CTNBOOLEAN * sendBack)
{
    MSG_N_SET_RESP
	setResponse;
    CONDITION
	cond = SRV_NORMAL;

    /* clear the contents of the response message */
    memset((void *) &setResponse, 0, sizeof(MSG_N_SET_RESP));

    /*
     * Here we first need to find out for which SOP class, the SET request
     * has arrived
     */
    if (strcmp((*request)->classUID,
	       DICOM_SOPCLASSBASICGREYSCALEIMAGEBOX) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetImageBoxCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of Grayscale IMAGE BOX\n");
	    showHierarchy();
	}
	return cond;
    } else if (strcmp((*request)->classUID,
		      DICOM_SOPCLASSBASICCOLORIMAGEBOX) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetImageBoxCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of Color IMAGE BOX\n");
	    showHierarchy();
	}
	return cond;
    } else if (strcmp((*request)->classUID,
		      DICOM_SOPCLASSBASICFILMSESSION) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetBFSCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of BASIC FILM SESSION\n");
	    showHierarchy();
	}
	return cond;
#ifdef ASG
    } else if (strcmp((*request)->classUID,
		      DICOM_SOPCLASSBASICFILMBOX) == 0) {
	(void) COND_PopCondition(TRUE);
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				nsetBFBCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	if (traceFlag) {
	    printf("AFTER setting attributes of BASIC FILM BOX\n");
	    showHierarchy();
	}
	return cond;
#endif
    } else {
	/* unsupported command for the given SOP class */
	cond = SRV_NSetResponse(association, ctx, request, &setResponse,
				unsupportedCallback, sendBack, ".");
	if (cond != SRV_NORMAL) {
	    printf("In setRequest : SRV_NSetResponse failed\n");
	    return cond;
	}
	return cond;
    }
}
示例#9
0
static void
browseSelectionCB_scrolledList3(
				Widget wgt,
				XtPointer cd,
				XtPointer cb)
{
    Widget UxWidget = wgt;
    XtPointer UxClientData = cd;
    XtPointer UxCallbackArg = cb;
    {
	/*
	 * scrolledList3 *
	 * 
	 * Purpose: *   This subroutine lists the description of the selected
	 * attribute *   in the text widgets. *
	 * 
	 * Parameter Dictinary: *      cbs            input, pointer to the
	 * selected attribute *
	 * 
	 * Return Value: *      Description of the element *
	 * 
	 * Notes: *
	 * 
	 * Algorithm: *      Description of the algorithm (optional) and any
	 * other notes. *
	 * 
	 */

	XmListCallbackStruct *cbs;

	char *atname;
	int i;
	char buf2[64],
	    buf1[64];

	CONDITION cond;

	unsigned short gg,
	    ee;

	cbs = (XmListCallbackStruct *) UxCallbackArg;

	if ((atname = (char *) malloc(64)) == NULL)
	    printf(" malloc atname failed\n");

	XmStringGetLtoR(cbs->item, XmSTRING_DEFAULT_CHARSET, &atname);


	if (strlen(XmTextGetString(text1)) != 0)
	    XmTextSetString(text1, NULL);
	if (strlen(XmTextGetString(text2)) != 0)
	    XmTextSetString(text2, NULL);

	ieAttr = LST_Head(&attr_head);
	(void) LST_Position(&attr_head, ieAttr);
	for (i = 2; i <= cbs->item_position; i++)
	    ieAttr = LST_Next(&attr_head);

	cond = DCM_LookupElement(&ieAttr->element);
	if (cond != DCM_NORMAL) {
	    (void) COND_ExtractConditions(errorstackP);
	    copyWtext(info);
	    (void) COND_PopCondition(clearStack);
	    free(info);
	}
	sprintf(buf1, " %s", atname);
	XmTextSetString(text1, buf1);

	if (ieAttr->element.length == 0) {
	    strcpy(buf2, "<None>");
	    XmTextSetString(text2, buf2);
	} else {
	    switch (ieAttr->element.representation) {

	    case DCM_AS:	/* Age String */
	    case DCM_CS:	/* control string */
	    case DCM_DA:	/* date */
	    case DCM_DS:	/* decimal string */
	    case DCM_IS:	/* integer string */
	    case DCM_LO:	/* long string */
	    case DCM_LT:	/* long text */
	    case DCM_ST:	/* short text */
	    case DCM_SH:	/* short string */
	    case DCM_TM:	/* time */
	    case DCM_UI:	/* uid */
	    case DCM_PN:	/* person name */

		gg = DCM_TAG_GROUP(ieAttr->element.tag);
		ee = DCM_TAG_ELEMENT(ieAttr->element.tag);

		sprintf(buf2, "%04x,  %04x,   %s", gg, ee, ieAttr->element.d.string);
		XmTextSetString(text2, buf2);

		break;

	    case DCM_SS:	/* signed short */
		gg = DCM_TAG_GROUP(ieAttr->element.tag);
		ee = DCM_TAG_ELEMENT(ieAttr->element.tag);
		sprintf(buf2, "%04x,  %04x,  %d", gg, ee, *(ieAttr->element.d.us));
		XmTextSetString(text2, buf2);
		break;

	    case DCM_SL:	/* signed long */
		gg = DCM_TAG_GROUP(ieAttr->element.tag);
		ee = DCM_TAG_ELEMENT(ieAttr->element.tag);
		sprintf(buf2, " %04x,  %04x,  %d", gg, ee, *(ieAttr->element.d.sl));
		XmTextSetString(text2, buf2);
		break;

	    case DCM_US:	/* unsigned short */
		gg = DCM_TAG_GROUP(ieAttr->element.tag);
		ee = DCM_TAG_ELEMENT(ieAttr->element.tag);
		sprintf(buf2, " %04x, %04x, %d", gg, ee, *(ieAttr->element.d.us));
		XmTextSetString(text2, buf2);
		break;

	    case DCM_UL:	/* unsigned long */
		gg = DCM_TAG_GROUP(ieAttr->element.tag);
		ee = DCM_TAG_ELEMENT(ieAttr->element.tag);
		sprintf(buf2, " %04x, %04x, %d", gg, ee, *(ieAttr->element.d.ul));
		XmTextSetString(text2, buf2);
		break;

	    default:
		break;
	    }
	}
	free(atname);

    }
}
示例#10
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);


    }
}
示例#11
0
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);



    }
}
示例#12
0
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);
}
示例#13
0
文件: requests.c 项目: nagyistge/ctn
CONDITION
serviceRequests(DUL_NETWORKKEY ** network, DUL_ASSOCIATIONKEY ** association,
		DUL_ASSOCIATESERVICEPARAMETERS * service)
{
    CONDITION
	cond;
    DUL_PRESENTATIONCONTEXT
	* ctx;
    DUL_PRESENTATIONCONTEXTID
	ctxID;
    void
       *message;
    MSG_TYPE
	messageType;
    CTNBOOLEAN
	networkLink = TRUE,
	commandServiced;
    DMAN_HANDLE
	* handle;
    DMAN_STORAGEACCESS
	storage;
    DMAN_FISACCESS fisAccess;

    cond = DMAN_Open(controlDatabase, service->callingAPTitle,
		     service->calledAPTitle, &handle);

    if (cond == DMAN_NORMAL) {
	cond = DMAN_LookupStorage(&handle, service->calledAPTitle,
				  &storage);
    }
    if (cond == DMAN_NORMAL)
	cond = IDB_Open(storage.DbKey, &IDBHandle);

    if (!CTN_ERROR(cond)) {
	cond = DMAN_LookupFISAccess(&handle, service->calledAPTitle, &fisAccess);
	if (!CTN_ERROR(cond))
	    cond = FIS_Open(fisAccess.DbKey, &fisHandle);
    }
    while ((networkLink == TRUE) && !CTN_ERROR(cond)) {
	cond = SRV_ReceiveCommand(association, service, DUL_BLOCK, 0, &ctxID,
				  NULL, &messageType, &message);
	if (cond == SRV_PEERREQUESTEDRELEASE) {
	    networkLink = FALSE;
	    (void) DUL_AcknowledgeRelease(association);
	    (void) DUL_DropAssociation(association);
	} else if (cond == SRV_PEERABORTEDASSOCIATION) {
	    networkLink = FALSE;
	    (void) DUL_DropAssociation(association);
	} else if (cond != SRV_NORMAL) {
	    (void) DUL_DropAssociation(association);
	    COND_DumpConditions();
	    cond = 2;
	} else {
	    ctx = LST_Head(&service->acceptedPresentationContext);
	    if (ctx != NULL)
		(void) LST_Position(&service->acceptedPresentationContext, ctx);
	    commandServiced = FALSE;
	    while (ctx != NULL && !commandServiced) {
		if (ctx->presentationContextID == ctxID) {
		    if (commandServiced) {
			if (!silent)
			    fprintf(stderr,
			      "Context ID Repeat in serviceRequests (%d)\n",
				    ctxID);
		    } else {
			cond = serviceThisCommand(network, association, ctx,
					     messageType, &message, service,
						  &handle);
			if (cond == SRV_OPERATIONCANCELLED) {
			    if (!silent)
				printf("Operation cancelled\n");
			    (void) COND_PopCondition(TRUE);
			} else if (cond != SRV_NORMAL)
			    COND_DumpConditions();
			commandServiced = TRUE;
		    }
		}
		ctx = LST_Next(&service->acceptedPresentationContext);
	    }
	    if (!commandServiced) {
		fprintf(stderr, "In serviceRequests, context ID %d not found\n",
			ctxID);
		(void) DUL_DropAssociation(association);
		networkLink = FALSE;
	    }
	}
    }
    (void) DMAN_Close(&handle);
    (void) IDB_Close(&IDBHandle);
    return cond;
}
示例#14
0
文件: cparse.c 项目: bhavik86/Dicom
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;
}
示例#15
0
static CTNBOOLEAN
findElement(DCM_OBJECT * object, DCM_TAG tag, DCM_ELEMENT * element)
{
    CONDITION		cond;				/* Return value from DUL and ACR routines */
    DCM_ELEMENT		dcm_element;		/* Handle to the dicom data element */
    void			*ctx;				/* Context variable used by DCM_GetElementValue */
    CTNBOOLEAN		flag = TRUE;		/* See Return Values in the header */
    CTNBOOLEAN		isString = FALSE;	/* Flag indicates if value is of string type */


    /* Find the group and element fields in the tag. */
    dcm_element.tag = tag;
    element->tag = dcm_element.tag;

    /* Find the representation of the data in the element. */
    cond = DCM_LookupElement(&dcm_element);
    if (cond != DCM_NORMAL) {
    	cond = COND_PopCondition(FALSE);
    	return FALSE;
    }

    /* Fill the length field and assign the memory for the data. */
    switch (dcm_element.representation) {
		case DCM_LO:		/* Long string */
		case DCM_UI:		/* UID */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_DA:		/* Date */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_CS:		/* Control string */
		case DCM_TM:		/* Time */
		case DCM_SH:		/* Short string */
		case DCM_DS:		/* Decimal string */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_IS:		/* Integer string */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_ST:		/* Short text */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_LT:		/* Long text */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_PN:		/* Person name */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_AS:		/* Age string */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.string = malloc((dcm_element.length + 1) * sizeof(char));
								isString = TRUE;
							}
							break;
		case DCM_SS:		/* Signed short */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.ss = malloc((dcm_element.length + 1) * sizeof(char));
							}
							break;
		case DCM_SL:		/* signed long */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.sl = malloc((dcm_element.length + 1) * sizeof(char));
							}
							break;
		case DCM_US:		/* unsigned short */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.us = malloc((dcm_element.length + 1) * sizeof(char));
							}
							break;
		case DCM_UL:		/* unsigned long */
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond != DCM_NORMAL){
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}else{
								dcm_element.d.ul = malloc((dcm_element.length + 1) * sizeof(char));
							}
							break;
		case DCM_SQ:		/* Sequence of items */
							break;
		default:
							cond = DCM_GetElementSize(&object, tag, &(dcm_element.length));
							if (cond == DCM_NORMAL){
								return flag;
							}else{
								cond = COND_PopCondition(FALSE);
								return FALSE;
							}
    }

    /* The following is necessary when made the first call to DCM_GetElementValue(). */
    ctx = NULL;
    cond = DCM_GetElementValue(&object, &dcm_element, &(dcm_element.length), &ctx);
    if (cond != DCM_NORMAL) {	/* check for error */
    	/* the attribute is not found */
    	flag = FALSE;
    	cond = COND_PopCondition(FALSE);
    }else{
    	if (isString) dcm_element.d.string[dcm_element.length] = '\0';
    	*element = dcm_element;
    }
    return flag;
}
示例#16
0
文件: requests.c 项目: nagyistge/ctn
static CONDITION
storeImage(DMAN_HANDLE ** handle, char *origFileName,
	   char *transferSyntax, char *SOPClass,
	   char *owner, char *groupName, char *priv, DCM_OBJECT ** object)
{
    IDB_Insertion
    Insertion;
    IDB_InstanceListElement
	imageInstance;

    CONDITION
	cond;
    char
        fileName[256];
    char
       *accession;
    int
        i;

    memset(&Insertion, 0, sizeof(Insertion));

    cond = parseImageForInsert(object, &Insertion);
    if (cond != APP_NORMAL)
	return 0;

    strcpy(Insertion.patient.Owner, owner);
    strcpy(Insertion.patient.GroupName, groupName);
    strcpy(Insertion.patient.Priv, priv);

    if (strlen(Insertion.study.AccNum) != 0)
	accession = Insertion.study.AccNum;
    else
	accession = Insertion.study.StuInsUID;

    cond = DMAN_PermImageFile(handle, SOPClass, accession,
			      Insertion.series.SerInsUID,
			      fileName,
			      sizeof(fileName));
    if (cond != DMAN_NORMAL)
	return 0;

    i = rename(origFileName, fileName);
    if (i != 0)
	return 0;

    strcpy(Insertion.image.Path, fileName);
    strcpy(Insertion.image.Transfer, transferSyntax);
    cond = IDB_InsertImage(&IDBHandle, &Insertion);
    if (cond != IDB_NORMAL) {
	COND_DumpConditions();
	return 0;
    }
/*    (void) copyEnqueue(object); */
    (void) COND_PopCondition(TRUE);

/*
    memset(&imageInstance, 0, sizeof(imageInstance));
    strcpy(imageInstance.Path, fileName);
    strcpy(imageInstance.Transfer, transferSyntax);
    cond = IDB_InsertImageInstance(&IDBHandle, Insertion.image.SOPInsUID,
	&imageInstance);
    if (cond != IDB_NORMAL) {
	COND_DumpConditions();
	return 0;
    }
*/
    return APP_NORMAL;
}
示例#17
0
文件: hap.c 项目: ccteng/dicomprop
CONDITION
HAP_ObjectToQuery(DCM_OBJECT ** object, char *SOPClass, Query * query,
		  int *elementCount)
{
    CONDITION
	cond,
	returnCondition;
    int
        index;
    void
       *ctx;
    unsigned long
        l;
    long
        flag;
    static char
        queryLevelString[48];
    DCM_ELEMENT
	queryLevelElement =
    {
	DCM_IDQUERYLEVEL, DCM_CS, "", 1,
	    sizeof(queryLevelString), (void *) queryLevelString
    };

    *elementCount = 0;
    q.QueryState = 0;
    q.Patient.Query_Flag = 0;
    q.Study.Query_Flag = 0;
    q.Series.Query_Flag = 0;
    q.Image.Query_Flag = 0;

    ctx = NULL;
    returnCondition = HAP_NORMAL;

    cond = DCM_GetElementValue(object, &queryLevelElement, &l, &ctx);
    if (cond != DCM_NORMAL) {
	if (cond == DCM_ILLEGALOBJECT)
	    return COND_PushCondition(HAP_ILLEGALOBJECT, "");
	else {
	    (void) COND_PopCondition(FALSE);
	    (void) COND_PushCondition(HAP_QUERYLEVELMISSING, "");
	    returnCondition = HAP_INCOMPLETEOBJECT;
	}
    } else {
	queryLevelString[l] = '\0';
	if (queryLevelString[l - 1] == ' ')
	    queryLevelString[l - 1] = '\0';

	for (index = 0; index < DIM_OF(levelMap); index++) {
	    if (strcmp(levelMap[index].queryLevel, queryLevelString) == 0)
		q.QueryState |= levelMap[index].flag;
	}
    }

    flag = 0;
    for (index = 0; index < DIM_OF(classMap); index++) {
	if (strcmp(classMap[index].SOPClass, SOPClass) == 0)
	    flag |= classMap[index].flag;
    }
    if (flag == 0)
	return HAP_ILLEGALSOPCLASS;

    q.QueryState |= flag;

    for (index = 0; index < (int) DIM_OF(list); index++) {
	ctx = NULL;
	cond = DCM_GetElementValue(object, &list[index].e, &l, &ctx);
	if (cond == DCM_NORMAL) {
	    (*elementCount)++;
	    list[index].e.d.string[l] = '\0';
	    *list[index].flagAddress |= list[index].flag;
	} else
	    (void) COND_PopCondition(FALSE);
    }
    *query = q;
    return returnCondition;
}
示例#18
0
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;
}
示例#19
0
main(int argc, char **argv)
{

    CONDITION			/* Return values from DUL and ACR routines */
	cond;
    DUL_NETWORKKEY		/* Used to initialize our network */
	* network = NULL;
    DUL_ASSOCIATIONKEY		/* Describes the Association with the
				 * Acceptor */
	* association = NULL;
    DUL_ASSOCIATESERVICEPARAMETERS	/* The items which describe this
					 * Association */
	params = {
	DICOM_STDAPPLICATIONCONTEXT, "DICOM_TEST", "DICOM_VERIFY",
	    "", 16384, 0, 0, 0,
	    "calling presentation addr", "called presentation addr",
	    NULL, NULL, 0, 0,
	    MIR_IMPLEMENTATIONCLASSUID, MIR_IMPLEMENTATIONVERSIONNAME,
	    "", ""
    };
    char
       *calledAPTitle = "DICOM_STORAGE",
       *callingAPTitle = "DICOM_ECHO";

    char
        localHost[256];

    int
        port;			/* TCP port used to establish Association */
    char
       *node;			/* The node we are calling */

    CTNBOOLEAN
	verbose = FALSE,
	abortFlag = FALSE,
	paramsFlag = FALSE,
	drop = FALSE,
	noRelease = FALSE;
    int
        repeat = 1,
        connections = 1,
        repeatCopy,
        sleepTime = 0;
    DUL_SC_ROLE
	role = DUL_SC_ROLE_DEFAULT;
    MSG_C_ECHO_RESP
	response;
    char *classFile = NULL;

    while (--argc > 0 && (*++argv)[0] == '-') {
	switch (*(argv[0] + 1)) {
	case 'a':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    callingAPTitle = *argv;
	    break;
	case 'c':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    calledAPTitle = *argv;
	    break;
	case 'd':
	    drop = TRUE;
	    break;
	case 'f':
	    argc--;
	    argv++;
	    if (argc <= 0) {
		usageerror();
	    }
	    classFile = *argv;
	    break;
	case 'm':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    if (strcmp(*argv, "SCU") == 0)
		role = DUL_SC_ROLE_SCU;
	    else if (strcmp(*argv, "SCP") == 0)
		role = DUL_SC_ROLE_SCP;
	    else if (strcmp(*argv, "SCUSCP") == 0)
		role = DUL_SC_ROLE_SCUSCP;
	    else
		usageerror();
	    break;
	case 'n':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    if (sscanf(*argv, "%d", &connections) != 1)
		usageerror();
	    break;
	case 'p':
	    paramsFlag = TRUE;
	    break;
	case 'r':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    if (sscanf(*argv, "%d", &repeat) != 1)
		usageerror();
	    if (repeat <= 0)	/* A special case */
		repeat = 32 * 1024 * 1024;
	    break;
	case 's':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    if (sscanf(*argv, "%d", &sleepTime) != 1)
		usageerror();
	    break;
	case 'v':
	    verbose = TRUE;
	    break;
	case 'x':
	    noRelease = TRUE;
	    break;
	default:
	    break;
	}
    }
    if (argc < 2)
	usageerror();

    THR_Init();
    DUL_Debug(verbose);
    SRV_Debug(verbose);

    node = *argv;
    if (sscanf(*++argv, "%d", &port) != 1)
	usageerror();
    (void) gethostname(localHost, sizeof(localHost));

    cond = DUL_InitializeNetwork(DUL_NETWORK_TCP, DUL_AEREQUESTOR,
				 NULL, 10, DUL_ORDERBIGENDIAN, &network);
    if (cond != DUL_NORMAL)
	myExit(&association);
	
    if (classFile != NULL) {
	testSOPClasses(network, classFile, callingAPTitle, localHost,
	  calledAPTitle, node, port);
	connections = 0;			/* This will force us to skip the next section of echo code */
    }

    while (connections-- > 0) {
	sprintf(params.calledPresentationAddress, "%s:%s", node, *argv);
	strcpy(params.callingPresentationAddress, localHost);
	strcpy(params.calledAPTitle, calledAPTitle);
	strcpy(params.callingAPTitle, callingAPTitle);
	cond = SRV_RequestServiceClass(DICOM_SOPCLASSVERIFICATION, role,
				       &params);
	if (cond != SRV_NORMAL) {
	    COND_DumpConditions();
	    THR_Shutdown();
	    exit(1);
	}
	cond = DUL_RequestAssociation(&network, &params, &association);
	if (cond != DUL_NORMAL) {
	    if (cond == DUL_ASSOCIATIONREJECTED) {
		fprintf(stderr, "Association Rejected\n");
		fprintf(stderr, " Result: %2x Source %2x Reason %2x\n",
			params.result, params.resultSource,
			params.diagnostic);
	    }
	    myExit(&association);
	}
	if (verbose || paramsFlag) {
	    (void) printf("Association accepted, parameters:\n");
	    DUL_DumpParams(&params);
	}
	repeatCopy = repeat;
	while (repeatCopy-- > 0) {
	    MSG_C_ECHO_REQ echoRequest = {MSG_K_C_ECHO_REQ, 0, 0, DCM_CMDDATANULL,
	    DICOM_SOPCLASSVERIFICATION};

	    echoRequest.messageID = SRV_MessageIDOut();

	    cond = SRV_CEchoRequest(&association, &params,
				    &echoRequest, &response,
				    echoCallback, "Context", "");
	    if (!(CTN_SUCCESS(cond))) {
		(void) printf("Verification Request unsuccessful\n");
		COND_DumpConditions();
	    } else {
		MSG_DumpMessage(&response, stdout);
	    }
	    SRV_MessageIDIn(echoRequest.messageID);
#ifdef _MSC_VER
	    if (sleepTime > 0)
		Sleep(sleepTime * 1000);
#else
	    if (sleepTime > 0)
		sleep(sleepTime);
#endif
	}

	if (abortFlag) {
	    cond = DUL_AbortAssociation(&association);
	} else if (drop) {
	    cond = DUL_DropAssociation(&association);
	} else if (noRelease == FALSE) {
	    cond = DUL_ReleaseAssociation(&association);
	    if (cond != DUL_RELEASECONFIRMED) {
		(void) COND_PopCondition(TRUE);
#if 0
		(void) fprintf(stderr, "%x\n", cond);
		COND_DumpConditions();
#endif
	    }
	}
	(void) DUL_ClearServiceParameters(&params);
    }
    (void) DUL_DropNetwork(&network);
    THR_Shutdown();
    return 0;
}