Exemplo n.º 1
0
main(int argc, char *argv[])
{

    CONDITION r;

    CTNDISP_Queue e;
    int qid;

    if (argc != 6) {
	printf("\nUsage: %s <qid> <imagefile> <dpnid> <conn> <imagenum>\n", argv[0]);
	exit(1);
    }
    qid = atoi(argv[1]);
    if (GQ_GetQueue(qid, sizeof(CTNDISP_Queue)) != GQ_NORMAL) {
	printf("\nGQ_GetQueue failed!\n\n");
	COND_DumpConditions();
	exit(-1);
    }
    strcpy(e.imagefile, argv[2]);
    strcpy(e.dpnid, argv[3]);
    e.connection = atoi(argv[4]);
    e.inumber = atoi(argv[5]);
    if ((r = GQ_Enqueue(qid, (void *) &e)) != GQ_NORMAL) {
	if (r == GQ_QUEUEFULL)
	    printf("\nThe queue is full!\n\n");
	else {
	    printf("\nGQ_Enqueue failed\n\n");
	    COND_DumpConditions();
	    exit(-1);
	}
    }
    return 0;
}
Exemplo n.º 2
0
static void
activateCB_pushButton11(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
    _UxCgroupNamesForm *UxSaveCtx,
       *UxContext;
    Widget UxWidget = wgt;
    XtPointer UxClientData = cd;
    XtPointer UxCallbackArg = cb;

    UxSaveCtx = UxGroupNamesFormContext;
    UxGroupNamesFormContext = UxContext =
	(_UxCgroupNamesForm *) UxGetContext(UxWidget);
    {
	DMAN_GROUPNAMES g;
	CONDITION cond;

	cond = readGroup(&g);
	if (cond != 1) {
	    COND_DumpConditions();
	    return;
	}
	cond = DMAN_Delete(&dmanHandle, (DMAN_GENERICRECORD *) & g);
	if (cond != DMAN_NORMAL)
	    COND_DumpConditions();

	loadGroupGroupList();
	loadGroupTitleList(g.GroupName);
    }
    UxGroupNamesFormContext = UxSaveCtx;
}
Exemplo n.º 3
0
main()
{
    CONDITION
	cond;
    char
        tab[50],
        db[50];
    TBL_HANDLE
	* handle;

    void
       *foo = NULL;


    printf("Input database: ");
    scanf("%s", db);
    printf("Input table: ");
    scanf("%s", tab);

    THR_Init();
    cond = TBL_Open(db, tab, &handle);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(1);
    }
    cond = TBL_Layout(db, tab, callback, (void *) foo);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(2);
    }
    THR_Shutdown();
    exit(0);
}
Exemplo n.º 4
0
static void
activateCB_pushButton14(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
    _UxCFISAccessForm *UxSaveCtx,
       *UxContext;
    Widget UxWidget = wgt;
    XtPointer UxClientData = cd;
    XtPointer UxCallbackArg = cb;

    UxSaveCtx = UxFISAccessFormContext;
    UxFISAccessFormContext = UxContext =
	(_UxCFISAccessForm *) UxGetContext(UxWidget);
    {
	DMAN_FISACCESS f;
	CONDITION cond;

	cond = readFISAccess(&f);
	if (cond != 1) {
	    COND_DumpConditions();
	    return;
	}
	cond = DMAN_Delete(&dmanHandle, (DMAN_GENERICRECORD *) & f);
	if (cond != DMAN_NORMAL)
	    COND_DumpConditions();

	loadFISAccessList();
    }
    UxFISAccessFormContext = UxSaveCtx;
}
Exemplo n.º 5
0
static void  addString(DCM_OBJECT* obj, DCM_TAG tag, char* s)
{
  DCM_ELEMENT e;
  CONDITION cond;

  if (s == 0)
    return;

  memset(&e, 0, sizeof(e));
  e.tag = tag;

  cond = DCM_LookupElement(&e);
  if (cond != DCM_NORMAL) {
    COND_DumpConditions();
    exit(1);
  }

  e.d.string = s;
  e.length = strlen(s);
  cond = DCM_ModifyElements(&obj, &e, 1, 0, 0, 0);
  if (cond != DCM_NORMAL) {
    COND_DumpConditions();
    exit(1);
  }
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
DCM_OBJECT *
createQueryObject(const char *fileName)
{
    DCM_OBJECT *obj;
    CONDITION cond;
    DCM_ELEMENT e;
    char txt[1024] = "";

    int group = 0;
    int element = 0;
    char textValue[1024];

    if (fileName != NULL) {
	cond = DCM_OpenFile(fileName, DCM_ORDERLITTLEENDIAN, &obj);
	if (cond != DCM_NORMAL) {
	    COND_DumpConditions();
	    exit(1);
	}
	return obj;
    }
    cond = DCM_CreateObject(&obj, 0);
    if (cond != DCM_NORMAL) {
	COND_DumpConditions();
	exit(1);
    }
    while (fgets(txt, sizeof(txt), stdin) != NULL) {
	if (txt[0] == '#' || txt[0] == '\0')
	    continue;
	if (txt[0] == '\n' || txt[0] == '\r')
	    continue;

	if (sscanf(txt, "%x %x %[^\n]", &group, &element, textValue) != 3)
	    continue;

	e.tag = DCM_MAKETAG(group, element);
	DCM_LookupElement(&e);
	if (strncmp(textValue, "#", 1) == 0) {
	    e.length = 0;
	    e.d.string = NULL;
	} else {
	    e.length = strlen(textValue);
	    e.d.string = textValue;
	}

	cond = DCM_AddElement(&obj, &e);
	if (cond != DCM_NORMAL) {
	    COND_DumpConditions();
	    exit(1);
	}
    }

    return obj;
}
Exemplo n.º 8
0
/* selectStudy
**
** Purpose:
**	This function is called when the user selects a study from
**	the study list.  This will then call other functions
**	to display the images in that study.
**
** Parameter Dictionary:
**	w
**	client_data
**	call_data
**
** Return Values:
**	None.
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
static void
selectStudy(Widget w, XtPointer client_data, XtPointer call_data)
{
    XawListReturnStruct
    * data;
    LIST_ITEM
	* item;

    data = (XawListReturnStruct *) call_data;
    printf("you have selected %s\n", data->string);
    item = LST_Position(&lst_studylist, LST_Head(&lst_studylist));
    if (item == NULL) {
	printf("Fatal Error: LST_Position failed in selectStudy \n");
	return;
    }
    printf("searching in list, getting \n");
    printf("%s\n", item->combo);
    while ((item != NULL) && (strcmp(item->combo, data->string) != 0)) {
	item = LST_Next(&lst_studylist);
	printf("searching in list, getting \n");
	printf("%s\n", item->combo);
    }
    if (item == NULL) {
	printf("Fatal Error: Major Logic Error in selectStudy\n");
	return;
    }
    if (PreviewStudy(icon_index, icon_file, item->AccessionNumber) == FALSE) {
	COND_DumpConditions();
	printf("Error: PreviewStudy failed in selectStudy\n");
    }
}
Exemplo n.º 9
0
static int
requestAssociation(DUL_NETWORKKEY ** network,
		   DUL_ASSOCIATIONKEY ** association,
		 DUL_ASSOCIATESERVICEPARAMETERS * params, char **SOPClasses,
		   int classCount)
{
    CONDITION
    cond;

    while (classCount-- > 0) {
	cond = SRV_RequestServiceClass(*SOPClasses++, DUL_SC_ROLE_DEFAULT, params);
	if (cond != SRV_NORMAL) {
	    COND_DumpConditions();
	    return 0;
	}
    }
    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);
	}
	return 0;
    }
    (void) printf("Association accepted, parameters:\n");
    DUL_DumpParams(params);
    return 1;
}
Exemplo n.º 10
0
int
main(int argc, char *argv[])
{
    int
        iconfilesize;
    char
       *iconindex,
       *iconfile,
       *imagefile;
    char
       *accessionNumber;
    CONDITION
	cond;
    ICON_STUDYOFFSET
	studyoffset;

    while (--argc > 0 && (*++argv)[0] == '-') {
	switch (*(argv[0] + 1)) {
	case 'v':
	    verbose = TRUE;
	    break;
	default:
	    break;
	}
    }
    DCM_Debug(verbose);
    if (argc != 3) {
	printf("Usage: append_icon_index ICONCindex ICONfile imagefilei\n");
	return (0);
    }
    THR_Init();
    iconindex = strdup(argv[0]);
    iconfile = strdup(argv[1]);
    imagefile = strdup(argv[2]);
    iconfilesize = getFileSize(iconfile);
    if (iconfilesize < 0) {
	THR_Shutdown();
	return (1);
    }
    printf("Size of %s is %d\n", iconfile, iconfilesize);
    accessionNumber = extractAccessionNumber(imagefile);
    if (accessionNumber == NULL) {
	THR_Shutdown();
	return (1);
    }
    printf("Accession Number = %s\n", accessionNumber);
    strcpy(studyoffset.accessionNumber, accessionNumber);
    studyoffset.Offset = iconfilesize;
    cond = ICON_AppendStudyOffset(iconindex, &studyoffset);
    if (cond != ICON_NORMAL) {
	printf("ICON_AppendStudyOffset failed\n");
	if (verbose == TRUE)
	    COND_DumpConditions();
	THR_Shutdown();
	return (1);
    }
    (void) ICON_DumpStudyOffset(iconindex);
    THR_Shutdown();
    return 0;
}
Exemplo n.º 11
0
static CONDITION
studySet(MSG_N_SET_REQ * request, MSG_N_SET_RESP * response,
         CALLBACK_CTX * ctx)
{
    CONDITION cond;
    FIS_STUDYRECORD study;
    long flag;

    if (request->dataSetType != DCM_CMDDATANULL) {
        (void) DCM_DumpElements(&request->dataSet, 0);
    }
    cond = FIS_ParseObject(&request->dataSet, FIS_K_STUDY, &study);
    if (cond != FIS_NORMAL)
        return 0;

    study.Flag &= STUDY_SET_FLAGS;
    if (study.Flag == 0)
        return 1;

    strcpy(study.StuInsUID, request->instanceUID);
    study.Flag |= FIS_K_STU_STUINSUID;
    cond = FIS_Update(ctx->fis, FIS_K_STUDY, &study);
    if (cond != FIS_NORMAL) {
        COND_DumpConditions();
    } else {
        response->status = MSG_K_SUCCESS;
    }
    response->dataSetType = DCM_CMDDATANULL;
    strcpy(response->classUID, request->classUID);
    strcpy(response->instanceUID, request->instanceUID);
    response->conditionalFields = MSG_K_N_SETRESP_REQUESTEDCLASSUID |
                                  MSG_K_N_SETRESP_REQUESTEDINSTANCEUID;

    return 1;
}
Exemplo n.º 12
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);

}
Exemplo n.º 13
0
static void handleStudyQueries(DUL_ASSOCIATIONKEY** association,
			       DUL_ASSOCIATESERVICEPARAMETERS* params,
			       MSG_C_FIND_REQ* patientRequest,
			       LST_HEAD* patientList,
			       const char* queryLevel)
{
  ITEM* item;
  CONDITION cond;
  MSG_C_FIND_RESP response;

  item = (ITEM*)LST_Head(&patientList);
  (void)LST_Position(&patientList, item);
  while (item != 0) {
    char* patientName;
    char* patientID;
    char* charSet;
    MSG_C_FIND_REQ studyRequest;
    DCM_OBJECT* q;

    patientName = getString(item->obj, DCM_PATNAME);
    patientID = getString(item->obj, DCM_PATID);
    charSet = getString(patientRequest->identifier, DCM_IDSPECIFICCHARACTER);

    printf("%s %s\n", patientID, patientName);

    studyRequest = *patientRequest;
    studyRequest.identifier = 0;
    DCM_CreateObject(&q, 0);

    addString(q, DCM_PATID, patientID);
    addString(q, DCM_IDSPECIFICCHARACTER, charSet);
    addString(q, DCM_IDQUERYLEVEL, "STUDY");
    addString(q, DCM_RELSTUDYINSTANCEUID, "");
    addString(q, DCM_IDSTUDYDATE, "");
    addString(q, DCM_IDSTUDYTIME, "");
    addString(q, DCM_IDACCESSIONNUMBER, "");
    addString(q, DCM_IDSTUDYDESCRIPTION, "");

    studyRequest.identifier = q;
    studyRequest.messageID = SRV_MessageIDOut();

    item->lst = LST_Create();

    cond = SRV_CFindRequest(association, params,
			    &studyRequest, &response,
			    queryCallback, item->lst, "");
    if (!(CTN_SUCCESS(cond))) {
      (void) printf("Verification Request unsuccessful\n");
      COND_DumpConditions();
    } else {

    }

    item = LST_Next(&patientList);
  }
}
Exemplo n.º 14
0
static void
openFIS(char *fisDatabase, FIS_HANDLE ** fisHandle)
{
    CONDITION cond = 0;

    cond = FIS_Open(fisDatabase, fisHandle);
    if (cond != FIS_NORMAL) {
	COND_DumpConditions();
	exit(1);
    }
}
Exemplo n.º 15
0
static void
closeFIS(FIS_HANDLE ** fisHandle)
{
    CONDITION cond = 0;

    cond = FIS_Close(fisHandle);
    if (cond != FIS_NORMAL) {
	COND_DumpConditions();
	exit(1);
    }
}
Exemplo n.º 16
0
static void
myExit(DUL_ASSOCIATIONKEY ** association)
{
    fprintf(stderr, "Abnormal exit\n");
    COND_DumpConditions();

    if (association != NULL)
	if (*association != NULL)
	    (void) DUL_DropAssociation(association);
    THR_Shutdown();
    exit(1);
}
Exemplo n.º 17
0
void
clearAssociationKeyAndServiceParameters(CONDITION cond)
{
    CONDITION
    rtnCond;

    if (appHandles.association) {
	rtnCond = DUL_DropAssociation(&appHandles.association);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error freeing association key\n");
	    COND_DumpConditions();
	}
    }
    if (appHandles.service) {
	rtnCond = DUL_ClearServiceParameters(appHandles.service);
	if (CTN_ERROR(rtnCond)) {
	    fprintf(stderr, "APP Error clearing service parameters\n");
	    COND_DumpConditions();
	}
    }
}
Exemplo n.º 18
0
static void* extractPixelsMONOCHROME2(DCM_OBJECT** obj, PARAMS *p)
{
  void *pixels = NULL;
  int byteCount;
  int pixelCount;
  DCM_ELEMENT e;
  CONDITION cond;

  pixelCount = p->rows * p->columns;
  byteCount = p->rows * p->columns;
  if (p->bitsAllocated > 8)
    byteCount *= 2;

  if (pixels == NULL) {
    pixels = malloc(byteCount);
    if (pixels == NULL) {
      fprintf(stderr, "Could not allocated %d bytes for pixel data\n",
	      byteCount);
      exit(7);
    }
  }
  memset(&e, 0, sizeof(e));
  e.tag = DCM_PXLPIXELDATA;
  e.representation = DCM_OW;
  e.length = byteCount;
  e.d.ot = pixels;

  cond = DCM_ParseObject(obj, &e, 1, NULL, 0, NULL);
  if (cond != DCM_NORMAL  && cond != DCM_GETINCOMPLETE) {
    fprintf(stderr, "Could not extract pixels: %d %d %d %d\n",
	    p->rows, p->columns, p->bitsAllocated, byteCount);
    COND_DumpConditions();
    exit(8);
  }

  if (p->bitsAllocated == 8) {
    unsigned char* p1;
    U16* p2;
    int index;

    p2 = malloc(pixelCount * 2);
    p1 = (unsigned char*) pixels;
    for (index = 0; index < pixelCount; index++) {
      p2[index] = p1[index];
    }

    free(pixels);
    pixels = p2;
  }

  return pixels;
}
Exemplo n.º 19
0
main(int argc, char *argv[])
{

    CONDITION r;

    CTNNETWORK_Queue e;
    int qid;

    if (argc != 7) {
	printf("\nUsage: %s <qid> <vendorid> <dpnid> <association id> <conn> <percentage>\n", argv[0]);
	exit(1);
    }
    THR_Init();
    qid = atoi(argv[1]);
    if (GQ_GetQueue(qid, sizeof(CTNNETWORK_Queue)) != GQ_NORMAL) {
	printf("\nGQ_GetQueue failed!\n\n");
	COND_DumpConditions();
	THR_Shutdown();
	exit(-1);
    }
    strcpy(e.vendorid, argv[2]);
    strcpy(e.dpnid, argv[3]);
    e.association_id = atoi(argv[4]);
    e.connection = atoi(argv[5]);
    e.percentage = atoi(argv[6]);
    if ((r = GQ_Enqueue(qid, (void *) &e)) != GQ_NORMAL) {
	if (r == GQ_QUEUEFULL)
	    printf("\nThe queue is full!\n\n");
	else {
	    printf("\nGQ_Enqueue failed\n\n");
	    COND_DumpConditions();
	    THR_Shutdown();
	    exit(-1);
	}
    }
    THR_Shutdown();
    return 0;
}
Exemplo n.º 20
0
main(int argc, char *argv[])
{

    int
        qid;

    CTNNETWORK_Queue
	e;

    if (argc != 2) {
	printf("\nUsage: %s <queue_number>\n\n", argv[0]);
	exit(0);
    }
    THR_Init();
    qid = atoi(argv[1]);
    if (GQ_GetQueue(qid, sizeof(CTNNETWORK_Queue)) != GQ_NORMAL) {
	printf("\nGQ_GetQueue failed!\n\n");
	COND_DumpConditions();
	THR_Shutdown();
	exit(-1);
    }
    strcpy(e.vendorid, "KILL_DISPLAY");
    if (GQ_Enqueue(qid, (void *) &e) != GQ_NORMAL) {
	printf("\nGQ_Enqueue failed!\n\n");
	COND_DumpConditions();
	THR_Shutdown();
	exit(-1);
    }
    sleep(5);
    if (GQ_KillQueue(qid) != GQ_NORMAL) {
	printf("\nGQ_KillQueue failed!\n\n");
	COND_DumpConditions();
	THR_Shutdown();
	exit(-1);
    }
    THR_Shutdown();
    exit(0);
}
Exemplo n.º 21
0
unsigned short
SRV_MessageIDOut()
{
    static unsigned short	  messageID = 0;

#ifdef CTN_USE_THREADS
    if (THR_ObtainMutex(FAC_SRV) != THR_NORMAL) {
    	COND_DumpConditions();
    	fprintf(stderr, " SRV_MessageIDOut unable to obtain mutex, exiting\n");
    	exit(1);
    }
#endif
    messageID++;

#ifdef CTN_USE_THREADS
    if (THR_ReleaseMutex(FAC_SRV) != THR_NORMAL) {
    	COND_DumpConditions();
    	fprintf(stderr, " SRV_MessageIDOut unable to release mutex, exiting\n");
    	exit(1);
    }
#endif
    return messageID;
}
Exemplo n.º 22
0
/* extractAccessionNumber
**
** Purpose:
**	Extract the Accession number from a DICOM image file.
**
** Parameter Dictionary:
**	file		Name of the file
**
** Return Values:
**	Accession number if found, else NULL
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
static
char *
extractAccessionNumber(char *file)
{
    DCM_OBJECT
    * object = NULL;
    DCM_ELEMENT
	element;
    CONDITION
	cond;

    cond = DCM_OpenFile(file, DCM_ORDERLITTLEENDIAN, &object);
    if (cond != DCM_NORMAL) {
	printf("DCM_Openfile failed on %s\n", file);
	if (verbose == TRUE)
	    COND_DumpConditions();
	return (NULL);
    }
    element.tag = DCM_IDACCESSIONNUMBER;
    element.d.string = (char *) malloc(DICOM_CS_LENGTH + 1);
    element.length = DICOM_CS_LENGTH + 1;
    cond = DCM_LookupElement(&element);
    if (cond != DCM_NORMAL) {
	printf("DCM_LookupElement failed\n");
	if (verbose == TRUE)
	    COND_DumpConditions();
	return (NULL);
    }
    cond = DCM_ParseObject(&object, &element, 1, NULL, 0, NULL);
    if (cond != DCM_NORMAL) {
	printf("DCM Parse Object failed\n");
	if (verbose == TRUE)
	    COND_DumpConditions();
	return (NULL);
    }
    return (element.d.string);
}
Exemplo n.º 23
0
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);
}
Exemplo n.º 24
0
static void
addImageLeafAttributes(DCM_OBJECT ** leafObject, DDR_SERIES_LEAF * leaf)
{
    CONDITION cond;
    DCM_ELEMENT required[] = {
	{DCM_RELIMAGENUMBER, DCM_IS, "", 1,
	sizeof(leaf->specific.image.ImageNumber), NULL}
    };
    required[0].d.string = leaf->specific.image.ImageNumber;
    cond = DCM_ParseObject(leafObject, required,
			   (int) DIM_OF(required), NULL, 0, NULL);
    if (cond != DCM_NORMAL) {
	COND_DumpConditions();
	exit(1);		/* repair */
    }
}
Exemplo n.º 25
0
static XtCallbackProc
quit(Widget w, XtPointer client_data, XtPointer call_data)
{
    CONDITION
    cond;

    if (session_list != NULL)
        DISP_DeleteAllSession(&session_list);

    /* we also kill the created GQ */
    cond = kill_queue(queue_id);
    if (cond != GQ_NORMAL) {
        fprintf(stderr, "Error removing the GQ ID : %d\n", queue_id);
        COND_DumpConditions();
        exit(1);
    }
    exit(0);
}
Exemplo n.º 26
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;
}
Exemplo n.º 27
0
static char* getString(DCM_OBJECT* obj, DCM_TAG tag)
{
  DCM_ELEMENT e;
  CONDITION cond;

  memset(&e, 0, sizeof(e));
  e.tag = tag;
  cond = DCM_GetElement(&obj, tag, &e);
  if (cond != DCM_NORMAL)
    return 0;

  e.d.string = malloc(e.length + 1);
  cond = DCM_ParseObject(&obj, &e, 1, 0, 0, 0);
  if (cond != DCM_NORMAL) {
    COND_DumpConditions();
    exit(1);
  }

  return e.d.string;
}
Exemplo n.º 28
0
void
loadGroupGroupList()
{
    CONDITION
    cond;
    DMAN_GROUPNAMES
	g,
	criteria;
    char
        b[256];

    if (createLists() == 0)
	return;

    memset(&g, 0, sizeof(g));
    g.Type = DMAN_K_GROUPNAMES;
    criteria.Type = DMAN_K_GROUPNAMES;
    criteria.Flag = 0;
    cond = DMAN_Select(&dmanHandle,
		       (DMAN_GENERICRECORD *) & g,
		       (DMAN_GENERICRECORD *) & criteria,
		       groupNamesList, NULL, NULL, NULL);
    if (cond != DMAN_NORMAL) {
	COND_DumpConditions();
	return;
    }
    cond = extractGroups(groupNamesList, groupGroupList);
    if (cond != 1)
	return;

    MUT_LoadList(wGroupGroupList, groupGroupList,
		 formatGroupGroup, b);


    (void) DMAN_ClearList(groupTitleList);
    MUT_LoadList(wGroupTitleList, groupTitleList,
		 formatGroupTitle, b);
}
Exemplo n.º 29
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;
    }
*/
}
Exemplo n.º 30
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;
}