Пример #1
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);
}
Пример #2
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;
}
Пример #3
0
main(int argc, char **argv)
{
    FIS_HANDLE *fisHandle = NULL;
    char *fisDatabase;

    while (--argc > 0 && (*++argv)[0] == '-') {
	switch (*(argv[0] + 1)) {
	case 'h':
	    usageerror();
	    break;
	default:
	    break;
	}
    }

    if (argc < 1)
	usageerror();

    THR_Init();
    fisDatabase = *argv++;
    openFIS(fisDatabase, &fisHandle);

    dumpCommitRequests(&fisHandle);

    closeFIS(&fisHandle);
    THR_Shutdown();

    return 0;
}
Пример #4
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;
}
Пример #5
0
static void fileToHTML(const char* path)
{
  DCM_OBJECT* obj;
  CONDITION cond;

  THR_Init();
  cond = DCM_OpenFile(path, DCM_ORDERLITTLEENDIAN, &obj);
  if (cond != DCM_NORMAL) {
    (void) DCM_CloseObject(&obj);
    cond = DCM_OpenFile(path, DCM_PART10FILE, &obj);
  }
  if (cond != DCM_NORMAL) {
    exit(0);
  }
#if 1
    printf("Content-type: text/html\n\n");
    printf("<HTML>\n");
    printf("<HEAD>\n");
    printf("<META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=iso-2022-jp"">\n");
    printf("<TITLE>dcm_to_html</TITLE>\n");
    printf("</HEAD>");

    printf("<BODY BGCOLOR=#ffffff FGCOLOR=#ff000000>\n");
    printf("<B>%s</B>\n", path);
    printf("<TABLE BORDER>\n");
    DCM_ScanParseObject(&obj,
			NULL, 0,           /* Buffer/buffer size */
			NULL, 0,           /* Vector of elements to scan */
			callback, NULL);
    printf("</TABLE>\n");
    printf("</BODY>\n");
    printf("</HTML>");

    (void) DCM_CloseObject(&obj);
    THR_Shutdown();
#else
  html_header();
  html_begin_body_options("File View", "bgcolor=#ffffff");
  printf("%s<br>\n", path);
  html_end();
#endif
}
Пример #6
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);
}
Пример #7
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;
}
Пример #8
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;
}
Пример #9
0
int
main(int argc, char **argv)
{
    CONDITION
    cond = APP_NORMAL;		/* condition code returned by various
				 * facilities */
    DUL_NETWORKKEY
	* network;		/* The handle to the network */
    DUL_ASSOCIATIONKEY
	* association = NULL;	/* The handle to the Association */
    DUL_ASSOCIATESERVICEPARAMETERS
	service;		/* Presentation parameters */
    int
        pid,			/* process id */
        port;			/* port number on which the server listens */
    char
        node[MAXHOSTNAMELEN + 1] = "";	/* name of node */
    CTNBOOLEAN
	singleUserMode = FALSE;	/* indicates if the server will run in single
				 * user mode i.e. iterative */
    LST_HEAD
	* processList = NULL;	/* maintains a list of children processes */
    CTNBOOLEAN paramsFlag = FALSE;	/* Dump association parameters? */

    (void) gethostname(node, MAXHOSTNAMELEN);
    /* Parse the command line arguments. First process all the switches */
    while (--argc > 0 && *(++argv)[0] == '-') {
	switch ((*argv)[1]) {
	case 'd':		/* option to put a specific facility in debug
				 * mode */
	    argc--;
	    argv++;
	    if (!argc)
		usageError();
	    if (strcmp(*argv, "DCM") == 0)
		verboseDCM = TRUE;
	    else if (strcmp(*argv, "DUL") == 0)
		verboseDUL = TRUE;
	    else if (strcmp(*argv, "SRV") == 0)
		verboseSRV = TRUE;
	    else
		usageError();
	    break;
	case 'f':		/* database selection option */
	    argc--;
	    argv++;
	    if (!argc)
		usageError();
	    controlDatabase = *argv;
	    break;
	case 'i':		/* set the forgive option */
	    forgiveFlag = TRUE;
	    break;
	case 'n':		/* use node as name rather than hostname */
	    if (argc < 1)
		usageError();
	    argc--;
	    argv++;
	    strcpy(node, *argv);
	    break;
	case 'p':
	    paramsFlag = TRUE;	/* Dump the association parameters to stdout */
	    break;
	case 'r':
	    sendBack = TRUE;	/* send optional attributes back in the
				 * response messages */
	    break;
	case 's':		/* set single user mode. Useful for debugging */
	    singleUserMode = TRUE;
	    break;
	case 't':
	    traceFlag = TRUE;	/* tracing ON (non silent operation) */
	    break;
	case 'v':		/* set verbose mode ON */
	    verboseDUL = TRUE;
	    verboseSRV = TRUE;
	    verboseDCM = TRUE;
	    break;
	case 'x':		/* for maintaining a Generalized Queue. This
				 * option is useful for terminals having X
				 * capability */
	    gqueueFlag = TRUE;
#ifdef ASG
	    argc--;
	    argv++;
	    if (sscanf(*argv, "%d", &gqID) != 1)
		usageError();
#endif
	    break;
	default:
	    printf("Unrecognized option: %s\n", *argv);
	    break;
	}
    }

    if (argc < 1)
	usageError();

    if (sscanf(*argv++, "%d", &port) != 1)
	usageError();

#ifdef _MSC_VER
    singleUserMode = TRUE;
#endif

    THR_Init();
    DCM_Debug(verboseDCM);
    DUL_Debug(verboseDUL);
    SRV_Debug(verboseSRV);

    /* Handle interrupts */
    (void) signal(SIGINT, signalHandler);

    /* Initialize a network connection and listen on the specified port */
    cond = DUL_InitializeNetwork(DUL_NETWORK_TCP, DUL_AEBOTH,
		 (void *) &port, DUL_TIMEOUT, DUL_ORDERBIGENDIAN, &network);
    if (cond != DUL_NORMAL) {
	exitApplication(cond);
    }
    appHandles.network = network;	/* set the network key field */
    if (!singleUserMode) {
	/*
	 * initialize a list that will hold information about all the
	 * children processes that are active
	 */
	if ((processList = LST_Create()) == NULL) {
	    cond = COND_PushCondition(APP_ERROR(APP_FAILURE), "LST_Create",
				      "main");
	    exitApplication(cond);
	}
	appHandles.processList = processList;	/* set the process list field */
    }
    /* The server loops forever accepting new requests */
    while (1) {
	/* get the next Association request */
	cond = nextAssociationRequest(node, &network, &service, maxPDU,
				      forgiveFlag, &gqID, &association);
	if (cond == APP_NORMAL) {
	    appHandles.association = association;
	    appHandles.service = &service;
	    if (!singleUserMode) {
		/*
		 * remove all those child processes that have exited so that
		 * zombie processes are not created
		 */
		(void) harvestChildrenProcesses(&processList);
		/*
		 * server continues to accept new requests, whereas the child
		 * services the requests on that association. To create a
		 * child process, we fork
		 */
		pid = fork();
	    } else
		pid = 0;	/* setting pid to 0 in this else clause is
				 * essential due to the manner in which the
				 * following if condition is coded */

	    if (pid < 0) {
		/* fork failed */
		printf("Cannot spawn child process. Request rejected\n");
		clearAssociationKeyAndServiceParameters(APP_FAILURE);
		continue;
	    } else if (pid == 0) {	/* This is the child process unless
					 * the single user mode is ON in
					 * which case this is the parent
					 * process itself. For this part of
					 * the code to be activated when the
					 * singleUserMode is TRUE, we need to
					 * set pid = 0 as done above */
		if (!singleUserMode)
		    printf("Forked child\n");
		cond = DUL_AcknowledgeAssociationRQ(&association, &service);
		if (cond != DUL_NORMAL) {
		    if (!singleUserMode) {
			/* child process exits with a status of -1 */
			exitApplication(cond);
		    } else {
			/*
			 * In the single user mode, the parent just discards
			 * the current association and service parameters and
			 * continues to listen to new requests
			 */
			clearAssociationKeyAndServiceParameters(cond);
			continue;	/* go to next iteration of main loop */
		    }
		}
		/*
		 * open a GQ queue, if the GQ facility is to be used
		 */
		if (gqueueFlag) {
		    if (gqID == -1) {	/* we were unsuccessful retrieving
					 * the GQ ID info from the database.
					 * Hence we decide to ignore the
					 * display */
			fprintf(stderr,
				"Failure to retrieve GQ ID information\n");
			fprintf(stderr,
				"GQ facility ignored\n");
			gqueueFlag = FALSE;
		    } else {
			/* open a GQ */
			cond = openGQ(gqID);
			if (cond != APP_NORMAL) {
			    if (!singleUserMode) {
				/* child process exits with a status of -1 */
				exitApplication(cond);
			    } else {
				clearAssociationKeyAndServiceParameters(cond);
				continue;	/* go to next iteration of
						 * main loop */
			    }
			}
		    }
		}
		if (paramsFlag)
		    DUL_DumpParams(&service);
		cond = serviceRequests(&network, &association, &service);
		if (cond == SRV_PEERREQUESTEDRELEASE)
		    cond = SRV_NORMAL;
		if (CTN_ERROR(cond)) {
		    if (!singleUserMode) {
			fprintf(stderr, "child failed to service request\n");
			COND_DumpConditions();
			exitApplication(cond);
		    } else {
			/*
			 * In the single user mode, the parent just discards
			 * the current association and service parameters and
			 * continues to listen to new requests
			 */
			fprintf(stderr,
			      "Iterative server failed to serve request\n");
			clearAssociationKeyAndServiceParameters(cond);
			continue;	/* go to next iteration of main loop */
		    }
		}
		if (!singleUserMode) {
		    /* graceful exit by the child process (return status 0) */
		    exitApplication(SRV_NORMAL);
		}
	    } else {
		/*
		 * Parent has to drop the Association that was created for
		 * the child when an Association request arrived from the
		 * client. If this is not done, both the parent and the child
		 * are capable of receiving on the same association
		 */
		cond = DUL_DropAssociation(&association);
		if (cond != DUL_NORMAL) {
		    exitApplication(cond);
		}
		/*
		 * Add information of the process to the list maintained by
		 * the parent
		 */
		(void) addChildProcess(&service, pid, &processList);
		/*
		 * Now clear the service parameters so as to accept a new set
		 * of parameters on the association
		 */
		(void) DUL_ClearServiceParameters(&service);
		printf("Parent ready to accept new request\n");
	    }
	} else {
	    /*
	     * something went wrong accepting the next Association request
	     * Parent server issues an error message and continues to serve
	     * the next request
	     */
	    fprintf(stderr, "!!!! Error getting next Request.\n");
	    fprintf(stderr, "Discarding this request\n");
	    COND_DumpConditions();
	}
    }
#ifdef MALLOC_DEBUG
    malloc_verify(0);
    malloc_shutdown();
#endif
    return 0;
}
Пример #10
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);
}
Пример #11
0
main(int argc, char **argv)
{
    CONDITION			/* Return values from facilities */
	cond;
    DUL_NETWORKKEY		/* Used to initialize our network */
	* network = NULL;
    DUL_ASSOCIATESERVICEPARAMETERS	/* The items which describe this
					 * Association */
	params = {
	DICOM_STDAPPLICATIONCONTEXT, "DEMO_SENDER_93", "RSNA_STORAGE_93",
	    "", 16384, 0, 0, 0,
	    "calling addr", "called addr", NULL, NULL, 0, 0,
	    MIR_IMPLEMENTATIONCLASSUID, MIR_IMPLEMENTATIONVERSIONNAME,
	    "", ""
    };
    char
       *calledAPTitle = "RSNA_STORAGE_93",
       *callingAPTitle = "DEMO_SENDER_93",
        localHost[40],
       *node,			/* The node we are calling */
       *port;			/* ASCIIZ representation of TCP port */
    int
        scratch;		/* Used to check syntax of port number */
    unsigned long
        maxPDU = 16384;

    CTNBOOLEAN
	verboseDCM = FALSE,
	verboseDUL = FALSE,
	verboseSRV = FALSE;

    while (--argc > 0 && (*++argv)[0] == '-') {
	switch (*(argv[0] + 1)) {
	case 'c':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    callingAPTitle = *argv;
	    break;
	case 'd':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    if (strcmp(*argv, "DCM") == 0)
		verboseDCM = TRUE;
	    else if (strcmp(*argv, "DUL") == 0)
		verboseDUL = TRUE;
	    else if (strcmp(*argv, "SRV") == 0)
		verboseSRV = TRUE;
	    else
		usageerror();
	    break;
	case 'm':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    if (sscanf(*argv, "%lu", &maxPDU) != 1)
		usageerror();
	    break;
	case 't':
	    argc--;
	    argv++;
	    if (argc <= 0)
		usageerror();
	    calledAPTitle = *argv;
	    break;
	case 'v':
	    verboseDUL = TRUE;
	    verboseSRV = TRUE;
	    break;
	default:
	    break;
	}
    }
    if (argc < 2)
	usageerror();

    THR_Init();
    DCM_Debug(verboseDCM);
    DUL_Debug(verboseDUL);
    SRV_Debug(verboseSRV);
    node = *argv++;
    argc--;
    port = *argv++;
    argc--;
    if (sscanf(port, "%d", &scratch) != 1)
	usageerror();

    cond = DUL_InitializeNetwork(DUL_NETWORK_TCP, DUL_AEREQUESTOR,
			   NULL, DUL_TIMEOUT, DUL_ORDERBIGENDIAN, &network);
    if (cond != DUL_NORMAL)
	myExit(NULL);

    (void) gethostname(localHost, sizeof(localHost));
    sprintf(params.calledPresentationAddress, "%s:%s", node, port);
    strcpy(params.callingPresentationAddress, localHost);
    strcpy(params.calledAPTitle, calledAPTitle);
    strcpy(params.callingAPTitle, callingAPTitle);
    params.maxPDU = maxPDU;

    reqReleaseAssociation(&network, &params);
    THR_Shutdown();
    exit(0);
}
Пример #12
0
main(int argc, char **argv)
{

  CONDITION cond;

  DUL_NETWORKKEY* network = NULL;
  DUL_ASSOCIATIONKEY* association = NULL;
  DUL_ASSOCIATESERVICEPARAMETERS params;
  char
    *calledAPTitle = "QUERY_SCP",
    *callingAPTitle = "QUERY_SCU";

  char localHost[40];

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

  CTNBOOLEAN
    verbose = FALSE,
    abortFlag = FALSE,
    paramsFlag = FALSE;
  char *fileName = NULL;
  DUL_SC_ROLE role = DUL_SC_ROLE_DEFAULT;
  MSG_C_FIND_RESP response;
  MSG_C_FIND_REQ findRequest = {MSG_K_C_FIND_REQ, 0, 0,
				DCM_CMDDATAIDENTIFIER,
				0, NULL, DICOM_SOPPATIENTQUERY_FIND};
  char* queryLevel = "patient";
  LST_HEAD* patientList = 0;
  LST_HEAD* studyList = 0;

  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 'f':
      argc--;
      argv++;
      if (argc <= 0)
	usageerror();
      fileName = *argv;
      break;
    case 'l':
      argc--;
      argv++;
      if (argc <= 0)
	usageerror();
      queryLevel = *argv;
      break;
    case 'p':
      paramsFlag = TRUE;
      break;
    case 'v':
      verbose = 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);

  DUL_DefaultServiceParameters(&params);
  sprintf(params.calledPresentationAddress, "%s:%s", node, *argv);
  strcpy(params.callingPresentationAddress, localHost);
  strcpy(params.calledAPTitle, calledAPTitle);
  strcpy(params.callingAPTitle, callingAPTitle);
  cond = SRV_RequestServiceClass(DICOM_SOPPATIENTQUERY_FIND, 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);
  }
  findRequest.messageID = SRV_MessageIDOut();
  findRequest.identifier = createQueryObject(fileName);


  patientList = LST_Create();
  studyList = LST_Create();

  cond = SRV_CFindRequest(&association, &params,
			  &findRequest, &response,
			  queryCallback, patientList, "");
  if (!(CTN_SUCCESS(cond))) {
    (void) printf("Verification Request unsuccessful\n");
    COND_DumpConditions();
  } else {
    MSG_DumpMessage(&response, stdout);
  }
  SRV_MessageIDIn(findRequest.messageID);

  if (strcmp(queryLevel, "patient") != 0) {
    handleStudyQueries(&association, &params, &findRequest,
		       patientList, queryLevel);
  }

  if (strcmp(queryLevel, "series") == 0) {
    handleSeriesQueries(&association, &params, &findRequest,
			patientList, queryLevel);
  }

  cond = DUL_ReleaseAssociation(&association);
  if (cond != DUL_RELEASECONFIRMED) {
    (void) fprintf(stderr, "%x\n", cond);
    COND_DumpConditions();
  }
  (void) DUL_ClearServiceParameters(&params);

  printResults(patientList);

  (void) DUL_DropNetwork(&network);
  THR_Shutdown();
  return 0;
}
Пример #13
0
main(int argc, char *argv[])
#endif				/* _NO_PROTO */
{
    char
       *databaseName = "CTNControl";
    CONDITION
	cond;
    CTNBOOLEAN
	verboseTBL = FALSE;

    /*-----------------------------------------------------------
     * Declarations.
     * The default identifier - mainIface will only be declared
     * if the interface function is global and of type swidget.
     * To change the identifier to a different name, modify the
     * string mainIface in the file "xtmain.dat". If "mainIface"
     * is declared, it will be used below where the return value
     * of  PJ_INTERFACE_FUNCTION_CALL will be assigned to it.
     *----------------------------------------------------------*/

    Widget mainIface;

    /*---------------------------------
     * Interface function declaration
     *--------------------------------*/

    Widget create_applicationShell1(swidget);

    swidget UxParent = NULL;


    /*---------------------
     * Initialize program
     *--------------------*/

#ifdef XOPEN_CATALOG
    if (XSupportsLocale()) {
	XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
    }
#endif

    SgePreInitialize(&argc, argv);

    UxTopLevel = XtAppInitialize(&UxAppContext, "cfg_ctn_tables",
				 NULL, 0, &argc, argv, NULL, NULL, 0);

    UxDisplay = XtDisplay(UxTopLevel);
    UxScreen = XDefaultScreen(UxDisplay);

    /*
     * We set the geometry of UxTopLevel so that dialogShells that are
     * parented on it will get centered on the screen (if defaultPosition is
     * true).
     */

    XtVaSetValues(UxTopLevel,
		  XtNx, 0,
		  XtNy, 0,
		  XtNwidth, DisplayWidth(UxDisplay, UxScreen),
		  XtNheight, DisplayHeight(UxDisplay, UxScreen),
		  NULL);

    /*-------------------------------------------------------
     * Insert initialization code for your application here
     *------------------------------------------------------*/
    while (--argc > 0 && *(++argv)[0] == '-') {
	switch ((*argv)[1]) {
	case 'f':
	    if (argc-- < 1)
		exit(1);
	    databaseName = *++argv;
	    break;
	case 'h':
	    usageerror();
	    break;
	case 'x':
	    if (argc-- < 0)
		usageerror();
	    argv++;
	    if (strcmp(*argv, "TBL") == 0)
		verboseTBL = TRUE;
	    else
		usageerror();
	    break;
	default:
	    printf("Unrecognized option: %s\n", *argv);
	    break;
	}
    }
    TBL_Debug(verboseTBL);
    THR_Init();
    cond = DMAN_Open(databaseName, "", "", &dmanHandle);
    if (cond != DMAN_NORMAL) {
	COND_DumpConditions();
	exit(1);
    }
    /*----------------------------------------------------------------
     * Create and popup the first window of the interface.  The
     * return value can be used in the popdown or destroy functions.
     * The Widget return value of  PJ_INTERFACE_FUNCTION_CALL will
     * be assigned to "mainIface" from  PJ_INTERFACE_RETVAL_TYPE.
     *---------------------------------------------------------------*/

    mainIface = create_applicationShell1(UxParent);

    UxPopupInterface(mainIface, no_grab);

    /*-----------------------
     * Enter the event loop
     *----------------------*/

    XtAppMainLoop(UxAppContext);

}
Пример #14
0
int
main(int argc, char **argv)
{
    XEvent
    report;
    CONDITION
	retval;
    void
       *data;
    unsigned char
       *new_data;
    int count_args,
        file_arg;
    int study_Q_id,
        status_Q_id;

    struct timeval
        t_start,		/* Variables to compute timings... */
        t_end;
    struct timezone
        t_zone;

    double
        deltaTime;

    char dicom_file[MAX_STRING_LENGTH];

    unsigned long options = DCM_ORDERLITTLEENDIAN;
    int overrideWidth = NO_OVERRIDE,
        overrideCenter = NO_OVERRIDE;

    CTNBOOLEAN verbose = FALSE;
    CTNBOOLEAN useImport = FALSE;

/*
 * Get the input paramaters from command line
 */
    if (argc < 2) {
	COND_PushCondition(DICOMXDISP_CMDLINE, DICOMXDISP_usage);
	COND_DumpConditions();
	return (-1);
    }
    count_args = file_arg = 0;
    argc--;
    argv++;
    while (argc > 0) {
	if (strcmp(*argv, "-b") == 0) {
	    argc--;
	    argv++;
	    options &= ~DCM_ORDERMASK;
	    options |= DCM_ORDERBIGENDIAN;
	} else if ((strcmp(*argv, "-i")) == 0) {
	    argc--;
	    argv++;
	    useImport = TRUE;
	} else if ((strcmp(*argv, "-t")) == 0) {
	    argc--;
	    argv++;
	    options &= ~DCM_FILEFORMATMASK;
	    options |= DCM_PART10FILE;
	} else if ((strcmp(*argv, "-v")) == 0) {
	    verbose = TRUE;
	} else if ((strcmp(*argv, "-w")) == 0) {
	    argc--;
	    argv++;
	    G_display_width = atoi(*argv);
	    if (G_display_width < MIN_DISPLAY_WIDTH) {
		COND_PushCondition(DICOMXDISP_CMDLINE,
		  "%s: Display width must be > MIN_DISPLAY_WIDTH", argv[0]);
		COND_DumpConditions();
		return (-1);
	    }
	    count_args++;
	    argc--;
	    argv++;
	} else if ((strcmp(*argv, "-h")) == 0) {
	    argc--;
	    argv++;
	    G_display_height = atoi(*argv);
	    if (G_display_height < MIN_DISPLAY_HEIGHT) {
		COND_PushCondition(DICOMXDISP_CMDLINE,
		"%s: Display height must be > MIN_DISPLAY_HEIGHT", argv[0]);
		COND_DumpConditions();
		return (-1);
	    }
	    count_args++;
	    argc--;
	    argv++;
	} else if ((strcmp(*argv, "-W")) == 0) {
	    argc--;
	    argv++;
	    overrideWidth = atoi(*argv);
	    argc--;
	    argv++;
	} else if ((strcmp(*argv, "-C")) == 0) {
	    argc--;
	    argv++;
	    overrideCenter = atoi(*argv);
	    argc--;
	    argv++;
	} else {
	    strcpy(dicom_file, *argv);
	    file_arg++;
	    argc--;
	    argv++;
	}
    }
    if (count_args != 2)	/* -1's indicate to set the width and height
				 * to full screen */
	G_display_width = G_display_height = -1;

    THR_Init();
    if (file_arg != 1) {
	COND_PushCondition(DICOMXDISP_CMDLINE, "No filename specified");
	COND_DumpConditions();
	THR_Shutdown();
	return (-1);
    }
    /* Initialize the X stuff, load gray-scale color table */
    if ((InitializeX(128)) != DICOMXDISP_NORMAL) {
	COND_PushCondition(DICOMXDISP_NOXWINDOWS,
			   "No Connection to X-Server.");
	COND_DumpConditions();
	THR_Shutdown();
	return (-1);
    }
/*
 * Main Control loop for acrxdisp
 */
    next_img.error_condition = FALSE;

    gettimeofday(&t_start, &t_zone);

    data = GetDICOMData(dicom_file, options, &next_img, overrideWidth, overrideCenter, useImport);

    gettimeofday(&t_end, &t_zone);
    deltaTime = DELTATIME(t_start, t_end);

    if (data != NULL) {
	gettimeofday(&t_start, &t_zone);

	if (overrideWidth != NO_OVERRIDE) {
	    COND_PushCondition(DICOMXDISP, "  New Window Width: %d", overrideWidth);
	    next_img.window = overrideWidth;
	}
	if (overrideCenter != NO_OVERRIDE) {
	    COND_PushCondition(DICOMXDISP, " New Window Center: %d", overrideCenter);
	    next_img.level = overrideCenter;
	}
	new_data = ScaleImageData(data, &next_img);
	if (new_data == NULL)
	    fprintf(stderr, "ScaleImageData returned null pointer\n");

	gettimeofday(&t_end, &t_zone);
	deltaTime = DELTATIME(t_start, t_end);
    }
    gettimeofday(&t_start, &t_zone);
    /* 8-bit data must be converted if G_pixel_depth != 8 */
    AdjustImageDepth(&next_img);

    DisplayImageData(&next_img, &xnext_img);
    COND_DumpConditions();
    cur_img = next_img;
    xcur_img = xnext_img;

    gettimeofday(&t_end, &t_zone);
    deltaTime = DELTATIME(t_start, t_end);
    if (verbose)
	printf("Time to get to display is: %f\n", deltaTime);

    Refresh();

    THR_Shutdown();
    return 0;
}
Пример #15
0
main()
{
    CONDITION
	cond;
    TBL_HANDLE
	* handle;
/*
    TBL_CRITERIA
	criteria[10];
*/
    long
        count;
    void
       *foo = NULL;

    static TBL_FIELD
        fields[] = {
	{"FNAME", TBL_STRING, 50, 0, 1, (void *) fname},
	{"LNAME", TBL_STRING, 50, 0, 1, (void *) lname},
	{"AGE", TBL_SIGNED4, 4, 0, 1, &age},
	{"ZIP", TBL_SIGNED4, 4, 0, 1, &zip},
	{"WEIGHT", TBL_FLOAT4, 4, 0, 1, &weight},
	{NULL}
    };

    static TBL_FIELD
        fields1[] = {
	{"T_TEXT", TBL_TEXT, 50, 0, 1, (void *) textTest},
	{NULL}
    };

    THR_Init();
    cond = TBL_Open("TBLTest", "TBL_Persons", &handle);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	exit(1);
    }
/*
    criteria[0].FieldName = "LNAME";
    criteria[0].Operator = TBL_EQUAL;
    TBL_LOAD_STRING(&criteria[0].Value, "JONES");

    criteria[1].FieldName = 0;
*/

    cond = TBL_Select(&handle, NULL, fields, &count, callback, (void *) foo);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(2);
    }
    printf("ALL DONE--Count: %d\n", count);

    (void) TBL_Close(&handle);

#ifdef _MSC_VER
    cond = TBL_Open("TBLTest", "TBL_DataTypes", &handle);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(1);
    }
    count = 0;
    cond = TBL_Select(&handle, NULL, fields1, &count, callback, (void *) foo);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(3);
    }
    printf("ALL DONE--Count: %d\n", count);


#endif

    THR_Shutdown();
    exit(0);
}
Пример #16
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;
}
Пример #17
0
void
main(int argc, char *argv[])
{
    int
    height,
    width,
    temp;
    Boolean
    GOT_QID = False;
    CONDITION
    cond;

    toplevel = XtAppInitialize(	/* create application context */
                   &app_ctx,
                   "print_server_display",
                   NULL, 0,
#ifdef SOLARIS
                   (Cardinal *) & argc,
#else
                   &argc,
#endif
                   argv,
                   NULL,
                   NULL, 0);

    width = MAX_WIDTH - 10;
    height = MAX_HEIGHT - 10;
    argc--;
    argv++;
    while (argc > 0) {
        if (strcmp(*argv, "-w") == 0) {
            argc--;
            argv++;
            temp = atoi(*argv);
            if (temp < MIN_WIDTH) {
                fprintf(stderr, "Height must be > %d\n", MIN_WIDTH);
                UsageError();
                exit(0);
            }
            if (temp > MAX_WIDTH) {
                fprintf(stderr, "Height must be < %d\n", MAX_WIDTH);
                UsageError();
                exit(0);
            }
            width = temp;
            argc--;
            argv++;
        } else if (strcmp(*argv, "-h") == 0) {
            argc--;
            argv++;
            temp = atoi(*argv);
            if (temp < MIN_HEIGHT) {
                fprintf(stderr, "Height must be > %d\n", MIN_HEIGHT);
                UsageError();
                exit(0);
            }
            if (temp > MAX_HEIGHT) {
                fprintf(stderr, "Height must be < %d\n", MAX_HEIGHT);
                UsageError();
                exit(0);
            }
            height = temp;
            argc--;
            argv++;
        } else if (strcmp(*argv, "-v") == 0) {
            argc--;
            argv++;
            (void) COND_EstablishCallback(cond_CB);
        } else {
            if (argc != 1) {
                fprintf(stderr, "Only the last parameter is a none switch\n");
                UsageError();
                exit(0);
            }
            queue_id = atoi(*argv);
            if (queue_id == 0) {
                fprintf(stderr, "Invalid queueu ID\n");
                UsageError();
                exit(0);
            }
            argc--;
            argv++;
            GOT_QID = True;
        }
    }
    if (GOT_QID == False) {
        fprintf(stderr, "Error: Missing QID\n");
        UsageError();
        exit(0);
    }
    THR_Init();
    /* The print_server_display creates a GQ with the specified ID */
    cond = GQ_InitQueue(queue_id, 128, sizeof(GQ_ELEM));
    if (cond != GQ_NORMAL) {
        fprintf(stderr, "GQ_InitQueue failed to create GQ with ID : %d\n",
                queue_id);
        COND_DumpConditions();
        exit(1);
    }
    /* now get hold of the just created GQ */
    cond = GQ_GetQueue(queue_id, sizeof(GQ_ELEM));
    switch (cond) {
    case GQ_SHAREDMEMORYFAIL:
        fprintf(stderr, "GQ Shared Memory failed\n");
        exit(0);
    case GQ_FILEACCESSFAIL:
        fprintf(stderr, "GQ File Access failed\n");
        exit(0);
    case GQ_BADELEMSIZE:
        fprintf(stderr, "GQ Bad Element Size\n");
        exit(0);
    case GQ_UNIMPLEMENTED:
        fprintf(stderr, "GQ Unimplemented\n");
        exit(0);
    case GQ_NORMAL:
        break;
    }
    session_list = LST_Create();
    printf("width = %d, height = %d\n", width, height);
    createMainWin();
    XtRealizeWidget(toplevel);
    DISP_Initialize(toplevel, width, height);
    /*
        DISP_CreateSession("1.2.840.113654.2.3.1993.9.123.9.3221", "test", &session_list);
        DISP_AddBox("test", "PRN_13674.2", &session_list);
        DISP_AddBox("test2", "PRN_13674.2", &session_list);
        DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.5", &session_list);
        DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3225", "PRN_13674.4", &session_list);
        DISP_SetImage("1.2.840.113654.2.3.1993.9.123.9.3226", "PRN_13674.3", &session_list);
    */
    /*lint -e64*/
    XtAppAddTimeOut(app_ctx, TIMEOUT, pollQueue, NULL);
    /*lint +e64*/
    XtAppMainLoop(app_ctx);
    THR_Shutdown();
}
Пример #18
0
main(int argc, char **argv)
{
    CONDITION cond;
    LST_HEAD *l,
       *elementList;
    DCM_ELEMENT_NODE *n,
       *elementNode;
    unsigned short group;
    CTNBOOLEAN uidDictionary = FALSE;

    while (--argc > 0 && (*++argv)[0] == '-') {
	switch (*(argv[0] + 1)) {
	case 'u':
	    uidDictionary = TRUE;
	    break;
	default:
	    fprintf(stderr, "Unrecognized option: %s\n", *argv);
	    exit(1);
	    break;
	}
    }

    THR_Init();
    if (uidDictionary) {
	UID_ScanDictionary(uidCallback, 0);
	THR_Shutdown();
	return 0;
    }
    l = LST_Create();
    if (l == NULL) {
	THR_Shutdown();
	return 1;
    }
    elementList = LST_Create();
    if (elementList == NULL) {
	THR_Shutdown();
	return 1;
    }
    cond = DCM_GroupDictionary(0xffff, &l, groupCallback);
    if (cond != DCM_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(1);
    }
    n = LST_Dequeue(&l);
    while (n != NULL) {
	group = DCM_TAG_GROUP(n->e.tag);
	printf("%04x  %s\n", group, n->e.description);

	cond = DCM_ElementDictionary(DCM_MAKETAG(group, 0xffff), &elementList,
				     elementCallback);
	if (cond != DCM_NORMAL) {
	    COND_DumpConditions();
	    THR_Shutdown();
	    exit(1);
	}
	elementNode = LST_Dequeue(&elementList);
	while (elementNode != NULL) {
	    printf("  %04x %04x %s %s\n",
		   DCM_TAG_GROUP(elementNode->e.tag),
		   DCM_TAG_ELEMENT(elementNode->e.tag),
		   translate(elementNode->e.representation),
		   elementNode->e.description);

	    free(elementNode);
	    elementNode = LST_Dequeue(&elementList);
	}

	free(n);
	n = LST_Dequeue(&l);
    }
    THR_Shutdown();
    return 0;
}
Пример #19
0
static void *
vwe_thread(void *priv)
{
	struct epoll_event ev[NEEV], *ep;
	struct waited *wp;
	struct waiter *w;
	double now, then;
	int i, n, active;
	struct vwe *vwe;
	char c;

	CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC);
	w = vwe->waiter;
	CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
	THR_SetName("cache-epoll");
	THR_Init();

	now = VTIM_real();
	while (1) {
		while (1) {
			Lck_Lock(&vwe->mtx);
			/*
			 * XXX: We could avoid many syscalls here if we were
			 * XXX: allowed to just close the fd's on timeout.
			 */
			then = Wait_HeapDue(w, &wp);
			if (wp == NULL) {
				vwe->next = now + 100;
				break;
			} else if (then > now) {
				vwe->next = then;
				break;
			}
			CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC);
			AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_DEL, wp->fd, NULL));
			vwe->nwaited--;
			AN(Wait_HeapDelete(w, wp));
			Lck_Unlock(&vwe->mtx);
			Wait_Call(w, wp, WAITER_TIMEOUT, now);
		}
		then = vwe->next - now;
		i = (int)ceil(1e3 * then);
		assert(i > 0);
		Lck_Unlock(&vwe->mtx);
		do {
			/* Due to a linux kernel bug, epoll_wait can
			   return EINTR when the process is subjected to
			   ptrace or waking from OS suspend. */
			n = epoll_wait(vwe->epfd, ev, NEEV, i);
		} while (n < 0 && errno == EINTR);
		assert(n >= 0);
		assert(n <= NEEV);
		now = VTIM_real();
		for (ep = ev, i = 0; i < n; i++, ep++) {
			if (ep->data.ptr == vwe) {
				assert(read(vwe->pipe[0], &c, 1) == 1);
				continue;
			}
			CAST_OBJ_NOTNULL(wp, ep->data.ptr, WAITED_MAGIC);
			Lck_Lock(&vwe->mtx);
			active = Wait_HeapDelete(w, wp);
			Lck_Unlock(&vwe->mtx);
			if (!active) {
				VSL(SLT_Debug, wp->fd, "epoll: spurious event");
				continue;
			}
			AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_DEL, wp->fd, NULL));
			vwe->nwaited--;
			if (ep->events & EPOLLIN)
				Wait_Call(w, wp, WAITER_ACTION, now);
			else if (ep->events & EPOLLERR)
				Wait_Call(w, wp, WAITER_REMCLOSE, now);
			else if (ep->events & EPOLLHUP)
				Wait_Call(w, wp, WAITER_REMCLOSE, now);
			else
				Wait_Call(w, wp, WAITER_REMCLOSE, now);
		}
		if (vwe->nwaited == 0 && vwe->die)
			break;
	}
	closefd(&vwe->pipe[0]);
	closefd(&vwe->pipe[1]);
	closefd(&vwe->epfd);
	return (NULL);
}
Пример #20
0
main()
{
    CONDITION
	cond;
    TBL_HANDLE
	* handle;
    TBL_CRITERIA
	criteria[10];
    int
        age;

    static TBL_UPDATE
        fields[] = {
	{"LNAME", TBL_SET, TBL_STRING, 50, 0, 1, (void *) "WOODROW"},
	{NULL}
    };
#ifdef _MSC_VER
    static TBL_UPDATE
        fields1[] = {
	{"T_TEXT", TBL_SET, TBL_STRING, 50, 0, 1, (void *) "Updated Text Data"},
	{NULL}
    };
#endif

    THR_Init();
    cond = TBL_Open("TBLTest", "TBL_Persons", &handle);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(1);
    }
    criteria[0].FieldName = "AGE";
    criteria[0].Operator = TBL_EQUAL;
    criteria[0].Value.Type = TBL_SIGNED4;
    age = 50;
    criteria[0].Value.Value.Signed4 = &age;
    criteria[0].Value.IsNull = 0;
    criteria[0].Value.AllocatedSize = 4;
    criteria[1].FieldName = 0;

    cond = TBL_Update(&handle, criteria, fields);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(2);
    }
    (void) TBL_Close(&handle);

#ifdef _MSC_VER
    cond = TBL_Open("TBLTest", "TBL_DataTypes", &handle);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(1);
    }
    cond = TBL_Update(&handle, NULL, fields1);
    if (cond != TBL_NORMAL) {
	COND_DumpConditions();
	THR_Shutdown();
	exit(3);
    }
    (void) TBL_Close(&handle);
#endif

    printf("\n\nUpdate operation succeeded\n\n");

    THR_Shutdown();
    exit(0);
}