Doxygen Source Code Documentation
l_mri_dicom_hdr.c File Reference
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <errno.h>#include <stdarg.h>#include <ctype.h>#include "mri_dicom_hdr.h"#include "Amalloc.h"#include "dbtrace.h"Go to the source code of this file.
Define Documentation
|
|
Definition at line 80 of file l_mri_dicom_hdr.c. Referenced by copyData(), DCM_GetCompressedValue(), DCM_GetElementValue(), DCM_GetElementValueOffset(), and RWC_set_endianosity(). |
|
|
Definition at line 79 of file l_mri_dicom_hdr.c. Referenced by exportData(), exportFixedFields(), exportVRLength(), readData(), readFile(), readGroupElement(), readVRLength(), and RWC_set_endianosity(). |
|
|
Definition at line 10721 of file l_mri_dicom_hdr.c. Referenced by LST_Insert(), LST_Next(), LST_Position(), LST_Previous(), and LST_Remove(). |
|
|
Definition at line 353 of file l_mri_dicom_hdr.c. Referenced by COND_PushCondition(). |
|
|
Definition at line 81 of file l_mri_dicom_hdr.c. Referenced by DCM_GetCompressedValue(), exportStream(), extractFileOptions(), newElementItem(), readFile(), and readFile1(). |
|
|
Definition at line 113 of file l_mri_dicom_hdr.c. Referenced by RWC_printf(). |
|
|
Definition at line 10722 of file l_mri_dicom_hdr.c. Referenced by LST_Insert(), and LST_Remove(). |
|
|
Definition at line 10723 of file l_mri_dicom_hdr.c. Referenced by LST_Insert(), and LST_Remove(). |
|
|
Definition at line 164 of file l_mri_dicom_hdr.c. Referenced by DCM_DumpElements(), and mri_dicom_nohex(). |
|
|
Definition at line 163 of file l_mri_dicom_hdr.c. Referenced by DCM_DumpElements(), and mri_dicom_noname(). |
Typedef Documentation
|
|
|
Function Documentation
|
||||||||||||||||||||
|
Definition at line 6859 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CTNBOOLEAN, DCM_ELEMENTOUTOFORDER, DCM_Message(), DCM_NORMAL, DCM_REPEATEDELEMENT, DCM_TAG_ELEMENT, DCM_TAG_GROUP, and DCM_ELEMENT::tag. Referenced by readFile1().
06861 {
06862 unsigned short group;
06863 unsigned short element;
06864
06865 group = DCM_TAG_GROUP(e->tag);
06866 element = DCM_TAG_ELEMENT(e->tag);
06867
06868 if ((long) group == *lastGroup) {
06869 if (((long) element == *lastElement) && allowRepeatElements) {
06870 return DCM_REPEATEDELEMENT;
06871 }
06872 if ((long) element <= *lastElement)
06873 return COND_PushCondition(DCM_ELEMENTOUTOFORDER,
06874 DCM_Message(DCM_ELEMENTOUTOFORDER),
06875 group, element, "checkAttributeOrder");
06876 } else if ((long) group > *lastGroup) {
06877 } else {
06878 return COND_PushCondition(DCM_ELEMENTOUTOFORDER,
06879 DCM_Message(DCM_ELEMENTOUTOFORDER),
06880 group, element, "checkAttributeOrder");
06881 }
06882 *lastGroup = (long) group;
06883 *lastElement = (long) element;
06884
06885 return DCM_NORMAL;
06886 }
|
|
||||||||||||
|
||||||||||||||||||||
|
Definition at line 7598 of file l_mri_dicom_hdr.c. References PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, LST_Head(), LST_Next(), LST_Position(), and DCM_ELEMENT::tag. Referenced by DCM_CompareAttributes().
07603 {
07604 PRV_ELEMENT_ITEM *e1 = NULL,
07605 *e2 = NULL;
07606
07607 if (g1 != NULL) {
07608 e1 = (void *)LST_Head(&g1->elementList);
07609 if (e1 != NULL)
07610 LST_Position(&g1->elementList, (void *)e1);
07611 }
07612 if (g2 != NULL) {
07613 e2 = (void *)LST_Head(&g2->elementList);
07614 if (e2 != NULL)
07615 LST_Position(&g2->elementList, (void *)e2);
07616 }
07617 while (e1 != NULL) {
07618 if (e2 == NULL) {
07619 callback(&e1->element, NULL, ctx);
07620 e1 = (void *)LST_Next(&g1->elementList);
07621 } else if (e1->element.tag == e2->element.tag) {
07622 callback(&e1->element, &e2->element, ctx);
07623 e1 = (void *)LST_Next(&g1->elementList);
07624 e2 = (void *)LST_Next(&g2->elementList);
07625 } else if (e1->element.tag < e2->element.tag) {
07626 callback(&e1->element, NULL, ctx);
07627 e1 = (void *)LST_Next(&g1->elementList);
07628 } else {
07629 callback(NULL, &e2->element, ctx);
07630 e2 = (void *)LST_Next(&g2->elementList);
07631 }
07632 }
07633
07634 while (e2 != NULL) {
07635 callback(NULL, &e2->element, ctx);
07636 e2 = (void *)LST_Next(&g2->elementList);
07637 }
07638 }
|
|
||||||||||||
|
Definition at line 5141 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, CTNBOOLEAN, and PRV_GROUP_ITEM::longVRAttributes. Referenced by exportStream().
05143 {
05144 return (explicitVR) ?
05145 groupItem->baseLength + 4 * groupItem->longVRAttributes :
05146 groupItem->baseLength;
05147
05148 }
|
|
||||||||||||
|
Definition at line 7290 of file l_mri_dicom_hdr.c. References c, DCM_ELEMENT::d, DCM_AE, DCM_AS, DCM_AT, DCM_CS, DCM_CTX, DCM_DA, DCM_DD, DCM_DS, DCM_DT, DCM_FD, DCM_FL, DCM_IS, DCM_LO, DCM_LT, DCM_OT, DCM_PN, DCM_RET, DCM_SH, DCM_SL, DCM_SQ, DCM_SS, DCM_ST, DCM_TM, DCM_UI, DCM_UL, DCM_UN, DCM_US, DCM_UT, i, DCM_ELEMENT::length, DCM_ELEMENT::multiplicity, object, and DCM_ELEMENT::representation. Referenced by readFile(), and readFile1().
07291 {
07292 char
07293 *c;
07294 int
07295 i;
07296
07297 switch (element->representation) {
07298 case DCM_AE: /* Application Entity */
07299 case DCM_AS: /* Age string */
07300 case DCM_CS: /* Control string */
07301 case DCM_DA: /* Date */
07302 case DCM_DS: /* Decimal string */
07303 case DCM_DT: /* Date/Time */
07304 case DCM_IS: /* Integer string */
07305 case DCM_LO: /* Long string */
07306 case DCM_PN: /* Person Name */
07307 case DCM_SH: /* Short string */
07308 case DCM_TM: /* Time */
07309 case DCM_UI: /* Unique identifier (UID) */
07310 case DCM_UT: /* Unlimited text */
07311 element->multiplicity = 1;
07312 c = element->d.string;
07313 for (i = 0; i < (int) element->length; i++)
07314 if (*c++ == '\\')
07315 element->multiplicity++;
07316 break;
07317
07318 case DCM_FD: /* Floating double */
07319 element->multiplicity = element->length / 8;
07320 break;
07321 case DCM_AT: /* Attribute tag */
07322 case DCM_FL: /* Float */
07323 case DCM_SL: /* Signed long */
07324 case DCM_UL: /* Unsigned long */
07325 element->multiplicity = element->length / 4;
07326 break;
07327 case DCM_SS: /* Signed short */
07328 case DCM_US: /* Unsigned short */
07329 element->multiplicity = element->length / 2;
07330 break;
07331 case DCM_LT: /* Long text */
07332 case DCM_OT: /* Other binary value */
07333 case DCM_SQ: /* Sequence of items */
07334 case DCM_ST: /* Short text */
07335 /*case DCM_UNKNOWN:*/
07336 case DCM_UN:
07337 case DCM_RET:
07338 case DCM_CTX:
07339 case DCM_DD: /* Data set */
07340 default:
07341 element->multiplicity = 1;
07342 break;
07343 }
07344 }
|
|
||||||||||||
|
Definition at line 680 of file l_mri_dicom_hdr.c.
00681 {
00682 size_t i;
00683 int j;
00684
00685 txt[0] = '\0';
00686
00687 j = stackPtr;
00688 while (length > 2 && j >= 0) {
00689 i = strlen(EDBStack[j].statusText);
00690 if (i > length)
00691 i = length - 2;
00692 strncpy(txt, EDBStack[j].statusText, i);
00693 txt[i++] = '\n';
00694 txt[i] = '\0';
00695 length -= i;
00696 txt += i;
00697 j--;
00698 }
00699 }
|
|
|
Definition at line 637 of file l_mri_dicom_hdr.c. References dumpstack(), and stackPtr.
|
|
|
Definition at line 613 of file l_mri_dicom_hdr.c. References COND_NORMAL, and ErrorCallback.
00614 {
00615
00616 ErrorCallback = callback;
00617
00618 return COND_NORMAL;
00619 }
|
|
|
Definition at line 467 of file l_mri_dicom_hdr.c. References AFNI_CALL_VALU_2ARG, COND_NORMAL, CONDITION, and stackPtr.
00468 {
00469 int
00470 index,
00471 returnflag;
00472
00473 for (index = stackPtr, returnflag = 1; index >= 0 && returnflag != 0;
00474 index--) {
00475 #if 0
00476 returnflag = callback(EDBStack[index].statusCode,
00477 EDBStack[index].statusText);
00478 #else
00479 AFNI_CALL_VALU_2ARG( callback , int,returnflag ,
00480 CONDITION,EDBStack[index].statusCode ,
00481 char * ,EDBStack[index].statusText ) ;
00482 #endif
00483 }
00484
00485 return COND_NORMAL;
00486 }
|
|
|
Definition at line 566 of file l_mri_dicom_hdr.c. References COND_NORMAL, CONDITION, CTNBOOLEAN, and stackPtr. Referenced by DCM_AddElement(), DCM_AddSequenceElement(), DCM_GetString(), DCM_ModifyElements(), DCM_ParseObject(), mri_dicom_header(), readFile(), and readGroupElement().
00567 {
00568 CONDITION
00569 value;
00570
00571 if (stackPtr >= 0)
00572 value = EDBStack[stackPtr].statusCode;
00573 else
00574 value = COND_NORMAL;
00575
00576 if (clearstack) {
00577 stackPtr = -1;
00578 } else if (stackPtr <= 0) {
00579 stackPtr = -1;
00580 } else {
00581 stackPtr--;
00582 }
00583
00584 return value;
00585 }
|
|
||||||||||||||||
|
||||||||||||||||
|
Definition at line 520 of file l_mri_dicom_hdr.c. References COND_NORMAL, CONDITION, and stackPtr.
00521 {
00522 CONDITION rtnValue;
00523
00524 if (stackPtr >= 0) {
00525 *code = EDBStack[stackPtr].statusCode;
00526 (void) strncpy(text, EDBStack[stackPtr].statusText, maxlength - 1);
00527 text[maxlength - 1] = '\0';
00528 rtnValue = EDBStack[stackPtr].statusCode;
00529 } else {
00530 *code = COND_NORMAL;
00531 *text = '\0';
00532 rtnValue = COND_NORMAL;
00533 }
00534
00535 return rtnValue;
00536 }
|
|
|
Definition at line 716 of file l_mri_dicom_hdr.c. References dumpstack(), and stackPtr.
|
|
||||||||||||||||||||
|
Definition at line 7393 of file l_mri_dicom_hdr.c. References PRV_ELEMENT_ITEM::byteOrder, BYTEORDER_REVERSE, COND_PushCondition(), CONDITION, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_AT, DCM_CANNOTGETSEQUENCEVALUE, DCM_FILEACCESSERROR, DCM_GETINCOMPLETE, DCM_Message(), DCM_NORMAL, DCM_SQ, PRV_ELEMENT_ITEM::element, l, DCM_ELEMENT::length, MIN, object, p, q, read(), DCM_ELEMENT::representation, swapATGroupElement(), swapInPlace(), DCM_ELEMENT::tag, and U32. Referenced by DCM_ScanParseObject().
07395 {
07396 unsigned char *p = NULL;
07397 U32 l;
07398 int nBytes;
07399 CONDITION cond;
07400
07401 if (from->element.representation == DCM_SQ)
07402 return COND_PushCondition(DCM_CANNOTGETSEQUENCEVALUE,
07403 DCM_Message(DCM_CANNOTGETSEQUENCEVALUE),
07404 from->element.tag, "copyData (DCM internal)");
07405
07406 l = MIN(from->element.length, to->length);
07407 if (rtnLength != NULL)
07408 *rtnLength = l;
07409
07410 if (from->element.d.ot == NULL) {
07411 if ((*object)->fd != -1) {
07412 (void) lseek((*object)->fd,
07413 from->dataOffset + (off_t) p, SEEK_SET);
07414 nBytes = read((*object)->fd, to->d.ot, (int) l);
07415 } else {
07416 (*object)->sk((*object)->userCtx,
07417 (long) (from->dataOffset + (off_t) p), SEEK_SET);
07418 cond = (*object)->rd((*object)->userCtx, to->d.ot, (long) l, &nBytes);
07419 }
07420 if (nBytes != (int) l) {
07421 return COND_PushCondition(DCM_FILEACCESSERROR,
07422 DCM_Message(DCM_FILEACCESSERROR),
07423 (*object)->fileName,
07424 "copyData (DCM internal)");
07425 }
07426 if( LITTLE_ENDIAN_ARCHITECTURE ){
07427 if (from->element.representation == DCM_AT) {
07428 DCM_ELEMENT e;
07429 e = from->element;
07430 e.length = l;
07431 e.d.ot = to->d.ot;
07432 swapATGroupElement(&e);
07433 }
07434 }
07435 if (from->byteOrder == BYTEORDER_REVERSE) {
07436 DCM_ELEMENT e;
07437 e = from->element;
07438 e.length = l;
07439 e.d.ot = to->d.ot;
07440 swapInPlace(object, &e);
07441 }
07442 } else {
07443 unsigned char *q;
07444 q = (unsigned char *) from->element.d.ot +
07445 (U32) p;
07446 (void) memcpy(to->d.ot, q, l);
07447 }
07448 p += l;
07449 if ((unsigned) p == from->element.length)
07450 return DCM_NORMAL;
07451 else
07452 return DCM_GETINCOMPLETE;
07453 }
|
|
||||||||||||
|
Definition at line 7657 of file l_mri_dicom_hdr.c. References AFMALL, DCM_ELEMENT::d, DCM_AddSequenceElement(), DCM_CopyObject(), DCM_OBJECT, LST_Create(), LST_Enqueue(), LST_Head(), LST_Next(), LST_Position(), DCM_SEQUENCE_ITEM::object, DCM_ELEMENT::representation, and DCM_ELEMENT::tag. Referenced by DCM_CopyObject(), and DCM_MergeObject().
07658 {
07659 LST_HEAD *lst;
07660 DCM_SEQUENCE_ITEM *sqItem;
07661 DCM_ELEMENT newElement;
07662
07663 lst = LST_Create();
07664 if (e->d.sq != NULL) {
07665 sqItem = (void *)LST_Head(&e->d.sq);
07666 (void) LST_Position(&e->d.sq, (void *)sqItem);
07667 }
07668 while (sqItem != NULL) {
07669 DCM_OBJECT *copy;
07670 DCM_SEQUENCE_ITEM *copyItem;
07671
07672 DCM_CopyObject(&sqItem->object, ©);
07673 copyItem = AFMALL( DCM_SEQUENCE_ITEM, sizeof(*copyItem));
07674 copyItem->object = copy;
07675 (void) LST_Enqueue(&lst, (void *)copyItem);
07676
07677 sqItem = (void *)LST_Next(&e->d.sq);
07678 }
07679
07680 memset(&newElement, 0, sizeof(newElement));
07681 newElement.tag = e->tag;
07682 newElement.representation = e->representation;
07683 newElement.d.sq = lst;
07684 DCM_AddSequenceElement((DCM_OBJECT **) dstObj, &newElement);
07685 }
|
|
||||||||||||||||||||
|
Definition at line 5047 of file l_mri_dicom_hdr.c. References DCM_NORMAL, and U32. Referenced by DCM_ComputeExportLength().
05049 {
05050 unsigned long *size;
05051
05052 size = (unsigned long *) sizePtr;
05053
05054 *size += length;
05055
05056 return DCM_NORMAL;
05057 }
|
|
||||||||||||
|
||||||||||||
|
Definition at line 1335 of file l_mri_dicom_hdr.c. References checkObject(), COND_PopCondition(), COND_PushCondition(), CONDITION, DCM_CTX, DCM_ILLEGALADD, DCM_ILLEGALREPRESENTATION, DCM_INSERTFAILED, DCM_LookupElement(), DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_OT, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UN, findCreateGroup(), insertNewElement(), object, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and updateObjectType(). Referenced by DCM_AddElementList(), DCM_CopyObject(), DCM_MergeObject(), and DCM_ModifyElements().
01336 {
01337 CONDITION
01338 cond;
01339 DCM_ELEMENT
01340 localElement;
01341 PRIVATE_OBJECT
01342 ** object;
01343 PRV_GROUP_ITEM
01344 * groupItem;
01345
01346 object = (PRIVATE_OBJECT **) callerObject;
01347
01348 cond = checkObject(object, "DCM_AddElement");
01349 if (cond != DCM_NORMAL)
01350 return cond;
01351
01352 if ((DCM_TAG_ELEMENT(element->tag) == 0x0000))
01353 return COND_PushCondition(DCM_ILLEGALADD,
01354 DCM_Message(DCM_ILLEGALADD), DCM_TAG_GROUP(element->tag),
01355 DCM_TAG_ELEMENT(element->tag), "DCM_AddElement");
01356
01357
01358 localElement = *element;
01359
01360 cond = DCM_LookupElement(&localElement);
01361 if (cond != DCM_NORMAL) {
01362 (void) COND_PopCondition(0);
01363 localElement = *element;
01364 } else {
01365 if (localElement.representation == DCM_OT ||
01366 localElement.representation == DCM_CTX)
01367 localElement.representation = element->representation;
01368 if (element->representation != DCM_UN &&
01369 element->representation != localElement.representation) {
01370 return COND_PushCondition(DCM_ILLEGALREPRESENTATION,
01371 DCM_Message(DCM_ILLEGALREPRESENTATION),
01372 DCM_TAG_GROUP(element->tag),
01373 DCM_TAG_ELEMENT(element->tag),
01374 "DCM_AddElement");
01375 }
01376 }
01377
01378 cond = findCreateGroup(object, DCM_TAG_GROUP(localElement.tag), &groupItem);
01379 if (cond != DCM_NORMAL)
01380 return COND_PushCondition(DCM_INSERTFAILED,
01381 DCM_Message(DCM_INSERTFAILED), DCM_TAG_GROUP(element->tag),
01382 DCM_TAG_ELEMENT(element->tag),
01383 "DCM_AddElement");
01384
01385 cond = insertNewElement(object, &localElement);
01386 if (cond != DCM_NORMAL)
01387 return COND_PushCondition(DCM_INSERTFAILED,
01388 DCM_Message(DCM_INSERTFAILED), DCM_TAG_GROUP(element->tag),
01389 DCM_TAG_ELEMENT(element->tag),
01390 "DCM_AddElement");
01391
01392 cond = updateObjectType(object, &localElement);
01393 if (cond != DCM_NORMAL)
01394 return COND_PushCondition(DCM_INSERTFAILED,
01395 DCM_Message(DCM_INSERTFAILED), DCM_TAG_GROUP(element->tag),
01396 DCM_TAG_ELEMENT(element->tag),
01397 "DCM_AddElement");
01398
01399 return DCM_NORMAL;
01400 }
|
|
||||||||||||||||||||
|
Definition at line 3335 of file l_mri_dicom_hdr.c. References CONDITION, CTN_FREE, DCM_ELEMENT::d, DCM_AddElement(), DCM_ListToString(), DCM_NORMAL, DCM_OBJECT, DCM_ELEMENT::length, and offset.
03337 {
03338 DCM_ELEMENT
03339 e; /* Local copy of caller's element */
03340 CONDITION
03341 cond;
03342 char
03343 *s;
03344
03345 e = *element;
03346 cond = DCM_ListToString(list, offset, &s);
03347 if (cond != DCM_NORMAL)
03348 return cond;
03349
03350 e.d.string = s;
03351 e.length = strlen(s);
03352 cond = DCM_AddElement(callerObject, &e);
03353 CTN_FREE(s);
03354 return cond;
03355 }
|
|
||||||||||||||||
|
Definition at line 8124 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, CTN_MALLOC, DCM_ELEMENT::d, DCM_INSERTFAILED, DCM_LISTFAILURE, DCM_MALLOCFAILURE, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_PXLPIXELDATA, DCM_UNEVENFRAGMENTLENGTH, PRV_ELEMENT_ITEM::element, findCreateGroup(), DCM_FRAGMENT_ITEM::fragment, PRV_ELEMENT_ITEM::fragmentFlag, insertThisElementItem(), DCM_FRAGMENT_ITEM::length, DCM_ELEMENT::length, locateElement(), LST_Create(), LST_Enqueue(), DCM_ELEMENT::multiplicity, newElementItem(), object, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32.
08125 {
08126 PRIVATE_OBJECT** object;
08127 PRV_ELEMENT_ITEM* elementItem;
08128 PRV_ELEMENT_ITEM* newItem;
08129 CONDITION cond;
08130 PRV_GROUP_ITEM *groupItem = 0;
08131 DCM_FRAGMENT_ITEM* fragmentItem;
08132 U32 mallocLength;
08133
08134 if ((fragmentLength & 1) != 0) {
08135 return COND_PushCondition(DCM_UNEVENFRAGMENTLENGTH,
08136 DCM_Message(DCM_UNEVENFRAGMENTLENGTH), fragmentLength, "DCM_AddFragment");
08137 }
08138
08139 object = (PRIVATE_OBJECT **) callerObject;
08140 cond = checkObject(object, "DCM_AddFragment");
08141 if (cond != DCM_NORMAL)
08142 return cond;
08143
08144 cond = findCreateGroup(object, 0x7fe0, &groupItem);
08145 if (cond != DCM_NORMAL)
08146 return COND_PushCondition(DCM_INSERTFAILED,
08147 DCM_Message(DCM_INSERTFAILED), 0x7fe0, 0x0010, "DCM_AddFragment");
08148
08149 elementItem = locateElement(object, 0x7fe00010);
08150 if (elementItem == NULL) {
08151 DCM_ELEMENT e;
08152 memset(&e, 0, sizeof(e));
08153 e.tag = DCM_PXLPIXELDATA;
08154 e.representation = DCM_OB;
08155 e.multiplicity = 1;
08156 e.length = 0;
08157 e.d.fragments = 0;
08158 cond = newElementItem(&e, FALSE, &newItem);
08159 if (cond != DCM_NORMAL)
08160 return cond;
08161 newItem->element.d.fragments = LST_Create();
08162 if (newItem->element.d.fragments == NULL) {
08163 return COND_PushCondition(DCM_LISTFAILURE,
08164 DCM_Message(DCM_LISTFAILURE), "DCM_AddFragment");
08165 }
08166 cond = insertThisElementItem(object, newItem);
08167 if (cond != DCM_NORMAL)
08168 return cond;
08169 }
08170
08171 elementItem = locateElement(object, 0x7fe00010);
08172
08173 mallocLength = sizeof(DCM_FRAGMENT_ITEM) + fragmentLength;
08174 fragmentItem = CTN_MALLOC(mallocLength);
08175 if (fragmentItem == NULL) {
08176 return COND_PushCondition(DCM_MALLOCFAILURE,
08177 DCM_Message(DCM_MALLOCFAILURE), mallocLength,
08178 "DCM_AddFragment");
08179 }
08180
08181 fragmentItem->fragment = ((char*)fragmentItem)+ sizeof(DCM_FRAGMENT_ITEM);
08182 fragmentItem->length = fragmentLength;
08183 memcpy(fragmentItem->fragment, fragment, fragmentLength);
08184 elementItem->fragmentFlag = 1;
08185 LST_Enqueue(&elementItem->element.d.fragments, (void *)fragmentItem);
08186
08187 return DCM_NORMAL;
08188 }
|
|
||||||||||||
|
Definition at line 1426 of file l_mri_dicom_hdr.c. References checkObject(), COND_PopCondition(), COND_PushCondition(), CONDITION, DCM_ELEMENT::d, DCM_ILLEGALADD, DCM_INSERTFAILED, DCM_LookupElement(), DCM_Message(), DCM_NORMAL, DCM_NOTASEQUENCE, DCM_OBJECT, DCM_SQ, DCM_TAG_ELEMENT, DCM_TAG_GROUP, findCreateGroup(), insertNewElement(), object, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and updateObjectType(). Referenced by copySequence().
01427 {
01428 CONDITION cond;
01429 DCM_ELEMENT localElement;
01430 PRIVATE_OBJECT **object;
01431 PRV_GROUP_ITEM *groupItem;
01432
01433 object = (PRIVATE_OBJECT **) callerObject;
01434
01435 cond = checkObject(object, "DCM_AddSequenceElement");
01436 if (cond != DCM_NORMAL)
01437 return cond;
01438
01439 if ((DCM_TAG_ELEMENT(element->tag) == 0x0000))
01440 return COND_PushCondition(DCM_ILLEGALADD,
01441 DCM_Message(DCM_ILLEGALADD), DCM_TAG_GROUP(element->tag),
01442 DCM_TAG_ELEMENT(element->tag), "DCM_AddElement");
01443
01444
01445 localElement = *element;
01446
01447 cond = DCM_LookupElement(&localElement);
01448 if (cond != DCM_NORMAL) {
01449 (void) COND_PopCondition(0);
01450 localElement = *element;
01451 } else {
01452 localElement.representation = element->representation;
01453 }
01454 if (localElement.representation != DCM_SQ) {
01455 return COND_PushCondition(DCM_NOTASEQUENCE,
01456 DCM_Message(DCM_NOTASEQUENCE),
01457 DCM_TAG_GROUP(localElement.tag),
01458 DCM_TAG_ELEMENT(localElement.tag),
01459 "DCM_AddSequenceElement");
01460 }
01461 cond = findCreateGroup(object, DCM_TAG_GROUP(localElement.tag), &groupItem);
01462 if (cond != DCM_NORMAL)
01463 return COND_PushCondition(DCM_INSERTFAILED,
01464 DCM_Message(DCM_INSERTFAILED), DCM_TAG_GROUP(element->tag),
01465 DCM_TAG_ELEMENT(element->tag),
01466 "DCM_AddSequenceElement");
01467
01468 cond = insertNewElement(object, &localElement);
01469 if (cond != DCM_NORMAL)
01470 return COND_PushCondition(DCM_INSERTFAILED,
01471 DCM_Message(DCM_INSERTFAILED), DCM_TAG_GROUP(element->tag),
01472 DCM_TAG_ELEMENT(element->tag),
01473 "DCM_AddElement");
01474
01475 cond = updateObjectType(object, &localElement);
01476 if (cond != DCM_NORMAL)
01477 return COND_PushCondition(DCM_INSERTFAILED,
01478 DCM_Message(DCM_INSERTFAILED), DCM_TAG_GROUP(element->tag),
01479 DCM_TAG_ELEMENT(element->tag),
01480 "DCM_AddSequenceElement");
01481
01482 /*
01483 * We have taken ownership of the sequence list, so zero out caller's
01484 * copy
01485 */
01486 element->d.sq = NULL;
01487
01488 return DCM_NORMAL;
01489 }
|
|
|
Definition at line 1208 of file l_mri_dicom_hdr.c. References checkObject(), close(), COND_PushCondition(), CONDITION, CTN_FREE, DCM_ELEMENT::d, DCM_FILEDELETEFAILED, DCM_LISTFAILURE, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_SQ, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_ELEMENT_ITEM::fragmentFlag, PRV_GROUP_ITEM::group, LST_Destroy(), LST_NORMAL, LST_Pop(), DCM_SEQUENCE_ITEM::object, object, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and unlink. Referenced by DCM_CloseObject(), handleGroupItem(), mri_dicom_header(), readData(), readFile(), readFile1(), readGroupElement(), readLengthToEnd(), readPreamble(), and readVRLength().
01209 {
01210 CONDITION
01211 cond;
01212 PRV_GROUP_ITEM
01213 * group;
01214 PRV_ELEMENT_ITEM
01215 * element;
01216 PRIVATE_OBJECT
01217 ** object;
01218 DCM_SEQUENCE_ITEM
01219 * sequenceItem;
01220 DCM_FRAGMENT_ITEM* fragmentItem;
01221
01222 if (debug)
01223 fprintf(stderr, "Starting DCM_CloseObject\n");
01224
01225 object = (PRIVATE_OBJECT **) callerObject;
01226 cond = checkObject(object, "DCM_CloseObject");
01227 if (cond != DCM_NORMAL)
01228 return cond;
01229
01230 if ((*object)->fd > 0)
01231 (void) close((*object)->fd);
01232
01233 if (debug)
01234 fprintf(stderr, "DCM_CloseObject: Legal object and file closed\n");
01235
01236 while ((group = (void *)LST_Pop(&(*object)->groupList)) != NULL) {
01237 if (debug)
01238 fprintf(stderr, "DCM_CloseObject: group %04x\n", group->group);
01239
01240 while ((element = (void *)LST_Pop(&group->elementList)) != NULL) {
01241 if (debug)
01242 fprintf(stderr, "DCM_CloseObject: Element %08x\n",
01243 element->element.tag);
01244 if (element->element.representation == DCM_SQ) {
01245 if (debug)
01246 fprintf(stderr, "Sequence List Address: %p\n",
01247 element->element.d.sq);
01248 if (element->element.d.sq != NULL) {
01249 while ((sequenceItem = (void *)LST_Pop(&element->element.d.sq)) != NULL) {
01250 (void) DCM_CloseObject(&sequenceItem->object);
01251 CTN_FREE(sequenceItem);
01252 }
01253 (void) LST_Destroy(&element->element.d.sq);
01254 }
01255 } else if (element->fragmentFlag) {
01256 if (debug)
01257 fprintf(stderr, "Fragment List Address: %p\n",
01258 element->element.d.fragments);
01259 if (element->element.d.fragments != NULL) {
01260 while ((fragmentItem = (void *)LST_Pop(&element->element.d.fragments)) != NULL) {
01261 CTN_FREE(fragmentItem);
01262 }
01263 (void) LST_Destroy(&element->element.d.fragments);
01264 }
01265 }
01266 if (debug)
01267 fprintf(stderr, "DCM_CloseObject: free %8p\n", element);
01268
01269 CTN_FREE(element);
01270 }
01271 cond = LST_Destroy(&group->elementList);
01272 if (cond != LST_NORMAL)
01273 return COND_PushCondition(DCM_LISTFAILURE,
01274 DCM_Message(DCM_LISTFAILURE), "DCM_CloseObject");
01275 CTN_FREE(group);
01276 }
01277 cond = LST_Destroy(&(*object)->groupList);
01278 if (cond != LST_NORMAL)
01279 return COND_PushCondition(DCM_LISTFAILURE,
01280 DCM_Message(DCM_LISTFAILURE), "DCM_CloseObject");
01281
01282 cond = DCM_NORMAL;
01283 if ((*object)->deleteFlag) {
01284 if (unlink((*object)->fileName) != 0) {
01285 /**** (void) COND_PushCondition(DCM_FILEDELETEFAILED, strerror(errno));****/
01286 cond = COND_PushCondition(DCM_FILEDELETEFAILED,
01287 DCM_Message(DCM_FILEDELETEFAILED), (*object)->fileName, strerror(errno),
01288 "DCM_CloseObject");
01289
01290 }
01291 }
01292 CTN_FREE(*object);
01293 *object = NULL;
01294 return cond;
01295 }
|
|
||||||||||||||||||||
|
Definition at line 3433 of file l_mri_dicom_hdr.c. References checkObject(), compareGroup(), CONDITION, DCM_NORMAL, DCM_OBJECT, PRV_GROUP_ITEM::group, LST_Head(), LST_Next(), and LST_Position().
03438 {
03439 PRIVATE_OBJECT **object1,
03440 **object2;
03441 PRV_GROUP_ITEM *groupItem1,
03442 *groupItem2;
03443 CONDITION cond;
03444
03445 object1 = (PRIVATE_OBJECT **) o1;
03446 cond = checkObject(object1, "DCM_CompareAttributes");
03447 if (cond != DCM_NORMAL)
03448 return cond;
03449
03450 object2 = (PRIVATE_OBJECT **) o2;
03451 cond = checkObject(object1, "DCM_CompareAttributes");
03452 if (cond != DCM_NORMAL)
03453 return cond;
03454
03455 groupItem1 = (void *)LST_Head(&(*object1)->groupList);
03456 if (groupItem1 != NULL)
03457 (void) LST_Position(&(*object1)->groupList, (void *)groupItem1);
03458
03459 groupItem2 = (void *)LST_Head(&(*object2)->groupList);
03460 if (groupItem2 != NULL)
03461 (void) LST_Position(&(*object2)->groupList, (void *)groupItem2);
03462
03463
03464 while (groupItem1 != NULL) {
03465 if (groupItem2 == NULL) {
03466 compareGroup(groupItem1, NULL, callback, ctx);
03467 groupItem1 = (void *)LST_Next(&(*object1)->groupList);
03468 } else if (groupItem1->group == groupItem2->group) {
03469 compareGroup(groupItem1, groupItem2, callback, ctx);
03470 groupItem1 = (void *)LST_Next(&(*object1)->groupList);
03471 groupItem2 = (void *)LST_Next(&(*object2)->groupList);
03472 } else if (groupItem1->group > groupItem2->group) {
03473 compareGroup(NULL, groupItem2, callback, ctx);
03474 groupItem2 = (void *)LST_Next(&(*object2)->groupList);
03475 } else {
03476 compareGroup(groupItem1, NULL, callback, ctx);
03477 groupItem1 = (void *)LST_Next(&(*object1)->groupList);
03478 }
03479 }
03480
03481 while (groupItem2 != NULL) {
03482 compareGroup(NULL, groupItem2, callback, ctx);
03483 groupItem2 = (void *)LST_Next(&(*object2)->groupList);
03484 }
03485 return DCM_NORMAL;
03486 }
|
|
||||||||||||||||
|
Definition at line 3408 of file l_mri_dicom_hdr.c. References checkObject(), CONDITION, countBytes(), DCM_ExportStream(), DCM_NORMAL, DCM_OBJECT, and object.
03410 {
03411 PRIVATE_OBJECT
03412 ** object;
03413 unsigned char
03414 buf[2048];
03415 CONDITION
03416 cond;
03417
03418 object = (PRIVATE_OBJECT **) callerObject;
03419 cond = checkObject(object, "DCM_ComputeExportSize");
03420 if (cond != DCM_NORMAL)
03421 return cond;
03422
03423 *length = 0;
03424 cond = DCM_ExportStream(callerObject, opt, buf,
03425 (unsigned long) sizeof(buf), countBytes, length);
03426 if (cond != DCM_NORMAL)
03427 return cond;
03428
03429 return DCM_NORMAL;
03430 }
|
|
||||||||||||
|
||||||||||||
|
|
Definition at line 2708 of file l_mri_dicom_hdr.c. References CTNBOOLEAN, and debug. Referenced by mri_dicom_header().
02709 {
02710 debug = flag;
02711 }
|
|
||||||||||||
|
Definition at line 2288 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, checkObject(), CONDITION, DCM_ELEMENT::d, DCM_ELEMENT::data_offset, DCM_AE, DCM_AS, DCM_AT, DCM_CS, DCM_DA, DCM_DD, DCM_DS, DCM_DT, DCM_FD, DCM_FL, DCM_IS, DCM_LO, DCM_LT, DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_OBJECTCOMMAND, DCM_OBJECTELEMENTLIST, DCM_OBJECTIMAGE, DCM_OBJECTUNKNOWN, DCM_OT, DCM_OW, DCM_PN, DCM_RET, DCM_SH, DCM_SL, DCM_SQ, DCM_SS, DCM_ST, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_TM, DCM_UI, DCM_UL, DCM_UN, DCM_US, DCM_UT, DCM_ELEMENT::description, dumpBinaryData(), PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, DCM_ELEMENT::length, LST_Head(), LST_Next(), LST_Position(), MIN, DCM_SEQUENCE_ITEM::object, object, DCM_ELEMENT::representation, RWC_NOHEX_MASK, RWC_NONAME_MASK, rwc_opt, RWC_printf(), rwc_vm, scratch, DCM_ELEMENT::tag, U32, and vm. Referenced by DCM_DumpElements(), DCM_OpenFile(), mri_dicom_header(), readFile(), readGroupElement(), readPreamble(), and readVRLength().
02289 {
02290 PRV_GROUP_ITEM
02291 * groupItem;
02292 PRV_ELEMENT_ITEM
02293 * elementItem;
02294 PRIVATE_OBJECT
02295 ** object;
02296 CONDITION
02297 cond;
02298 DCM_SEQUENCE_ITEM
02299 * sq;
02300 char
02301 scratch[128];
02302 int
02303 stringLength;
02304
02305 object = (PRIVATE_OBJECT **) callerObject;
02306
02307 cond = checkObject(object, "DCM_DumpElements");
02308 if (cond != DCM_NORMAL)
02309 return cond;
02310
02311 switch ((*object)->objectType) {
02312 case DCM_OBJECTUNKNOWN:
02313 RWC_printf("Object type: UNKNOWN\n");
02314 break;
02315 case DCM_OBJECTCOMMAND:
02316 RWC_printf("Object type: COMMAND\n");
02317 break;
02318 case DCM_OBJECTIMAGE:
02319 RWC_printf("Object type: IMAGE\n");
02320 break;
02321 case DCM_OBJECTELEMENTLIST:
02322 RWC_printf("Object type: ELEMENT LIST\n");
02323 break;
02324 default:
02325 RWC_printf("Object type: Unknown (error)\n");
02326 break;
02327 }
02328 RWC_printf("Object size: %ld\n", (*object)->objectSize);
02329
02330 groupItem = (void *)LST_Head(&(*object)->groupList);
02331 if (groupItem != NULL)
02332 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
02333
02334 while (groupItem != NULL) {
02335 #ifdef MACOS
02336 RWC_printf("Group: %04x, Length: %8ld\n", groupItem->group,
02337 groupItem->baseLength);
02338 #else
02339 RWC_printf("Group: %04x, Length: %8d\n", groupItem->group,
02340 groupItem->baseLength);
02341 #endif
02342 elementItem = (void *)LST_Head(&groupItem->elementList);
02343 if (elementItem != NULL)
02344 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
02345 while (elementItem != NULL) {
02346 #ifdef MACOS
02347 (void) RWC_printf("%04x %04x %8ld [%-8lu] ",
02348 DCM_TAG_GROUP(elementItem->element.tag),
02349 DCM_TAG_ELEMENT(elementItem->element.tag),
02350 elementItem->element.length ,
02351 (unsigned long) elementItem->element.data_offset );
02352 #else
02353 (void) RWC_printf("%04x %04x %8d [%-8lu] ",
02354 DCM_TAG_GROUP(elementItem->element.tag),
02355 DCM_TAG_ELEMENT(elementItem->element.tag),
02356 elementItem->element.length ,
02357 (unsigned long) elementItem->element.data_offset );
02358 #endif
02359
02360 if( (rwc_opt & RWC_NONAME_MASK) == 0 )
02361 (void) RWC_printf("//%31s//", elementItem->element.description);
02362 else
02363 (void) RWC_printf("//") ;
02364
02365 if (elementItem->element.d.ot == NULL)
02366 (void) RWC_printf("Data on disk\n");
02367 else {
02368 switch (elementItem->element.representation) {
02369 case DCM_AE:
02370 case DCM_AS:
02371 case DCM_CS:
02372 case DCM_DA:
02373 case DCM_DT:
02374 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02375 strncpy(scratch, elementItem->element.d.string, stringLength);
02376 scratch[stringLength] = '\0';
02377 (void) RWC_printf("%s\n", scratch);
02378 break;
02379 case DCM_DD:
02380 case DCM_FD:
02381 case DCM_FL:
02382 (void) RWC_printf("Unimplemented\n");
02383 break;
02384 case DCM_DS:
02385 case DCM_IS:
02386 case DCM_LO:
02387 case DCM_LT:
02388 case DCM_PN:
02389 case DCM_SH:
02390 case DCM_UT:
02391 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02392 strncpy(scratch, elementItem->element.d.string, stringLength);
02393 scratch[stringLength] = '\0';
02394 (void) RWC_printf("%s\n", scratch);
02395 break;
02396 case DCM_SL:
02397 #ifdef MACOS
02398 (void) RWC_printf("%8lx %ld\n", *elementItem->element.d.sl,
02399 *elementItem->element.d.sl);
02400 #else
02401 if( (rwc_opt & RWC_NOHEX_MASK) == 0 )
02402 (void) RWC_printf("%8x %d\n", *elementItem->element.d.sl,
02403 *elementItem->element.d.sl);
02404 else
02405 (void) RWC_printf(" %d\n", *elementItem->element.d.sl ) ;
02406
02407 if (vm > 1)
02408 dumpBinaryData(elementItem->element.d.ot,
02409 elementItem->element.representation,
02410 elementItem->element.length / sizeof(U32), vm);
02411 #endif
02412 break;
02413 case DCM_SS:
02414 if( (rwc_opt & RWC_NOHEX_MASK) == 0 )
02415 (void) RWC_printf("%4x %d\n", *elementItem->element.d.ss,
02416 *elementItem->element.d.ss);
02417 else
02418 (void) RWC_printf(" %d\n", *elementItem->element.d.ss ) ;
02419
02420 if (vm > 1)
02421 dumpBinaryData(elementItem->element.d.ot,
02422 elementItem->element.representation,
02423 elementItem->element.length / sizeof(short), vm);
02424 break;
02425 case DCM_SQ:
02426 (void) RWC_printf("SEQUENCE\n");
02427 sq = (void *)LST_Head(&elementItem->element.d.sq);
02428 if (sq != NULL)
02429 (void) LST_Position(&elementItem->element.d.sq, (void *)sq);
02430 RWC_printf("DCM Dump SEQUENCE\n");
02431 while (sq != NULL) {
02432 (void) DCM_DumpElements(&sq->object, vm);
02433 sq = (void *)LST_Next(&elementItem->element.d.sq);
02434 }
02435 RWC_printf("DCM Dump SEQUENCE Complete\n");
02436 break;
02437 case DCM_ST:
02438 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02439 strncpy(scratch, elementItem->element.d.string, stringLength);
02440 scratch[stringLength] = '\0';
02441 (void) RWC_printf("%s\n", scratch);
02442 break;
02443 case DCM_TM:
02444 case DCM_UI:
02445 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02446 strncpy(scratch, elementItem->element.d.string, stringLength);
02447 scratch[stringLength] = '\0';
02448 (void) RWC_printf("%s\n", scratch);
02449 break;
02450 case DCM_AT:
02451 case DCM_UL:
02452 #ifdef MACOS
02453 (void) RWC_printf("%8lx %ld\n", *elementItem->element.d.ul,
02454 *elementItem->element.d.ul);
02455 #else
02456 if( (rwc_opt & RWC_NOHEX_MASK) == 0 )
02457 (void) RWC_printf("%8x %d\n", *elementItem->element.d.ul,
02458 *elementItem->element.d.ul);
02459 else
02460 (void) RWC_printf(" %d\n", *elementItem->element.d.ul ) ;
02461
02462 if (vm > 1)
02463 dumpBinaryData(elementItem->element.d.ot,
02464 elementItem->element.representation,
02465 elementItem->element.length / sizeof(U32), vm);
02466 #endif
02467 break;
02468 case DCM_US:{
02469 int nel = elementItem->element.length / sizeof(unsigned short) , rr ;
02470 for( rr=0 ; rr < nel ; rr++ ){
02471 if( (rwc_opt & RWC_NOHEX_MASK) == 0 )
02472 (void) RWC_printf("%4x %d", elementItem->element.d.us[rr],
02473 elementItem->element.d.us[rr]);
02474 else
02475 (void) RWC_printf(" %d", elementItem->element.d.us[rr] ) ;
02476 }
02477 RWC_printf("\n") ;
02478
02479 if (vm > 1)
02480 dumpBinaryData(elementItem->element.d.ot,
02481 elementItem->element.representation,
02482 elementItem->element.length / sizeof(unsigned short), vm);
02483 }
02484 break;
02485 case DCM_OB:
02486 case DCM_UN:
02487 dumpBinaryData(elementItem->element.d.ot,
02488 elementItem->element.representation,
02489 elementItem->element.length , MAX(rwc_vm,8));
02490 break;
02491
02492 case DCM_OT:
02493 case DCM_OW:
02494 /*case DCM_UNKNOWN:*/
02495 case DCM_RET:
02496 (void) RWC_printf("Unimplemented\n");
02497 break;
02498 default:
02499 (void) RWC_printf("Some unimplemented logic if here\n");
02500 break;
02501 }
02502 }
02503 elementItem = (void *)LST_Next(&groupItem->elementList);
02504 }
02505 groupItem = (void *)LST_Next(&(*object)->groupList);
02506 }
02507
02508 RWC_printf("DCM Dump Elements Complete\n");
02509 return DCM_NORMAL;
02510 }
|
|
|
Definition at line 8334 of file l_mri_dicom_hdr.c. References DIM_OF, vector::message, and RWC_printf().
08335 {
08336 int index;
08337
08338 for (index = 0; index < (int) DIM_OF(messageVector); index++) {
08339 if (messageVector[index].message != NULL)
08340 RWC_printf("%8x %8d %s\n", messageVector[index].cond,
08341 messageVector[index].cond,
08342 messageVector[index].message);
08343 }
08344 }
|
|
||||||||||||||||
|
Definition at line 10433 of file l_mri_dicom_hdr.c. References DCM_NORMAL, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_VALUEREPRESENTATION, GROUPPTR::dict, DIM_OF, DCMDICT::englishDescription, GROUPPTR::entries, i, p, r, DCMDICT::representation, and DCMDICT::tag.
10436 {
10437 int i;
10438 unsigned long j;
10439 GROUPPTR *p;
10440 DCMDICT *dictionaryPtr;
10441
10442 for (i = 0; i < (int) DIM_OF(group_dictionary); i++) {
10443 if ((DCM_TAG_GROUP(tag) == group_dictionary[i].group) ||
10444 (DCM_TAG_GROUP(tag) == 0xffff)) {
10445 p = &group_dictionary[i];
10446 dictionaryPtr = p->dict;
10447 for (j = 0; j < p->entries; j++, dictionaryPtr++) {
10448 if ((DCM_TAG_ELEMENT(tag) == 0xffff) ||
10449 (DCM_TAG_ELEMENT(tag) == DCM_TAG_ELEMENT(dictionaryPtr->tag))) {
10450 callback(dictionaryPtr->tag,
10451 dictionaryPtr->englishDescription,
10452 dictionaryPtr->representation,
10453 ctx);
10454 }
10455 }
10456 }
10457 }
10458 return DCM_NORMAL;
10459 }
|
|
||||||||||||||||||||||||||||
|
Referenced by DCM_ComputeExportLength(), and DCM_WriteFile(). |
|
||||||||||||||||
|
Definition at line 2513 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, checkObject(), CONDITION, DCM_ELEMENT::d, DCM_AE, DCM_AS, DCM_AT, DCM_CS, DCM_DA, DCM_DD, DCM_DS, DCM_DT, DCM_FD, DCM_FL, DCM_IS, DCM_LO, DCM_LT, DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_OBJECTCOMMAND, DCM_OBJECTELEMENTLIST, DCM_OBJECTIMAGE, DCM_OBJECTUNKNOWN, DCM_OT, DCM_OW, DCM_PN, DCM_RET, DCM_SH, DCM_SL, DCM_SQ, DCM_SS, DCM_ST, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_TM, DCM_UI, DCM_UL, DCM_US, DCM_UT, DCM_ELEMENT::description, dumpBinaryData(), PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, DCM_ELEMENT::length, LST_Head(), LST_Next(), LST_Position(), MIN, DCM_SEQUENCE_ITEM::object, object, DCM_ELEMENT::representation, RWC_printf(), scratch, DCM_ELEMENT::tag, U32, and vm. Referenced by DCM_FormatElements(), and mri_dicom_header().
02514 {
02515 PRV_GROUP_ITEM
02516 * groupItem;
02517 PRV_ELEMENT_ITEM
02518 * elementItem;
02519 PRIVATE_OBJECT
02520 ** object;
02521 CONDITION
02522 cond;
02523 DCM_SEQUENCE_ITEM
02524 * sq;
02525 char
02526 scratch[128];
02527 int
02528 stringLength;
02529 char localPrefix[128];
02530
02531 object = (PRIVATE_OBJECT **) callerObject;
02532
02533 cond = checkObject(object, "DCM_DumpElements");
02534 if (cond != DCM_NORMAL)
02535 return cond;
02536
02537 RWC_printf("\n%sDCM Dump Elements\n", prefix);
02538 switch ((*object)->objectType) {
02539 case DCM_OBJECTUNKNOWN:
02540 RWC_printf("%sObject type: UNKNOWN\n", prefix);
02541 break;
02542 case DCM_OBJECTCOMMAND:
02543 RWC_printf("%sObject type: COMMAND\n", prefix);
02544 break;
02545 case DCM_OBJECTIMAGE:
02546 RWC_printf("%sObject type: IMAGE\n", prefix);
02547 break;
02548 case DCM_OBJECTELEMENTLIST:
02549 RWC_printf("%sObject type: ELEMENT LIST\n", prefix);
02550 break;
02551 default:
02552 RWC_printf("%sObject type: Unknown (error)\n", prefix);
02553 break;
02554 }
02555 RWC_printf("%sObject size: %ld\n", prefix, (*object)->objectSize);
02556
02557 groupItem = (void *)LST_Head(&(*object)->groupList);
02558 if (groupItem != NULL)
02559 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
02560
02561 while (groupItem != NULL) {
02562 RWC_printf("%sGroup: %04x, Length: %8d\n", prefix, groupItem->group,
02563 groupItem->baseLength);
02564 elementItem = (void *)LST_Head(&groupItem->elementList);
02565 if (elementItem != NULL)
02566 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
02567 while (elementItem != NULL) {
02568 (void) RWC_printf("%s%04x %04x %8d ",
02569 prefix,
02570 DCM_TAG_GROUP(elementItem->element.tag),
02571 DCM_TAG_ELEMENT(elementItem->element.tag),
02572 elementItem->element.length);
02573 (void) RWC_printf("//%31s//", elementItem->element.description);
02574 if (elementItem->element.d.ot == NULL)
02575 (void) RWC_printf("Data on disk\n");
02576 else {
02577 switch (elementItem->element.representation) {
02578 case DCM_AE:
02579 case DCM_AS:
02580 case DCM_CS:
02581 case DCM_DA:
02582 case DCM_DT:
02583 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02584 strncpy(scratch, elementItem->element.d.string, stringLength);
02585 scratch[stringLength] = '\0';
02586 (void) RWC_printf("%s\n", scratch);
02587 break;
02588 case DCM_DD:
02589 case DCM_FD:
02590 case DCM_FL:
02591 (void) RWC_printf("Unimplemented\n");
02592 break;
02593 case DCM_DS:
02594 case DCM_IS:
02595 case DCM_LO:
02596 case DCM_LT:
02597 case DCM_PN:
02598 case DCM_SH:
02599 case DCM_UT:
02600 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02601 strncpy(scratch, elementItem->element.d.string, stringLength);
02602 scratch[stringLength] = '\0';
02603 (void) RWC_printf("%s\n", scratch);
02604 break;
02605 case DCM_SL:
02606 #ifdef MACOS
02607 (void) RWC_printf("%8lx %ld\n", *elementItem->element.d.sl,
02608 *elementItem->element.d.sl);
02609 #else
02610 (void) RWC_printf("%8x %d\n", *elementItem->element.d.sl,
02611 *elementItem->element.d.sl);
02612 if (vm > 1)
02613 dumpBinaryData(elementItem->element.d.ot,
02614 elementItem->element.representation,
02615 elementItem->element.length / sizeof(U32), vm);
02616 #endif
02617 break;
02618 case DCM_SS:
02619 (void) RWC_printf("%4x %d\n", *elementItem->element.d.ss,
02620 *elementItem->element.d.ss);
02621 if (vm > 1)
02622 dumpBinaryData(elementItem->element.d.ot,
02623 elementItem->element.representation,
02624 elementItem->element.length / sizeof(short), vm);
02625 break;
02626 case DCM_SQ:
02627 (void) RWC_printf("SEQUENCE\n");
02628 sq = (void *)LST_Head(&elementItem->element.d.sq);
02629 if (sq != NULL)
02630 (void) LST_Position(&elementItem->element.d.sq, (void *)sq);
02631 RWC_printf("%sDCM Dump SEQUENCE\n", prefix);
02632 strcpy(localPrefix, prefix);
02633 strcat(localPrefix, " ");
02634 while (sq != NULL) {
02635 (void) DCM_FormatElements(&sq->object, vm, localPrefix);
02636 sq = (void *)LST_Next(&elementItem->element.d.sq);
02637 }
02638 RWC_printf("%sDCM Dump SEQUENCE Complete\n", prefix);
02639 break;
02640 case DCM_ST:
02641 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02642 strncpy(scratch, elementItem->element.d.string, stringLength);
02643 scratch[stringLength] = '\0';
02644 (void) RWC_printf("%s\n", scratch);
02645 break;
02646 case DCM_TM:
02647 case DCM_UI:
02648 stringLength = MIN(sizeof(scratch) - 1, elementItem->element.length);
02649 strncpy(scratch, elementItem->element.d.string, stringLength);
02650 scratch[stringLength] = '\0';
02651 (void) RWC_printf("%s\n", scratch);
02652 break;
02653 case DCM_AT:
02654 case DCM_UL:
02655 (void) RWC_printf("%8x %d\n", *elementItem->element.d.ul,
02656 *elementItem->element.d.ul);
02657 if (vm > 1)
02658 dumpBinaryData(elementItem->element.d.ot,
02659 elementItem->element.representation,
02660 elementItem->element.length / sizeof(U32), vm);
02661 break;
02662 case DCM_US:
02663 (void) RWC_printf("%4x %d\n", *elementItem->element.d.us,
02664 *elementItem->element.d.us);
02665 if (vm > 1)
02666 dumpBinaryData(elementItem->element.d.ot,
02667 elementItem->element.representation,
02668 elementItem->element.length / sizeof(unsigned short), vm);
02669 break;
02670 case DCM_OT:
02671 case DCM_OW:
02672 case DCM_OB:
02673 /*case DCM_UNKNOWN:*/
02674 case DCM_RET:
02675 (void) RWC_printf("Unimplemented\n");
02676 break;
02677 default:
02678 (void) RWC_printf("Some unimplemented logic if here\n");
02679 break;
02680 }
02681 }
02682 elementItem = (void *)LST_Next(&groupItem->elementList);
02683 }
02684 groupItem = (void *)LST_Next(&(*object)->groupList);
02685 }
02686
02687 RWC_printf("%sDCM Dump Elements Complete\n\n", prefix);
02688 return DCM_NORMAL;
02689 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 7690 of file l_mri_dicom_hdr.c. References BIG_ORDER, BYTEORDER_REVERSE, checkObject(), COND_PushCondition(), CONDITION, CTN_MALLOC, CTNBOOLEAN, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_ACCEPTVRMISMATCH, DCM_ELEMENTNOTFOUND, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_GET_COMPRESSED_CALLBACK, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_ORDERBIGENDIAN, DCM_ORDERLITTLEENDIAN, DCM_ORDERMASK, DCM_ORDERNATIVE, DCM_STREAMCOMPLETE, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UL, DCM_UNSPECIFIEDLENGTH, DCM_VRMASK, l, DCM_ELEMENT::length, LITTLE_ORDER, locateElement(), MIN, NATIVE_ORDER, object, PRV_ELEMENT_ITEM::originalDataLength, read(), readGroupElement(), readVRLength(), DCM_ELEMENT::representation, swapInPlace(), and U32.
07693 {
07694 PRIVATE_OBJECT
07695 ** object;
07696 PRV_ELEMENT_ITEM
07697 * elementItem;
07698 S32 nBytes;
07699 S32 toRead;
07700 CONDITION cond;
07701 int doneFlag = 0;
07702 size_t elementLength;
07703 unsigned char *ptr;
07704 U32 size = 0;
07705 off_t fileOffset = 0;
07706 unsigned long opt;
07707 int byteOrder;
07708 int explicitVR;
07709 CTNBOOLEAN acceptVRMismatch = FALSE;
07710 DCM_ELEMENT e;
07711 U32 sequenceLength = 0;
07712 CONDITION flag;
07713 int index = 0;
07714 CTNBOOLEAN firstBuffer = TRUE;
07715 U32 *offsetBuffer = NULL;
07716 U32 offsetBufferCount = 0;
07717 U32 streamOffset = 0;
07718 int startOfFragment = 1;
07719
07720 object = (PRIVATE_OBJECT **) callerObject;
07721 cond = checkObject(object, "DCM_GetCompressedValue");
07722 if (cond != DCM_NORMAL)
07723 return cond;
07724
07725 elementItem = locateElement(object, tag);
07726
07727 if (elementItem == NULL)
07728 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
07729 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
07730 DCM_TAG_ELEMENT(tag),
07731 "DCM_GetEncodedValue");
07732
07733 elementLength = elementItem->originalDataLength;
07734 ptr = NULL; /* Means reading from a file */
07735 size = DCM_UNSPECIFIEDLENGTH;
07736 fileOffset = elementItem->dataOffset;
07737
07738 opt |= (*object)->dataOptions & DCM_ORDERMASK;
07739 explicitVR = FALSE;
07740 switch (opt & DCM_ORDERMASK) {
07741 case DCM_ORDERNATIVE:
07742 byteOrder = NATIVE_ORDER;
07743 break;
07744 case DCM_ORDERLITTLEENDIAN:
07745 byteOrder = LITTLE_ORDER;
07746 break;
07747 case DCM_EXPLICITLITTLEENDIAN:
07748 byteOrder = LITTLE_ORDER;
07749 explicitVR = TRUE;
07750 break;
07751 case DCM_ORDERBIGENDIAN:
07752 byteOrder = BIG_ORDER;
07753 break;
07754 case DCM_EXPLICITBIGENDIAN:
07755 byteOrder = BIG_ORDER;
07756 explicitVR = TRUE;
07757 break;
07758 default:
07759 byteOrder = LITTLE_ORDER;
07760 explicitVR = TRUE;
07761 break;
07762 }
07763 if ((opt & DCM_VRMASK) == DCM_ACCEPTVRMISMATCH)
07764 acceptVRMismatch = TRUE;
07765
07766 (void) lseek((*object)->fd, elementItem->dataOffset, SEEK_SET);
07767 while (elementLength != 0) {
07768 sequenceLength = 0;
07769 memset(&e, 0, sizeof(e));
07770 flag = readGroupElement("", &ptr, (*object)->fd, &size, &fileOffset,
07771 FALSE, byteOrder, explicitVR, acceptVRMismatch,
07772 object, &sequenceLength, &e);
07773 if (flag == DCM_STREAMCOMPLETE)
07774 break;
07775 else if (flag != DCM_NORMAL)
07776 return flag;
07777
07778 flag = readVRLength("", &ptr, (*object)->fd, &size, &fileOffset,
07779 FALSE, /* Known length */
07780 byteOrder, explicitVR, acceptVRMismatch, object,
07781 &sequenceLength, &e);
07782 if (flag != DCM_NORMAL)
07783 return flag;
07784
07785 elementLength -= sequenceLength + e.length;
07786
07787 if (firstBuffer) {
07788 firstBuffer = FALSE;
07789 if (e.length != 0) {
07790 offsetBuffer = CTN_MALLOC(e.length);
07791 offsetBufferCount = e.length / sizeof(U32);
07792 if (offsetBuffer == NULL)
07793 exit(1); /* repair */
07794 nBytes = read((*object)->fd, offsetBuffer, e.length);
07795 if (nBytes != e.length) {
07796 exit(1); /* repair */
07797 }
07798 if (byteOrder == BYTEORDER_REVERSE) {
07799 DCM_ELEMENT offsetBufferElement;
07800 memset(&offsetBufferElement, 0, sizeof(DCM_ELEMENT));
07801 offsetBufferElement.length = e.length;
07802 offsetBufferElement.d.ul = offsetBuffer;
07803 offsetBufferElement.representation = DCM_UL;
07804 swapInPlace(object, &offsetBufferElement);
07805 }
07806 callback(offsetBuffer, e.length, index, 1, 0, 1, ctx);
07807 streamOffset = 0;
07808 } else {
07809 streamOffset = 0xffffffff;
07810 }
07811 } else {
07812 U32 l = e.length;
07813 int j;
07814 int lastIndex;
07815
07816 lastIndex = index;
07817 for (j = 0; j < offsetBufferCount; j++) {
07818 if (streamOffset == offsetBuffer[j])
07819 index = j + 1;
07820 }
07821 startOfFragment = 1;
07822 while (l != 0) {
07823 toRead = MIN(bufSize, l);
07824 nBytes = read((*object)->fd, buf, toRead);
07825 if (nBytes != toRead) {
07826 exit(1); /* repair */
07827 }
07828 callback(buf, toRead, index,
07829 (index != lastIndex) ? 1 : 0,
07830 0, startOfFragment, ctx);
07831 l -= toRead;
07832 lastIndex = index; /* Guarantee first flag is off */
07833 startOfFragment = 0;
07834 }
07835 streamOffset += sequenceLength + e.length;
07836 }
07837 fileOffset += e.length;
07838 index++;
07839 }
07840 callback(buf, 0, index, 0, 1, 1, ctx);
07841 return DCM_NORMAL;
07842 }
|
|
||||||||||||||||
|
Definition at line 3382 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, DCM_ELEMENT::d, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, and locateElement(). Referenced by DCM_GetString().
03383 {
03384 PRIVATE_OBJECT
03385 ** obj;
03386 CONDITION
03387 cond;
03388 PRV_ELEMENT_ITEM
03389 * elementItem;
03390
03391 obj = (PRIVATE_OBJECT **) callerObject;
03392 cond = checkObject(obj, "DCM_GetElementVM");
03393 if (cond != DCM_NORMAL)
03394 return cond;
03395
03396 elementItem = locateElement(obj, tag);
03397 if (elementItem == NULL)
03398 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03399 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03400 DCM_TAG_ELEMENT(tag),
03401 "DCM_GetElementVM");
03402 *element = elementItem->element;
03403 element->d.ot = NULL;
03404 return DCM_NORMAL;
03405 }
|
|
||||||||||||||||
|
Definition at line 1991 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, DCM_ELEMENT::length, LST_Head(), LST_Next(), LST_Position(), object, DCM_ELEMENT::tag, and U32.
01993 {
01994 PRIVATE_OBJECT
01995 ** object;
01996 PRV_GROUP_ITEM
01997 * groupItem;
01998 PRV_ELEMENT_ITEM
01999 * elementItem;
02000 CONDITION
02001 cond;
02002 CTNBOOLEAN
02003 flag;
02004 unsigned short
02005 group,
02006 element;
02007
02008 object = (PRIVATE_OBJECT **) callerObject;
02009 cond = checkObject(object, "DCM_GetElementSize");
02010 if (cond != DCM_NORMAL)
02011 return cond;
02012
02013 group = DCM_TAG_GROUP(tag);
02014 element = DCM_TAG_ELEMENT(tag);
02015
02016 groupItem = (void *)LST_Head(&((*object)->groupList));
02017 if (groupItem == NULL)
02018 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
02019 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
02020 "DCM_GetElementSize");
02021
02022 (void) LST_Position(&((*object)->groupList), (void *)groupItem);
02023
02024 flag = FALSE;
02025 while ((groupItem != NULL) && (flag == FALSE)) {
02026 if (groupItem->group == group)
02027 flag = TRUE;
02028 else
02029 groupItem = (void *)LST_Next(&(*object)->groupList);
02030 }
02031 if (flag == FALSE)
02032 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
02033 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
02034 "DCM_GetElementSize");
02035
02036 elementItem = (void *)LST_Head(&groupItem->elementList);
02037 if (elementItem == NULL)
02038 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
02039 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
02040 "DCM_GetElementSize");
02041
02042 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
02043
02044 flag = FALSE;
02045 while ((elementItem != NULL) && (flag == FALSE)) {
02046 if (elementItem->element.tag == tag)
02047 flag = TRUE;
02048 else
02049 elementItem = (void *)LST_Next(&groupItem->elementList);
02050 }
02051
02052 if (flag == FALSE)
02053 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
02054 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
02055 "DCM_GetElementSize");
02056
02057
02058 *rtnLength = elementItem->element.length;
02059 return DCM_NORMAL;
02060 }
|
|
||||||||||||||||||||
|
Definition at line 1652 of file l_mri_dicom_hdr.c. References PRV_ELEMENT_ITEM::byteOrder, BYTEORDER_REVERSE, checkObject(), COND_PushCondition(), CONDITION, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_AT, DCM_CANNOTGETSEQUENCEVALUE, DCM_ELEMENTNOTFOUND, DCM_FILEACCESSERROR, DCM_GETINCOMPLETE, DCM_ILLEGALCONTEXT, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_SQ, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, l, DCM_ELEMENT::length, LST_Head(), LST_Next(), LST_Position(), MIN, object, p, q, read(), DCM_ELEMENT::representation, swapATGroupElement(), swapInPlace(), DCM_ELEMENT::tag, and U32. Referenced by DCM_ParseObject(), and readLengthToEnd().
01654 {
01655 PRIVATE_OBJECT
01656 ** object;
01657 PRV_GROUP_ITEM
01658 * groupItem;
01659 PRV_ELEMENT_ITEM
01660 * elementItem;
01661 int
01662 nBytes;
01663 CONDITION
01664 cond;
01665
01666 object = (PRIVATE_OBJECT **) callerObject;
01667 cond = checkObject(object, "DCM_GetElementValue");
01668 if (cond != DCM_NORMAL)
01669 return cond;
01670
01671 groupItem = (void *)LST_Head(&(*object)->groupList);
01672 if (groupItem == NULL)
01673 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01674 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(element->tag),
01675 DCM_TAG_ELEMENT(element->tag),
01676 "DCM_GetElementValue");
01677
01678 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
01679 while (groupItem != NULL) {
01680 if (groupItem->group == DCM_TAG_GROUP(element->tag))
01681 break;
01682
01683 groupItem = (void *)LST_Next(&(*object)->groupList);
01684 }
01685 if (groupItem == NULL)
01686 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01687 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(element->tag),
01688 DCM_TAG_ELEMENT(element->tag),
01689 "DCM_GetElementValue");
01690
01691 elementItem = (void *)LST_Head(&groupItem->elementList);
01692 if (elementItem == NULL)
01693 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01694 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(element->tag),
01695 DCM_TAG_GROUP(element->tag),
01696 "DCM_GetElementValue");
01697
01698 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
01699 while (elementItem != NULL) {
01700 if (elementItem->element.tag == element->tag) {
01701 unsigned char *p;
01702 U32 l;
01703
01704 if (element->representation == DCM_SQ)
01705 return COND_PushCondition(DCM_CANNOTGETSEQUENCEVALUE,
01706 DCM_Message(DCM_CANNOTGETSEQUENCEVALUE),
01707 element->tag, "DCM_GetElementValue");
01708
01709 p = *ctx;
01710 if ((U32) p > elementItem->element.length)
01711 return COND_PushCondition(DCM_ILLEGALCONTEXT,
01712 DCM_Message(DCM_ILLEGALCONTEXT),
01713 "DCM_GetElementValue");
01714
01715 l = MIN(element->length, (elementItem->element.length - (U32) p));
01716
01717 *rtnLength = l;
01718 {
01719 if (elementItem->element.d.ot == NULL) {
01720 if ((*object)->fd != -1) {
01721 (void) lseek((*object)->fd,
01722 elementItem->dataOffset + (off_t) p, SEEK_SET);
01723 nBytes = read((*object)->fd, element->d.ot, (int) l);
01724 } else {
01725 (*object)->sk((*object)->userCtx,
01726 (long) (elementItem->dataOffset + (off_t) p), SEEK_SET);
01727 cond = (*object)->rd((*object)->userCtx, element->d.ot, l,
01728 &nBytes);
01729 }
01730 if ((unsigned) nBytes != l) {
01731 return COND_PushCondition(DCM_FILEACCESSERROR,
01732 DCM_Message(DCM_FILEACCESSERROR),
01733 (*object)->fileName,
01734 "DCM_GetElementValue");
01735 }
01736 if( LITTLE_ENDIAN_ARCHITECTURE ){
01737 if (elementItem->element.representation == DCM_AT) {
01738 DCM_ELEMENT e;
01739 e = elementItem->element;
01740 e.length = l;
01741 e.d.ot = element->d.ot;
01742 swapATGroupElement(&e);
01743 }
01744 }
01745 if (elementItem->byteOrder == BYTEORDER_REVERSE) {
01746 DCM_ELEMENT e;
01747 e = elementItem->element;
01748 e.length = l;
01749 e.d.ot = element->d.ot;
01750 swapInPlace(object, &e);
01751 }
01752 } else {
01753 unsigned char *q;
01754 q = (unsigned char *) elementItem->element.d.ot +
01755 (U32) p;
01756 (void) memcpy(element->d.ot, q, l);
01757 if (elementItem->byteOrder == BYTEORDER_REVERSE) {
01758 DCM_ELEMENT e;
01759 e = elementItem->element;
01760 e.length = l;
01761 e.d.ot = element->d.ot;
01762 swapInPlace(object, &e);
01763 }
01764 }
01765 p += l;
01766 *ctx = (void *) p;
01767 if ((unsigned) p == elementItem->element.length)
01768 return DCM_NORMAL;
01769 else
01770 return DCM_GETINCOMPLETE;
01771 }
01772
01773 }
01774 elementItem = (void *)LST_Next(&groupItem->elementList);
01775 }
01776 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01777 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(element->tag),
01778 DCM_TAG_ELEMENT(element->tag),
01779 "DCM_GetElementValue");
01780 }
|
|
||||||||||||||||||||||||
|
Definition at line 3199 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, CTN_MALLOC, CTNBOOLEAN, DCM_ELEMENT::d, DCM_DELIMITOR, DCM_ELEMENTNOTFOUND, DCM_IsString(), DCM_LISTFAILURE, DCM_MALLOCFAILURE, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNEXPECTEDREPRESENTATION, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, l, DCM_ELEMENT::length, LST_Enqueue(), LST_Head(), LST_Next(), LST_NORMAL, LST_Position(), object, p, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32.
03201 {
03202 PRIVATE_OBJECT
03203 ** obj;
03204 CONDITION
03205 cond;
03206 PRV_GROUP_ITEM
03207 * groupItem;
03208 PRV_ELEMENT_ITEM
03209 * elementItem;
03210 CTNBOOLEAN
03211 found = FALSE;
03212 char
03213 *src,
03214 *dst,
03215 *p;
03216 U32
03217 l;
03218
03219 obj = (PRIVATE_OBJECT **) object;
03220 cond = checkObject(obj, "DCM_GetSequenceList");
03221 if (cond != DCM_NORMAL)
03222 return cond;
03223
03224 groupItem = (void *)LST_Head(&(*obj)->groupList);
03225 if (groupItem == NULL)
03226 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03227 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03228 DCM_TAG_ELEMENT(tag),
03229 "DCM_GetSequenceList");
03230
03231 (void) LST_Position(&(*obj)->groupList, (void *)groupItem);
03232 while (groupItem != NULL) {
03233 if (groupItem->group == DCM_TAG_GROUP(tag))
03234 break;
03235
03236 groupItem = (void *)LST_Next(&(*obj)->groupList);
03237 }
03238 if (groupItem == NULL)
03239 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03240 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03241 DCM_TAG_ELEMENT(tag),
03242 "DCM_GetSequenceList");
03243
03244 elementItem = (void *)LST_Head(&groupItem->elementList);
03245 if (elementItem == NULL)
03246 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03247 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03248 DCM_TAG_GROUP(tag),
03249 "DCM_GetSequenceTag");
03250
03251 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
03252 while (!found && (elementItem != NULL)) {
03253 if (elementItem->element.tag == tag) {
03254 found = TRUE;
03255 } else
03256 elementItem = (void *)LST_Next(&groupItem->elementList);
03257 }
03258 if (!found)
03259 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03260 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03261 DCM_TAG_ELEMENT(tag),
03262 "DCM_GetElementValueList");
03263
03264 if (!DCM_IsString(elementItem->element.representation)) {
03265 return COND_PushCondition(DCM_UNEXPECTEDREPRESENTATION,
03266 DCM_Message(DCM_UNEXPECTEDREPRESENTATION), "DCM_GetElementValueList",
03267 "string");
03268 }
03269 src = elementItem->element.d.string;
03270 l = elementItem->element.length;
03271 while (l > 0) {
03272 while (l > 1 && (*src == ' ' || *src == DCM_DELIMITOR)) {
03273 l--;
03274 src++;
03275 }
03276 if ((l == 1) && (*src == ' ' || *src == DCM_DELIMITOR))
03277 l--;
03278
03279 if (l != 0) {
03280 p = CTN_MALLOC(structureSize);
03281 if (p == NULL)
03282 return COND_PushCondition(DCM_MALLOCFAILURE,
03283 DCM_Message(DCM_MALLOCFAILURE), structureSize,
03284 "DCM_GetElementValueList");
03285 dst = p + stringOffset;
03286 while ((l > 1) && (*src != DCM_DELIMITOR)) {
03287 *dst++ = *src++;
03288 l--;
03289 }
03290 if ((l == 1) && (*src != ' ')) {
03291 *dst++ = *src++;
03292 l--;
03293 }
03294 *dst = '\0';;
03295 cond = LST_Enqueue(list, (void *)p);
03296 if (cond != LST_NORMAL)
03297 return COND_PushCondition(DCM_LISTFAILURE,
03298 DCM_Message(DCM_LISTFAILURE), "DCM_GetElementValueList");
03299 }
03300 }
03301 return DCM_NORMAL;
03302 }
|
|
||||||||||||||||
|
Definition at line 1867 of file l_mri_dicom_hdr.c. References PRV_ELEMENT_ITEM::byteOrder, BYTEORDER_REVERSE, checkObject(), COND_PushCondition(), CONDITION, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_AT, DCM_BADLENGTH, DCM_BADOFFSET, DCM_CANNOTGETSEQUENCEVALUE, DCM_ELEMENTNOTFOUND, DCM_FILEACCESSERROR, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_SQ, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, l, DCM_ELEMENT::length, locateElement(), object, offset, p, q, read(), DCM_ELEMENT::representation, swapATGroupElement(), swapInPlace(), DCM_ELEMENT::tag, and U32.
01869 {
01870 PRIVATE_OBJECT **object;
01871 PRV_ELEMENT_ITEM *elementItem;
01872 int nBytes;
01873 CONDITION cond;
01874
01875 object = (PRIVATE_OBJECT **) callerObject;
01876 cond = checkObject(object, "DCM_GetElementValue");
01877 if (cond != DCM_NORMAL)
01878 return cond;
01879
01880 elementItem = locateElement(object, element->tag);
01881 if (elementItem == NULL)
01882 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01883 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(element->tag),
01884 DCM_TAG_ELEMENT(element->tag),
01885 "DCM_GetElementValueOffset");
01886
01887
01888 {
01889 unsigned char *p;
01890 U32 l;
01891
01892 if (element->representation == DCM_SQ)
01893 return COND_PushCondition(DCM_CANNOTGETSEQUENCEVALUE,
01894 DCM_Message(DCM_CANNOTGETSEQUENCEVALUE),
01895 element->tag, "DCM_GetElementValueOffset");
01896
01897 p = (unsigned char *) offset;;
01898 if ((U32) p > elementItem->element.length)
01899 return COND_PushCondition(DCM_BADOFFSET,
01900 DCM_Message(DCM_BADOFFSET),
01901 (int) offset,
01902 (int) elementItem->element.length,
01903 "DCM_GetElementValueLength");
01904
01905 l = element->length;
01906 if (l + offset > elementItem->element.length) {
01907 return COND_PushCondition(DCM_BADLENGTH,
01908 DCM_Message(DCM_BADLENGTH),
01909 (int) offset, (int) l,
01910 (int) elementItem->element.length,
01911 "DCM_GetElementValueLength");
01912 } {
01913 if (elementItem->element.d.ot == NULL) {
01914 if ((*object)->fd != -1) {
01915 (void) lseek((*object)->fd,
01916 elementItem->dataOffset + (off_t) p, SEEK_SET);
01917 nBytes = read((*object)->fd, element->d.ot, (int) l);
01918 } else {
01919 (*object)->sk((*object)->userCtx,
01920 (long) (elementItem->dataOffset + (off_t) p), SEEK_SET);
01921 cond = (*object)->rd((*object)->userCtx, element->d.ot, l,
01922 &nBytes);
01923 }
01924 if ((unsigned) nBytes != l) {
01925 return COND_PushCondition(DCM_FILEACCESSERROR,
01926 DCM_Message(DCM_FILEACCESSERROR),
01927 (*object)->fileName,
01928 "DCM_GetElementValueValue");
01929 }
01930 if( LITTLE_ENDIAN_ARCHITECTURE ){
01931 if (elementItem->element.representation == DCM_AT) {
01932 DCM_ELEMENT e;
01933 e = elementItem->element;
01934 e.length = l;
01935 e.d.ot = element->d.ot;
01936 swapATGroupElement(&e);
01937 }
01938 }
01939 if (elementItem->byteOrder == BYTEORDER_REVERSE) {
01940 DCM_ELEMENT e;
01941 e = elementItem->element;
01942 e.length = l;
01943 e.d.ot = element->d.ot;
01944 swapInPlace(object, &e);
01945 }
01946 } else {
01947 unsigned char *q;
01948 q = (unsigned char *) elementItem->element.d.ot +
01949 (U32) p;
01950 (void) memcpy(element->d.ot, q, l);
01951 if (elementItem->byteOrder == BYTEORDER_REVERSE) {
01952 DCM_ELEMENT e;
01953 e = elementItem->element;
01954 e.length = l;
01955 e.d.ot = element->d.ot;
01956 swapInPlace(object, &e);
01957 }
01958 }
01959 return DCM_NORMAL;
01960 }
01961
01962 }
01963 }
|
|
||||||||||||
|
dst = (DCM_OBJECT *) dstObj; Definition at line 8048 of file l_mri_dicom_hdr.c. References checkObject(), CONDITION, DCM_EMPTYOBJECT, DCM_GetNextElement(), DCM_NORMAL, DCM_OBJECT, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, LST_Head(), LST_Position(), and object.
08049 {
08050 PRIVATE_OBJECT** object;
08051 PRV_GROUP_ITEM* groupItem;
08052 PRV_ELEMENT_ITEM* elementItem;
08053 CONDITION cond;
08054
08055 object = (PRIVATE_OBJECT **) callerObject;
08056 cond = checkObject(object, "DCM_GetFirstElement");
08057 if (cond != DCM_NORMAL)
08058 return cond;
08059
08060 groupItem = (void *)LST_Head(&(*object)->groupList);
08061
08062 if (groupItem == NULL) {
08063 *e = 0;
08064 return DCM_EMPTYOBJECT;
08065 }
08066 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
08067 (*object)->groupCtx = groupItem;
08068
08069 elementItem = (void *)LST_Head(&groupItem->elementList);
08070 (*object)->elementCtx = elementItem;
08071 if (elementItem == NULL) {
08072 return DCM_GetNextElement(callerObject, e);
08073 }
08074
08075 *e = &elementItem->element;
08076 return DCM_NORMAL;
08077 }
|
|
||||||||||||
|
Definition at line 8080 of file l_mri_dicom_hdr.c. References checkObject(), CONDITION, DCM_GETNEXTELEMENTCOMPLETE, DCM_NORMAL, DCM_OBJECT, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, LST_Head(), LST_Next(), LST_Position(), and object. Referenced by DCM_GetFirstElement(), and DCM_GetNextElement().
08081 {
08082 PRIVATE_OBJECT** object;
08083 PRV_GROUP_ITEM* groupItem;
08084 PRV_ELEMENT_ITEM* elementItem;
08085 CONDITION cond;
08086
08087 object = (PRIVATE_OBJECT **) callerObject;
08088 cond = checkObject(object, "DCM_GetNextElement");
08089 if (cond != DCM_NORMAL)
08090 return cond;
08091
08092 groupItem = (*object)->groupCtx;
08093 elementItem = (*object)->elementCtx;
08094
08095 if (elementItem != 0) {
08096 (void)LST_Position(&groupItem->elementList, (void *)elementItem);
08097 elementItem = (PRV_ELEMENT_ITEM*)LST_Next(&groupItem->elementList);
08098 }
08099
08100 if (elementItem == 0) {
08101 (void)LST_Position(&(*object)->groupList, (void *)groupItem);
08102 groupItem = (PRV_GROUP_ITEM*)LST_Next(&(*object)->groupList);
08103 if (groupItem != 0) {
08104 elementItem = (PRV_ELEMENT_ITEM*)LST_Head(&groupItem->elementList);
08105 }
08106 }
08107
08108 if (groupItem == 0) {
08109 *e = 0;
08110 return DCM_GETNEXTELEMENTCOMPLETE;
08111 }
08112
08113 (*object)->groupCtx = groupItem;
08114 (*object)->elementCtx = elementItem;
08115
08116 if (elementItem == 0)
08117 return DCM_GetNextElement(callerObject, e);
08118
08119 *e = &elementItem->element;
08120 return DCM_NORMAL;
08121 }
|
|
||||||||||||
|
Definition at line 2243 of file l_mri_dicom_hdr.c. References checkObject(), CONDITION, DCM_NORMAL, DCM_OBJECT, and object.
02244 {
02245 PRIVATE_OBJECT
02246 ** object;
02247 CONDITION
02248 cond;
02249
02250 object = (PRIVATE_OBJECT **) callerObject;
02251 cond = checkObject(object, "DCM_GetObjectSize");
02252 if (cond != DCM_NORMAL)
02253 return cond;
02254
02255 *returnlength = (*object)->objectSize;
02256 return DCM_NORMAL;
02257 }
|
|
||||||||||||||||||||
|
Definition at line 7881 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, DCM_ELEMENT::d, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, locateElement(), LST_Head(), LST_Next(), LST_Position(), DCM_SEQUENCE_ITEM::object, object, PRIVATE_OBJECT::offset, and offset.
07883 {
07884 PRIVATE_OBJECT **obj,
07885 *sqObject;
07886 CONDITION cond;
07887 PRV_ELEMENT_ITEM *elementItem;
07888 LST_HEAD *lst;
07889 DCM_SEQUENCE_ITEM *sqItem;
07890
07891 obj = (PRIVATE_OBJECT **) object;
07892 cond = checkObject(obj, "DCM_PrintSequenceList");
07893 if (cond != DCM_NORMAL)
07894 return cond;
07895
07896 elementItem = locateElement(obj, tag);
07897
07898 if (elementItem == NULL)
07899 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
07900 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
07901 DCM_TAG_ELEMENT(tag),
07902 "DCM_PrintSequenceList");
07903
07904 lst = elementItem->element.d.sq;
07905 sqItem = (void *)LST_Head(&lst);
07906 (void) LST_Position(&lst, (void *)sqItem);
07907 while (sqItem != NULL) {
07908 sqObject = (PRIVATE_OBJECT *) sqItem->object;
07909 if (sqObject->offset == offset) {
07910 *rtnObject = sqItem->object;
07911 return DCM_NORMAL;
07912 }
07913 sqItem = (void *)LST_Next(&lst);
07914 }
07915 return 0;
07916 }
|
|
||||||||||||||||
|
Definition at line 3140 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_ELEMENT::d, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_ParseObject(), DCM_SQ, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNEXPECTEDREPRESENTATION, PRV_ELEMENT_ITEM::element, locateElement(), LST_Head(), DCM_SEQUENCE_ITEM::object, object, DCM_ELEMENT::representation, and top.
03141 {
03142 PRIVATE_OBJECT **obj;
03143 CONDITION cond;
03144 PRV_GROUP_ITEM *groupItem;
03145 PRV_ELEMENT_ITEM *elementItem;
03146 DCM_SEQUENCE_ITEM *seqItem;
03147
03148 CTNBOOLEAN found = FALSE;
03149
03150 obj = (PRIVATE_OBJECT **) object;
03151 cond = checkObject(obj, "DCM_GetSequenceElement");
03152 if (cond != DCM_NORMAL)
03153 return cond;
03154
03155 elementItem = locateElement(obj, top);
03156 if (elementItem == NULL) {
03157 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03158 DCM_Message(DCM_ELEMENTNOTFOUND),
03159 DCM_TAG_GROUP(top),
03160 DCM_TAG_ELEMENT(top),
03161 "DCM_GetElementSequence");
03162 }
03163 if (elementItem->element.representation != DCM_SQ) {
03164 return COND_PushCondition(DCM_UNEXPECTEDREPRESENTATION,
03165 DCM_Message(DCM_UNEXPECTEDREPRESENTATION),
03166 "DCM_GetSequenceElement", "sequence");
03167 }
03168 seqItem = (void *)LST_Head(&elementItem->element.d.sq);
03169 cond = DCM_ParseObject(&seqItem->object, e, 1, NULL, 0, NULL);
03170 return cond;
03171
03172 #if 0
03173 return DCM_NORMAL;
03174 #endif
03175 }
|
|
||||||||||||||||
|
Definition at line 3077 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_ELEMENT::d, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, LST_Head(), LST_Next(), LST_Position(), object, and DCM_ELEMENT::tag.
03078 {
03079 PRIVATE_OBJECT
03080 ** obj;
03081 CONDITION
03082 cond;
03083 PRV_GROUP_ITEM
03084 * groupItem;
03085 PRV_ELEMENT_ITEM
03086 * elementItem;
03087 CTNBOOLEAN
03088 found = FALSE;
03089
03090 obj = (PRIVATE_OBJECT **) object;
03091 cond = checkObject(obj, "DCM_GetSequenceList");
03092 if (cond != DCM_NORMAL)
03093 return cond;
03094
03095 groupItem = (void *)LST_Head(&(*obj)->groupList);
03096 if (groupItem == NULL)
03097 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03098 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03099 DCM_TAG_ELEMENT(tag),
03100 "DCM_GetSequenceList");
03101
03102 (void) LST_Position(&(*obj)->groupList, (void *)groupItem);
03103 while (groupItem != NULL) {
03104 if (groupItem->group == DCM_TAG_GROUP(tag))
03105 break;
03106
03107 groupItem = (void *)LST_Next(&(*obj)->groupList);
03108 }
03109 if (groupItem == NULL)
03110 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03111 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03112 DCM_TAG_ELEMENT(tag),
03113 "DCM_GetSequenceList");
03114
03115 elementItem = (void *)LST_Head(&groupItem->elementList);
03116 if (elementItem == NULL)
03117 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03118 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03119 DCM_TAG_GROUP(tag),
03120 "DCM_GetSequenceTag");
03121
03122 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
03123 while (!found && (elementItem != NULL)) {
03124 if (elementItem->element.tag == tag) {
03125 *list = elementItem->element.d.sq;
03126 found = TRUE;
03127 }
03128 elementItem = (void *)LST_Next(&groupItem->elementList);
03129 }
03130 if (found)
03131 return DCM_NORMAL;
03132 else
03133 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
03134 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
03135 DCM_TAG_ELEMENT(tag),
03136 "DCM_GetSequenceList");
03137 }
|
|
||||||||||||
|
Definition at line 1783 of file l_mri_dicom_hdr.c. References AFMALL, COND_PopCondition(), CONDITION, DCM_ELEMENT::d, DCM_AT, DCM_CTX, DCM_DLM, DCM_FD, DCM_FL, DCM_GetElement(), DCM_IsString(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_OW, DCM_ParseObject(), DCM_RET, DCM_SL, DCM_SQ, DCM_SS, DCM_TAG, DCM_UL, DCM_UN, DCM_US, free, DCM_ELEMENT::length, malloc, DCM_ELEMENT::representation, and DCM_ELEMENT::tag.
01784 {
01785 DCM_ELEMENT e;
01786 CONDITION cond;
01787 char* s;
01788 char tmp[64] = "";
01789 char b[64] = "";
01790
01791 e.tag = tag;
01792 cond = DCM_GetElement(callerObject, tag, &e);
01793 if (cond != DCM_NORMAL) {
01794 COND_PopCondition(TRUE);
01795 return 0;
01796 }
01797
01798 if (DCM_IsString(e.representation)) {
01799 s = AFMALL( char, e.length + 1);
01800 e.d.string = s;
01801 cond = DCM_ParseObject(callerObject, &e, 1, 0, 0, 0);
01802 if (cond != DCM_NORMAL) {
01803 free(s);
01804 s = 0;
01805 }
01806 return s;
01807 }
01808
01809 if (e.representation == DCM_SQ) {
01810 return 0;
01811 }
01812
01813 if (e.length > sizeof(b))
01814 return 0;
01815
01816 e.d.ot = b;
01817 cond = DCM_ParseObject(callerObject, &e, 1, 0, 0, 0);
01818 if (cond != DCM_NORMAL) {
01819 COND_PopCondition(TRUE);
01820 return 0;
01821 }
01822
01823 switch (e.representation) {
01824 case DCM_AT:
01825 case DCM_FD:
01826 case DCM_FL:
01827 strcpy(tmp, "<Unimplemented>");
01828 break;
01829 case DCM_SL:
01830 sprintf(tmp, "%d", *e.d.sl);
01831 break;
01832 case DCM_SQ:
01833 strcpy(tmp, "<Unimplemented>");
01834 break;
01835 case DCM_SS:
01836 sprintf(tmp, "%d", *e.d.ss);
01837 break;
01838 case DCM_UL:
01839 sprintf(tmp, "%d", *e.d.ul);
01840 break;
01841 case DCM_UN:
01842 strcpy(tmp, "<Unimplemented>");
01843 break;
01844 case DCM_US:
01845 sprintf(tmp, "%d", *e.d.us);
01846 break;
01847 /*case DCM_UNKNOWN:*/
01848 case DCM_RET:
01849 case DCM_CTX:
01850 case DCM_OB:
01851 case DCM_OW:
01852 case DCM_DLM:
01853 default:
01854 strcpy(tmp, "<Unimplemented>");
01855 break;
01856 }
01857
01858 s = (char*) malloc(strlen(tmp) + 1);
01859 strcpy(s, tmp);
01860
01861 return s;
01862 }
|
|
||||||||||||||||
|
Definition at line 10385 of file l_mri_dicom_hdr.c. References DCM_NORMAL, DIM_OF, and i.
10387 {
10388 int i;
10389
10390 for (i = 0; i < (int) DIM_OF(groupTable); i++) {
10391 if ((group == 0xffff) || (group == groupTable[i].group)) {
10392 callback(groupTable[i].group, groupTable[i].description, ctx);
10393 }
10394 }
10395 return DCM_NORMAL;
10396 }
|
|
||||||||||||
|
Definition at line 3489 of file l_mri_dicom_hdr.c. References checkObject(), CONDITION, CTNBOOLEAN, DCM_NORMAL, DCM_OBJECT, PRV_GROUP_ITEM::group, LST_Head(), LST_Next(), LST_Position(), object, and U16.
03490 {
03491 PRIVATE_OBJECT **object;
03492 PRV_GROUP_ITEM * item;
03493 CONDITION cond;
03494 CTNBOOLEAN tooFar = FALSE;
03495
03496 object = (PRIVATE_OBJECT **) o1;
03497 cond = checkObject(object, "DCM_CompareAttributes");
03498 if (cond != DCM_NORMAL)
03499 return FALSE;
03500
03501
03502 item = (void *)LST_Head(&(*object)->groupList);
03503 if (item != NULL)
03504 (void) LST_Position(&(*object)->groupList, (void *)item);
03505
03506 while (item != NULL && !tooFar) {
03507 if (item->group == group) {
03508 return TRUE;
03509 } else if (item->group > group) {
03510 tooFar = TRUE;
03511 } else {
03512 item = (void *)LST_Next(&(*object)->groupList);
03513 }
03514 }
03515 return FALSE;
03516 }
|
|
||||||||||||||||||||
|
Definition at line 2204 of file l_mri_dicom_hdr.c. References COND_PushCondition(), DCM_ILLEGALOPTION, DCM_Message(), DCM_OBJECT, DCM_ORDERMASK, and readFile(). Referenced by readLengthToEnd().
02206 {
02207 #ifdef DEBUG
02208 if (debug)
02209 (void) fprintf(stderr, "DCM_ImportStream, %ld bytes\n", length);
02210 #endif
02211
02212 if ((opt & DCM_ORDERMASK) == 0)
02213 return COND_PushCondition(DCM_ILLEGALOPTION,
02214 DCM_Message(DCM_ILLEGALOPTION), "Byte order",
02215 "DCM_ImportStream");
02216
02217 return readFile("", buf, -1, length, 0, 0, opt, callerObject, NULL, NULL,
02218 NULL, NULL, NULL);
02219 }
|
|
|
Definition at line 10612 of file l_mri_dicom_hdr.c. References CTNBOOLEAN, DCM_AE, DCM_AS, DCM_AT, DCM_CS, DCM_CTX, DCM_DA, DCM_DD, DCM_DS, DCM_DT, DCM_FD, DCM_FL, DCM_IS, DCM_LO, DCM_LT, DCM_OB, DCM_OT, DCM_OW, DCM_PN, DCM_RET, DCM_SH, DCM_SL, DCM_SQ, DCM_SS, DCM_ST, DCM_TM, DCM_UI, DCM_UL, DCM_US, DCM_UT, and DCM_VALUEREPRESENTATION. Referenced by DCM_GetElementValueList(), DCM_GetString(), DCM_ModifyElements(), DCM_ParseObject(), and DCM_ScanParseObject().
10613 {
10614 CTNBOOLEAN
10615 flag = FALSE;
10616
10617 switch (representation) {
10618 case DCM_AE: /* Application Entity */
10619 case DCM_AS: /* Age string */
10620 flag = TRUE;
10621 break;
10622 case DCM_AT: /* Attribute tag */
10623 break;
10624 case DCM_CS: /* Control string */
10625 case DCM_DA: /* Date */
10626 flag = TRUE;
10627 break;
10628 case DCM_DD: /* Data set */
10629 break;
10630 case DCM_DS: /* Decimal string */
10631 case DCM_DT: /* Old date/time */
10632 flag = TRUE;
10633 break;
10634 case DCM_FD: /* Floating double */
10635 case DCM_FL: /* Float */
10636 break;
10637 case DCM_IS: /* Integer string */
10638 case DCM_LO: /* Long string */
10639 case DCM_LT: /* Long text */
10640 flag = TRUE;
10641 break;
10642 case DCM_OB: /* Other binary value (byte) */
10643 case DCM_OT: /* Other binary value */
10644 case DCM_OW: /* Other binary value (word) */
10645 break;
10646 case DCM_SH: /* Short string */
10647 flag = TRUE;
10648 break;
10649 case DCM_SL: /* Signed long */
10650 case DCM_SQ: /* Sequence of items */
10651 case DCM_SS: /* Signed short */
10652 break;
10653 case DCM_ST: /* Short text */
10654 case DCM_TM: /* Time */
10655 flag = TRUE;
10656 break;
10657 case DCM_UL: /* Unsigned long */
10658 case DCM_US: /* Unsigned short */
10659 /*case DCM_UNKNOWN:*/ /* Unknown/unspecified */
10660 case DCM_RET: /* Retired */
10661 case DCM_CTX: /* Context sensitive */
10662 break;
10663 case DCM_PN: /* Person Name */
10664 case DCM_UI: /* Unique identifier (UID) */
10665 case DCM_UT: /* Unlimited Text */
10666 flag = TRUE;
10667 break;
10668 };
10669 return flag;
10670 }
|
|
||||||||||||||||
|
Definition at line 10540 of file l_mri_dicom_hdr.c. References c, COND_PushCondition(), CTN_MALLOC, DCM_LISTFAILURE, DCM_MALLOCFAILURE, DCM_Message(), DCM_NORMAL, LST_Head(), LST_Next(), LST_Position(), offset, and p. Referenced by DCM_AddElementList().
10541 {
10542 GENERIC
10543 * g;
10544 char
10545 *c,
10546 *p;
10547 long
10548 length;
10549
10550 *string = NULL;
10551 if (list == NULL)
10552 return DCM_NORMAL;
10553
10554 g = (void *)LST_Head(&list);
10555 if (g == NULL)
10556 return DCM_NORMAL;
10557
10558 (void) LST_Position(&list, (void *)g);
10559
10560 length = 0;
10561 while (g != NULL) {
10562 c = ((char *) g) + offset;
10563 length += strlen(c) + 1;
10564 g = (void *)LST_Next(&list);
10565 }
10566
10567 p = CTN_MALLOC(length);
10568 if (p == NULL)
10569 return COND_PushCondition(DCM_MALLOCFAILURE,
10570 DCM_Message(DCM_MALLOCFAILURE), length, "DCM_ListToString");
10571
10572 *string = p;
10573 g = (void *)LST_Head(&list);
10574 if (g == NULL)
10575 return COND_PushCondition(DCM_LISTFAILURE, DCM_Message(DCM_LISTFAILURE),
10576 "DCM_ListToString");
10577 (void) LST_Position(&list, (void *)g);
10578
10579 length = 0;
10580 while (g != NULL) {
10581 c = ((char *) g) + offset;
10582 length = strlen(c);
10583 (void) memcpy(p, c, length);
10584 p += length;
10585 *p++ = '\\';
10586 g = (void *)LST_Next(&list);
10587 }
10588 *--p = '\0';
10589 return DCM_NORMAL;
10590 }
|
|
|
Definition at line 10257 of file l_mri_dicom_hdr.c. References COND_PushCondition(), DCM_Message(), DCM_NORMAL, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UL, DCM_UN, DCM_UNRECOGNIZEDELEMENT, DCM_UNRECOGNIZEDGROUP, DCM_ELEMENT::description, GROUPPTR::dict, DCMDICT::englishDescription, GROUPPTR::entries, GROUPPTR::group, p, DCMDICT::representation, DCM_ELEMENT::representation, DCMDICT::tag, and DCM_ELEMENT::tag. Referenced by DCM_AddElement(), DCM_AddSequenceElement(), readFile(), and readGroupElement().
10258 {
10259 int
10260 found;
10261 unsigned long
10262 index,
10263 entries;
10264 GROUPPTR
10265 * p;
10266 DCMDICT
10267 * dictionaryPtr;
10268
10269 element->representation = DCM_UN;
10270 (void) strcpy(element->description, "");
10271
10272 for (index = 0, p = NULL;
10273 index < sizeof(group_dictionary) / sizeof(group_dictionary[0]) && p == NULL;
10274 index++)
10275 if (DCM_TAG_GROUP(element->tag) == group_dictionary[index].group)
10276 p = &group_dictionary[index];
10277
10278 if (p == NULL) {
10279 if (DCM_TAG_ELEMENT(element->tag) == 0x0000) {
10280 element->representation = DCM_UL;
10281 (void) strcpy(element->description, "Unknown group length");
10282 return DCM_NORMAL;
10283 }
10284 return COND_PushCondition(DCM_UNRECOGNIZEDGROUP,
10285 DCM_Message(DCM_UNRECOGNIZEDGROUP),
10286 DCM_TAG_GROUP(element->tag),
10287 "DCM_LookupElement");
10288 }
10289 entries = p->entries;
10290 dictionaryPtr = p->dict;
10291
10292 for (found = 0; !found && entries > 0; entries--)
10293 if (element->tag == dictionaryPtr->tag)
10294 found++;
10295 else
10296 dictionaryPtr++;
10297
10298 if (!found)
10299 return COND_PushCondition(DCM_UNRECOGNIZEDELEMENT,
10300 DCM_Message(DCM_UNRECOGNIZEDELEMENT),
10301 DCM_TAG_GROUP(element->tag),
10302 DCM_TAG_ELEMENT(element->tag),
10303 "DCM_LookupElement");
10304
10305
10306 element->representation = dictionaryPtr->representation;
10307 (void) strcpy(element->description, dictionaryPtr->englishDescription);
10308 return DCM_NORMAL;
10309 }
|
|
||||||||||||
|
Definition at line 7999 of file l_mri_dicom_hdr.c. References COND_PushCondition(), copySequence(), DCM_AddElement(), DCM_MALLOCFAILURE, DCM_Message(), DCM_NORMAL, DCM_NULLADDRESS, DCM_OBJECT, DCM_OBJECTCREATEFAILED, DCM_SQ, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, LST_Head(), LST_Next(), LST_Position(), and DCM_ELEMENT::representation.
08000 {
08001 PRIVATE_OBJECT **srcObj;
08002 PRIVATE_OBJECT *dstObj;
08003 PRV_GROUP_ITEM *groupItem;
08004 PRV_ELEMENT_ITEM *elementItem;
08005
08006 if (src == NULL) {
08007 (void) COND_PushCondition(DCM_NULLADDRESS,
08008 DCM_Message(DCM_NULLADDRESS), "DCM_MergeObject");
08009 return COND_PushCondition(DCM_OBJECTCREATEFAILED,
08010 DCM_Message(DCM_OBJECTCREATEFAILED), "DCM_MergeObject");
08011 }
08012 dstObj = *((PRIVATE_OBJECT **)dst);
08013 if (dstObj == NULL) {
08014 (void) COND_PushCondition(DCM_MALLOCFAILURE,
08015 DCM_Message(DCM_MALLOCFAILURE), sizeof(PRIVATE_OBJECT),
08016 "DCM_MergeObject");
08017 *dst = NULL;
08018 return COND_PushCondition(DCM_OBJECTCREATEFAILED,
08019 DCM_Message(DCM_OBJECTCREATEFAILED), "DCM_MergeObject");
08020 }
08021 srcObj = (PRIVATE_OBJECT **) src;
08022
08023 groupItem = (void *)LST_Head(&(*srcObj)->groupList);
08024 if (groupItem != NULL)
08025 (void) LST_Position(&(*srcObj)->groupList, (void *)groupItem);
08026
08027 while (groupItem != NULL) {
08028 elementItem = (void *)LST_Head(&groupItem->elementList);
08029 if (elementItem != NULL)
08030 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
08031 while (elementItem != NULL) {
08032 if (elementItem->element.representation == DCM_SQ) {
08033 copySequence(&dstObj, &elementItem->element);
08034 } else {
08035 DCM_AddElement((DCM_OBJECT **) & dstObj, &elementItem->element);
08036 }
08037 elementItem = (void *)LST_Next(&groupItem->elementList);
08038 }
08039 groupItem = (void *)LST_Next(&(*srcObj)->groupList);
08040 }
08041
08042 /**dst = (DCM_OBJECT *) dstObj;*/
08043 return DCM_NORMAL;
08044 }
|
|
|
||||||||||||||||||||||||||||
|
Definition at line 2828 of file l_mri_dicom_hdr.c. References c, checkObject(), COND_PopCondition(), CONDITION, DCM_ELEMENT::d, DCM_AddElement(), DCM_IsString(), DCM_NORMAL, DCM_OBJECT, DCM_RemoveElement(), DCM_FLAGGED_ELEMENT::e, DCM_FLAGGED_ELEMENT::flag, DCM_FLAGGED_ELEMENT::flagAddress, DCM_ELEMENT::length, object, DCM_ELEMENT::representation, and DCM_ELEMENT::tag.
02831 {
02832 PRIVATE_OBJECT
02833 ** object;
02834 CONDITION
02835 cond;
02836 DCM_ELEMENT
02837 e;
02838 int
02839 c = 0;
02840
02841 object = (PRIVATE_OBJECT **) callerObject;
02842 cond = checkObject(object, "DCM_ModifyElement");
02843 if (cond != DCM_NORMAL)
02844 return cond;
02845
02846 while (count-- > 0) {
02847 cond = DCM_RemoveElement(callerObject, vector->tag);
02848 if (cond != DCM_NORMAL)
02849 (void) COND_PopCondition(FALSE);
02850
02851 e = *vector;
02852 if (DCM_IsString(e.representation))
02853 e.length = strlen(e.d.string);
02854
02855 cond = DCM_AddElement(callerObject, &e);
02856 if (cond != DCM_NORMAL)
02857 return cond;
02858
02859 c++;
02860 vector++;
02861 }
02862
02863 while (flaggedCount-- > 0) {
02864 if ((*(flaggedVector->flagAddress) & flaggedVector->flag) != 0) {
02865 cond = DCM_RemoveElement(callerObject, flaggedVector->e.tag);
02866 if (cond != DCM_NORMAL)
02867 (void) COND_PopCondition(FALSE);
02868
02869 e = flaggedVector->e;
02870 if (DCM_IsString(e.representation))
02871 e.length = strlen(e.d.string);
02872 cond = DCM_AddElement(callerObject, &e);
02873 if (cond != DCM_NORMAL)
02874 return cond;
02875 c++;
02876 }
02877 flaggedVector++;
02878 }
02879
02880 if (updateCount != NULL)
02881 *updateCount = c;
02882 return DCM_NORMAL;
02883 }
|
|
||||||||||||||||
|
Definition at line 1002 of file l_mri_dicom_hdr.c. References close(), COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_DumpElements(), DCM_FILEACCESSERROR, DCM_FILEFORMATMASK, DCM_FILENAMEMASK, DCM_FILEOPENFAILED, DCM_ILLEGALOPTION, DCM_LENGTHTOENDMASK, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_ORDERMASK, DCM_TRYFILENAMECHANGE, DCM_USELENGTHTOEND, ENTRY, fd, fileSize(), name, O_BINARY, readFile(), readFile1(), readLengthToEnd(), remapFileName(), RETURN, rwc_fd, and U32. Referenced by mri_dicom_header().
01003 {
01004 CONDITION cond;
01005 int fd;
01006 off_t fileOffset = 0;
01007 U32 lengthToEnd;
01008 U32 size;
01009 CTNBOOLEAN
01010 remainFileOpen = FALSE; /* Leave file open after parse ? */
01011
01012 ENTRY("DCM_OpenFile") ;
01013
01014 if ((opt & (DCM_ORDERMASK | DCM_FILEFORMATMASK)) == 0)
01015 RETURN(COND_PushCondition(DCM_ILLEGALOPTION,
01016 DCM_Message(DCM_ILLEGALOPTION), "Byte order",
01017 "DCM_OpenFile"));
01018
01019 #ifdef _MSC_VER
01020 fd = open(name, O_RDONLY | O_BINARY);
01021 #else
01022 rwc_fd = fd = open(name, O_RDONLY);
01023 #endif
01024 if ((fd < 0) && ((opt & DCM_FILENAMEMASK) == DCM_TRYFILENAMECHANGE)) {
01025 char mapName[1024];
01026 remapFileName(name, mapName);
01027 #ifdef _MSC_VER
01028 fd = open(mapName, O_RDONLY | O_BINARY);
01029 #else
01030 fd = open(mapName, O_RDONLY);
01031 if (fd < 0) {
01032 strcat(mapName, ".");
01033 fd = open(mapName, O_RDONLY);
01034 }
01035 #endif
01036 }
01037 if (fd < 0) {
01038 char msg[1024] ;
01039 sprintf(msg,"DCM_OpenFile open(%s) fails",name) ;
01040 perror(msg) ;
01041 RETURN(COND_PushCondition(DCM_FILEOPENFAILED,
01042 DCM_Message(DCM_FILEOPENFAILED), name,
01043 "DCM_OpenFile"));
01044 }
01045 size = fileSize(fd);
01046 if (size <= 0)
01047 RETURN(DCM_FILEACCESSERROR);
01048
01049 if ((opt & DCM_LENGTHTOENDMASK) == DCM_USELENGTHTOEND) {
01050 cond = readLengthToEnd(fd, name,
01051 opt & (~DCM_LENGTHTOENDMASK), &lengthToEnd);
01052 if (cond != DCM_NORMAL) {
01053 (void) close(fd); rwc_fd = -1 ;
01054 RETURN(COND_PushCondition(DCM_FILEOPENFAILED,
01055 DCM_Message(DCM_FILEOPENFAILED), name, "DCM_OpenFile"));
01056 }
01057 size = lengthToEnd;
01058 fileOffset = 24;
01059 (void) lseek(fd, 24, SEEK_SET);
01060 }
01061 #ifdef OLDSMM
01062 cond = readFile(name, NULL, fd, size, 0, 0, opt, callerObject, NULL,
01063 &remainFileOpen, NULL, NULL, NULL);
01064 #endif
01065 cond = readFile1(name, NULL, fd, size, &fileOffset, 0, opt, NULL,
01066 callerObject, NULL, &remainFileOpen, NULL, NULL, NULL);
01067 if ((cond != DCM_NORMAL) || !remainFileOpen){
01068 (void) close(fd); rwc_fd = -1 ;
01069 }
01070 if (cond != DCM_NORMAL) {
01071 if (debug)
01072 DCM_DumpElements(callerObject, 1);
01073 RETURN(COND_PushCondition(DCM_FILEOPENFAILED,
01074 DCM_Message(DCM_FILEOPENFAILED), name, "DCM_OpenFile"));
01075 } else
01076 RETURN(DCM_NORMAL);
01077 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 2918 of file l_mri_dicom_hdr.c. References c, checkObject(), COND_PopCondition(), CONDITION, DCM_ELEMENT::d, DCM_GetElementValue(), DCM_IsString(), DCM_NORMAL, DCM_OBJECT, DCM_FLAGGED_ELEMENT::e, DCM_FLAGGED_ELEMENT::flag, DCM_FLAGGED_ELEMENT::flagAddress, l, object, p, DCM_ELEMENT::representation, and U32. Referenced by DCM_GetSequenceElement(), DCM_GetString(), and setFileOptions().
02921 {
02922 PRIVATE_OBJECT
02923 ** object;
02924 CONDITION
02925 cond;
02926 void
02927 *ctx;
02928 U32
02929 l;
02930 int
02931 c = 0;
02932 char
02933 *p;
02934
02935 object = (PRIVATE_OBJECT **) callerObject;
02936 cond = checkObject(object, "DCM_ParseObject");
02937 if (cond != DCM_NORMAL)
02938 return cond;
02939
02940 while (count-- > 0) {
02941 ctx = NULL;
02942 cond = DCM_GetElementValue(callerObject, vector, &l, &ctx);
02943 if (cond != DCM_NORMAL)
02944 return cond;
02945 if (DCM_IsString(vector->representation)) {
02946 vector->d.string[l] = '\0';
02947 p = vector->d.string + l - 1;
02948 while (p >= vector->d.string && (*p == ' '))
02949 *p-- = '\0';
02950 }
02951 c++;
02952 vector++;
02953 }
02954
02955 while (flagCount-- > 0) {
02956 ctx = NULL;
02957 cond = DCM_GetElementValue(callerObject, &flaggedVector->e, &l, &ctx);
02958 if (cond != DCM_NORMAL) {
02959 (void) COND_PopCondition(FALSE);
02960 } else {
02961 c++;
02962 if (DCM_IsString(flaggedVector->e.representation)) {
02963 flaggedVector->e.d.string[l] = '\0';
02964 p = flaggedVector->e.d.string + l - 1;
02965 while (p >= flaggedVector->e.d.string && (*p == ' '))
02966 *p-- = '\0';
02967 }
02968 *(flaggedVector->flagAddress) |= flaggedVector->flag;
02969 }
02970 flaggedVector++;
02971 }
02972
02973 if (parseCount != NULL)
02974 *parseCount = c;
02975 return DCM_NORMAL;
02976 }
|
|
||||||||||||
|
Definition at line 7845 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, DCM_ELEMENT::d, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, locateElement(), LST_Head(), LST_Next(), LST_Position(), DCM_SEQUENCE_ITEM::object, object, PRIVATE_OBJECT::objectSize, PRIVATE_OBJECT::offset, PRIVATE_OBJECT::pixelOffset, and RWC_printf().
07846 {
07847 PRIVATE_OBJECT **obj,
07848 *sqObject;
07849 CONDITION cond;
07850 PRV_ELEMENT_ITEM *elementItem;
07851 LST_HEAD *lst;
07852 DCM_SEQUENCE_ITEM *sqItem;
07853
07854 obj = (PRIVATE_OBJECT **) object;
07855 cond = checkObject(obj, "DCM_PrintSequenceList");
07856 if (cond != DCM_NORMAL)
07857 return cond;
07858
07859 elementItem = locateElement(obj, tag);
07860
07861 if (elementItem == NULL)
07862 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
07863 DCM_Message(DCM_ELEMENTNOTFOUND), DCM_TAG_GROUP(tag),
07864 DCM_TAG_ELEMENT(tag),
07865 "DCM_PrintSequenceList");
07866
07867 lst = elementItem->element.d.sq;
07868 sqItem = (void *)LST_Head(&lst);
07869 (void) LST_Position(&lst, (void *)sqItem);
07870 while (sqItem != NULL) {
07871 sqObject = (PRIVATE_OBJECT *) sqItem->object;
07872 RWC_printf("size: %6d offset: %6d, pixel offset: %6d\n",
07873 sqObject->objectSize,
07874 sqObject->offset,
07875 sqObject->pixelOffset);
07876 sqItem = (void *)LST_Next(&lst);
07877 }
07878 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 1080 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_FILEFORMATMASK, DCM_ILLEGALOPTION, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_ORDERMASK, DCM_READSTREAMFAILED, fd, offset, and readFile1().
01084 {
01085 CONDITION cond;
01086 int fd = -1;
01087 CTNBOOLEAN
01088 remainFileOpen = FALSE; /* Leave file open after parse ? */
01089 off_t fileOffset = 0;
01090
01091 if ((opt & (DCM_ORDERMASK | DCM_FILEFORMATMASK)) == 0)
01092 return COND_PushCondition(DCM_ILLEGALOPTION,
01093 DCM_Message(DCM_ILLEGALOPTION), "Byte order",
01094 "DCM_ReadStream");
01095
01096 cond = readFile1("", NULL, fd, size, &fileOffset, 0, opt, NULL,
01097 callerObject, NULL, &remainFileOpen, ctx, rd, sk);
01098 if (cond != DCM_NORMAL)
01099 return COND_PushCondition(DCM_READSTREAMFAILED,
01100 DCM_Message(DCM_READSTREAMFAILED), "DCM_ReadStream");
01101 else
01102 return DCM_NORMAL;
01103 }
|
|
||||||||||||
|
Definition at line 1512 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, checkObject(), COND_PushCondition(), CONDITION, CTN_FREE, CTNBOOLEAN, DCM_ELEMENT::d, DCM_ELEMENTNOTFOUND, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_OW, DCM_SQ, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNSPECIFIEDLENGTH, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, PRV_GROUP_ITEM::longVRAttributes, LST_Head(), LST_K_AFTER, LST_Next(), LST_Position(), LST_Remove(), object, PRV_ELEMENT_ITEM::paddedDataLength, DCM_ELEMENT::representation, and DCM_ELEMENT::tag. Referenced by DCM_ModifyElements().
01513 {
01514 PRIVATE_OBJECT
01515 ** object;
01516 PRV_GROUP_ITEM
01517 * groupItem;
01518 PRV_ELEMENT_ITEM
01519 * elementItem,
01520 *groupLengthItem;
01521 CONDITION
01522 cond;
01523 CTNBOOLEAN
01524 flag;
01525 unsigned short
01526 group,
01527 element;
01528
01529 object = (PRIVATE_OBJECT **) callerObject;
01530 cond = checkObject(object, "DCM_RemoveElement");
01531 if (cond != DCM_NORMAL)
01532 return cond;
01533
01534 group = DCM_TAG_GROUP(tag);
01535 element = DCM_TAG_ELEMENT(tag);
01536
01537 groupItem = (void *)LST_Head(&((*object)->groupList));
01538 if (groupItem == NULL)
01539 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01540 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
01541 "DCM_RemoveElement");
01542
01543 (void) LST_Position(&((*object)->groupList), (void *)groupItem);
01544
01545 flag = FALSE;
01546 while ((groupItem != NULL) && (flag == FALSE)) {
01547 if (groupItem->group == group)
01548 flag = TRUE;
01549 else
01550 groupItem = (void *)LST_Next(&(*object)->groupList);
01551 }
01552 if (flag == FALSE)
01553 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01554 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
01555 "DCM_RemoveElement");
01556
01557 elementItem = (void *)LST_Head(&groupItem->elementList);
01558 if (elementItem == NULL)
01559 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01560 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
01561 "DCM_RemoveElement");
01562
01563 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
01564
01565 groupLengthItem = elementItem;
01566 if (DCM_TAG_ELEMENT(groupLengthItem->element.tag) != 0x0000)
01567 groupLengthItem = NULL;
01568
01569
01570 flag = FALSE;
01571 while ((elementItem != NULL) && (flag == FALSE)) {
01572 if (DCM_TAG_ELEMENT(elementItem->element.tag) == element)
01573 flag = TRUE;
01574 else
01575 elementItem = (void *)LST_Next(&groupItem->elementList);
01576 }
01577
01578 if (flag == FALSE)
01579 return COND_PushCondition(DCM_ELEMENTNOTFOUND,
01580 DCM_Message(DCM_ELEMENTNOTFOUND), group, element,
01581 "DCM_RemoveElement");
01582
01583 if (groupItem->baseLength != DCM_UNSPECIFIEDLENGTH) {
01584 groupItem->baseLength -= elementItem->paddedDataLength + 2 + 2 + 4;
01585 if (groupLengthItem != NULL) {
01586 *groupLengthItem->element.d.ul = groupItem->baseLength;
01587 }
01588 }
01589 if ((*object)->objectSize != DCM_UNSPECIFIEDLENGTH)
01590 (*object)->objectSize -= elementItem->paddedDataLength + 2 + 2 + 4;
01591 if (elementItem->element.representation == DCM_OW ||
01592 elementItem->element.representation == DCM_OB ||
01593 elementItem->element.representation == DCM_SQ) {
01594 groupItem->longVRAttributes--;
01595 (*object)->longVRAttributes--;
01596 }
01597 (void) LST_Remove(&(groupItem->elementList), LST_K_AFTER);
01598 CTN_FREE(elementItem);
01599 return DCM_NORMAL;
01600 }
|
|
||||||||||||
|
Definition at line 3003 of file l_mri_dicom_hdr.c. References checkObject(), COND_PushCondition(), CONDITION, CTN_FREE, CTNBOOLEAN, DCM_GROUPNOTFOUND, DCM_LISTFAILURE, DCM_Message(), DCM_NORMAL, DCM_OBJECT, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, LST_Destroy(), LST_Head(), LST_K_AFTER, LST_Next(), LST_NORMAL, LST_Pop(), LST_Position(), LST_Remove(), and object.
03004 {
03005 PRIVATE_OBJECT
03006 ** object;
03007 CONDITION
03008 cond;
03009 PRV_GROUP_ITEM
03010 * groupItem;
03011 PRV_ELEMENT_ITEM
03012 * elementItem;
03013 CTNBOOLEAN
03014 found = FALSE;
03015
03016 object = (PRIVATE_OBJECT **) callerObject;
03017 cond = checkObject(object, "DCM_RemoveGroup");
03018 if (cond != DCM_NORMAL)
03019 return cond;
03020
03021 groupItem = (void *)LST_Head(&(*object)->groupList);
03022 if (groupItem == NULL)
03023 return COND_PushCondition(DCM_GROUPNOTFOUND,
03024 DCM_Message(DCM_GROUPNOTFOUND), (int) group, "DCM_RemoveGroup");
03025
03026 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
03027
03028 while (!found && (groupItem != NULL)) {
03029 if (groupItem->group == group)
03030 found = TRUE;
03031 else
03032 groupItem = (void *)LST_Next(&(*object)->groupList);
03033 }
03034 if (groupItem == NULL)
03035 return COND_PushCondition(DCM_GROUPNOTFOUND,
03036 DCM_Message(DCM_GROUPNOTFOUND), (int) group, "DCM_RemoveGroup");
03037
03038
03039 while ((elementItem = (void *)LST_Pop(&groupItem->elementList)) != NULL)
03040 CTN_FREE(elementItem);
03041
03042 groupItem = (void *)LST_Remove(&(*object)->groupList, LST_K_AFTER);
03043 cond = LST_Destroy(&groupItem->elementList);
03044 if (cond != LST_NORMAL)
03045 return COND_PushCondition(DCM_LISTFAILURE,
03046 DCM_Message(DCM_LISTFAILURE), "DCM_RemoveGroup");
03047 CTN_FREE(groupItem);
03048 return DCM_NORMAL;
03049 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 2105 of file l_mri_dicom_hdr.c. References checkObject(), CONDITION, copyData(), CTNBOOLEAN, DCM_IsString(), DCM_NORMAL, DCM_OBJECT, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, i, l, LST_Head(), LST_Next(), LST_Position(), object, p, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32.
02109 {
02110 PRIVATE_OBJECT
02111 ** object;
02112 PRV_GROUP_ITEM
02113 * groupItem;
02114 PRV_ELEMENT_ITEM
02115 * elementItem;
02116 CONDITION
02117 cond;
02118 CTNBOOLEAN
02119 done = FALSE;
02120 DCM_ELEMENT
02121 e;
02122 int
02123 i;
02124 CTNBOOLEAN
02125 found;
02126 U32
02127 l;
02128 char
02129 *p;
02130
02131 object = (PRIVATE_OBJECT **) callerObject;
02132 cond = checkObject(object, "DCM_ScanParseObject");
02133 if (cond != DCM_NORMAL)
02134 return cond;
02135
02136 groupItem = (void *)LST_Head(&((*object)->groupList));
02137 (void) LST_Position(&((*object)->groupList), (void *)groupItem);
02138 while (groupItem != NULL && !done) {
02139 elementItem = (void *)LST_Head(&groupItem->elementList);
02140 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
02141 while (elementItem != NULL && !done) {
02142 for (found = FALSE, i = 0; !found && i < vectorLength; i++) {
02143 if (elementItem->element.tag == elementVector[i].e.tag) {
02144 found = TRUE;
02145 (void)copyData(object,elementItem,&elementVector[i].e, &l);
02146 *elementVector[i].flagAddress |= elementVector[i].flag;
02147
02148 if (DCM_IsString(elementVector[i].e.representation)) {
02149 elementVector[i].e.d.string[l] = '\0';
02150 p = elementVector[i].e.d.string + l - 1;
02151 while (p >= elementVector[i].e.d.string && (*p == ' '))
02152 *p-- = '\0';
02153 }
02154 }
02155 }
02156 if (!found) {
02157 e = elementItem->element;
02158 cond = callback(&e, ctx);
02159 if (cond != DCM_NORMAL)
02160 done = TRUE;
02161 }
02162 elementItem = (void *)LST_Next(&groupItem->elementList);
02163 }
02164 groupItem = (void *)LST_Next(&((*object)->groupList));
02165 }
02166 return DCM_NORMAL;
02167 }
|
|
||||||||||||||||
|
Definition at line 2748 of file l_mri_dicom_hdr.c. References checkObject(), close(), COND_PushCondition(), CONDITION, DCM_ExportStream(), DCM_FILECREATEFAILED, DCM_Message(), DCM_NORMAL, DCM_OBJECT, fd, file, O_BINARY, O_WRONLY, object, strerror(), and writeFile().
02749 {
02750 PRIVATE_OBJECT
02751 ** object;
02752 int
02753 fd;
02754 unsigned char
02755 buf[2048];
02756 CONDITION
02757 cond;
02758
02759 object = (PRIVATE_OBJECT **) callerObject;
02760 cond = checkObject(object, "DCM_WriteFile");
02761 if (cond != DCM_NORMAL)
02762 return cond;
02763 #ifdef MACOS
02764 fd = open(file, O_WRONLY | O_CREAT | O_TRUNC);
02765 #elif _MSC_VER
02766 fd = _open(file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
02767 _S_IREAD | _S_IWRITE);
02768 #else
02769 fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666);
02770 #endif
02771 if (fd < 0) {
02772 return COND_PushCondition(DCM_FILECREATEFAILED,
02773 DCM_Message(DCM_FILECREATEFAILED), file, strerror(errno),
02774 "DCM_WriteFile");
02775 }
02776 cond = DCM_ExportStream(callerObject, opt, buf,
02777 (unsigned long) sizeof(buf), writeFile, &fd);
02778 if (cond != DCM_NORMAL)
02779 return cond;
02780
02781 (void) close(fd);
02782 return DCM_NORMAL;
02783 }
|
|
||||||||||||||||||||
|
Definition at line 7567 of file l_mri_dicom_hdr.c. References DCM_OB, DCM_SL, DCM_SS, DCM_UL, DCM_UN, DCM_US, DCM_VALUEREPRESENTATION, dumpOB(), dumpSL(), dumpSS(), dumpUL(), dumpUS(), U32, and vm. Referenced by DCM_DumpElements(), and DCM_FormatElements().
07569 {
07570 vm = (vm < vmLimit) ? vm : vmLimit;
07571
07572 if (vm <= 1)
07573 return;
07574
07575 switch (vr) {
07576 case DCM_SL:
07577 dumpSL((S32 *) d, vm);
07578 break;
07579 case DCM_UL:
07580 dumpUL((U32 *) d, vm);
07581 break;
07582 case DCM_SS:
07583 dumpSS((short *) d, vm);
07584 break;
07585 case DCM_US:
07586 dumpUS((unsigned short *) d, vm);
07587 break;
07588 case DCM_OB:
07589 case DCM_UN:
07590 dumpOB((unsigned char*) d, vm);
07591 break;
07592 default:
07593 break;
07594 }
07595 }
|
|
||||||||||||
|
Definition at line 7554 of file l_mri_dicom_hdr.c. References c, RWC_printf(), and vm. Referenced by dumpBinaryData().
07555 {
07556 long index = 0;
07557 RWC_printf("hex OB:") ;
07558 while (index < vm) {
07559 RWC_printf("%02x ", *(c++));
07560 if ((++index) % 8 == 0)
07561 RWC_printf("\n");
07562 }
07563 if( index%8 != 0 ) RWC_printf("\n");
07564 }
|
|
||||||||||||
|
Definition at line 7517 of file l_mri_dicom_hdr.c. References RWC_printf(), and vm. Referenced by dumpBinaryData().
07518 {
07519 long index = 0;
07520 RWC_printf("decimal SL:") ;
07521 while (index < vm) {
07522 RWC_printf("%7d ", *(sl++));
07523 if ((++index) % 8 == 0)
07524 RWC_printf("\n");
07525 }
07526 RWC_printf("\n");
07527 }
|
|
||||||||||||
|
Definition at line 7504 of file l_mri_dicom_hdr.c. References RWC_printf(), and vm. Referenced by dumpBinaryData().
07505 {
07506 long index = 0;
07507 RWC_printf("decimal SS:") ;
07508 while (index < vm) {
07509 RWC_printf("%7d ", *(ss++));
07510 if ((++index) % 8 == 0)
07511 RWC_printf("\n");
07512 }
07513 RWC_printf("\n");
07514 }
|
|
|
Definition at line 645 of file l_mri_dicom_hdr.c. References stackPtr. Referenced by COND_DumpConditions(), COND_PushCondition(), and COND_WriteConditions().
|
|
||||||||||||
|
Definition at line 7542 of file l_mri_dicom_hdr.c. References RWC_printf(), U32, and vm. Referenced by dumpBinaryData().
07543 {
07544 long index = 0;
07545 RWC_printf("decimal UL:") ;
07546 while (index < vm) {
07547 RWC_printf("%7d ", *(ul++));
07548 if ((++index) % 8 == 0)
07549 RWC_printf("\n");
07550 }
07551 RWC_printf("\n");
07552 }
|
|
||||||||||||
|
Definition at line 7530 of file l_mri_dicom_hdr.c. References RWC_printf(), and vm. Referenced by dumpBinaryData().
07531 {
07532 long index = 0;
07533 RWC_printf("decimal US:") ;
07534 while (index < vm) {
07535 RWC_printf("%7d ", *(us++));
07536 if ((++index) % 8 == 0)
07537 RWC_printf("\n");
07538 }
07539 RWC_printf("\n");
07540 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 4441 of file l_mri_dicom_hdr.c. References PRV_ELEMENT_ITEM::byteOrder, BYTEORDER_SAME, COND_PushCondition(), CONDITION, PRV_ELEMENT_ITEM::currentOffset, DCM_ELEMENT::d, DCM_AE, DCM_AS, DCM_AT, DCM_CS, DCM_DA, DCM_DD, DCM_DS, DCM_DT, DCM_FD, DCM_FILEACCESSERROR, DCM_FL, DCM_GENERALWARNING, DCM_IS, DCM_LO, DCM_LT, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OT, DCM_OW, DCM_PN, DCM_PXLPIXELDATA, DCM_SH, DCM_SL, DCM_SQ, DCM_SS, DCM_ST, DCM_TAG, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_TM, DCM_UI, DCM_UL, DCM_UN, DCM_US, DCM_UT, PRV_ELEMENT_ITEM::element, groupElement, DCM_ELEMENT::length, object, p, read(), DCM_ELEMENT::representation, swab, swapATGroupElement(), swapInPlace(), DCM_ELEMENT::tag, and U32. Referenced by exportPixels(), and exportStream().
04445 {
04446 /* repair OT for pixel data*/
04447 unsigned char
04448 *p;
04449 DCM_TAG
04450 * tag;
04451 DCM_ELEMENT
04452 * element;
04453 int nBytes;
04454 CONDITION cond;
04455
04456 element = &item->element;
04457
04458 *rtnLength = 0;
04459 if (element->d.ot == NULL) {
04460 if ((*object)->fd != -1) {
04461 (void) lseek((*object)->fd, item->currentOffset, SEEK_SET);
04462 nBytes = read((*object)->fd, b, (int) length);
04463 } else {
04464 (*object)->sk((*object)->userCtx, item->currentOffset, SEEK_SET);
04465 cond = (*object)->rd((*object)->userCtx, b, (long) length, &nBytes);
04466 }
04467 if ((U32) nBytes != length) {
04468 char b[512];
04469 sprintf(b, "byte count: %d %d, errno: %d", nBytes, length, errno);
04470 (void) COND_PushCondition(DCM_GENERALWARNING,
04471 DCM_Message(DCM_GENERALWARNING), "exportData", b);
04472 return COND_PushCondition(DCM_FILEACCESSERROR,
04473 DCM_Message(DCM_FILEACCESSERROR), (*object)->fileName,
04474 "exportData");
04475 }
04476 if( LITTLE_ENDIAN_ARCHITECTURE ){
04477 if (item->element.representation == DCM_AT) {
04478 DCM_ELEMENT e;
04479 e = *element;
04480 e.length = length;
04481 e.d.ot = b;
04482 swapATGroupElement(&e);
04483 }
04484 }
04485 if (byteOrder != item->byteOrder) {
04486 DCM_ELEMENT e;
04487 e = *element;
04488 e.length = length;
04489 e.d.ot = b;
04490 swapInPlace(object, &e);
04491 }
04492 *rtnLength = (U32) nBytes;
04493 item->currentOffset += nBytes;
04494 } else {
04495 p = src;
04496 switch (element->representation) {
04497 case DCM_AE:
04498 case DCM_AS:
04499 case DCM_CS:
04500 case DCM_DA:
04501 case DCM_DT:
04502 case DCM_DD:
04503 case DCM_DS:
04504 case DCM_FD:
04505 case DCM_IS:
04506 case DCM_LO:
04507 case DCM_LT:
04508 case DCM_OB:
04509 case DCM_OT:
04510 case DCM_PN:
04511 case DCM_SH:
04512 case DCM_SQ:
04513 case DCM_ST:
04514 case DCM_TM:
04515 case DCM_UI:
04516 case DCM_UT:
04517 (void) memcpy(b, p, length);
04518 *rtnLength = length;
04519 break;
04520 case DCM_AT:
04521 tag = (DCM_TAG *) p;
04522 while (length >= 4) {
04523 groupElement.sh[0] = DCM_TAG_GROUP(*tag);
04524 groupElement.sh[1] = DCM_TAG_ELEMENT(*tag);
04525 if (byteOrder == BYTEORDER_SAME) {
04526 *b++ = groupElement.ch[0]; /* Copy the group */
04527 *b++ = groupElement.ch[1];
04528 *b++ = groupElement.ch[2]; /* Now, the element */
04529 *b++ = groupElement.ch[3];
04530 } else {
04531 *b++ = groupElement.ch[1]; /* Copy the group */
04532 *b++ = groupElement.ch[0];
04533 *b++ = groupElement.ch[3]; /* Now, the element */
04534 *b++ = groupElement.ch[2];
04535 }
04536 tag++;
04537 length -= 4;
04538 *rtnLength += 4;
04539 }
04540 break;
04541 case DCM_SL:
04542 case DCM_UL:
04543 case DCM_FL:
04544 while (length >= 4) {
04545 if (byteOrder == BYTEORDER_SAME) {
04546 *b++ = *p++;
04547 *b++ = *p++;
04548 *b++ = *p++;
04549 *b++ = *p++;
04550 } else {
04551 *b++ = p[3];
04552 *b++ = p[2];
04553 *b++ = p[1];
04554 *b++ = p[0];
04555 p += 4;
04556 }
04557 length -= 4;
04558 *rtnLength += 4;
04559 }
04560 break;
04561 case DCM_SS:
04562 case DCM_US:
04563 case DCM_OW:
04564 /*
04565 * Temorary hack by Nilesh to support memory mapping for testing
04566 * purposes.
04567 */
04568 length &= ~1;
04569 *rtnLength += length;
04570 if (element->tag == DCM_PXLPIXELDATA) {
04571 if (byteOrder == item->byteOrder)
04572 (void) memcpy(b, p, length);
04573 else
04574 #ifdef SOLARIS
04575 swab((char *) p, (char *) b, length);
04576 #elif defined AIXV3
04577 swab((short *) p, (short *) b, length);
04578 #elif defined MACOS
04579 /* Not Yet Defined */
04580 #else
04581 swab(p, b, length);
04582 #endif
04583 } else {
04584 if (byteOrder == BYTEORDER_SAME)
04585 (void) memcpy(b, p, length);
04586 else
04587 #ifdef SOLARIS
04588 swab((char *) p, (char *) b, length);
04589 #elif defined AIXV3
04590 swab((short *) p, (short *) b, length);
04591 #elif defined MACOS
04592 /* Not Yet Defined */
04593 #else
04594 swab(p, b, length);
04595 #endif
04596 }
04597 break;
04598 /*case DCM_UNKNOWN:*/
04599 case DCM_UN:
04600 default:
04601 #if 0
04602 fprintf(stderr, "Should not get to default in exportData: %08x\n",
04603 element->tag);
04604 #endif
04605 (void) memcpy(b, p, length);
04606 *rtnLength = length;
04607 break;
04608 }
04609 }
04610 return DCM_NORMAL;
04611 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 4614 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CONDITION, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_CALLBACKABORTED, DCM_DLM, DCM_EXPORT_STREAM_CALLBACK, DCM_FILEACCESSERROR, DCM_GENERALWARNING, DCM_Message(), DCM_NOFRAGMENTSINOBJECT, DCM_NORMAL, DCM_OB, DCM_PXLPIXELDATA, PRV_ELEMENT_ITEM::element, exportFixedFields(), DCM_FRAGMENT_ITEM::fragment, PRV_ELEMENT_ITEM::fragmentFlag, DCM_FRAGMENT_ITEM::length, DCM_ELEMENT::length, LITTLE_ORDER, LST_Head(), LST_Next(), LST_Position(), object, PRV_ELEMENT_ITEM::originalDataLength, read(), DCM_ELEMENT::representation, RWC_printf(), DCM_ELEMENT::tag, and U32. Referenced by exportPixels().
04617 {
04618 DCM_ELEMENT * element;
04619 int nBytes;
04620 CONDITION cond;
04621 U32 toExport;
04622 int length;
04623 DCM_FRAGMENT_ITEM* fragmentItem = 0;
04624 DCM_ELEMENT e;
04625 U32 rtnLength = 0;
04626
04627 element = &item->element;
04628 if (element->d.ot == NULL) {
04629 if ((*object)->fd != -1) {
04630 /* Seek to the beginning of the data. Have to back up 12 bytes to
04631 ** get the pixel tag, VR, etc
04632 */
04633 (void) lseek((*object)->fd, item->dataOffset-12, SEEK_SET);
04634 } else {
04635 (*object)->sk((*object)->userCtx, item->dataOffset-12, SEEK_SET);
04636 }
04637
04638 toExport = item->originalDataLength + 12;
04639 while(toExport > 0) {
04640 length = (toExport < bufferlength) ? toExport : bufferlength;
04641
04642 if ((*object)->fd != -1) {
04643 nBytes = read((*object)->fd, buffer, length);
04644 } else {
04645 cond = (*object)->rd((*object)->userCtx, buffer, (long) length, &nBytes);
04646 }
04647 if ((U32) nBytes != length) {
04648 char b[512];
04649 sprintf(b, "byte count: %d %d, errno: %d", nBytes, length, errno);
04650 (void) COND_PushCondition(DCM_GENERALWARNING,
04651 DCM_Message(DCM_GENERALWARNING), "exportEncapsualtedPixels", b);
04652 return COND_PushCondition(DCM_FILEACCESSERROR,
04653 DCM_Message(DCM_FILEACCESSERROR), (*object)->fileName,
04654 "exportEncapsualtedPixels");
04655 }
04656 cond = callback(buffer, length, 0, ctx);
04657 if (cond != DCM_NORMAL) {
04658 return COND_PushCondition(DCM_CALLBACKABORTED,
04659 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
04660 }
04661 toExport -= length;
04662 }
04663 } else {
04664 if (item->fragmentFlag != 1) {
04665 return COND_PushCondition(DCM_NOFRAGMENTSINOBJECT,
04666 "DCM Exporting pixels but did not find expected fragments in object");
04667 }
04668 e.tag = DCM_PXLPIXELDATA;
04669 e.d.ot = 0;
04670 e.representation = DCM_OB;
04671 e.length = 0xffffffff;
04672 exportFixedFields(&e, buffer, bufferlength,
04673 LITTLE_ORDER /*byteOrder*/,
04674 1 /* explicitV*/,
04675 &rtnLength);
04676 toExport = rtnLength;
04677 e.tag = 0xfffee000;
04678 e.length = 0;
04679 e.representation = DCM_DLM;
04680 e.d.ot = 0;
04681 exportFixedFields(&e, buffer+toExport, bufferlength,
04682 LITTLE_ORDER /*byteOrder*/,
04683 1 /* explicitV*/,
04684 &rtnLength);
04685 toExport += rtnLength;
04686
04687 cond = callback(buffer, toExport, 0, ctx);
04688 if (cond != DCM_NORMAL) {
04689 return COND_PushCondition(DCM_CALLBACKABORTED,
04690 DCM_Message(DCM_CALLBACKABORTED), "exportEncapsulatedPixels");
04691 }
04692
04693 fragmentItem = (DCM_FRAGMENT_ITEM*)LST_Head(&item->element.d.fragments);
04694 (void)LST_Position(&item->element.d.fragments, (void *)fragmentItem);
04695 while (fragmentItem != NULL) {
04696 RWC_printf("Fragment size: %6d\n", fragmentItem->length);
04697 e.tag = 0xfffee000;
04698 e.length = fragmentItem->length;
04699 e.representation = DCM_DLM;
04700 exportFixedFields(&e, buffer, bufferlength,
04701 LITTLE_ORDER /*byteOrder*/,
04702 1 /* explicitV*/,
04703 &rtnLength);
04704 cond = callback(buffer, rtnLength, 0, ctx);
04705 if (cond != DCM_NORMAL) {
04706 return COND_PushCondition(DCM_CALLBACKABORTED,
04707 DCM_Message(DCM_CALLBACKABORTED), "exportEncapsulatedPixels");
04708 }
04709 cond = callback(fragmentItem->fragment, fragmentItem->length, 0, ctx);
04710 if (cond != DCM_NORMAL) {
04711 return COND_PushCondition(DCM_CALLBACKABORTED,
04712 DCM_Message(DCM_CALLBACKABORTED), "exportEncapsulatedPixels");
04713 }
04714
04715 fragmentItem = (void *)LST_Next(&item->element.d.fragments);
04716 }
04717 e.tag = 0xfffee0dd;
04718 e.length = 0;
04719 e.representation = DCM_DLM;
04720 e.d.ot = 0;
04721 exportFixedFields(&e, buffer, bufferlength,
04722 LITTLE_ORDER /*byteOrder*/,
04723 1 /* explicitV*/,
04724 &rtnLength);
04725 cond = callback(buffer, rtnLength, 0, ctx);
04726 if (cond != DCM_NORMAL) {
04727 return COND_PushCondition(DCM_CALLBACKABORTED,
04728 DCM_Message(DCM_CALLBACKABORTED), "exportEncapsulatedPixels");
04729 }
04730 }
04731 return DCM_NORMAL;
04732 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 4307 of file l_mri_dicom_hdr.c. References BYTEORDER_SAME, CTNBOOLEAN, DCM_DLM, DCM_TAG_ELEMENT, DCM_TAG_GROUP, exportVRLength(), DCM_ELEMENT::length, p, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32. Referenced by exportEncapsulatedPixels(), exportPixels(), and exportStream().
04310 {
04311 unsigned char
04312 *p;
04313 unsigned short
04314 group,
04315 element;
04316 U32
04317 minimumLength;
04318
04319 group = DCM_TAG_GROUP(e->tag);
04320 element = DCM_TAG_ELEMENT(e->tag);
04321 if (e->representation == DCM_DLM)
04322 explicitVR = FALSE;
04323
04324 minimumLength = sizeof(group) + sizeof(element) + sizeof(e->length);
04325 if (explicitVR)
04326 minimumLength += 4;
04327
04328 *rtnLength = 0;
04329 if (length >= minimumLength) {
04330 if (byteOrder == BYTEORDER_SAME) {
04331 p = (unsigned char *) &group;
04332 *b++ = *p++;
04333 *b++ = *p++;
04334 p = (unsigned char *) &element;
04335 *b++ = *p++;
04336 *b++ = *p++;
04337 *rtnLength += 4;
04338 if (explicitVR) {
04339 exportVRLength(e, b, byteOrder, rtnLength);
04340 } else {
04341 p = (unsigned char *) &e->length;
04342 *b++ = *p++;
04343 *b++ = *p++;
04344 *b++ = *p++;
04345 *b++ = *p++;
04346 *rtnLength += 4;
04347 }
04348 } else {
04349 p = (unsigned char *) &group;
04350 *b++ = p[1];
04351 *b++ = p[0];
04352 p = (unsigned char *) &element;
04353 *b++ = p[1];
04354 *b++ = p[0];
04355 *rtnLength += 4;
04356 if (explicitVR) {
04357 exportVRLength(e, b, byteOrder, rtnLength);
04358 } else {
04359 p = (unsigned char *) &e->length;
04360 *b++ = p[3];
04361 *b++ = p[2];
04362 *b++ = p[1];
04363 *b++ = p[0];
04364 *rtnLength += 4;
04365 }
04366 }
04367 }
04368 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Definition at line 4735 of file l_mri_dicom_hdr.c. References c, COND_PushCondition(), CONDITION, PRV_ELEMENT_ITEM::currentOffset, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_CALLBACKABORTED, DCM_EXPORT_STREAM_CALLBACK, DCM_FILEACCESSERROR, DCM_GENERALWARNING, DCM_Message(), DCM_NORMAL, PRV_ELEMENT_ITEM::element, exportData(), exportEncapsulatedPixels(), exportFixedFields(), DCM_ELEMENT::length, object, PRV_ELEMENT_ITEM::originalDataLength, read(), DCM_ELEMENT::tag, and U32. Referenced by exportStream().
04740 {
04741 DCM_ELEMENT * element;
04742 int nBytes;
04743 CONDITION cond;
04744 U32 toExport;
04745 U32 bytesExported = 0;
04746 U32 exportLength = 0;
04747 int length;
04748 U32 rtnLength;
04749 U32 remainingData;
04750 unsigned char* dst;
04751 unsigned char* src;
04752 int c;
04753
04754 if (encapsulatedPixels) {
04755 return exportEncapsulatedPixels(object, item, buffer,
04756 bufferlength, callback, ctx);
04757 }
04758
04759 element = &item->element;
04760 rtnLength = 0;
04761 dst = buffer;
04762 c = bufferlength;
04763 exportFixedFields(element, dst, bufferlength, byteOrder,
04764 explicitVR, &rtnLength);
04765 dst += rtnLength;
04766 c -= rtnLength;
04767 bytesExported = rtnLength;
04768
04769 remainingData = element->length;
04770 src = element->d.ot;
04771 item->currentOffset = item->dataOffset;
04772
04773 while (remainingData > 0) {
04774 if (debug) {
04775 fprintf(stderr, "Export: (%08x) %d\n", element->tag, element->length);
04776 }
04777
04778 if (element->d.ot != NULL) {
04779 remainingData = element->length -
04780 (src - ((unsigned char *) element->d.ot));
04781 } else {
04782 remainingData = element->length -
04783 (item->currentOffset - item->dataOffset);
04784 }
04785
04786 exportLength = (remainingData < c) ? remainingData : c;
04787 cond = exportData(object, item, src, dst,
04788 exportLength, byteOrder, &rtnLength);
04789 if (cond != DCM_NORMAL)
04790 return cond;
04791
04792 src += rtnLength;
04793 dst += rtnLength;
04794 bytesExported += rtnLength;
04795 c -= rtnLength;
04796
04797 if (c <= 20) {
04798 cond = callback(buffer, bytesExported, 0, ctx);
04799 if (cond != DCM_NORMAL) {
04800 return COND_PushCondition(DCM_CALLBACKABORTED,
04801 DCM_Message(DCM_CALLBACKABORTED), "exportPixels");
04802 }
04803 bytesExported = 0;
04804 c = bufferlength;
04805 dst = (unsigned char *) buffer;
04806 }
04807 }
04808 if (bytesExported > 0) {
04809 cond = callback(buffer, bytesExported, 0, ctx);
04810 if (cond != DCM_NORMAL) {
04811 return COND_PushCondition(DCM_CALLBACKABORTED,
04812 DCM_Message(DCM_CALLBACKABORTED), "exportPixels");
04813 }
04814 }
04815
04816 return DCM_NORMAL;
04817
04818 #if 0
04819 if (element->d.ot == NULL) {
04820 if ((*object)->fd != -1) {
04821 /* Seek to the beginning of the data. Have to back up 12 bytes to
04822 ** get the pixel tag, VR, etc
04823 */
04824 (void) lseek((*object)->fd, item->dataOffset-12, SEEK_SET);
04825 } else {
04826 (*object)->sk((*object)->userCtx, item->dataOffset-12, SEEK_SET);
04827 }
04828
04829 toExport = item->originalDataLength + 12;
04830 while(toExport > 0) {
04831 length = (toExport < bufferlength) ? toExport : bufferlength;
04832
04833 if ((*object)->fd != -1) {
04834 nBytes = read((*object)->fd, buffer, length);
04835 } else {
04836 cond = (*object)->rd((*object)->userCtx, buffer, (long) length, &nBytes);
04837 }
04838 if ((U32) nBytes != length) {
04839 char b[512];
04840 sprintf(b, "byte count: %d %d, errno: %d", nBytes, length, errno);
04841 (void) COND_PushCondition(DCM_GENERALWARNING,
04842 DCM_Message(DCM_GENERALWARNING), "exportPixels", b);
04843 return COND_PushCondition(DCM_FILEACCESSERROR,
04844 DCM_Message(DCM_FILEACCESSERROR), (*object)->fileName,
04845 "exportPixels");
04846 }
04847 cond = callback(buffer, length, 0, ctx);
04848 if (cond != DCM_NORMAL) {
04849 return COND_PushCondition(DCM_CALLBACKABORTED,
04850 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
04851 }
04852 toExport -= length;
04853 }
04854 } else {
04855 }
04856 return DCM_NORMAL;
04857 #endif
04858
04859 }
|
|
||||||||||||||||||||
|
Definition at line 4253 of file l_mri_dicom_hdr.c. References COND_PushCondition(), DCM_EXPORTBUFFERTOOSMALL, DCM_Message(), DCM_NORMAL, DCM_PREAMBLELENGTH, and U32. Referenced by exportStream().
04255 {
04256 *rtnLength = 0;
04257 if (bufferLength < (DCM_PREAMBLELENGTH + 4))
04258 return COND_PushCondition(DCM_EXPORTBUFFERTOOSMALL,
04259 DCM_Message(DCM_EXPORTBUFFERTOOSMALL), (int) bufferLength,
04260 "exportPreamble");
04261
04262 (void) memcpy(dst, (*obj)->preamble, DCM_PREAMBLELENGTH);
04263 dst += DCM_PREAMBLELENGTH;
04264 (void) memcpy(dst, "DICM", 4);
04265 *rtnLength += DCM_PREAMBLELENGTH + 4;
04266
04267 return DCM_NORMAL;
04268 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 5183 of file l_mri_dicom_hdr.c. References BIG_ORDER, c, checkObject(), computeGroupLength(), COND_PushCondition(), CONDITION, CTNBOOLEAN, PRV_ELEMENT_ITEM::currentOffset, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_CALLBACKABORTED, DCM_DLM, DCM_DLMITEM, DCM_DLMITEMDELIMITATIONITEM, DCM_DLMSEQUENCEDELIMITATIONITEM, DCM_ENCAPSULATEDPIXELS, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_EXPORT_STREAM_CALLBACK, DCM_FILEFORMATMASK, DCM_GROUPFILEMETA, DCM_ILLEGALOPTION, DCM_LISTFAILURE, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_ORDERBIGENDIAN, DCM_ORDERLITTLEENDIAN, DCM_ORDERMASK, DCM_ORDERNATIVE, DCM_PART10FILE, DCM_PXLPIXELDATA, DCM_SEQUENCELENGTHMASK, DCM_SQ, DCM_TAG_ELEMENT, DCM_UNSPECIFIEDLENGTH, DCM_UNSPECIFIEDLENGTHFLAG, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, exportData(), exportFixedFields(), exportPixels(), exportPreamble(), extractFileOptions(), PRV_GROUP_ITEM::group, l, DCM_ELEMENT::length, LITTLE_ORDER, LST_Head(), LST_Next(), LST_Position(), NATIVE_ORDER, DCM_SEQUENCE_ITEM::object, object, PRV_ELEMENT_ITEM::paddedDataLength, DCM_ELEMENT::representation, setFileOptions(), DCM_ELEMENT::tag, and U32. Referenced by exportStream().
05186 {
05187 PRIVATE_OBJECT
05188 ** object;
05189 PRV_GROUP_ITEM
05190 * groupItem;
05191 PRV_ELEMENT_ITEM
05192 * elementItem;
05193 DCM_ELEMENT
05194 element;
05195 int
05196 byteOrder;
05197 int
05198 lastFlag = 0;
05199 unsigned char
05200 *src,
05201 *dst;
05202 U32
05203 c,
05204 bytesExported = 0,
05205 rtnLength,
05206 remainingData,
05207 exportLength;
05208 CONDITION
05209 cond;
05210 DCM_SEQUENCE_ITEM
05211 * sequenceItem;
05212 DCM_ELEMENT
05213 itemMarker = {
05214 DCM_DLMITEM, DCM_DLM, "", 1, DCM_UNSPECIFIEDLENGTH, NULL
05215 },
05216 itemDelimiter = {
05217 DCM_DLMITEMDELIMITATIONITEM, DCM_DLM, "", 1, 0, NULL
05218 },
05219 sequenceDelimiter = {
05220 DCM_DLMSEQUENCEDELIMITATIONITEM, DCM_DLM, "", 1, 0, NULL
05221 };
05222 CTNBOOLEAN
05223 unspecifiedSQLength = FALSE,
05224 explicitVR = FALSE,
05225 part10File = FALSE,
05226 encapsulatedPixels = FALSE;
05227 unsigned long fileOptions = 0;
05228
05229 object = (PRIVATE_OBJECT **) callerObject;
05230 cond = checkObject(object, "exportStream");
05231 if (cond != DCM_NORMAL)
05232 return cond;
05233
05234 if ((opt & DCM_FILEFORMATMASK) == DCM_PART10FILE) {
05235 part10File = TRUE;
05236 opt &= ~DCM_ORDERMASK;
05237 opt |= DCM_EXPLICITLITTLEENDIAN;
05238 cond = setFileOptions(callerObject, &fileOptions);
05239 if (cond != DCM_NORMAL)
05240 return cond;
05241 }
05242 if ((opt & DCM_ORDERMASK) == 0)
05243 return COND_PushCondition(DCM_ILLEGALOPTION,
05244 DCM_Message(DCM_ILLEGALOPTION), "Byte order",
05245 "exportStream");
05246
05247 switch (opt & DCM_ORDERMASK) {
05248 case DCM_ORDERNATIVE:
05249 byteOrder = NATIVE_ORDER;
05250 break;
05251 case DCM_ORDERLITTLEENDIAN:
05252 byteOrder = LITTLE_ORDER;
05253 break;
05254 case DCM_EXPLICITLITTLEENDIAN:
05255 byteOrder = LITTLE_ORDER;
05256 explicitVR = TRUE;
05257 break;
05258 case DCM_ORDERBIGENDIAN:
05259 byteOrder = BIG_ORDER;
05260 break;
05261 case DCM_EXPLICITBIGENDIAN:
05262 byteOrder = BIG_ORDER;
05263 explicitVR = TRUE;
05264 break;
05265 case DCM_ENCAPSULATEDPIXELS:
05266 byteOrder = LITTLE_ORDER;
05267 explicitVR = TRUE;
05268 encapsulatedPixels = TRUE;
05269 break;
05270 default:
05271 byteOrder = LITTLE_ORDER;
05272 break;
05273 }
05274
05275 /* We are making this step mandatory for now (smm)*/
05276
05277 opt &= ~DCM_SEQUENCELENGTHMASK;
05278 opt |= DCM_UNSPECIFIEDLENGTHFLAG;
05279
05280 /* End of something that is out of place */
05281
05282 if ((opt & DCM_SEQUENCELENGTHMASK) == DCM_UNSPECIFIEDLENGTHFLAG)
05283 unspecifiedSQLength = TRUE;
05284
05285 dst = (unsigned char *) buffer;
05286 c = bufferlength;
05287
05288 if (part10File) {
05289 cond = exportPreamble(object, dst, c, &rtnLength);
05290 if (cond != DCM_NORMAL)
05291 return cond;
05292
05293 dst += rtnLength;
05294 c -= rtnLength;
05295 bytesExported += rtnLength;
05296 }
05297 if (sequenceLevel != 0) {
05298 if (!unspecifiedSQLength)
05299 itemMarker.length = (*object)->objectSize;
05300 exportFixedFields(&itemMarker, dst, bufferlength, byteOrder,
05301 explicitVR, &rtnLength);
05302 dst += rtnLength;
05303 c -= rtnLength;
05304 bytesExported += rtnLength;
05305 }
05306 groupItem = (void *)LST_Head(&(*object)->groupList);
05307
05308 /* Take this code out to allow empty groups. */
05309 #if 0
05310 if (groupItem == NULL)
05311 return COND_PushCondition(DCM_LISTFAILURE,
05312 DCM_Message(DCM_LISTFAILURE), "exportStream");
05313 #endif
05314 if (groupItem != NULL)
05315 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
05316
05317 while (groupItem != NULL) {
05318 if (part10File && groupItem->group != DCM_GROUPFILEMETA) {
05319 if (opt != fileOptions) {
05320 opt = fileOptions;
05321 cond = extractFileOptions(opt, &part10File,
05322 &explicitVR, &byteOrder,
05323 &encapsulatedPixels);
05324 if (cond != DCM_NORMAL)
05325 return cond;
05326 }
05327 }
05328 elementItem = (void *)LST_Head(&groupItem->elementList);
05329 if (elementItem != NULL)
05330 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
05331 if (DCM_TAG_ELEMENT(elementItem->element.tag) == 0x0000) {
05332 U32 l;
05333 l = computeGroupLength(groupItem, explicitVR);
05334 *elementItem->element.d.ul = l;
05335
05336 /* We have some problems computing group length for groups with sequences.
05337 ** For now, just remove this attribute, except for group 0000 and 0002.
05338 */
05339 if (groupItem->group != 0x0000 && groupItem->group != 0x0002)
05340 elementItem = (void *)LST_Next(&groupItem->elementList);
05341 }
05342 while (elementItem != NULL) {
05343 if (c <= 20) {
05344 cond = callback(buffer, bytesExported, 0, ctx);
05345 if (cond != DCM_NORMAL)
05346 return COND_PushCondition(DCM_CALLBACKABORTED,
05347 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
05348
05349 bytesExported = 0;
05350 c = bufferlength;
05351 dst = (unsigned char *) buffer;
05352 }
05353 element = elementItem->element;
05354
05355 if (element.tag == DCM_PXLPIXELDATA) {
05356 /* Lots of special rules for pixel data. Handle separately */
05357 /* First, dump the current buffer */
05358 cond = callback(buffer, bytesExported, 0, ctx);
05359 if (cond != DCM_NORMAL)
05360 return COND_PushCondition(DCM_CALLBACKABORTED,
05361 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
05362
05363 cond = exportPixels(object, elementItem, encapsulatedPixels,
05364 buffer, bufferlength, callback, ctx, byteOrder, explicitVR);
05365 if (cond != DCM_NORMAL)
05366 return cond;
05367
05368 bytesExported = 0;
05369 c = bufferlength;
05370 dst = (unsigned char *) buffer;
05371 rtnLength = 0;
05372 } else if (element.representation == DCM_SQ) {
05373 if (unspecifiedSQLength)
05374 element.length = DCM_UNSPECIFIEDLENGTH;
05375
05376 exportFixedFields(&element, dst, bufferlength, byteOrder,
05377 explicitVR, &rtnLength);
05378 } else {
05379 element.length = elementItem->paddedDataLength;
05380 exportFixedFields(&element, dst, bufferlength, byteOrder,
05381 explicitVR, &rtnLength);
05382 }
05383 dst += rtnLength;
05384 c -= rtnLength;
05385 bytesExported += rtnLength;
05386
05387 remainingData = element.length;
05388 src = element.d.ot;
05389 elementItem->currentOffset = elementItem->dataOffset;
05390
05391 if (element.tag == DCM_PXLPIXELDATA) {
05392 /* Then, we did that above */
05393 ;
05394 } else if (element.representation == DCM_SQ) {
05395
05396 cond = callback(buffer, bytesExported, 0, ctx);
05397 if (cond != DCM_NORMAL)
05398 return COND_PushCondition(DCM_CALLBACKABORTED,
05399 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
05400
05401 bytesExported = 0;
05402 c = bufferlength;
05403 dst = (unsigned char *) buffer;
05404
05405 if (element.d.sq != NULL) {
05406 sequenceItem = (void *)LST_Head(&element.d.sq);
05407 if (sequenceItem != NULL)
05408 (void) LST_Position(&element.d.sq, (void *)sequenceItem);
05409 while (sequenceItem != NULL) {
05410 cond = exportStream(&sequenceItem->object, opt,
05411 buffer, bufferlength, callback, ctx,
05412 sequenceLevel + 1);
05413 if (cond != DCM_NORMAL)
05414 return cond;
05415 sequenceItem = (void *)LST_Next(&element.d.sq);
05416 }
05417 }
05418 if (element.length == DCM_UNSPECIFIEDLENGTH) {
05419 sequenceDelimiter.length = 0;
05420 exportFixedFields(&sequenceDelimiter, dst, bufferlength,
05421 byteOrder, explicitVR, &rtnLength);
05422 dst += rtnLength;
05423 c -= rtnLength;
05424 bytesExported += rtnLength;
05425 }
05426 } else {
05427 while (remainingData > 0) {
05428 if (debug)
05429 fprintf(stderr, "Export: (%08x) %d\n",
05430 element.tag, element.length);
05431 if (element.d.ot != NULL)
05432 remainingData = element.length -
05433 (src - ((unsigned char *) element.d.ot));
05434 else
05435 remainingData = element.length -
05436 (elementItem->currentOffset - elementItem->dataOffset);
05437
05438 exportLength = (remainingData < c) ? remainingData : c;
05439 cond = exportData(object, elementItem, src, dst,
05440 exportLength, byteOrder, &rtnLength);
05441 if (cond != DCM_NORMAL)
05442 return cond;
05443
05444 src += rtnLength;
05445 dst += rtnLength;
05446 bytesExported += rtnLength;
05447 c -= rtnLength;
05448
05449 if (c <= 20) {
05450 cond = callback(buffer, bytesExported, 0, ctx);
05451 if (cond != DCM_NORMAL)
05452 return COND_PushCondition(DCM_CALLBACKABORTED,
05453 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
05454
05455 bytesExported = 0;
05456 c = bufferlength;
05457 dst = (unsigned char *) buffer;
05458 }
05459 }
05460 }
05461 elementItem = (void *)LST_Next(&groupItem->elementList);
05462 }
05463 groupItem = (void *)LST_Next(&(*object)->groupList);
05464 }
05465 if ((sequenceLevel != 0) && unspecifiedSQLength) {
05466 if (c <= 20) {
05467 cond = callback(buffer, bytesExported, 0, ctx);
05468 if (cond != DCM_NORMAL)
05469 return COND_PushCondition(DCM_CALLBACKABORTED,
05470 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
05471
05472 bytesExported = 0;
05473 c = bufferlength;
05474 dst = (unsigned char *) buffer;
05475 }
05476 exportFixedFields(&itemDelimiter, dst, bufferlength, byteOrder,
05477 explicitVR, &rtnLength);
05478 dst += rtnLength;
05479 c -= rtnLength;
05480 bytesExported += rtnLength;
05481 }
05482 lastFlag = (sequenceLevel == 0) ? 1 : 0;
05483 cond = callback(buffer, bytesExported, lastFlag, ctx);
05484 if (cond != DCM_NORMAL)
05485 return COND_PushCondition(DCM_CALLBACKABORTED,
05486 DCM_Message(DCM_CALLBACKABORTED), "exportStream");
05487
05488 return DCM_NORMAL;
05489 }
|
|
||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
Definition at line 4196 of file l_mri_dicom_hdr.c. References BYTEORDER_SAME, c, DCM_MAKETAG, DCM_OB, DCM_OW, DCM_SQ, DCM_UN, DCM_VALUEREPRESENTATION, DIM_OF, i, DCM_ELEMENT::length, p, DCM_ELEMENT::representation, DCM_ELEMENT::tag, U16, and U32. Referenced by exportFixedFields().
04198 {
04199 int i;
04200 char *c = "xx";
04201 unsigned char *p;
04202 U16 shortLength;
04203 DCM_VALUEREPRESENTATION vr;
04204
04205 vr = e->representation;
04206 if (e->tag == DCM_MAKETAG(0x003a, 0x1000))
04207 vr = DCM_OB;
04208
04209 for (i = 0; i < DIM_OF(vrMap); i++) {
04210 if (vr == vrMap[i].representation) {
04211 c = vrMap[i].code;
04212 break;
04213 }
04214 }
04215
04216 *b++ = *c++;
04217 *b++ = *c++;
04218 *rtnLength += 2;
04219
04220 if (vr == DCM_OB || vr == DCM_OW || vr == DCM_SQ || vr == DCM_UN) {
04221 *b++ = 0x00;
04222 *b++ = 0x00;
04223 if (byteOrder == BYTEORDER_SAME) {
04224 p = (unsigned char *) &e->length;
04225 *b++ = *p++;
04226 *b++ = *p++;
04227 *b++ = *p++;
04228 *b++ = *p++;
04229 } else {
04230 p = (unsigned char *) &e->length;
04231 *b++ = p[3];
04232 *b++ = p[2];
04233 *b++ = p[1];
04234 *b++ = p[0];
04235 }
04236 *rtnLength += 6;
04237 } else {
04238 shortLength = (U16) e->length;
04239 if (byteOrder == BYTEORDER_SAME) {
04240 p = (unsigned char *) &shortLength;
04241 *b++ = *p++;
04242 *b++ = *p++;
04243 } else {
04244 p = (unsigned char *) &shortLength;
04245 *b++ = p[1];
04246 *b++ = p[0];
04247 }
04248 *rtnLength += 2;
04249 }
04250 }
|
|
||||||||||||||||||||||||
|
Definition at line 5087 of file l_mri_dicom_hdr.c. References BIG_ORDER, COND_PushCondition(), CTNBOOLEAN, DCM_ENCAPSULATEDPIXELS, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_FILEFORMATMASK, DCM_ILLEGALOPTION, DCM_Message(), DCM_NORMAL, DCM_ORDERBIGENDIAN, DCM_ORDERLITTLEENDIAN, DCM_ORDERMASK, DCM_ORDERNATIVE, DCM_PART10FILE, LITTLE_ORDER, and NATIVE_ORDER. Referenced by exportStream().
05090 {
05091 *part10File = *explicitVR = FALSE;
05092
05093 if ((opt & DCM_FILEFORMATMASK) == DCM_PART10FILE) {
05094 *part10File = TRUE;
05095 opt &= ~DCM_ORDERMASK;
05096 opt |= DCM_EXPLICITLITTLEENDIAN;
05097 }
05098 if ((opt & DCM_ORDERMASK) == 0)
05099 return COND_PushCondition(DCM_ILLEGALOPTION,
05100 DCM_Message(DCM_ILLEGALOPTION), "Byte order",
05101 "extractFileOptions");
05102
05103 switch (opt & DCM_ORDERMASK) {
05104 case DCM_ORDERNATIVE:
05105 *byteOrder = NATIVE_ORDER;
05106 *encapsulatedPixels = FALSE;
05107 break;
05108 case DCM_ORDERLITTLEENDIAN:
05109 *byteOrder = LITTLE_ORDER;
05110 *encapsulatedPixels = FALSE;
05111 break;
05112 case DCM_EXPLICITLITTLEENDIAN:
05113 *byteOrder = LITTLE_ORDER;
05114 *explicitVR = TRUE;
05115 *encapsulatedPixels = FALSE;
05116 break;
05117 case DCM_ORDERBIGENDIAN:
05118 *byteOrder = BIG_ORDER;
05119 *encapsulatedPixels = FALSE;
05120 break;
05121 case DCM_EXPLICITBIGENDIAN:
05122 *byteOrder = BIG_ORDER;
05123 *explicitVR = TRUE;
05124 *encapsulatedPixels = FALSE;
05125 break;
05126 case DCM_ENCAPSULATEDPIXELS:
05127 *byteOrder = LITTLE_ORDER;
05128 *explicitVR = TRUE;
05129 *encapsulatedPixels = TRUE;
05130 break;
05131 default:
05132 *byteOrder = LITTLE_ORDER;
05133 *encapsulatedPixels = FALSE;
05134 break;
05135 }
05136
05137 return DCM_NORMAL;
05138 }
|
|
|
Definition at line 4885 of file l_mri_dicom_hdr.c. References fd. Referenced by DCM_OpenFile().
04886 {
04887 int
04888 status;
04889 struct stat
04890 im_stat;
04891
04892 status = fstat(fd, &im_stat);
04893 if (status < 0) {
04894 return status;
04895 } else
04896 return im_stat.st_size;
04897 }
|
|
||||||||||||||||
|
Definition at line 3638 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, COND_PushCondition(), CONDITION, CTN_MALLOC, CTNBOOLEAN, DCM_ELEMENT::d, DCM_ELEMENTCREATEFAILED, DCM_LISTFAILURE, DCM_MAKETAG, DCM_Message(), DCM_NORMAL, DCM_UL, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, l, DCM_ELEMENT::length, PRV_GROUP_ITEM::longVRAttributes, LST_Create(), LST_Enqueue(), LST_Head(), LST_Insert(), LST_K_AFTER, LST_K_BEFORE, LST_Next(), LST_NORMAL, LST_Position(), newElementItem(), object, DCM_ELEMENT::tag, and U32. Referenced by DCM_AddElement(), DCM_AddFragment(), DCM_AddSequenceElement(), and insertThisElementItem().
03640 {
03641 PRV_GROUP_ITEM
03642 * item;
03643 CONDITION
03644 cond;
03645 CTNBOOLEAN
03646 tooFar = FALSE;
03647
03648 item = (void *)LST_Head(&(*object)->groupList);
03649 if (item != NULL)
03650 (void) LST_Position(&(*object)->groupList, (void *)item);
03651
03652 while (item != NULL && !tooFar) {
03653 if (item->group == group) {
03654 *groupItem = item;
03655 return DCM_NORMAL;
03656 } else if (item->group > group) {
03657 tooFar = TRUE;
03658 } else {
03659 item = (void *)LST_Next(&(*object)->groupList);
03660 }
03661 }
03662
03663 {
03664 U32 l;
03665 PRV_GROUP_ITEM *newGroupItem;
03666 DCM_ELEMENT groupLength = {0, DCM_UL, "", 1, sizeof(l), NULL};
03667 PRV_ELEMENT_ITEM *groupLengthItem;
03668
03669 newGroupItem = CTN_MALLOC(sizeof(*newGroupItem));
03670 if (newGroupItem == NULL)
03671 return COND_PushCondition(DCM_ELEMENTCREATEFAILED,
03672 DCM_Message(DCM_ELEMENTCREATEFAILED),
03673 "findCreateGroup",
03674 group, 0xffff, sizeof(*newGroupItem));
03675
03676
03677 *groupItem = newGroupItem;
03678 newGroupItem->group = group;
03679 newGroupItem->baseLength = 0;
03680 newGroupItem->longVRAttributes = 0;
03681 newGroupItem->elementList = LST_Create();
03682 if (newGroupItem->elementList == NULL)
03683 return COND_PushCondition(DCM_LISTFAILURE,
03684 DCM_Message(DCM_LISTFAILURE),
03685 "findCreateGroup");
03686
03687 if (tooFar)
03688 cond = LST_Insert(&(*object)->groupList, (void *)newGroupItem, LST_K_BEFORE);
03689 else
03690 cond = LST_Enqueue(&(*object)->groupList, (void *)newGroupItem);
03691 if (cond != LST_NORMAL)
03692 return COND_PushCondition(DCM_LISTFAILURE,
03693 DCM_Message(DCM_LISTFAILURE),
03694 "findCreateGroup");
03695 (void) LST_Position(&(*object)->groupList, (void *)newGroupItem);
03696 if (cond != LST_NORMAL)
03697 return COND_PushCondition(DCM_LISTFAILURE,
03698 DCM_Message(DCM_LISTFAILURE),
03699 "findCreateGroup");
03700
03701 groupLength.d.ul = &l;
03702 l = 0;
03703 if ((*object)->groupLengthFlag) {
03704 groupLength.tag = DCM_MAKETAG(group, 0);
03705 cond = newElementItem(&groupLength, TRUE, &groupLengthItem);
03706 (void) memcpy(groupLengthItem->element.d.ot, &l, sizeof(l));
03707
03708 if (LST_Insert(&newGroupItem->elementList, (void *)groupLengthItem, LST_K_AFTER) !=
03709 LST_NORMAL)
03710 return COND_PushCondition(DCM_LISTFAILURE,
03711 DCM_Message(DCM_LISTFAILURE),
03712 "findCreateGroup");
03713
03714 (*object)->objectSize += 8 + groupLengthItem->element.length;
03715 }
03716 }
03717 return DCM_NORMAL;
03718 }
|
|
||||||||||||||||
|
Definition at line 6889 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CTN_MALLOC, CTNBOOLEAN, DCM_CloseObject(), DCM_ELEMENTCREATEFAILED, DCM_LISTFAILURE, DCM_Message(), DCM_NORMAL, DCM_OBJECT, LST_Create(), LST_Enqueue(), and LST_NORMAL. Referenced by readFile1().
06891 {
06892 CTNBOOLEAN createGroupFlag;
06893
06894 if (*groupItem == NULL)
06895 createGroupFlag = TRUE;
06896 else if ((*groupItem)->group != group)
06897 createGroupFlag = TRUE;
06898 else
06899 createGroupFlag = FALSE;
06900
06901 if (createGroupFlag == TRUE) {
06902 *groupItem = CTN_MALLOC(sizeof(**groupItem));
06903 if (*groupItem == NULL) {
06904 (void) DCM_CloseObject((DCM_OBJECT **) obj);
06905 return COND_PushCondition(DCM_ELEMENTCREATEFAILED,
06906 DCM_Message(DCM_ELEMENTCREATEFAILED),
06907 "handleGroupItem",
06908 group, 0xffff, sizeof(**groupItem));
06909 }
06910 (*groupItem)->group = group;
06911 (*groupItem)->baseLength = 0;
06912 (*groupItem)->longVRAttributes = 0;
06913 (*groupItem)->elementList = LST_Create();
06914 if ((*groupItem)->elementList == NULL) {
06915 (void) DCM_CloseObject((DCM_OBJECT **) obj);
06916 return COND_PushCondition(DCM_LISTFAILURE,
06917 DCM_Message(DCM_LISTFAILURE),
06918 "handleGroupItem");
06919 }
06920 if (LST_Enqueue(&(*obj)->groupList, (void *)*groupItem) != LST_NORMAL) {
06921 (void) DCM_CloseObject((DCM_OBJECT **) obj);
06922 return COND_PushCondition(DCM_LISTFAILURE,
06923 DCM_Message(DCM_LISTFAILURE),
06924 "handleGroupItem");
06925 }
06926 }
06927 return DCM_NORMAL;
06928 }
|
|
||||||||||||
|
Definition at line 3758 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, PRV_ELEMENT_ITEM::byteOrder, COND_PushCondition(), CONDITION, CTN_FREE, DCM_ELEMENT::d, DCM_AE, DCM_AS, DCM_BADELEMENTINGROUP, DCM_CS, DCM_DA, DCM_DS, DCM_IS, DCM_LISTFAILURE, DCM_LO, DCM_LT, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_ORDERNATIVE, DCM_OW, DCM_PN, DCM_SH, DCM_SQ, DCM_ST, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_TM, DCM_UI, DCM_UNEVENELEMENTLENGTH, DCM_UNSPECIFIEDLENGTH, DCM_UT, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, DCM_ELEMENT::length, PRV_GROUP_ITEM::longVRAttributes, LST_Current(), LST_Enqueue(), LST_Head(), LST_Insert(), LST_K_BEFORE, LST_Next(), LST_NORMAL, LST_Position(), newElementItem(), object, p, PRV_ELEMENT_ITEM::paddedDataLength, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and updateSpecialElements(). Referenced by DCM_AddElement(), and DCM_AddSequenceElement().
03759 {
03760 PRV_ELEMENT_ITEM
03761 * nextItem,
03762 *newItem;
03763 PRV_GROUP_ITEM
03764 * groupItem;
03765 CONDITION
03766 cond;
03767 char
03768 *p;
03769
03770 cond = newElementItem(element, TRUE, &newItem);
03771 if (cond != DCM_NORMAL) {
03772 return cond;
03773 }
03774 newItem->byteOrder = DCM_ORDERNATIVE;
03775 if ((newItem->element.length & 1) != 0) {
03776 if (newItem->element.representation == DCM_AE) {
03777 p = newItem->element.d.string; /* repair, check for 16 */
03778 p[newItem->element.length] = ' ';
03779 newItem->paddedDataLength = element->length + 1;
03780 (void) memcpy(p, element->d.string, element->length);
03781 } else if (newItem->element.representation == DCM_AS) {
03782 p = newItem->element.d.string;
03783 p[newItem->element.length] = ' ';
03784 newItem->paddedDataLength = element->length + 1;
03785 (void) memcpy(p, element->d.string, element->length);
03786 } else if (newItem->element.representation == DCM_CS) {
03787 p = newItem->element.d.string;
03788 p[newItem->element.length] = ' ';
03789 newItem->paddedDataLength = element->length + 1;
03790 (void) memcpy(p, element->d.string, element->length);
03791 } else if (newItem->element.representation == DCM_DA) {
03792 p = newItem->element.d.string;
03793 p[newItem->element.length] = ' ';
03794 newItem->paddedDataLength = element->length + 1;
03795 (void) memcpy(p, element->d.string, element->length);
03796 } else if (newItem->element.representation == DCM_DS) {
03797 p = newItem->element.d.string;
03798 p[newItem->element.length] = ' ';
03799 newItem->paddedDataLength = element->length + 1;
03800 (void) memcpy(p, element->d.string, element->length);
03801 } else if (newItem->element.representation == DCM_IS) {
03802 p = newItem->element.d.string;
03803 p[newItem->element.length] = ' ';
03804 newItem->paddedDataLength = element->length + 1;
03805 (void) memcpy(p, element->d.string, element->length);
03806 } else if (newItem->element.representation == DCM_LT) {
03807 p = newItem->element.d.string;
03808 p[newItem->element.length] = ' ';
03809 newItem->paddedDataLength = element->length + 1;
03810 (void) memcpy(p, element->d.string, element->length);
03811 } else if (newItem->element.representation == DCM_LO) {
03812 p = newItem->element.d.string;
03813 p[newItem->element.length] = ' ';
03814 newItem->paddedDataLength = element->length + 1;
03815 (void) memcpy(p, element->d.string, element->length);
03816 } else if (newItem->element.representation == DCM_PN) {
03817 p = newItem->element.d.string;
03818 p[newItem->element.length] = ' ';
03819 newItem->paddedDataLength = element->length + 1;
03820 (void) memcpy(p, element->d.string, element->length);
03821 } else if (newItem->element.representation == DCM_SH) {
03822 p = newItem->element.d.string;
03823 p[newItem->element.length] = ' ';
03824 newItem->paddedDataLength = element->length + 1;
03825 (void) memcpy(p, element->d.string, element->length);
03826 } else if (newItem->element.representation == DCM_ST) {
03827 p = newItem->element.d.string;
03828 p[newItem->element.length] = ' ';
03829 newItem->paddedDataLength = element->length + 1;
03830 (void) memcpy(p, element->d.string, element->length);
03831 } else if (newItem->element.representation == DCM_TM) {
03832 p = newItem->element.d.string;
03833 p[newItem->element.length] = ' ';
03834 newItem->paddedDataLength = element->length + 1;
03835 (void) memcpy(p, element->d.string, element->length);
03836 } else if (newItem->element.representation == DCM_UI) {
03837 p = newItem->element.d.string;
03838 p[newItem->element.length] = '\0';
03839 newItem->paddedDataLength = element->length + 1;
03840 (void) memcpy(p, element->d.string, element->length);
03841 } else if (newItem->element.representation == DCM_UT) {
03842 p = newItem->element.d.string;
03843 p[newItem->element.length] = ' ';
03844 newItem->paddedDataLength = element->length + 1;
03845 (void) memcpy(p, element->d.string, element->length);
03846 } else if (newItem->element.representation == DCM_SQ) {
03847 /* newItem->element.length = 0xffffffff; */
03848 newItem->element.d.sq = element->d.sq;
03849 } else {
03850 CTN_FREE(newItem);
03851 return COND_PushCondition(DCM_UNEVENELEMENTLENGTH,
03852 DCM_Message(DCM_UNEVENELEMENTLENGTH),
03853 DCM_TAG_GROUP(element->tag),
03854 DCM_TAG_ELEMENT(element->tag), element->length,
03855 "insertNewElement");
03856 }
03857 } else if (newItem->element.representation != DCM_SQ) {
03858 (void) memcpy(newItem->element.d.ot, element->d.ot, element->length);
03859 } else {
03860 /* newItem->element.length = 0xffffffff; */
03861 newItem->element.d.sq = element->d.sq;
03862 }
03863 if ((*object)->objectSize != DCM_UNSPECIFIEDLENGTH)
03864 (*object)->objectSize += 8 + newItem->paddedDataLength;
03865
03866 /* repair */
03867 cond = updateSpecialElements(object, newItem);
03868 if (cond != DCM_NORMAL)
03869 return cond;
03870
03871 groupItem = (void *)LST_Current(&(*object)->groupList);
03872 if (groupItem == NULL)
03873 return COND_PushCondition(DCM_LISTFAILURE,
03874 DCM_Message(DCM_LISTFAILURE), "insertNewElement");
03875
03876 if (groupItem->baseLength != DCM_UNSPECIFIEDLENGTH)
03877 groupItem->baseLength += 2 + 2 + 4 + newItem->paddedDataLength;
03878
03879 if (newItem->element.representation == DCM_OW ||
03880 newItem->element.representation == DCM_OB ||
03881 newItem->element.representation == DCM_SQ) {
03882 groupItem->longVRAttributes++;
03883 (*object)->longVRAttributes++;
03884 }
03885 if ((nextItem = (void *)LST_Head(&groupItem->elementList)) == NULL) {
03886 cond = LST_Enqueue(&groupItem->elementList, (void *)newItem);
03887 if (cond != LST_NORMAL)
03888 return COND_PushCondition(DCM_LISTFAILURE,
03889 DCM_Message(DCM_LISTFAILURE),
03890 "insertNewElement");
03891 else
03892 return DCM_NORMAL;
03893 }
03894 (void) LST_Position(&groupItem->elementList, (void *)nextItem);
03895 if (DCM_TAG_ELEMENT(nextItem->element.tag) == 0x0000)
03896 (void) memcpy(nextItem->element.d.ot, &groupItem->baseLength,
03897 sizeof(groupItem->baseLength));
03898
03899 /* Now, search through the linked list for a place to insert/append
03900 ** this new item.
03901 */
03902
03903 while (nextItem != NULL) {
03904 if (DCM_TAG_GROUP(element->tag) !=
03905 DCM_TAG_GROUP(nextItem->element.tag)) {
03906 return COND_PushCondition(DCM_BADELEMENTINGROUP,
03907 DCM_Message(DCM_BADELEMENTINGROUP),
03908 DCM_TAG_GROUP(nextItem->element.tag),
03909 DCM_TAG_ELEMENT(nextItem->element.tag),
03910 groupItem->group, "insertNewElement");
03911 } else if (DCM_TAG_ELEMENT(element->tag) <
03912 DCM_TAG_ELEMENT(nextItem->element.tag)) {
03913 cond = LST_Insert(&groupItem->elementList, (void *)newItem, LST_K_BEFORE);
03914 if (cond != LST_NORMAL)
03915 return COND_PushCondition(DCM_LISTFAILURE,
03916 DCM_Message(DCM_LISTFAILURE),
03917 "insertNewElement");
03918 else
03919 return DCM_NORMAL;
03920 }
03921 nextItem = (void *)LST_Next(&groupItem->elementList);
03922 }
03923
03924 /* If we fall out of the loop, we must have reached the end of
03925 ** the group. Add the element to the end of the list of elements
03926 ** in this group.
03927 */
03928
03929 cond = LST_Enqueue(&groupItem->elementList, (void *)newItem);
03930 if (cond != LST_NORMAL)
03931 return COND_PushCondition(DCM_LISTFAILURE,
03932 DCM_Message(DCM_LISTFAILURE),
03933 "insertNewElement");
03934 else
03935 return DCM_NORMAL;
03936 }
|
|
||||||||||||
|
Definition at line 3939 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, COND_PushCondition(), CONDITION, DCM_ELEMENT::d, DCM_BADELEMENTINGROUP, DCM_LISTFAILURE, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OW, DCM_SQ, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNSPECIFIEDLENGTH, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, findCreateGroup(), PRV_GROUP_ITEM::group, PRV_GROUP_ITEM::longVRAttributes, LST_Enqueue(), LST_Head(), LST_Insert(), LST_K_BEFORE, LST_Next(), LST_NORMAL, LST_Position(), object, PRV_ELEMENT_ITEM::paddedDataLength, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and updateSpecialElements(). Referenced by DCM_AddFragment().
03940 {
03941 PRV_ELEMENT_ITEM * nextItem;
03942 PRV_GROUP_ITEM * groupItem = 0;
03943 CONDITION cond;
03944
03945 /* repair */
03946 cond = updateSpecialElements(object, newItem);
03947 if (cond != DCM_NORMAL)
03948 return cond;
03949
03950 cond = findCreateGroup(object, DCM_TAG_GROUP(newItem->element.tag),
03951 &groupItem);
03952
03953 if (groupItem == NULL)
03954 return COND_PushCondition(DCM_LISTFAILURE,
03955 DCM_Message(DCM_LISTFAILURE), "insertThisElementItem");
03956
03957 if (groupItem->baseLength != DCM_UNSPECIFIEDLENGTH)
03958 groupItem->baseLength += 2 + 2 + 4 + newItem->paddedDataLength;
03959
03960 if (newItem->element.representation == DCM_OW ||
03961 newItem->element.representation == DCM_OB ||
03962 newItem->element.representation == DCM_SQ) {
03963 groupItem->longVRAttributes++;
03964 (*object)->longVRAttributes++;
03965 }
03966
03967 if ((nextItem = (void *)LST_Head(&groupItem->elementList)) == NULL) {
03968 cond = LST_Enqueue(&groupItem->elementList, (void *)newItem);
03969 if (cond != LST_NORMAL)
03970 return COND_PushCondition(DCM_LISTFAILURE,
03971 DCM_Message(DCM_LISTFAILURE),
03972 "insertThisElementItem");
03973 else
03974 return DCM_NORMAL;
03975 }
03976
03977 (void) LST_Position(&groupItem->elementList, (void *)nextItem);
03978 if (DCM_TAG_ELEMENT(nextItem->element.tag) == 0x0000)
03979 (void) memcpy(nextItem->element.d.ot, &groupItem->baseLength,
03980 sizeof(groupItem->baseLength));
03981
03982 /* Now, search through the linked list for a place to insert/append
03983 ** this new item.
03984 */
03985
03986 while (nextItem != NULL) {
03987 if (DCM_TAG_GROUP(newItem->element.tag) !=
03988 DCM_TAG_GROUP(nextItem->element.tag)) {
03989 return COND_PushCondition(DCM_BADELEMENTINGROUP,
03990 DCM_Message(DCM_BADELEMENTINGROUP),
03991 DCM_TAG_GROUP(nextItem->element.tag),
03992 DCM_TAG_ELEMENT(nextItem->element.tag),
03993 groupItem->group, "insertThisElementItem");
03994 } else if (DCM_TAG_ELEMENT(newItem->element.tag) <
03995 DCM_TAG_ELEMENT(nextItem->element.tag)) {
03996 cond = LST_Insert(&groupItem->elementList, (void *)newItem, LST_K_BEFORE);
03997 if (cond != LST_NORMAL)
03998 return COND_PushCondition(DCM_LISTFAILURE,
03999 DCM_Message(DCM_LISTFAILURE),
04000 "insertThisElementItem");
04001 else
04002 return DCM_NORMAL;
04003 }
04004 nextItem = (void *)LST_Next(&groupItem->elementList);
04005 }
04006
04007 /* If we fall out of the loop, we must have reached the end of
04008 ** the group. Add the element to the end of the list of elements
04009 ** in this group.
04010 */
04011
04012 cond = LST_Enqueue(&groupItem->elementList, (void *)newItem);
04013 if (cond != LST_NORMAL)
04014 return COND_PushCondition(DCM_LISTFAILURE,
04015 DCM_Message(DCM_LISTFAILURE),
04016 "insertThisElementItem");
04017 else
04018 return DCM_NORMAL;
04019 }
|
|
||||||||||||
|
Definition at line 7231 of file l_mri_dicom_hdr.c. References CTNBOOLEAN, DCM_TAG, DCM_TAG_GROUP, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, PRV_GROUP_ITEM::group, LST_Head(), LST_Next(), LST_Position(), and DCM_ELEMENT::tag. Referenced by DCM_AddFragment(), DCM_GetCompressedValue(), DCM_GetElement(), DCM_GetElementValueOffset(), DCM_GetSequenceByOffset(), DCM_GetSequenceElement(), and DCM_PrintSequenceList().
07232 {
07233 PRV_GROUP_ITEM
07234 * groupItem;
07235 PRV_ELEMENT_ITEM
07236 * elementItem;
07237 CTNBOOLEAN
07238 found = FALSE;
07239
07240 groupItem = (void *)LST_Head(&(*obj)->groupList);
07241 if (groupItem == NULL)
07242 return NULL;
07243
07244 (void) LST_Position(&(*obj)->groupList, (void *)groupItem);
07245 while (groupItem != NULL) {
07246 if (groupItem->group == DCM_TAG_GROUP(tag))
07247 break;
07248
07249 groupItem = (void *)LST_Next(&(*obj)->groupList);
07250 }
07251 if (groupItem == NULL)
07252 return NULL;
07253
07254 elementItem = (void *)LST_Head(&groupItem->elementList);
07255 if (elementItem == NULL)
07256 return NULL;
07257
07258 (void) LST_Position(&groupItem->elementList, (void *)elementItem);
07259 while (!found && (elementItem != NULL)) {
07260 if (elementItem->element.tag == tag) {
07261 found = TRUE;
07262 } else
07263 elementItem = (void *)LST_Next(&groupItem->elementList);
07264 }
07265 if (found)
07266 return elementItem;
07267 else
07268 return NULL;
07269 }
|
|
|
Definition at line 4167 of file l_mri_dicom_hdr.c. Referenced by readVRLength().
|
|
|
Definition at line 10870 of file l_mri_dicom_hdr.c.
10875 {
10876 return (*list)->count;
10877 }
|
|
|
Definition at line 10728 of file l_mri_dicom_hdr.c. References lst_head::count, CTN_MALLOC, lst_head::current, lst_head::head, and lst_head::tail.
|
|
|
Definition at line 10894 of file l_mri_dicom_hdr.c. Referenced by insertNewElement().
10900 {
10901 return (*list)->current;
10902 }
|
|
|
Definition at line 10812 of file l_mri_dicom_hdr.c. References lst_node::next, and lst_node::previous. Referenced by LST_Sort().
10818 {
10819 LST_NODE
10820 * ptr;
10821
10822 if ((*list)->head == NULL) {/* list is empty */
10823 (*list)->count = 0;
10824 return NULL;
10825 }
10826 ptr = (*list)->head; /* save the head */
10827 (*list)->head = ptr->next; /* set new head of list */
10828 if ((*list)->head == NULL) /* if the list is now empty */
10829 (*list)->tail = NULL; /* there is no tail anymore */
10830 else
10831 (*list)->head->previous = NULL; /* new head has no previous */
10832 ptr->next = NULL; /* hide data from user */
10833 (*list)->count--; /* list has one fewer node */
10834 /* now */
10835 return ptr;
10836 }
|
|
|
Definition at line 10751 of file l_mri_dicom_hdr.c. References CTN_FREE, LST_LISTNOTEMPTY, and LST_NORMAL. Referenced by DCM_CloseObject(), and DCM_RemoveGroup().
10757 {
10758
10759 if ((*list)->count != 0)
10760 return LST_LISTNOTEMPTY;
10761
10762 CTN_FREE(*list);
10763 *list = NULL;
10764 return LST_NORMAL;
10765 }
|
|
||||||||||||
|
Definition at line 10770 of file l_mri_dicom_hdr.c. References LST_NORMAL, lst_node::next, and lst_node::previous. Referenced by copySequence(), DCM_AddFragment(), DCM_GetElementValueList(), findCreateGroup(), handleGroupItem(), insertNewElement(), insertThisElementItem(), LST_Sort(), readFile(), readFile1(), and readSequence().
10776 {
10777 node->next = NULL; /* no next node */
10778 node->previous = (*list)->tail; /* previous is old tail */
10779 if ((*list)->head == NULL) /* if list was empty... */
10780 (*list)->head = node; /* it has a head now! */
10781 else
10782 (*list)->tail->next = node; /* old tail now has a next */
10783
10784 (*list)->tail = node; /* list now has a new tail */
10785 (*list)->count++; /* bump the counter */
10786 return LST_NORMAL;
10787 }
|
|
|
Definition at line 10882 of file l_mri_dicom_hdr.c. Referenced by compareGroup(), copySequence(), DCM_CompareAttributes(), DCM_CopyObject(), DCM_DumpElements(), DCM_FormatElements(), DCM_GetElementSize(), DCM_GetElementValue(), DCM_GetElementValueList(), DCM_GetFirstElement(), DCM_GetNextElement(), DCM_GetSequenceByOffset(), DCM_GetSequenceElement(), DCM_GetSequenceList(), DCM_GroupPresent(), DCM_ListToString(), DCM_MergeObject(), DCM_PrintSequenceList(), DCM_RemoveElement(), DCM_RemoveGroup(), DCM_ScanParseObject(), exportEncapsulatedPixels(), exportStream(), findCreateGroup(), insertNewElement(), insertThisElementItem(), locateElement(), LST_Index(), LST_Sort(), readFile(), and readFile1().
10888 {
10889 return (*list)->head;
10890 }
|
|
||||||||||||
|
Definition at line 11187 of file l_mri_dicom_hdr.c. References l, LST_Head(), LST_Next(), and LST_Position().
11188 {
11189 LST_NODE
11190 * n;
11191
11192 n = LST_Head(l);
11193 if (n == NULL)
11194 return NULL;
11195
11196 index--;
11197 LST_Position(l, n);
11198 while (index-- > 0 && n != NULL)
11199 n = LST_Next(l);
11200
11201 return n;
11202 }
|
|
||||||||||||||||
|
Definition at line 10919 of file l_mri_dicom_hdr.c. References CURRENT, LST_BADEND, LST_END, LST_K_AFTER, LST_K_BEFORE, LST_NOCURRENT, LST_NORMAL, lst_node::next, OLD_NEXT, OLD_PREV, and lst_node::previous. Referenced by findCreateGroup(), insertNewElement(), insertThisElementItem(), and LST_Sort().
10927 {
10928 if ((where != LST_K_BEFORE) && (where != LST_K_AFTER))
10929 goto badend;
10930
10931 if ((*list)->head == NULL) {/* if the list was empty */
10932 (*list)->tail = node; /* set the tail pointer */
10933 (*list)->head = node; /* set the head pointer */
10934 (*list)->count = 0; /* will get bumped later... */
10935 (node)->next = NULL; /* there is no next */
10936 (node)->previous = NULL;/* and no previous */
10937
10938 } else if (CURRENT == NULL) /* is he mixing semantics? */
10939 goto nocurrent;
10940
10941 else if ((CURRENT == (*list)->head) && /* if at the head */
10942 (where == LST_K_BEFORE)) { /* and inserting BEFORE */
10943 node->next = CURRENT; /* splice new node in */
10944 CURRENT->previous = node; /* before the current */
10945 node->previous = NULL; /* new one has no previous */
10946 (*list)->head = node; /* new one is first now */
10947
10948 } else if ((CURRENT == (*list)->tail) && /* if at the tail */
10949 (where == LST_K_AFTER)) { /* and inserting AFTER */
10950 node->next = NULL; /* new node has no next */
10951 node->previous = (*list)->tail; /* previous is old tail */
10952 CURRENT->next = node; /* splice new node in */
10953 (*list)->tail = node; /* new node is now the tail */
10954
10955 } else if (where == LST_K_AFTER) { /* not a special case */
10956 OLD_NEXT->previous = node; /* we preceed a node */
10957 node->next = OLD_NEXT; /* the old next follows us */
10958 node->previous = CURRENT; /* the current preceeds us */
10959 CURRENT->next = node; /* we follow current */
10960
10961 } else { /* not a special case */
10962 OLD_PREV->next = node; /* we follow the previous */
10963 node->previous = OLD_PREV; /* of current */
10964 node->next = CURRENT; /* current follows us and */
10965 CURRENT->previous = node; /* we preceed current */
10966 };
10967
10968 (*list)->count++; /* bump the counter */
10969 (*list)->current = node; /* and set current */
10970 return LST_NORMAL;
10971
10972 badend:
10973 return LST_BADEND;
10974
10975 nocurrent:
10976 return LST_NOCURRENT;
10977 }
|
|
|
|
Definition at line 10841 of file l_mri_dicom_hdr.c. References lst_node::next, and lst_node::previous. Referenced by DCM_CloseObject(), and DCM_RemoveGroup().
10847 {
10848 LST_NODE
10849 * ptr;
10850
10851 if ((*list)->head == NULL) {/* list is empty */
10852 (*list)->count = 0;
10853 return NULL;
10854 }
10855 ptr = (*list)->head; /* save the head */
10856 (*list)->head = ptr->next; /* set new head of list */
10857 if ((*list)->head == NULL) /* if the list is now empty */
10858 (*list)->tail = NULL; /* there is no tail anymore */
10859 else
10860 (*list)->head->previous = NULL; /* new head has no previous */
10861 ptr->next = NULL; /* hide data from user */
10862 (*list)->count--; /* list has one fewer node */
10863 /* now */
10864 return ptr;
10865 }
|
|
||||||||||||
|
Definition at line 11099 of file l_mri_dicom_hdr.c. References CURRENT, lst_node::next, and lst_node::previous. Referenced by compareGroup(), copySequence(), DCM_CompareAttributes(), DCM_CopyObject(), DCM_DumpElements(), DCM_FormatElements(), DCM_GetElementSize(), DCM_GetElementValue(), DCM_GetElementValueList(), DCM_GetFirstElement(), DCM_GetNextElement(), DCM_GetSequenceByOffset(), DCM_GetSequenceList(), DCM_GroupPresent(), DCM_ListToString(), DCM_MergeObject(), DCM_PrintSequenceList(), DCM_RemoveElement(), DCM_RemoveGroup(), DCM_ScanParseObject(), exportEncapsulatedPixels(), exportStream(), findCreateGroup(), insertNewElement(), insertThisElementItem(), locateElement(), LST_Index(), LST_Sort(), readFile(), and readFile1().
11104 : node = lst_position(list, lst_head(list)); 11105 * makes the node at the head of the list current 11106 * and returns a pointer to it. 11107 * 11108 * The routine tries to verify that "node" is in the list 11109 * by doing a few consistency checks. It assumes that if 11110 * any of three "known" pointers are what they should be 11111 * that all is well. Its not damnfoolproof, but... 11112 */ 11113 { 11114 if ((*list)->head == NULL) {/* list is empty */ 11115 return NULL; 11116 } 11117 if (node == NULL) 11118 return NULL; 11119 if (((node->previous == NULL) && ((*list)->head == node)) || 11120 ((node->next == NULL) && ((*list)->tail == node)) || 11121 (node->previous->next == node)) { /* its probably OK */ 11122 11123 CURRENT = node; 11124 return CURRENT; 11125 }; 11126 11127 return NULL; 11128 } |
|
|
Definition at line 11075 of file l_mri_dicom_hdr.c. References CURRENT.
11081 {
11082 if ((*list)->head == NULL) {/* list is empty */
11083 (*list)->count = 0;
11084 return NULL;
11085 }
11086 if (CURRENT == NULL) { /* there is no CURRENT */
11087 return NULL;
11088 }
11089 if (CURRENT->previous == NULL) { /* no PREVIOUS */
11090 return NULL;
11091 }
11092 CURRENT = CURRENT->previous;/* found it */
11093 return CURRENT;
11094 }
|
|
||||||||||||
|
Definition at line 10790 of file l_mri_dicom_hdr.c. References LST_NORMAL, lst_node::next, and lst_node::previous.
10797 {
10798 node->next = (*list)->head; /* set the forward link */
10799 node->previous = NULL; /* set rearward link */
10800 if ((*list)->tail == NULL) /* if the list was empty */
10801 (*list)->tail = node; /* set the tail pointer */
10802 else /* otherwise, */
10803 (*list)->head->previous = node; /* old head now has a previous */
10804
10805 (*list)->head = node; /* set new first node */
10806 (*list)->count++; /* bump the counter */
10807 return LST_NORMAL;
10808
10809 }
|
|
||||||||||||
|
Definition at line 10982 of file l_mri_dicom_hdr.c. References CURRENT, LST_END, LST_K_AFTER, LST_K_BEFORE, lst_node::next, OLD_NEXT, OLD_PREV, and lst_node::previous. Referenced by DCM_RemoveElement(), and DCM_RemoveGroup().
10992 {
10993 LST_NODE
10994 * ptr;
10995
10996 if ((dir != LST_K_BEFORE) && (dir != LST_K_AFTER))
10997 goto baddir;
10998 if (CURRENT == NULL)
10999 goto nocurrent;
11000 if ((*list)->head == NULL)
11001 goto listempty;
11002
11003 ptr = CURRENT; /* save node */
11004
11005 if (CURRENT == (*list)->head) { /* removing the head */
11006 (*list)->head = OLD_NEXT; /* set new head of list */
11007 if ((*list)->head == NULL) /* if the list is now empty */
11008 (*list)->tail = NULL; /* no tail anymore either */
11009 else
11010 (*list)->head->previous = NULL; /* new head has no previous */
11011 if (dir == LST_K_BEFORE)/* there is nothing before */
11012 (*list)->current = NULL; /* the head of the list */
11013 else /* otherwise, remain */
11014 (*list)->current = (*list)->head; /* at the head... */
11015
11016 } else if (CURRENT == (*list)->tail) { /* removing the tail */
11017 (*list)->tail = OLD_PREV; /* set new tail of list */
11018 (*list)->tail->next = NULL; /* new tail has no next */
11019 if (dir == LST_K_AFTER) /* there is nothing after */
11020 (*list)->current = NULL; /* the tail of a list */
11021 else /* otherwise, remain */
11022 (*list)->current = (*list)->tail; /* at the tail... */
11023
11024 } else { /* not a special case */
11025 OLD_PREV->next = CURRENT->next; /* set forward pointer */
11026 OLD_NEXT->previous = CURRENT->previous; /* set backward pointer */
11027 if (dir == LST_K_BEFORE)/* depending on direction, */
11028 (*list)->current = CURRENT->previous; /* set current */
11029 else /* in the */
11030 (*list)->current = CURRENT->next; /* list head */
11031 }
11032
11033 (*list)->count--; /* one fewer nodes now */
11034 ptr->previous = NULL; /* hide data from user */
11035 ptr->next = NULL; /* hide data from user */
11036 return ptr;
11037
11038 baddir:
11039 return NULL;
11040
11041 nocurrent:
11042 return NULL;
11043
11044 listempty:
11045 (*list)->count = 0;
11046 (*list)->current = NULL;
11047 (*list)->head = (*list)->tail = NULL;
11048 return NULL;
11049 }
|
|
||||||||||||||||
|
Definition at line 11136 of file l_mri_dicom_hdr.c. References AFNI_CALL_VALU_2ARG, compare(), lst_head::count, CTNBOOLEAN, lst_head::current, lst_head::head, LST_Dequeue(), LST_Enqueue(), LST_Head(), LST_Insert(), LST_K_BEFORE, LST_Next(), LST_NORMAL, LST_Position(), n1, n2, and lst_head::tail.
11137 {
11138 LST_NODE
11139 * n1,
11140 *n2;
11141 LST_HEAD
11142 temp,
11143 *head;
11144 CTNBOOLEAN
11145 inserted;
11146 int ccc ;
11147
11148 if ((*list)->head == NULL) {/* list is empty */
11149 return LST_NORMAL;
11150 }
11151 head = &temp;
11152 head->head = NULL;
11153 head->tail = NULL;
11154 head->current = NULL;
11155 head->count = 0;
11156
11157 while ((n1 = LST_Dequeue(list)) != NULL) {
11158 n2 = LST_Head(&head);
11159 if (n2 != NULL)
11160 (void) LST_Position(&head, n2);
11161 inserted = FALSE;
11162 while (n2 != NULL && !inserted) {
11163 #if 0
11164 if (compare(n1, n2) < 0) {
11165 #else
11166 AFNI_CALL_VALU_2ARG(compare,int,ccc,LST_NODE *,n1,LST_NODE *,n2) ;
11167 if( ccc < 0 ){
11168 #endif
11169 (void) LST_Insert(&head, n1, LST_K_BEFORE);
11170 inserted = TRUE;
11171 } else
11172 n2 = LST_Next(&head);
11173 }
11174 if (n2 == NULL)
11175 (void) LST_Enqueue(&head, n1);
11176 }
11177 **list = *head;
11178 return LST_NORMAL;
11179 }
|
|
|
Definition at line 10907 of file l_mri_dicom_hdr.c.
10913 {
10914 return (*list)->tail;
10915 }
|
|
||||||||||||
|
Definition at line 4180 of file l_mri_dicom_hdr.c. References DCM_VALUEREPRESENTATION, DIM_OF, and i. Referenced by readVRLength().
|
|
|
Definition at line 204 of file l_mri_dicom_hdr.c. References close(), COND_PopCondition(), CONDITION, CTNBOOLEAN, DCM_CloseObject(), DCM_Debug(), DCM_DumpElements(), DCM_FormatElements(), DCM_NORMAL, DCM_OBJECT, DCM_OpenFile(), DCM_ORDERLITTLEENDIAN, DCM_PART10FILE, ENTRY, getenv(), object, p, pbuf, pxl_len, pxl_off, RETURN, RWC_clear_pbuf(), rwc_fd, RWC_printf(), RWC_set_endianosity(), rwc_vm, and STATUS. Referenced by main(), mri_imcount_dicom(), mri_read_dicom(), and r_mri_read_dicom().
00205 {
00206 DCM_OBJECT * object;
00207 CONDITION cond;
00208 CTNBOOLEAN verbose = FALSE ,
00209 exitFlag = FALSE,
00210 formatFlag = FALSE;
00211 unsigned long
00212 options = DCM_ORDERLITTLEENDIAN;
00213 long vmLimit = rwc_vm ; /* 28 Oct 2002 */
00214 LST_HEAD* fileNames = 0;
00215 UTL_FILEITEM* p = NULL;
00216
00217 char *ppp=NULL ;
00218
00219 ENTRY("mri_dicom_header") ;
00220
00221 if( fname == NULL ) RETURN(NULL) ;
00222
00223 RWC_set_endianosity() ;
00224
00225 { char *eee = getenv("AFNI_TRACE") ;
00226 if( eee!=NULL && (*eee=='y' || *eee=='Y') ) verbose = TRUE ;
00227 }
00228
00229 DCM_Debug(verbose);
00230
00231 RWC_clear_pbuf() ; pxl_len = 0 ; pxl_off = 0 ;
00232
00233 STATUS(fname) ;
00234 rwc_fd = -1 ;
00235 cond = DCM_OpenFile(fname, options, &object);
00236 if (cond != DCM_NORMAL && ((options & DCM_PART10FILE) == 0)) {
00237 STATUS("DCM_OpenFile open failed; try again as Part 10") ;
00238 (void) DCM_CloseObject(&object);
00239 (void) COND_PopCondition(TRUE);
00240 if( rwc_fd >= 0 ){ close(rwc_fd); rwc_fd = -1; }
00241 cond = DCM_OpenFile(fname, options | DCM_PART10FILE, &object);
00242 }
00243 if (cond == DCM_NORMAL) {
00244 STATUS("DCM_OpenFile is good") ;
00245 RWC_printf("DICOM File: %s\n", fname);
00246 if (formatFlag)
00247 cond = DCM_FormatElements(&object, vmLimit, "");
00248 else
00249 cond = DCM_DumpElements(&object, vmLimit);
00250 } else {
00251 STATUS("DCM_OpenFile failed") ;
00252 }
00253 (void) DCM_CloseObject(&object);
00254 (void) COND_PopCondition(TRUE);
00255
00256 if( pbuf != NULL ){
00257 ppp = strdup(pbuf) ; RWC_clear_pbuf() ;
00258 }
00259
00260 if( rwc_fd >= 0 ){ close(rwc_fd); rwc_fd = -1; }
00261
00262 RETURN(ppp);
00263 }
|
|
|
Definition at line 174 of file l_mri_dicom_hdr.c. References RWC_NOHEX_MASK, and rwc_opt. Referenced by main(), mri_imcount_dicom(), mri_read_dicom(), and r_mri_read_dicom().
00175 {
00176 if( ii )
00177 rwc_opt |= RWC_NOHEX_MASK ;
00178 else if( rwc_opt & RWC_NOHEX_MASK )
00179 rwc_opt ^= RWC_NOHEX_MASK ;
00180 }
|
|
|
Definition at line 166 of file l_mri_dicom_hdr.c. References RWC_NONAME_MASK, and rwc_opt. Referenced by main(), mri_imcount_dicom(), mri_read_dicom(), and r_mri_read_dicom().
00167 {
00168 if( ii )
00169 rwc_opt |= RWC_NONAME_MASK ;
00170 else if( rwc_opt & RWC_NONAME_MASK )
00171 rwc_opt ^= RWC_NONAME_MASK ;
00172 }
|
|
||||||||||||
|
Definition at line 154 of file l_mri_dicom_hdr.c. References pxl_len, and pxl_off. Referenced by main(), mri_imcount_dicom(), mri_read_dicom(), and r_mri_read_dicom().
|
|
|
Definition at line 195 of file l_mri_dicom_hdr.c. References rwc_err. Referenced by main(), and mri_imcount().
00196 {
00197 rwc_err = vv ; /* 07 May 2003: an error will subtract 1 from rwc_err */
00198 }
|
|
|
Definition at line 186 of file l_mri_dicom_hdr.c. References rwc_vm. Referenced by main().
00187 {
00188 rwc_vm = vv ;
00189 }
|
|
||||||||||||||||
|
Definition at line 3548 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CTN_MALLOC, CTNBOOLEAN, DCM_ELEMENTCREATEFAILED, DCM_Message(), DCM_NORMAL, DCM_SQ, DCM_TAG_ELEMENT, DCM_TAG_GROUP, l, DCM_ELEMENT::length, NATIVE_ORDER, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32. Referenced by DCM_AddFragment(), findCreateGroup(), insertNewElement(), readData(), readFile(), and readSequence().
03550 {
03551 U32
03552 l;
03553
03554 if (allocateData && (src->representation != DCM_SQ)) {
03555 l = src->length;
03556 if (l & 1)
03557 l++;
03558 } else
03559 l = 0;
03560
03561 if (debug)
03562 fprintf(stderr, "newElementItem: CTN_MALLOC %8d %8d ", l,
03563 (int)(sizeof(PRV_ELEMENT_ITEM) + l));
03564
03565 *dst = (PRV_ELEMENT_ITEM *) CTN_MALLOC(sizeof(PRV_ELEMENT_ITEM) + l);
03566 if (debug)
03567 fprintf(stderr, "%8p\n", *dst);
03568
03569 if (*dst == NULL) {
03570 return COND_PushCondition(DCM_ELEMENTCREATEFAILED,
03571 DCM_Message(DCM_ELEMENTCREATEFAILED), "newElementItem",
03572 DCM_TAG_GROUP(src->tag),
03573 DCM_TAG_ELEMENT(src->tag),
03574 l);
03575 }
03576 memset(*dst, 0, sizeof(PRV_ELEMENT_ITEM));
03577 (*dst)->element = *src;
03578 (*dst)->byteOrder = NATIVE_ORDER;
03579 (*dst)->allocatedDataLength = (size_t) l;
03580 (*dst)->originalDataLength = src->length;
03581 (*dst)->paddedDataLength = src->length;
03582 if (allocateData)
03583 (*dst)->element.d.ot = ((char *) (*dst)) + sizeof(PRV_ELEMENT_ITEM);
03584 else
03585 (*dst)->element.d.ot = NULL;
03586
03587 (*dst)->fragmentFlag = 0;
03588 return DCM_NORMAL;
03589 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 6739 of file l_mri_dicom_hdr.c. References BYTEORDER_SAME, COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_AT, DCM_CloseObject(), DCM_FILEACCESSERROR, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_OW, DCM_PXLPIXELDATA, DCM_UNSPECIFIEDLENGTH, fd, name, newElementItem(), object, pxl_len, pxl_off, read(), scanCompressedPixels(), swapATGroupElement(), swapInPlace(), DCM_ELEMENT::tag, U32, and verifyFormat(). Referenced by readFile1().
06747 {
06748 CTNBOOLEAN pixelFlag;
06749 CONDITION cond;
06750 int nBytes;
06751
06752 pixelFlag = (e->tag == DCM_PXLPIXELDATA);
06753 cond = newElementItem(e, (pixelFlag == FALSE), elementItem);
06754 if (cond != DCM_NORMAL) {
06755 (void) DCM_CloseObject((DCM_OBJECT **) object);
06756 return cond;
06757 }
06758 (*elementItem)->element.data_offset = 0 ; /* RWCox */
06759 if (pixelFlag) {
06760 if (fileFlag)
06761 *remainOpenFlag = TRUE;
06762 (*elementItem)->byteOrder = byteOrder;
06763 (*elementItem)->dataOffset = *fileOffset;
06764 (*elementItem)->currentOffset = 0;
06765 (*elementItem)->element.d.ot = NULL;
06766 if ((*object)->pixelBitsAllocated == 8)
06767 (*elementItem)->element.representation = DCM_OB;
06768 else
06769 (*elementItem)->element.representation = DCM_OW;
06770 if (fileFlag) {
06771 if (fd != -1) {
06772 if ((*elementItem)->element.length != DCM_UNSPECIFIEDLENGTH){
06773
06774 pxl_off = lseek( fd , 0 , SEEK_CUR ) ;
06775 pxl_len = (*elementItem)->element.length ;
06776
06777 (*elementItem)->element.data_offset = pxl_off ; /* RWCox */
06778
06779 (void) lseek(fd,
06780 (off_t) (*elementItem)->element.length,
06781 SEEK_CUR);
06782 } else {
06783 U32 l1 = 0;
06784 U32 s1;
06785 off_t f1 = 0;
06786
06787 s1 = *size;
06788 scanCompressedPixels("", ptr, fd,
06789 &s1, /* size */
06790 &f1, /* fileOffset */
06791 0, 0,
06792 byteOrder, explicitVR,
06793 acceptVRMismatch,
06794 fileFlag, remainOpenFlag,
06795 convertFlag, object,
06796 &l1, /* scannedLength */
06797 e, elementItem);
06798 (*elementItem)->originalDataLength = l1;
06799 (*elementItem)->paddedDataLength = l1;
06800 }
06801 } else {
06802 (*object)->sk((*object)->userCtx,
06803 (*elementItem)->element.length, SEEK_CUR);
06804 }
06805 (*object)->fd = fd;
06806 }
06807 } else {
06808 if (fileFlag) {
06809 if (fd != -1) {
06810 (*elementItem)->element.data_offset = lseek(fd,0,SEEK_CUR); /* RWCox */
06811 nBytes = read(fd, (*elementItem)->element.d.ot,
06812 (int) (*elementItem)->element.length);
06813 } else {
06814 cond = (*object)->rd((*object)->userCtx,
06815 (*elementItem)->element.d.ot,
06816 (long) (*elementItem)->element.length, &nBytes);
06817 }
06818 if (nBytes != (int) (*elementItem)->element.length) {
06819 (void) DCM_CloseObject((DCM_OBJECT **) object);
06820 return COND_PushCondition(DCM_FILEACCESSERROR,
06821 DCM_Message(DCM_FILEACCESSERROR), name, "readFile");
06822 }
06823 } else {
06824 (void) memcpy((*elementItem)->element.d.ot, ptr,
06825 (*elementItem)->element.length);
06826 ptr += (*elementItem)->originalDataLength;
06827 }
06828 if( LITTLE_ENDIAN_ARCHITECTURE ){
06829 if ((*elementItem)->element.representation == DCM_AT)
06830 swapATGroupElement(&(*elementItem)->element);
06831 }
06832 if (byteOrder != BYTEORDER_SAME)
06833 swapInPlace(object, &(*elementItem)->element);
06834 if (convertFlag) {
06835 cond = verifyFormat(*elementItem);
06836 if (cond != DCM_NORMAL)
06837 return cond;
06838 }
06839 }
06840 if (*size != (long) DCM_UNSPECIFIEDLENGTH)
06841 *size -= (*elementItem)->originalDataLength;
06842 *fileOffset += (off_t) (*elementItem)->originalDataLength;
06843 if (scannedLength != NULL)
06844 (*scannedLength) += (*elementItem)->originalDataLength;
06845
06846 if ((*elementItem)->element.length != DCM_UNSPECIFIEDLENGTH) {
06847 (*elementItem)->paddedDataLength = (*elementItem)->element.length;
06848 }
06849 if (((*elementItem)->paddedDataLength != DCM_UNSPECIFIEDLENGTH) &&
06850 ((*elementItem)->paddedDataLength & 1) )
06851 (*elementItem)->paddedDataLength += 1;
06852 (*object)->objectSize += (*elementItem)->paddedDataLength;
06853
06854 return DCM_NORMAL;
06855
06856 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 5729 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, BIG_ORDER, PRV_ELEMENT_ITEM::byteOrder, BYTEORDER_SAME, computeVM(), COND_PopCondition(), COND_PushCondition(), CONDITION, CTN_FREE, CTN_MALLOC, CTNBOOLEAN, ctxSensitiveLookup(), PRV_ELEMENT_ITEM::currentOffset, DCM_ELEMENT::d, PRV_ELEMENT_ITEM::dataOffset, DCM_AT, DCM_CloseObject(), DCM_CONVERTMASK, DCM_CreateObject(), DCM_CTX, DCM_DELETEMASK, DCM_DELETEONCLOSE, DCM_DLMITEM, DCM_DLMITEMDELIMITATIONITEM, DCM_DLMSEQUENCEDELIMITATIONITEM, DCM_DumpElements(), DCM_ELEMENTCREATEFAILED, DCM_ELEMENTLENGTHERROR, DCM_ELEMENTOUTOFORDER, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_FILEACCESSERROR, DCM_FORMATCONVERSION, DCM_ILLEGALSTREAMLENGTH, DCM_LISTFAILURE, DCM_LookupElement(), DCM_MAKETAG, DCM_MALLOCFAILURE, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_ORDERBIGENDIAN, DCM_ORDERLITTLEENDIAN, DCM_ORDERMASK, DCM_ORDERNATIVE, DCM_OW, DCM_PXLPIXELDATA, DCM_SQ, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNEVENELEMENTLENGTH, DCM_UNSPECIFIEDLENGTH, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, fd, GET_LONG_REVERSE_ORDER, GET_LONG_SAME_ORDER, GET_SHORT_REVERSE_ORDER, GET_SHORT_SAME_ORDER, PRV_GROUP_ITEM::group, DCM_ELEMENT::length, LITTLE_ORDER, PRV_GROUP_ITEM::longVRAttributes, LST_Create(), LST_Enqueue(), LST_Head(), LST_Next(), LST_NORMAL, LST_Position(), name, NATIVE_ORDER, newElementItem(), DCM_SEQUENCE_ITEM::object, object, offset, PRV_ELEMENT_ITEM::originalDataLength, PRV_ELEMENT_ITEM::paddedDataLength, read(), DCM_ELEMENT::representation, swapATGroupElement(), swapInPlace(), DCM_ELEMENT::tag, U32, updateObjectType(), updateSpecialElements(), and verifyFormat(). Referenced by DCM_ImportStream(), DCM_OpenFile(), and readFile().
05736 {
05737 CONDITION
05738 cond;
05739 int
05740 byteOrder;
05741 long
05742 lastGroup = -1,
05743 lastElement = -1;
05744 U32
05745 sequenceLength,
05746 localLength;
05747 PRIVATE_OBJECT
05748 ** object;
05749 PRV_GROUP_ITEM
05750 * groupItem = NULL;
05751 unsigned short
05752 group,
05753 element,
05754 tagGroup,
05755 tagElement;
05756 DCM_ELEMENT
05757 e,
05758 tagE;
05759 CTNBOOLEAN
05760 pixelFlag,
05761 convertFlag = FALSE,
05762 done = FALSE,
05763 knownLength = TRUE,
05764 sequenceDone = FALSE,
05765 createGroupFlag,
05766 explicitVR = FALSE;
05767 unsigned char
05768 buf[8],
05769 *ptr;
05770 int
05771 nBytes;
05772 PRV_ELEMENT_ITEM
05773 * elementItem = NULL;
05774 DCM_OBJECT
05775 * sequenceObject;
05776 DCM_SEQUENCE_ITEM
05777 * sequenceItem;
05778 CTNBOOLEAN
05779 fileFlag = TRUE;
05780
05781 if (callerBuf != NULL) {
05782 ptr = callerBuf;
05783 fileFlag = FALSE;
05784 } else
05785 ptr = buf;
05786
05787 switch (opt & DCM_ORDERMASK) {
05788 case DCM_ORDERNATIVE:
05789 byteOrder = NATIVE_ORDER;
05790 break;
05791 case DCM_ORDERLITTLEENDIAN:
05792 byteOrder = LITTLE_ORDER;
05793 break;
05794 case DCM_EXPLICITLITTLEENDIAN:
05795 byteOrder = LITTLE_ORDER;
05796 explicitVR = TRUE;
05797 break;
05798 case DCM_ORDERBIGENDIAN:
05799 byteOrder = BIG_ORDER;
05800 break;
05801 case DCM_EXPLICITBIGENDIAN:
05802 byteOrder = BIG_ORDER;
05803 explicitVR = TRUE;
05804 break;
05805 default:
05806 byteOrder = NATIVE_ORDER;
05807 break;
05808 }
05809 if ((opt & DCM_CONVERTMASK) == DCM_FORMATCONVERSION)
05810 convertFlag = TRUE;
05811
05812 if (scannedLength != NULL)
05813 *scannedLength = 0;
05814
05815 cond = DCM_CreateObject(callerObject, opt);
05816 if (cond != DCM_NORMAL)
05817 return cond;
05818
05819 object = (PRIVATE_OBJECT **) callerObject;
05820 if (fileFlag)
05821 strcpy((*object)->fileName, name);
05822
05823 (*object)->fd = -1;
05824 (*object)->rd = rd;
05825 (*object)->sk = sk;
05826 (*object)->userCtx = ctx;
05827 if (size == (long) DCM_UNSPECIFIEDLENGTH)
05828 knownLength = FALSE;
05829
05830 if ((fileFlag) && ((opt & DCM_DELETEMASK) == DCM_DELETEONCLOSE) && (recursionLevel == 0))
05831 (*object)->deleteFlag = TRUE;
05832
05833 if (knownLength && (size == 0))
05834 done = TRUE;
05835
05836 while (!done) {
05837
05838 if ((size < 8) && knownLength) {
05839 if (debug)
05840 (void) DCM_DumpElements(callerObject, 0);
05841 (void) DCM_CloseObject(callerObject);
05842 return COND_PushCondition(DCM_ILLEGALSTREAMLENGTH,
05843 DCM_Message(DCM_ILLEGALSTREAMLENGTH), size,
05844 "readFile");
05845 }
05846 if (fileFlag) {
05847 if (fd != -1) {
05848 nBytes = read(fd, buf, 4);
05849 } else {
05850 cond = (*object)->rd((*object)->userCtx, buf, 4, &nBytes);
05851 }
05852
05853 if (nBytes != 4)
05854 return COND_PushCondition(DCM_FILEACCESSERROR,
05855 DCM_Message(DCM_FILEACCESSERROR), name,
05856 "readFile");
05857 ptr = buf;
05858 }
05859 if (knownLength)
05860 size -= 4;
05861 fileOffset += (off_t) 4;
05862 if (scannedLength != NULL)
05863 (*scannedLength) += 4;
05864 (*object)->objectSize += 4;
05865
05866 if (byteOrder == BYTEORDER_SAME) {
05867 GET_SHORT_SAME_ORDER(ptr, group);
05868 GET_SHORT_SAME_ORDER(ptr + 2, element);
05869 e.tag = DCM_MAKETAG(group, element);
05870 } else {
05871 GET_SHORT_REVERSE_ORDER(ptr, group);
05872 GET_SHORT_REVERSE_ORDER(ptr + 2, element);
05873 e.tag = DCM_MAKETAG(group, element);
05874 }
05875 ptr += 4;
05876
05877 if (explicitVR) {
05878 if (fileFlag) {
05879 if (fd != -1) {
05880 nBytes = read(fd, buf, 4);
05881 } else {
05882 cond = (*object)->rd((*object)->userCtx, buf, 4, &nBytes);
05883 }
05884
05885 if (nBytes != 4)
05886 return COND_PushCondition(DCM_FILEACCESSERROR,
05887 DCM_Message(DCM_FILEACCESSERROR), name,
05888 "readFile");
05889 ptr = buf;
05890 }
05891 if (knownLength)
05892 size -= 4;
05893 fileOffset += (off_t) 4;
05894 if (scannedLength != NULL)
05895 (*scannedLength) += 4;
05896 (*object)->objectSize += 4;
05897 if ((strncmp((char *) ptr, "OB", 2) == 0) ||
05898 (strncmp((char *) ptr, "OW", 2) == 0) ||
05899 (strncmp((char *) ptr, "SQ", 2) == 0)) {
05900 } else {
05901 }
05902 } else {
05903
05904 if (fileFlag) {
05905 if (fd != -1) {
05906 nBytes = read(fd, buf, 4);
05907 } else {
05908 cond = (*object)->rd((*object)->userCtx, buf, 4, &nBytes);
05909 }
05910
05911 if (nBytes != 4)
05912 return COND_PushCondition(DCM_FILEACCESSERROR,
05913 DCM_Message(DCM_FILEACCESSERROR), name,
05914 "readFile");
05915 ptr = buf;
05916 }
05917 if (knownLength)
05918 size -= 4;
05919 fileOffset += (off_t) 4;
05920 if (scannedLength != NULL)
05921 (*scannedLength) += 4;
05922 (*object)->objectSize += 4;
05923
05924
05925 if (byteOrder == BYTEORDER_SAME) {
05926 GET_LONG_SAME_ORDER(ptr, e.length);
05927 } else {
05928 GET_LONG_REVERSE_ORDER(ptr, e.length);
05929 }
05930 ptr += 4;
05931 }
05932
05933 if (((e.length & 1) != 0) && (e.length != DCM_UNSPECIFIEDLENGTH)) {
05934 if (debug)
05935 (void) DCM_DumpElements(callerObject, 0);
05936 (void) DCM_CloseObject(callerObject);
05937 return COND_PushCondition(DCM_UNEVENELEMENTLENGTH,
05938 DCM_Message(DCM_UNEVENELEMENTLENGTH),
05939 group, element, e.length,
05940 "readFile");
05941 }
05942 if ((e.length != (U32) DCM_UNSPECIFIEDLENGTH) && (e.length > (U32) size)) {
05943 if (debug)
05944 (void) DCM_DumpElements(callerObject, 0);
05945 (void) DCM_CloseObject(callerObject);
05946 return COND_PushCondition(DCM_ELEMENTLENGTHERROR,
05947 DCM_Message(DCM_ELEMENTLENGTHERROR),
05948 group, element, e.length, size, "readFile");
05949 }
05950 if ((e.tag == DCM_DLMITEMDELIMITATIONITEM) ||
05951 (e.tag == DCM_DLMSEQUENCEDELIMITATIONITEM)) {
05952 return DCM_NORMAL;
05953 }
05954 cond = DCM_LookupElement(&e);
05955 if (cond != DCM_NORMAL)
05956 (void) COND_PopCondition(0);
05957 if (e.representation == DCM_CTX)
05958 ctxSensitiveLookup(object, &e);
05959
05960 if (e.representation == DCM_SQ) {
05961 cond = newElementItem(&e, FALSE, &elementItem);
05962 if (cond != DCM_NORMAL)
05963 return cond;
05964 elementItem->element.d.sq = LST_Create();
05965 if (elementItem->element.d.sq == NULL)
05966 return COND_PushCondition(DCM_LISTFAILURE,
05967 DCM_Message(DCM_LISTFAILURE), "readFile");
05968
05969 localLength = elementItem->element.length;
05970 sequenceDone = (localLength == 0);
05971
05972 while (!sequenceDone) {
05973 if (debug)
05974 fprintf(stderr, "Sequence Length: %d %x\n", localLength,
05975 localLength);
05976 if (fileFlag) {
05977 if (fd != -1) {
05978 nBytes = read(fd, buf, 8);
05979 } else {
05980 cond = (*object)->rd((*object)->userCtx, buf, 8, &nBytes);
05981 }
05982 if (nBytes != 8)
05983 return COND_PushCondition(DCM_FILEACCESSERROR,
05984 DCM_Message(DCM_FILEACCESSERROR), name,
05985 "readFile");
05986 ptr = buf;
05987 }
05988 if (size != (long) DCM_UNSPECIFIEDLENGTH)
05989 size -= 8;
05990 fileOffset += (off_t) 8;
05991 if (scannedLength != NULL)
05992 (*scannedLength) += 8;
05993 (*object)->objectSize += 8;
05994 if (localLength != DCM_UNSPECIFIEDLENGTH)
05995 localLength -= 8;
05996
05997 if (byteOrder == BYTEORDER_SAME) {
05998 GET_SHORT_SAME_ORDER(ptr, tagGroup);
05999 GET_SHORT_SAME_ORDER(ptr + 2, tagElement);
06000 tagE.tag = DCM_MAKETAG(tagGroup, tagElement);
06001 GET_LONG_SAME_ORDER(ptr + 4, tagE.length);
06002 } else {
06003 GET_SHORT_REVERSE_ORDER(ptr, tagGroup);
06004 GET_SHORT_REVERSE_ORDER(ptr + 2, tagElement);
06005 tagE.tag = DCM_MAKETAG(tagGroup, tagElement);
06006 GET_LONG_REVERSE_ORDER(ptr + 4, tagE.length);
06007 }
06008 ptr += 8;
06009 if (debug)
06010 fprintf(stderr, "Sequence item: %4x %4x %d (%x)\n",
06011 tagGroup, tagElement, tagE.length, tagE.length);
06012 if (tagE.tag == DCM_DLMITEM) {
06013 /* if (size != DCM_UNSPECIFIEDLENGTH)
06014 size -= 8;
06015 */
06016 /* fileOffset += 8;
06017 */
06018 cond = readFile(name,
06019 (fileFlag) ? NULL : ptr,
06020 fd, tagE.length,
06021 fileOffset, recursionLevel + 1, opt,
06022 &sequenceObject, &sequenceLength,
06023 remainOpenFlag, ctx, rd, sk);
06024 if (cond == DCM_NORMAL) {
06025 sequenceItem = CTN_MALLOC(sizeof(*sequenceItem));
06026 if (sequenceItem == NULL)
06027 return COND_PushCondition(DCM_MALLOCFAILURE,
06028 DCM_Message(DCM_MALLOCFAILURE),
06029 sizeof(*sequenceItem), "readFile");
06030
06031 sequenceItem->object = sequenceObject;
06032 cond = LST_Enqueue(&elementItem->element.d.sq,
06033 (void *)sequenceItem);
06034 if (cond != LST_NORMAL)
06035 return COND_PushCondition(DCM_LISTFAILURE,
06036 DCM_Message(DCM_LISTFAILURE), "readFile");
06037 if (size != (long) DCM_UNSPECIFIEDLENGTH)
06038 size -= sequenceLength;
06039 fileOffset += (off_t) sequenceLength;
06040 if (scannedLength != NULL)
06041 *scannedLength += sequenceLength;
06042 (*object)->objectSize += sequenceLength;
06043 if (localLength != DCM_UNSPECIFIEDLENGTH)
06044 localLength -= sequenceLength;
06045 ptr += sequenceLength;
06046 } else
06047 return cond;
06048 } else {
06049 sequenceDone = TRUE;
06050 }
06051 if (localLength == 0)
06052 sequenceDone = TRUE;
06053 }
06054 } else {
06055 pixelFlag = (e.tag == DCM_PXLPIXELDATA);
06056 cond = newElementItem(&e, (pixelFlag == FALSE), &elementItem);
06057 if (cond != DCM_NORMAL) {
06058 (void) DCM_CloseObject(callerObject);
06059 return cond;
06060 }
06061 if (pixelFlag) {
06062 if (fileFlag)
06063 *remainOpenFlag = TRUE;
06064 elementItem->byteOrder = byteOrder;
06065 elementItem->dataOffset = fileOffset;
06066 elementItem->currentOffset = 0;
06067 if (fileFlag)
06068 elementItem->element.d.ot = NULL;
06069 else
06070 elementItem->element.d.ot = (void *) ptr;
06071 if ((*object)->pixelBitsAllocated == 8)
06072 elementItem->element.representation = DCM_OB;
06073 else
06074 elementItem->element.representation = DCM_OW;
06075 if (fileFlag) {
06076 if (fd != -1) {
06077 (void) lseek(fd, (off_t) elementItem->element.length, SEEK_CUR);
06078 } else {
06079 (*object)->sk((*object)->userCtx,
06080 elementItem->element.length, SEEK_CUR);
06081 }
06082 (*object)->fd = fd;
06083 }
06084 } else {
06085 if (fileFlag) {
06086 if (fd != -1) {
06087 nBytes = read(fd, elementItem->element.d.ot,
06088 (int) elementItem->element.length);
06089 } else {
06090 cond = (*object)->rd((*object)->userCtx,
06091 elementItem->element.d.ot,
06092 (long) elementItem->element.length, &nBytes);
06093 }
06094 if (nBytes != (int) elementItem->element.length) {
06095 (void) DCM_CloseObject(callerObject);
06096 return COND_PushCondition(DCM_FILEACCESSERROR,
06097 DCM_Message(DCM_FILEACCESSERROR), name, "readFile");
06098 }
06099 } else {
06100 (void) memcpy(elementItem->element.d.ot, ptr,
06101 elementItem->element.length);
06102 ptr += elementItem->originalDataLength;
06103 }
06104
06105 if( LITTLE_ENDIAN_ARCHITECTURE ){
06106 if (elementItem->element.representation == DCM_AT)
06107 swapATGroupElement(&elementItem->element);
06108 }
06109 if (byteOrder != BYTEORDER_SAME)
06110 swapInPlace(object, &elementItem->element);
06111 if (convertFlag) {
06112 cond = verifyFormat(elementItem);
06113 if (cond != DCM_NORMAL)
06114 return cond;
06115 }
06116 }
06117 if (size != (long) DCM_UNSPECIFIEDLENGTH)
06118 size -= elementItem->originalDataLength;
06119 fileOffset += (off_t) elementItem->originalDataLength;
06120 if (scannedLength != NULL)
06121 (*scannedLength) += elementItem->originalDataLength;
06122
06123 elementItem->paddedDataLength = elementItem->element.length;
06124 if (elementItem->paddedDataLength & 1)
06125 elementItem->paddedDataLength += 1;
06126 (*object)->objectSize += elementItem->paddedDataLength;
06127 }
06128
06129 computeVM(object, &elementItem->element);
06130
06131 if ((long) DCM_TAG_GROUP(e.tag) == lastGroup) {
06132 if ((long) DCM_TAG_ELEMENT(e.tag) <= lastElement)
06133 return COND_PushCondition(DCM_ELEMENTOUTOFORDER,
06134 DCM_Message(DCM_ELEMENTOUTOFORDER),
06135 group, element, "readFile");
06136 } else if ((long) DCM_TAG_GROUP(e.tag) > lastGroup) {
06137 } else {
06138 return COND_PushCondition(DCM_ELEMENTOUTOFORDER,
06139 DCM_Message(DCM_ELEMENTOUTOFORDER), group, element,
06140 "readFile");
06141 }
06142 lastGroup = (long) group;
06143 lastElement = (long) element;
06144
06145 if (groupItem == NULL)
06146 createGroupFlag = TRUE;
06147 else if (groupItem->group != group)
06148 createGroupFlag = TRUE;
06149 else
06150 createGroupFlag = FALSE;
06151
06152 if (createGroupFlag == TRUE) {
06153 groupItem = CTN_MALLOC(sizeof(*groupItem));
06154 if (groupItem == NULL) {
06155 (void) DCM_CloseObject(callerObject);
06156 return COND_PushCondition(DCM_ELEMENTCREATEFAILED,
06157 DCM_Message(DCM_ELEMENTCREATEFAILED),
06158 "readFile",
06159 group, 0xffff, sizeof(*groupItem));
06160 }
06161 groupItem->group = group;
06162 groupItem->baseLength = 0;
06163 groupItem->longVRAttributes = 0;
06164 groupItem->elementList = LST_Create();
06165 if (groupItem->elementList == NULL) {
06166 (void) DCM_CloseObject(callerObject);
06167 return COND_PushCondition(DCM_LISTFAILURE,
06168 DCM_Message(DCM_LISTFAILURE),
06169 "readFile");
06170 }
06171 if (LST_Enqueue(&(*object)->groupList, (void *)groupItem) != LST_NORMAL) {
06172 (void) DCM_CloseObject(callerObject);
06173 return COND_PushCondition(DCM_LISTFAILURE,
06174 DCM_Message(DCM_LISTFAILURE),
06175 "readFile");
06176 }
06177 }
06178 if (element != 0x0000)
06179 groupItem->baseLength += 8 + elementItem->paddedDataLength;
06180 if ((element == 0x0000) && ((*object)->groupLengthFlag == FALSE)) {
06181 CTN_FREE(elementItem);
06182 } else {
06183 cond = LST_Enqueue(&groupItem->elementList, (void *)elementItem);
06184 if (cond != LST_NORMAL) {
06185 (void) DCM_CloseObject(callerObject);
06186 return COND_PushCondition(DCM_LISTFAILURE,
06187 DCM_Message(DCM_LISTFAILURE),
06188 "readFile");
06189 }
06190 cond = updateObjectType(object, &elementItem->element); /* repair */
06191
06192 cond = updateSpecialElements(object, elementItem); /* repair */
06193 }
06194
06195 if (size == 0)
06196 done = TRUE;
06197
06198 #ifdef DEBUG
06199 if (debug) {
06200 /*lint -e644 */
06201 (void) fprintf(stderr, "Address: %px Group %2x, element %2x, length %ld ",
06202 elementItem,
06203 DCM_TAG_GROUP(elementItem->element.tag),
06204 DCM_TAG_ELEMENT(elementItem->element.tag),
06205 elementItem->element.length);
06206 /*lint +e644 */
06207 (void) fprintf(stderr, "Object size: %d\n", (*object)->objectSize);
06208 }
06209 #endif
06210 }
06211
06212 groupItem = (void *)LST_Head(&(*object)->groupList);
06213 if (groupItem != NULL) {
06214 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
06215 while (groupItem != NULL) {
06216 elementItem = (void *)LST_Head(&groupItem->elementList);
06217 if (elementItem != NULL) {
06218 if (DCM_TAG_ELEMENT(elementItem->element.tag) == 0x0000) {
06219 *elementItem->element.d.ul = groupItem->baseLength;
06220 }
06221 }
06222 groupItem = (void *)LST_Next(&(*object)->groupList);
06223 }
06224 }
06225 return DCM_NORMAL;
06226 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 6931 of file l_mri_dicom_hdr.c. References PRV_GROUP_ITEM::baseLength, BIG_ORDER, checkAttributeOrder(), computeVM(), COND_PushCondition(), CONDITION, CTN_FREE, CTNBOOLEAN, DCM_ELEMENT::d, DCM_ACCEPTVRMISMATCH, DCM_ALLOWREPEATELEMENTS, DCM_CloseObject(), DCM_CONVERTMASK, DCM_CreateObject(), DCM_DELETEMASK, DCM_DELETEONCLOSE, DCM_DLMITEMDELIMITATIONITEM, DCM_DLMSEQUENCEDELIMITATIONITEM, DCM_EFILM, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_FILEFORMATMASK, DCM_FORMATCONVERSION, DCM_LISTFAILURE, DCM_MAKETAG, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_ORDERBIGENDIAN, DCM_ORDERLITTLEENDIAN, DCM_ORDERMASK, DCM_ORDERNATIVE, DCM_OW, DCM_PART10FILE, DCM_PREAMBLELENGTH, DCM_REPEATEDELEMENT, DCM_REPEATELEMENTSMASK, DCM_SPECIALFORMATMASK, DCM_SQ, DCM_STREAMCOMPLETE, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UN, DCM_UNSPECIFIEDLENGTH, DCM_VRMASK, PRV_ELEMENT_ITEM::element, PRV_GROUP_ITEM::elementList, ENTRY, fd, handleGroupItem(), DCM_ELEMENT::length, LITTLE_ORDER, PRV_GROUP_ITEM::longVRAttributes, LST_Enqueue(), LST_Head(), LST_Next(), LST_NORMAL, LST_Position(), name, NATIVE_ORDER, object, offset, PRV_ELEMENT_ITEM::paddedDataLength, readData(), readGroupElement(), readPreamble(), readSequence(), readVRLength(), DCM_ELEMENT::representation, RETURN, STATUS, DCM_ELEMENT::tag, U32, updateObjectType(), and updateSpecialElements(). Referenced by DCM_OpenFile(), DCM_ReadStream(), and readSequence().
06939 {
06940 CONDITION
06941 cond;
06942 int
06943 byteOrder;
06944 long
06945 lastGroup = -1,
06946 lastElement = -1;
06947 U32
06948 sequenceLength,
06949 scannedSequenceLength;
06950 PRIVATE_OBJECT
06951 ** object;
06952 PRV_GROUP_ITEM
06953 * groupItem = NULL;
06954 DCM_ELEMENT
06955 e;
06956 CTNBOOLEAN
06957 convertFlag = FALSE,
06958 done = FALSE,
06959 knownLength = TRUE,
06960 explicitVR = FALSE,
06961 acceptVRMismatch = FALSE,
06962 part10Flag = FALSE;
06963 unsigned char
06964 *ptr = NULL;
06965 PRV_ELEMENT_ITEM
06966 * elementItem = NULL;
06967 CTNBOOLEAN
06968 fileFlag = TRUE;
06969 CONDITION flag;
06970 CTNBOOLEAN allowRepeatElements = FALSE;
06971
06972 ENTRY("readFile1") ;
06973
06974 ptr = callerBuf;
06975 if (ptr != NULL)
06976 fileFlag = FALSE;
06977
06978 if ((opt & DCM_FILEFORMATMASK) == DCM_PART10FILE) {
06979 part10Flag = TRUE;
06980 opt &= ~DCM_ORDERMASK;
06981 opt &= ~DCM_FILEFORMATMASK;
06982 opt |= DCM_EXPLICITLITTLEENDIAN;
06983 }
06984 if ((opt & DCM_SPECIALFORMATMASK) == DCM_EFILM) {
06985 part10Flag = TRUE;
06986 opt &= ~DCM_ORDERMASK;
06987 opt &= ~DCM_FILEFORMATMASK;
06988 opt |= DCM_ORDERLITTLEENDIAN;
06989 }
06990 if ((opt & DCM_REPEATELEMENTSMASK) == DCM_ALLOWREPEATELEMENTS) {
06991 allowRepeatElements = TRUE;
06992 }
06993
06994 switch (opt & DCM_ORDERMASK) {
06995 case DCM_ORDERNATIVE:
06996 byteOrder = NATIVE_ORDER;
06997 break;
06998 case DCM_ORDERLITTLEENDIAN:
06999 byteOrder = LITTLE_ORDER;
07000 break;
07001 case DCM_EXPLICITLITTLEENDIAN:
07002 byteOrder = LITTLE_ORDER;
07003 explicitVR = TRUE;
07004 break;
07005 case DCM_ORDERBIGENDIAN:
07006 byteOrder = BIG_ORDER;
07007 break;
07008 case DCM_EXPLICITBIGENDIAN:
07009 byteOrder = BIG_ORDER;
07010 explicitVR = TRUE;
07011 break;
07012 default:
07013 byteOrder = NATIVE_ORDER;
07014 break;
07015 }
07016 if ((opt & DCM_CONVERTMASK) == DCM_FORMATCONVERSION)
07017 convertFlag = TRUE;
07018 if ((opt & DCM_VRMASK) == DCM_ACCEPTVRMISMATCH)
07019 acceptVRMismatch = TRUE;
07020
07021 if (scannedLength != NULL)
07022 *scannedLength = 0;
07023
07024 cond = DCM_CreateObject(callerObject, opt);
07025 if (cond != DCM_NORMAL)
07026 RETURN( cond ) ;
07027
07028 object = (PRIVATE_OBJECT **) callerObject;
07029 if (fileFlag)
07030 strcpy((*object)->fileName, name);
07031
07032 (*object)->fd = -1;
07033 (*object)->rd = rd;
07034 (*object)->sk = sk;
07035 (*object)->userCtx = ctx;
07036 (*object)->dataOptions = 0;
07037 if (size == (long) DCM_UNSPECIFIEDLENGTH)
07038 knownLength = FALSE;
07039
07040 if ((fileFlag) && ((opt & DCM_DELETEMASK) == DCM_DELETEONCLOSE) && (recursionLevel == 0))
07041 (*object)->deleteFlag = TRUE;
07042
07043 if (parentObject != NULL)
07044 (*object)->pixelRepresentation = (*parentObject)->pixelRepresentation;
07045
07046 if (recursionLevel == 0 && part10Flag) {
07047 flag = readPreamble(name, &ptr, fd, &size, fileOffset, knownLength,
07048 object, scannedLength);
07049 if (flag != DCM_NORMAL)
07050 { STATUS("readPreamble fails"); goto abort; }
07051 }
07052 while (!done) {
07053 flag = readGroupElement(name, &ptr, fd, &size, fileOffset, knownLength,
07054 byteOrder, explicitVR, acceptVRMismatch, object,
07055 scannedLength, &e);
07056 if (flag == DCM_STREAMCOMPLETE)
07057 break;
07058 else if (flag != DCM_NORMAL)
07059 { STATUS("readGroupElement fails"); goto abort; }
07060 #if 0
07061 if (e.tag == DCM_MAKETAG(0x003a, 0x1000)) {
07062 fprintf(stderr, "Found waveform\n");
07063 }
07064 #endif
07065 flag = readVRLength(name, &ptr, fd, &size, fileOffset, knownLength,
07066 byteOrder, explicitVR, acceptVRMismatch, object,
07067 scannedLength, &e);
07068 if (flag != DCM_NORMAL)
07069 { STATUS("readVRLength fails"); goto abort; }
07070
07071 if ((e.representation == DCM_UN) &&
07072 (e.length == DCM_UNSPECIFIEDLENGTH)) {
07073 e.representation = DCM_SQ;
07074 }
07075 #ifndef SMM
07076 if ((e.tag == DCM_DLMITEMDELIMITATIONITEM) ||
07077 (e.tag == DCM_DLMSEQUENCEDELIMITATIONITEM)) {
07078 RETURN( DCM_NORMAL) ;
07079 }
07080 #else
07081 if (e.tag == DCM_DLMITEMDELIMITATIONITEM) {
07082 (*object)->objectSize -= 8;
07083 RETURN( DCM_NORMAL );
07084 }
07085 if (e.tag == DCM_DLMSEQUENCEDELIMITATIONITEM)
07086 RETURN( DCM_NORMAL );
07087 #endif
07088
07089 if (e.representation == DCM_SQ) {
07090 sequenceLength = e.length;
07091 scannedSequenceLength = 0;
07092 flag = readSequence(name, &ptr, fd, &sequenceLength,
07093 fileOffset, recursionLevel, opt,
07094 byteOrder, explicitVR, acceptVRMismatch,
07095 fileFlag, remainOpenFlag,
07096 convertFlag, object, &scannedSequenceLength,
07097 &e, &elementItem);
07098 if (flag != DCM_NORMAL)
07099 { STATUS("readSequence fails"); goto abort; }
07100 if (size != (long) DCM_UNSPECIFIEDLENGTH)
07101 size -= scannedSequenceLength;
07102 if (scannedLength != NULL)
07103 *scannedLength += scannedSequenceLength;
07104
07105 } else {
07106
07107 flag = readData(name, &ptr, fd, &size, fileOffset, knownLength,
07108 byteOrder, explicitVR, acceptVRMismatch, fileFlag,
07109 remainOpenFlag, convertFlag,
07110 object, scannedLength, &e, &elementItem);
07111 if (flag != DCM_NORMAL)
07112 { STATUS("readData fails"); goto abort; }
07113 }
07114 computeVM(object, &elementItem->element);
07115
07116 cond = checkAttributeOrder(&e, &lastGroup, &lastElement, allowRepeatElements);
07117 if (cond != DCM_NORMAL) {
07118 if (cond == DCM_REPEATEDELEMENT) {
07119 CTN_FREE(elementItem);
07120 continue;
07121 } else {
07122 CTN_FREE(elementItem); /* 14 June 2005 [rickr] */
07123 RETURN( cond ) ;
07124 }
07125 }
07126
07127 cond = handleGroupItem(object, &groupItem, DCM_TAG_GROUP(e.tag));
07128 if (cond != DCM_NORMAL)
07129 /* goto abort; ASG */ RETURN( cond );
07130
07131 if (DCM_TAG_ELEMENT(e.tag) != 0x0000) {
07132 groupItem->baseLength += 8 + elementItem->paddedDataLength;
07133 if (elementItem->element.representation == DCM_OB ||
07134 elementItem->element.representation == DCM_OW ||
07135 elementItem->element.representation == DCM_SQ) {
07136 groupItem->longVRAttributes++;
07137 (*object)->longVRAttributes++;
07138 }
07139 }
07140 if ((DCM_TAG_ELEMENT(e.tag) == 0x0000) && ((*object)->groupLengthFlag == FALSE)) {
07141 CTN_FREE(elementItem);
07142 } else {
07143 cond = LST_Enqueue(&groupItem->elementList, (void *)elementItem);
07144 if (cond != LST_NORMAL) {
07145 (void) DCM_CloseObject(callerObject);
07146 RETURN( COND_PushCondition(DCM_LISTFAILURE,
07147 DCM_Message(DCM_LISTFAILURE),
07148 "readFile") );
07149 }
07150 cond = updateObjectType(object, &elementItem->element); /* repair */
07151
07152 cond = updateSpecialElements(object, elementItem); /* repair */
07153 }
07154
07155 if (size == 0)
07156 done = TRUE;
07157
07158 if (part10Flag) {
07159 if ((*object)->objectSize == (DCM_PREAMBLELENGTH + 4 + 12 + (*object)->metaHeaderLength)) {
07160 opt &= ~DCM_ORDERMASK;
07161 opt |= (*object)->dataOptions & DCM_ORDERMASK;
07162 explicitVR = FALSE;
07163 switch (opt & DCM_ORDERMASK) {
07164 case DCM_ORDERNATIVE:
07165 byteOrder = NATIVE_ORDER;
07166 break;
07167 case DCM_ORDERLITTLEENDIAN:
07168 byteOrder = LITTLE_ORDER;
07169 break;
07170 case DCM_EXPLICITLITTLEENDIAN:
07171 byteOrder = LITTLE_ORDER;
07172 explicitVR = TRUE;
07173 break;
07174 case DCM_ORDERBIGENDIAN:
07175 byteOrder = BIG_ORDER;
07176 break;
07177 case DCM_EXPLICITBIGENDIAN:
07178 byteOrder = BIG_ORDER;
07179 explicitVR = TRUE;
07180 break;
07181 default:
07182 byteOrder = LITTLE_ORDER;
07183 explicitVR = TRUE;
07184 break;
07185 }
07186 }
07187 }
07188 }
07189
07190 #ifdef SMM
07191 #endif
07192
07193 groupItem = (void *)LST_Head(&(*object)->groupList);
07194 if (groupItem != NULL) {
07195 (void) LST_Position(&(*object)->groupList, (void *)groupItem);
07196 while (groupItem != NULL) {
07197 elementItem = (void *)LST_Head(&groupItem->elementList);
07198 if (elementItem != NULL) {
07199 if (DCM_TAG_ELEMENT(elementItem->element.tag) == 0x0000) {
07200 *elementItem->element.d.ul = groupItem->baseLength;
07201 }
07202 }
07203 groupItem = (void *)LST_Next(&(*object)->groupList);
07204 }
07205 }
07206 RETURN( DCM_NORMAL );
07207
07208 abort:
07209 RETURN (flag);
07210 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 6286 of file l_mri_dicom_hdr.c. References BYTEORDER_SAME, COND_PopCondition(), COND_PushCondition(), CONDITION, CTNBOOLEAN, ctxSensitiveLookup(), DCM_CloseObject(), DCM_CTX, DCM_DumpElements(), DCM_FILEACCESSERROR, DCM_ILLEGALSTREAMLENGTH, DCM_LookupElement(), DCM_MAKETAG, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_STREAMCOMPLETE, fd, GET_SHORT_REVERSE_ORDER, GET_SHORT_SAME_ORDER, name, object, read(), DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32. Referenced by DCM_GetCompressedValue(), readFile1(), readSequence(), and scanCompressedPixels().
06291 {
06292 unsigned char *localPtr;
06293 unsigned char buf[4];
06294 int nBytes;
06295 CONDITION cond;
06296 unsigned short group,
06297 element;
06298
06299 if (*size == 0)
06300 return DCM_STREAMCOMPLETE;
06301
06302 if ((*size < 4) && knownLength) {
06303 if (debug)
06304 (void) DCM_DumpElements((DCM_OBJECT **) object, 0);
06305 (void) DCM_CloseObject((DCM_OBJECT **) object);
06306 return COND_PushCondition(DCM_ILLEGALSTREAMLENGTH,
06307 DCM_Message(DCM_ILLEGALSTREAMLENGTH), *size,
06308 "readFile");
06309 }
06310 if (*ptr == NULL) {
06311 if (fd != -1) {
06312 nBytes = read(fd, buf, 4);
06313 } else {
06314 cond = (*object)->rd((*object)->userCtx, buf, 4, &nBytes);
06315 }
06316
06317 if (nBytes != 4)
06318 return COND_PushCondition(DCM_FILEACCESSERROR,
06319 DCM_Message(DCM_FILEACCESSERROR), name,
06320 "readGroupElement");
06321 localPtr = buf;
06322 } else {
06323 localPtr = *ptr;
06324 }
06325
06326 if (knownLength)
06327 *size -= 4;
06328 *fileOffset += (off_t) 4;
06329 if (scannedLength != NULL)
06330 (*scannedLength) += 4;
06331 (*object)->objectSize += 4;
06332
06333 if (byteOrder == BYTEORDER_SAME) {
06334 GET_SHORT_SAME_ORDER(localPtr, group);
06335 GET_SHORT_SAME_ORDER(localPtr + 2, element);
06336 e->tag = DCM_MAKETAG(group, element);
06337 } else {
06338 GET_SHORT_REVERSE_ORDER(localPtr, group);
06339 GET_SHORT_REVERSE_ORDER(localPtr + 2, element);
06340 e->tag = DCM_MAKETAG(group, element);
06341 }
06342 if (*ptr != NULL)
06343 *ptr += 4;
06344
06345 if (debug)
06346 fprintf(stderr, "%04x %04x ", group, element);
06347
06348 cond = DCM_LookupElement(e);
06349 if (cond != DCM_NORMAL)
06350 (void) COND_PopCondition(0);
06351 if (e->representation == DCM_CTX)
06352 ctxSensitiveLookup(object, e);
06353
06354 return DCM_NORMAL;
06355 }
|
|
||||||||||||||||||||
|
Definition at line 7456 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CONDITION, DCM_ELEMENT::d, DCM_CloseObject(), DCM_FILEACCESSERROR, DCM_GetElementValue(), DCM_ImportStream(), DCM_MAKETAG, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_UL, fd, fileName, read(), and U32. Referenced by DCM_OpenFile().
07458 {
07459 unsigned char buf[24];
07460 DCM_OBJECT *obj;
07461 CONDITION cond;
07462 DCM_ELEMENT e = {DCM_MAKETAG(0x0008, 0x0001), DCM_UL, "", 1, 4, NULL};
07463 void *ctx = NULL;
07464 U32 rtnLength = 0;
07465
07466 if (read(fd, buf, 24) != 24)
07467 return COND_PushCondition(DCM_FILEACCESSERROR,
07468 DCM_Message(DCM_FILEACCESSERROR), fileName,
07469 "(DCM)readLengthToEnd");
07470
07471 cond = DCM_ImportStream(buf, 24, opt, &obj);
07472 if (cond != DCM_NORMAL)
07473 return cond;
07474
07475 e.d.ul = lengthToEnd;
07476 cond = DCM_GetElementValue(&obj, &e, &rtnLength, &ctx);
07477
07478 (void) DCM_CloseObject(&obj);
07479
07480 return cond;
07481 }
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 6229 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_CloseObject(), DCM_DumpElements(), DCM_FILEACCESSERROR, DCM_ILLEGALSTREAMLENGTH, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_PREAMBLELENGTH, DCM_STREAMCOMPLETE, fd, name, object, read(), and U32. Referenced by readFile1().
06232 {
06233 int nBytes,
06234 tmp;
06235 CONDITION cond;
06236 char label[4];
06237
06238 if (*size == 0)
06239 return DCM_STREAMCOMPLETE;
06240
06241 if ((*size < DCM_PREAMBLELENGTH + 4) && knownLength) {
06242 if (debug)
06243 (void) DCM_DumpElements((DCM_OBJECT **) object, 0);
06244 (void) DCM_CloseObject((DCM_OBJECT **) object);
06245 return COND_PushCondition(DCM_ILLEGALSTREAMLENGTH,
06246 DCM_Message(DCM_ILLEGALSTREAMLENGTH), *size,
06247 "readPreamble");
06248 }
06249 if (*ptr == NULL) {
06250 if (fd != -1) {
06251 nBytes = read(fd, (*object)->preamble, DCM_PREAMBLELENGTH);
06252 nBytes += read(fd, label, sizeof(label));
06253 } else {
06254 cond = (*object)->rd((*object)->userCtx, (*object)->preamble,
06255 DCM_PREAMBLELENGTH, &nBytes);
06256 cond = (*object)->rd((*object)->userCtx, label,
06257 sizeof(label), &tmp);
06258 nBytes += tmp;
06259 }
06260
06261 if (nBytes != DCM_PREAMBLELENGTH + sizeof(label))
06262 return COND_PushCondition(DCM_FILEACCESSERROR,
06263 DCM_Message(DCM_FILEACCESSERROR), name,
06264 "readPreamble");
06265 } else {
06266 (void) memcpy((*object)->preamble, *ptr, DCM_PREAMBLELENGTH);
06267 (void) memcpy(label, (*ptr) + DCM_PREAMBLELENGTH, sizeof(label));
06268 }
06269
06270 if (knownLength)
06271 *size -= DCM_PREAMBLELENGTH + sizeof(label);
06272 *fileOffset += (off_t) DCM_PREAMBLELENGTH + sizeof(label);
06273 if (*ptr != NULL)
06274 *ptr += DCM_PREAMBLELENGTH + sizeof(label);
06275 (*object)->objectSize += DCM_PREAMBLELENGTH + sizeof(label);
06276
06277 if (strncmp(label, "DICM", 4) != 0)
06278 return 0;
06279
06280 (*object)->preambleFlag = TRUE;
06281 return DCM_NORMAL;
06282 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 6547 of file l_mri_dicom_hdr.c. References COND_PushCondition(), CONDITION, CTN_MALLOC, CTNBOOLEAN, DCM_DLMITEM, DCM_LISTFAILURE, DCM_MALLOCFAILURE, DCM_Message(), DCM_NORMAL, DCM_OBJECT, DCM_STREAMCOMPLETE, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNSPECIFIEDLENGTH, fd, DCM_ELEMENT::length, LST_Create(), LST_Enqueue(), LST_NORMAL, name, newElementItem(), DCM_SEQUENCE_ITEM::object, object, readFile1(), readGroupElement(), readVRLength(), DCM_ELEMENT::tag, U32, and PRIVATE_OBJECT::userCtx. Referenced by readFile1().
06554 {
06555 CTNBOOLEAN knownLength = TRUE;
06556 CONDITION cond;
06557 U32 sequenceLength;
06558
06559 U32 localLength;
06560 CTNBOOLEAN sequenceDone;
06561 DCM_ELEMENT tagE;
06562 DCM_OBJECT
06563 * sequenceObject;
06564 DCM_SEQUENCE_ITEM *sequenceItem;
06565 CONDITION flag;
06566 unsigned char *localPtr;
06567 off_t itemTagOffset;
06568
06569 if (*size == (long) DCM_UNSPECIFIEDLENGTH)
06570 knownLength = FALSE;
06571
06572 cond = newElementItem(e, FALSE, elementItem);
06573 if (cond != DCM_NORMAL)
06574 return cond;
06575 (*elementItem)->element.d.sq = LST_Create();
06576 if ((*elementItem)->element.d.sq == NULL)
06577 return COND_PushCondition(DCM_LISTFAILURE,
06578 DCM_Message(DCM_LISTFAILURE), "readSequence");
06579
06580 localLength = (*elementItem)->element.length;
06581 sequenceDone = (localLength == 0);
06582
06583 while (!sequenceDone) {
06584 if (debug)
06585 fprintf(stderr, "Sequence Length: %d %x\n", localLength,
06586 localLength);
06587
06588 sequenceLength = 0;
06589 itemTagOffset = *fileOffset;
06590
06591 flag = readGroupElement(name, ptr, fd, &localLength, fileOffset, knownLength,
06592 byteOrder, explicitVR, acceptVRMismatch, object, &sequenceLength, &tagE);
06593 if (flag == DCM_STREAMCOMPLETE)
06594 break;
06595 else if (flag != DCM_NORMAL)
06596 return flag;
06597
06598 flag = readVRLength(name, ptr, fd, &localLength, fileOffset, knownLength,
06599 byteOrder, explicitVR, acceptVRMismatch, object,
06600 &sequenceLength, &tagE);
06601 if (flag != DCM_NORMAL)
06602 return flag;
06603
06604 if (*size != (long) DCM_UNSPECIFIEDLENGTH)
06605 *size -= sequenceLength;
06606 if (scannedLength != NULL)
06607 *scannedLength += sequenceLength;
06608
06609 sequenceLength = 0;
06610
06611
06612 if (debug)
06613 fprintf(stderr, "Sequence item: %4x %4x %d (%x)\n",
06614 DCM_TAG_GROUP(tagE.tag),
06615 DCM_TAG_ELEMENT(tagE.tag), tagE.length, tagE.length);
06616 if (tagE.tag == DCM_DLMITEM) {
06617 localPtr = *ptr;
06618 cond = readFile1(name,
06619 localPtr,
06620 fd, tagE.length,
06621 fileOffset, recursionLevel + 1, opt,
06622 object, &sequenceObject, &sequenceLength,
06623 remainOpenFlag, (*object)->userCtx, (*object)->rd,
06624 (*object)->sk);
06625 *ptr = localPtr;
06626 if (cond == DCM_NORMAL) {
06627 sequenceItem = CTN_MALLOC(sizeof(*sequenceItem));
06628 if (sequenceItem == NULL)
06629 return COND_PushCondition(DCM_MALLOCFAILURE,
06630 DCM_Message(DCM_MALLOCFAILURE),
06631 sizeof(*sequenceItem), "readFile");
06632
06633 ((PRIVATE_OBJECT *) sequenceObject)->offset = itemTagOffset;
06634 sequenceItem->object = sequenceObject;
06635 cond = LST_Enqueue(&(*elementItem)->element.d.sq,
06636 (void *)sequenceItem);
06637 if (cond != LST_NORMAL)
06638 return COND_PushCondition(DCM_LISTFAILURE,
06639 DCM_Message(DCM_LISTFAILURE), "readFile");
06640 if (*size != (long) DCM_UNSPECIFIEDLENGTH)
06641 *size -= sequenceLength;
06642 if (scannedLength != NULL)
06643 *scannedLength += sequenceLength;
06644 (*object)->objectSize += sequenceLength;
06645 if (localLength != DCM_UNSPECIFIEDLENGTH)
06646 localLength -= sequenceLength;
06647 } else
06648 return cond;
06649 } else {
06650 sequenceDone = TRUE;
06651 }
06652 if (localLength == 0)
06653 sequenceDone = TRUE;
06654 }
06655 return DCM_NORMAL;
06656 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 6358 of file l_mri_dicom_hdr.c. References BYTEORDER_SAME, COND_PushCondition(), CONDITION, CTNBOOLEAN, DCM_CloseObject(), DCM_CTX, DCM_DLM, DCM_DumpElements(), DCM_ELEMENTLENGTHERROR, DCM_FILEACCESSERROR, DCM_ILLEGALSTREAMLENGTH, DCM_Message(), DCM_NORMAL, DCM_OB, DCM_OBJECT, DCM_OW, DCM_PXLPIXELDATA, DCM_RET, DCM_SQ, DCM_STREAMCOMPLETE, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UN, DCM_UNEVENELEMENTLENGTH, DCM_UNRECOGNIZEDVRCODE, DCM_UNSPECIFIEDLENGTH, DCM_UT, DCM_VRMISMATCH, DCM_ELEMENT::description, ENTRY, fd, GET_LONG_REVERSE_ORDER, GET_LONG_SAME_ORDER, GET_SHORT_REVERSE_ORDER, GET_SHORT_SAME_ORDER, DCM_ELEMENT::length, lookupVRCode(), mapVRtoASCII(), name, object, read(), VRMAP::representation, DCM_ELEMENT::representation, RETURN, rwc_err, STATUS, DCM_ELEMENT::tag, and U32. Referenced by DCM_GetCompressedValue(), readFile1(), readSequence(), and scanCompressedPixels().
06363 {
06364 unsigned char *localPtr;
06365 unsigned char buf[4];
06366 char vrCode[3];
06367 VRMAP *vrPtr;
06368 int nBytes;
06369 CONDITION cond;
06370 CTNBOOLEAN calculatedLength = FALSE;
06371
06372 ENTRY("readVRLength") ;
06373
06374 if (*size == 0)
06375 RETURN( DCM_STREAMCOMPLETE );
06376
06377 if ((*size < 4) && knownLength) {
06378 if (debug)
06379 (void) DCM_DumpElements((DCM_OBJECT **) object, 0);
06380 (void) DCM_CloseObject((DCM_OBJECT **) object);
06381 RETURN( COND_PushCondition(DCM_ILLEGALSTREAMLENGTH,
06382 DCM_Message(DCM_ILLEGALSTREAMLENGTH), *size,
06383 "readVRLength") );
06384 }
06385 if (*ptr == NULL) {
06386 if (fd != -1) {
06387 nBytes = read(fd, buf, 4);
06388 } else {
06389 cond = (*object)->rd((*object)->userCtx, buf, 4, &nBytes);
06390 }
06391
06392 if (nBytes != 4)
06393 RETURN( COND_PushCondition(DCM_FILEACCESSERROR,
06394 DCM_Message(DCM_FILEACCESSERROR), name,
06395 "readVRLength") ) ;
06396 localPtr = buf;
06397 } else
06398 localPtr = *ptr;
06399
06400 if (knownLength)
06401 *size -= 4;
06402 *fileOffset += (off_t) 4;
06403 if (scannedLength != NULL)
06404 (*scannedLength) += 4;
06405 (*object)->objectSize += 4;
06406
06407 e->length = 0;
06408 if (e->representation == DCM_DLM) {
06409 explicitVR = FALSE; /* Special rule for delimitors */
06410 }
06411 if (explicitVR) {
06412 vrCode[0] = buf[0];
06413 vrCode[1] = buf[1];
06414 vrCode[2] = '\0';
06415 vrPtr = lookupVRCode(vrCode);
06416 if (vrPtr == NULL){
06417 if( rwc_err ){
06418 fprintf(stderr,"** DICOM ERROR: unknown VR code %s in element (%04x,%04x)\n", /* RWC */
06419 vrCode,DCM_TAG_GROUP(e->tag), DCM_TAG_ELEMENT(e->tag) ) ; rwc_err-- ;
06420 }
06421 RETURN( COND_PushCondition(DCM_UNRECOGNIZEDVRCODE,
06422 DCM_Message(DCM_UNRECOGNIZEDVRCODE), vrCode,
06423 "readVRLength") );
06424 }
06425
06426 if (vrPtr->representation != e->representation) {
06427 if (vrPtr->representation == DCM_OB) {
06428 /* This is probably from the waveform supplement where they */
06429 /* transmit as OB and expect us to pull it out later */
06430 /* We will just keep our VR which was based on context in */
06431 /* the object */
06432 e->representation = vrPtr->representation;
06433 } else if (e->representation == DCM_UN ||
06434 e->representation == DCM_CTX ||
06435 e->representation == DCM_RET ||
06436 vrPtr->representation == DCM_OW ||
06437 acceptVRMismatch) { /* Believe input */
06438 e->representation = vrPtr->representation;
06439 } else {
06440 #if 0
06441 if (e->tag != DCM_PXLPIXELDATA){
06442 STATUS("VR mismatch") ;
06443 RETURN( COND_PushCondition(DCM_VRMISMATCH,
06444 DCM_Message(DCM_VRMISMATCH), vrCode, e->tag));
06445 }
06446 #else
06447 if( rwc_err ){
06448 fprintf(stderr,"++ DICOM WARNING: VR mismatch in element (%04x,%04x)\n", /* RWC */
06449 DCM_TAG_GROUP(e->tag), DCM_TAG_ELEMENT(e->tag) ) ; rwc_err-- ;
06450 }
06451 e->representation = vrPtr->representation;
06452 #endif
06453 }
06454 }
06455 if (vrPtr->representation != DCM_OW &&
06456 vrPtr->representation != DCM_OB &&
06457 vrPtr->representation != DCM_UN &&
06458 vrPtr->representation != DCM_UT &&
06459 vrPtr->representation != DCM_SQ) {
06460 unsigned short shortLength;
06461 if (byteOrder == BYTEORDER_SAME) {
06462 GET_SHORT_SAME_ORDER(localPtr + 2, shortLength);
06463 } else {
06464 GET_SHORT_REVERSE_ORDER(localPtr + 2, shortLength);
06465 }
06466 e->length = shortLength;
06467 if (*ptr != NULL)
06468 *ptr += 4;
06469 calculatedLength = TRUE;
06470 } else {
06471 if ((*size < 4) && knownLength) {
06472 if (debug)
06473 (void) DCM_DumpElements((DCM_OBJECT **) object, 0);
06474 (void) DCM_CloseObject((DCM_OBJECT **) object);
06475 RETURN( COND_PushCondition(DCM_ILLEGALSTREAMLENGTH,
06476 DCM_Message(DCM_ILLEGALSTREAMLENGTH), *size,
06477 "readVRLength"));
06478 }
06479 if (*ptr == NULL) {
06480 if (fd != -1) {
06481 nBytes = read(fd, buf, 4);
06482 } else {
06483 cond = (*object)->rd((*object)->userCtx, buf, 4, &nBytes);
06484 }
06485
06486 if (nBytes != 4)
06487 RETURN( COND_PushCondition(DCM_FILEACCESSERROR,
06488 DCM_Message(DCM_FILEACCESSERROR), name,
06489 "readVRLength"));
06490 localPtr = buf;
06491 } else
06492 localPtr = *ptr;
06493
06494 if (knownLength)
06495 *size -= 4;
06496 *fileOffset += (off_t) 4;
06497 if (scannedLength != NULL)
06498 (*scannedLength) += 4;
06499 (*object)->objectSize += 4;
06500 }
06501 }
06502 if (!calculatedLength) {
06503 if (byteOrder == BYTEORDER_SAME) {
06504 GET_LONG_SAME_ORDER(localPtr, e->length);
06505 } else {
06506 GET_LONG_REVERSE_ORDER(localPtr, e->length);
06507 }
06508 if (*ptr != NULL)
06509 *ptr += 4;
06510 }
06511 if (debug) {
06512 char localVR[10];
06513 mapVRtoASCII(e->representation, localVR);
06514 fprintf(stderr, "%2s %6d %06x %s\n", localVR, e->length,
06515 (unsigned int)*fileOffset, e->description);
06516 }
06517 if (((e->length & 1) != 0) && (e->length != DCM_UNSPECIFIEDLENGTH)) {
06518 if (debug)
06519 (void) DCM_DumpElements((DCM_OBJECT **) object, 0);
06520 (void) DCM_CloseObject((DCM_OBJECT **) object);
06521 if( rwc_err ){
06522 fprintf(stderr,"** DICOM ERROR: illegal odd length=%d in element (%04x,%04x)\n", /* RWC */
06523 e->length,DCM_TAG_GROUP(e->tag), DCM_TAG_ELEMENT(e->tag) ) ; rwc_err-- ;
06524 }
06525 RETURN( COND_PushCondition(DCM_UNEVENELEMENTLENGTH,
06526 DCM_Message(DCM_UNEVENELEMENTLENGTH),
06527 DCM_TAG_GROUP(e->tag), DCM_TAG_ELEMENT(e->tag),
06528 e->length, "readFile"));
06529 }
06530 if ((e->length != (U32) DCM_UNSPECIFIEDLENGTH) && (e->length > (U32) (*size))) {
06531 if (debug)
06532 (void) DCM_DumpElements((DCM_OBJECT **) object, 0);
06533 (void) DCM_CloseObject((DCM_OBJECT **) object);
06534 if( rwc_err ){
06535 fprintf(stderr,"** DICOM ERROR: oversize length=%d in element (%04x,%04x)\n", /* RWC */
06536 e->length,DCM_TAG_GROUP(e->tag), DCM_TAG_ELEMENT(e->tag) ) ; rwc_err-- ;
06537 }
06538 RETURN( COND_PushCondition(DCM_ELEMENTLENGTHERROR,
06539 DCM_Message(DCM_ELEMENTLENGTHERROR),
06540 DCM_TAG_GROUP(e->tag), DCM_TAG_ELEMENT(e->tag),
06541 e->length, *size, "readFile"));
06542 }
06543 RETURN( DCM_NORMAL);
06544 }
|
|
||||||||||||
|
Definition at line 7641 of file l_mri_dicom_hdr.c. Referenced by DCM_OpenFile().
|
|
|
Definition at line 115 of file l_mri_dicom_hdr.c. References free, npbuf, and pbuf.
|
|
||||||||||||
|
Definition at line 120 of file l_mri_dicom_hdr.c. References AFMALL, AFREALL, npbuf, NPBUF, and pbuf. Referenced by DCM_DumpElements(), DCM_DumpVector(), DCM_FormatElements(), DCM_PrintSequenceList(), dumpOB(), dumpSL(), dumpSS(), dumpUL(), dumpUS(), exportEncapsulatedPixels(), and mri_dicom_header().
00121 {
00122 static char *sbuf = NULL ;
00123 int nsbuf , nn , lpbuf ;
00124 va_list vararg_ptr ;
00125
00126 va_start( vararg_ptr , fmt ) ;
00127
00128 if( sbuf == NULL ) sbuf = AFMALL( char, NPBUF) ; /* 1st time in */
00129
00130 sbuf[0] = '\0' ;
00131 nn = vsprintf( sbuf , fmt , vararg_ptr ) ;
00132 va_end( vararg_ptr ) ;
00133 nsbuf = strlen(sbuf) ;
00134 if( nsbuf == 0 ) return(0);
00135
00136 if( npbuf == 0 ){
00137 pbuf = AFMALL(char,NPBUF) ; npbuf = NPBUF ; pbuf[0] = '\0' ;
00138 }
00139
00140 lpbuf = strlen(pbuf) ;
00141 if( lpbuf+nsbuf+8 > npbuf ){
00142 npbuf += NPBUF; pbuf = AFREALL( pbuf, char, npbuf);
00143 }
00144
00145 strcat(pbuf,sbuf) ;
00146 return(nn);
00147 }
|
|
|
Definition at line 87 of file l_mri_dicom_hdr.c. References BIG_ORDER, BYTEORDER_REVERSE, BYTEORDER_SAME, LITTLE_ENDIAN_ARCHITECTURE, and LITTLE_ORDER.
00088 {
00089 union { unsigned char bb[2] ;
00090 short ss ; } fred ;
00091
00092 if( LITTLE_ENDIAN_ARCHITECTURE < 0 ){
00093 fred.bb[0] = 1 ; fred.bb[1] = 0 ;
00094
00095 LITTLE_ENDIAN_ARCHITECTURE = (fred.ss == 1) ;
00096
00097 if( LITTLE_ENDIAN_ARCHITECTURE ){
00098 LITTLE_ORDER = BYTEORDER_SAME ;
00099 BIG_ORDER = BYTEORDER_REVERSE ;
00100 } else {
00101 BIG_ORDER = BYTEORDER_SAME ;
00102 LITTLE_ORDER = BYTEORDER_REVERSE ;
00103 }
00104 }
00105 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 6659 of file l_mri_dicom_hdr.c. References CONDITION, CTNBOOLEAN, DCM_DLMITEM, DCM_NORMAL, DCM_STREAMCOMPLETE, DCM_TAG_ELEMENT, DCM_TAG_GROUP, DCM_UNSPECIFIEDLENGTH, fd, DCM_ELEMENT::length, name, object, readGroupElement(), readVRLength(), DCM_ELEMENT::tag, and U32. Referenced by readData().
06667 {
06668 CTNBOOLEAN knownLength = TRUE;
06669 U32 sequenceLength;
06670 U32 scannedBytes = 0;
06671
06672 U32 localLength;
06673 CTNBOOLEAN sequenceDone;
06674 DCM_ELEMENT tagE;
06675 CONDITION flag;
06676 unsigned char *localPtr;
06677
06678 if (*size == (long) DCM_UNSPECIFIEDLENGTH)
06679 knownLength = FALSE;
06680
06681 localLength = (*elementItem)->element.length;
06682 sequenceDone = (localLength == 0);
06683
06684 while (!sequenceDone) {
06685 sequenceLength = 0;
06686 flag = readGroupElement(name, ptr, fd, &localLength, fileOffset,
06687 FALSE, byteOrder, explicitVR, acceptVRMismatch,
06688 object, &sequenceLength, &tagE);
06689 if (flag == DCM_STREAMCOMPLETE)
06690 break;
06691 else if (flag != DCM_NORMAL)
06692 return flag;
06693
06694 flag = readVRLength(name, ptr, fd, &localLength, fileOffset, knownLength,
06695 byteOrder, explicitVR, acceptVRMismatch, object,
06696 &sequenceLength, &tagE);
06697 if (flag != DCM_NORMAL)
06698 return flag;
06699
06700 if (*size != (long) DCM_UNSPECIFIEDLENGTH)
06701 *size -= sequenceLength;
06702 if (scannedLength != NULL)
06703 *scannedLength += sequenceLength;
06704 scannedBytes += sequenceLength;
06705
06706 if (debug)
06707 fprintf(stderr, "Sequence item: %4x %4x %d (%x)\n",
06708 DCM_TAG_GROUP(tagE.tag),
06709 DCM_TAG_ELEMENT(tagE.tag), tagE.length, tagE.length);
06710 if (tagE.tag == DCM_DLMITEM) {
06711 localPtr = *ptr;
06712 if (tagE.length != 0) {
06713 lseek(fd, tagE.length, SEEK_CUR);
06714 *fileOffset += tagE.length;
06715 if (*size != (long) DCM_UNSPECIFIEDLENGTH)
06716 *size -= tagE.length;
06717 if (scannedLength != NULL)
06718 *scannedLength += tagE.length;
06719 }
06720 } else {
06721 sequenceDone = TRUE;
06722 }
06723 if (localLength == 0)
06724 sequenceDone = TRUE;
06725
06726 if (debug)
06727 fprintf(stderr, "Scanned Bytes: %d\n", scannedBytes);
06728 }
06729 if ((scannedBytes & 1) != 0) {
06730 lseek(fd, 1, SEEK_CUR);
06731 *fileOffset += 1;
06732 if (*size != (long) DCM_UNSPECIFIEDLENGTH)
06733 *size -= 1;
06734 }
06735 return DCM_NORMAL;
06736 }
|
|
||||||||||||
|
Definition at line 5060 of file l_mri_dicom_hdr.c. References CONDITION, DCM_ELEMENT::d, DCM_ENCAPSULATEDPIXELS, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_METATRANSFERSYNTAX, DCM_NORMAL, DCM_OBJECT, DCM_ORDERLITTLEENDIAN, DCM_ParseObject(), DCM_UI, DICOM_TRANSFERBIGENDIANEXPLICIT, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIANEXPLICIT, and DICOM_UI_LENGTH. Referenced by exportStream().
05061 {
05062 CONDITION cond;
05063 char xferSyntax[DICOM_UI_LENGTH + 1];
05064 DCM_ELEMENT e = {DCM_METATRANSFERSYNTAX, DCM_UI, "", 1, sizeof(xferSyntax),
05065 NULL};
05066
05067 e.d.string = xferSyntax;
05068 cond = DCM_ParseObject(obj, &e, 1, NULL, 0, NULL);
05069 if (cond != DCM_NORMAL)
05070 return cond;
05071
05072 *opt = 0;
05073 if (strcmp(xferSyntax, DICOM_TRANSFERLITTLEENDIAN) == 0) {
05074 *opt = DCM_ORDERLITTLEENDIAN;
05075 } else if (strcmp(xferSyntax, DICOM_TRANSFERLITTLEENDIANEXPLICIT) == 0) {
05076 *opt = DCM_EXPLICITLITTLEENDIAN;
05077 } else if (strcmp(xferSyntax, DICOM_TRANSFERBIGENDIANEXPLICIT) == 0) {
05078 *opt = DCM_EXPLICITBIGENDIAN;
05079 } else { /* Must be an encapsulated xfer syntax */
05080 *opt = DCM_ENCAPSULATEDPIXELS;
05081 }
05082
05083 return DCM_NORMAL;
05084 }
|
|
|
Definition at line 7484 of file l_mri_dicom_hdr.c. References DCM_ELEMENT::d, DCM_ELEMENT::length, and U32. Referenced by copyData(), DCM_GetElementValue(), DCM_GetElementValueOffset(), exportData(), readData(), and readFile().
|
|
||||||||||||
|
Definition at line 4925 of file l_mri_dicom_hdr.c. References DCM_ELEMENT::d, DCM_AT, DCM_OW, DCM_PXLPIXELDATA, DCM_SL, DCM_SS, DCM_UL, DCM_US, DCM_ELEMENT::length, object, DCM_ELEMENT::representation, DCM_ELEMENT::tag, and U32. Referenced by copyData(), DCM_GetCompressedValue(), DCM_GetElementValue(), DCM_GetElementValueOffset(), exportData(), readData(), and readFile().
04926 {
04927 U32
04928 length;
04929 unsigned char
04930 tmp,
04931 *p1;
04932
04933 length = e->length;
04934 p1 = e->d.ot;
04935 if (e->representation == DCM_US || e->representation == DCM_SS ||
04936 e->representation == DCM_OW || e->representation == DCM_AT) {
04937 if (e->tag == DCM_PXLPIXELDATA &&
04938 (*object)->pixelBitsAllocated != 16)
04939 return;
04940
04941 while (length > 0) {
04942 tmp = p1[0];
04943 p1[0] = p1[1];
04944 p1[1] = tmp;
04945 p1 += 2;
04946 length -= 2;
04947 }
04948 } else if (e->representation == DCM_UL || e->representation == DCM_SL) {
04949 while (length > 0) {
04950 tmp = p1[0];
04951 p1[0] = p1[3];
04952 p1[3] = tmp;
04953 tmp = p1[1];
04954 p1[1] = p1[2];
04955 p1[2] = tmp;
04956 length -= 4;
04957 p1 += 4;
04958 }
04959 }
04960 }
|
|
||||||||||||
|
Definition at line 4041 of file l_mri_dicom_hdr.c. References DCM_GROUPCOMMAND, DCM_NORMAL, DCM_OBJECTCOMMAND, DCM_OBJECTELEMENTLIST, DCM_OBJECTIMAGE, DCM_OBJECTUNKNOWN, DCM_TAG_GROUP, object, and DCM_ELEMENT::tag. Referenced by DCM_AddElement(), DCM_AddSequenceElement(), readFile(), and readFile1().
04042 {
04043 switch ((*object)->objectType) {
04044 case DCM_OBJECTUNKNOWN:
04045 if (DCM_TAG_GROUP(element->tag) == DCM_GROUPCOMMAND)
04046 (*object)->objectType = DCM_OBJECTCOMMAND;
04047 else
04048 (*object)->objectType = DCM_OBJECTELEMENTLIST;
04049 break;
04050 case DCM_OBJECTCOMMAND:
04051 if (DCM_TAG_GROUP(element->tag) != DCM_GROUPCOMMAND)
04052 (*object)->objectType = DCM_OBJECTELEMENTLIST;
04053 break;
04054 case DCM_OBJECTELEMENTLIST:
04055 case DCM_OBJECTIMAGE:
04056 break;
04057 default:
04058 break;
04059 }
04060 return DCM_NORMAL;
04061 }
|
|
||||||||||||
|
Definition at line 4084 of file l_mri_dicom_hdr.c. References DCM_ELEMENT::d, DCM_EXPLICITBIGENDIAN, DCM_EXPLICITLITTLEENDIAN, DCM_IMGBITSALLOCATED, DCM_IMGPIXELREPRESENTATION, DCM_MAKETAG, DCM_METAGROUPLENGTH, DCM_METATRANSFERSYNTAX, DCM_NORMAL, DCM_ORDERLITTLEENDIAN, DICOM_TRANSFERBIGENDIANEXPLICIT, DICOM_TRANSFERLITTLEENDIAN, DICOM_TRANSFERLITTLEENDIANEXPLICIT, PRV_ELEMENT_ITEM::element, idx, DCM_ELEMENT::length, object, and DCM_ELEMENT::tag. Referenced by insertNewElement(), insertThisElementItem(), readFile(), and readFile1().
04086 {
04087 int idx;
04088
04089 switch (item->element.tag) {
04090 case DCM_IMGBITSALLOCATED:
04091 (*object)->pixelBitsAllocated = *item->element.d.us;
04092 break;
04093 case DCM_IMGPIXELREPRESENTATION:
04094 (*object)->pixelRepresentation = *item->element.d.us;
04095 break;
04096 case DCM_METAGROUPLENGTH:
04097 (*object)->metaHeaderLength = *item->element.d.ul;
04098 break;
04099 case DCM_METATRANSFERSYNTAX:
04100 if (strcmp(item->element.d.string, DICOM_TRANSFERLITTLEENDIAN) == 0) {
04101 (*object)->dataOptions = DCM_ORDERLITTLEENDIAN;
04102 } else if (strcmp(item->element.d.string, DICOM_TRANSFERLITTLEENDIANEXPLICIT) == 0) {
04103 (*object)->dataOptions = DCM_EXPLICITLITTLEENDIAN;
04104 } else if (strcmp(item->element.d.string, DICOM_TRANSFERBIGENDIANEXPLICIT) == 0) {
04105 (*object)->dataOptions = DCM_EXPLICITBIGENDIAN;
04106 } else { /* Must be an encapsulated transfer syntax */
04107 (*object)->dataOptions = DCM_EXPLICITLITTLEENDIAN;
04108 }
04109 break;
04110 case DCM_MAKETAG(0x003a, 0x0103):
04111 strncpy((*object)->waveformDataVR, item->element.d.string,
04112 item->element.length);
04113 (*object)->waveformDataVR[item->element.length] = '\0';
04114 idx = item->element.length - 1;
04115 while (idx >= 0 && (*object)->waveformDataVR[idx] == ' ') {
04116 (*object)->waveformDataVR[idx] = '\0';
04117 idx--;
04118 }
04119 break;
04120 default:
04121 break;
04122 }
04123 return DCM_NORMAL;
04124 }
|
|
|
Definition at line 11483 of file l_mri_dicom_hdr.c. Referenced by UTL_DateMatch().
11484 {
11485
11486 char
11487 year[5],
11488 month[3],
11489 day[3];
11490
11491 strncpy(year, date, 4);
11492 year[4] = '\000';
11493 strncpy(month, date + 4, 2);
11494 month[2] = '\000';
11495 strncpy(day, date + 6, 2);
11496 day[2] = '\000';
11497
11498 return ((atol(year) * 10000) + (atol(month) * 100) + atol(day));
11499 }
|
|
||||||||||||
|
Definition at line 11608 of file l_mri_dicom_hdr.c. References dt.
11609 {
11610 int
11611 hour,
11612 minute,
11613 second,
11614 fracsec;
11615
11616 hour = (int) (dt / 3600.0);
11617 dt -= (hour * 3600);
11618
11619 minute = (int) (dt / 60.);
11620 dt -= (minute * 60);
11621
11622 second = (int) dt;
11623 dt -= second;
11624
11625 fracsec = (int) ((dt * 1000000) + 0.5);
11626
11627 sprintf(time, "%02d%02d%02d.%06d", hour, minute, second, fracsec);
11628
11629 return;
11630 }
|
|
||||||||||||
|
Definition at line 11505 of file l_mri_dicom_hdr.c.
11506 {
11507
11508 int
11509 year,
11510 month,
11511 day;
11512
11513 year = ld / 10000;
11514 ld -= (year * 10000);
11515 month = ld / 100;
11516 ld -= (month * 100);
11517 day = ld;
11518
11519 sprintf(date, "%04d%02d%02d", year, month, day);
11520
11521 return;
11522 }
|
|
|
Definition at line 11528 of file l_mri_dicom_hdr.c. Referenced by UTL_TimeMatch().
11529 {
11530
11531 size_t
11532 i;
11533 char
11534 hour[3],
11535 minute[3],
11536 second[3],
11537 fracsec[7];
11538 const char *p;
11539 double
11540 divisor,
11541 hh,
11542 mm,
11543 ss,
11544 fs;
11545
11546 hh = mm = ss = fs = 0.0;
11547 hour[0] = minute[0] = second[0] = fracsec[0] = '\000';
11548
11549 p = time;
11550 /*
11551 * Just a brute force way to tear down a Dicom time...not very pretty,
11552 * but it works... We are not guaranteed to have every field present as
11553 * we are in the date...
11554 */
11555 hour[0] = *p++;
11556 hour[1] = *p++;
11557 hour[2] = '\000';
11558 if (isdigit(*p)) {
11559 minute[0] = *p++;
11560 minute[1] = *p++;
11561 minute[2] = '\000';
11562 if (isdigit(*p)) {
11563 second[0] = *p++;
11564 second[1] = *p++;
11565 second[2] = '\000';
11566 if (*p == '.') {
11567 p++;
11568 fracsec[0] = *p++;
11569 if ((*p != '\000') && (isdigit(*p))) {
11570 fracsec[1] = *p++;
11571 if ((*p != '\000') && (isdigit(*p))) {
11572 fracsec[2] = *p++;
11573 if ((*p != '\000') && (isdigit(*p))) {
11574 fracsec[3] = *p++;
11575 if ((*p != '\000') && (isdigit(*p))) {
11576 fracsec[4] = *p++;
11577 if ((*p != '\000') && (isdigit(*p))) {
11578 fracsec[5] = *p++;
11579 fracsec[6] = '\000';
11580 } else
11581 fracsec[5] = '\000';
11582 } else
11583 fracsec[4] = '\000';
11584 } else
11585 fracsec[3] = '\000';
11586 } else
11587 fracsec[2] = '\000';
11588 } else
11589 fracsec[1] = '\000';
11590 }
11591 }
11592 }
11593 hh = atof(hour);
11594 mm = atof(minute);
11595 ss = atof(second);
11596 divisor = 1;
11597 for (i = 0; i < strlen(fracsec); i++)
11598 divisor *= 10;
11599 fs = atof(fracsec) / divisor;
11600
11601 return ((hh * 3600.0) + (mm * 60.0) + ss + fs);
11602 }
|
|
||||||||||||
|
Definition at line 11660 of file l_mri_dicom_hdr.c. References free, malloc, UTL_ConvertDatetoLong(), and UTL_SqueezeBlanks().
11661 {
11662
11663 int
11664 match;
11665 char
11666 *ndate;
11667 long
11668 start_date,
11669 end_date,
11670 date_in_question;
11671
11672 if ((ndate = (char *) malloc(strlen(datestring) + 1)) == (char *) NULL)
11673 return (UTL_NOMATCH);
11674
11675 strcpy(ndate, datestring);
11676 UTL_SqueezeBlanks(ndate);
11677 UTL_SqueezeBlanks(stm);
11678
11679 match = 0;
11680 if (strchr(ndate, (int) '-') == (char *) NULL) {
11681 if (strcmp(ndate, stm) == 0)
11682 match = 1;
11683 } else {
11684 date_in_question = UTL_ConvertDatetoLong(stm);
11685 if (ndate[0] == '-') {
11686 end_date = UTL_ConvertDatetoLong(ndate + 1);
11687 if (date_in_question <= end_date)
11688 match = 1;
11689 } else if (ndate[strlen(ndate) - 1] == '-') {
11690 start_date = UTL_ConvertDatetoLong(ndate);
11691 if (date_in_question >= start_date)
11692 match = 1;
11693 } else {
11694 start_date = UTL_ConvertDatetoLong(ndate);
11695 end_date = UTL_ConvertDatetoLong(strchr(ndate, (int) '-') + 1);
11696 if ((date_in_question >= start_date) &&
11697 (date_in_question <= end_date))
11698 match = 1;
11699 }
11700 }
11701 free(ndate);
11702 if (match)
11703 return (UTL_MATCH);
11704 else
11705 return (UTL_NOMATCH);
11706 }
|
|
|
Definition at line 11827 of file l_mri_dicom_hdr.c.
11828 {
11829 struct timeval timeNow;
11830 UTL_TIMESTRUCTURE *t;
11831 double delta = 0.;
11832
11833 gettimeofday(&timeNow, NULL);
11834
11835 t = (UTL_TIMESTRUCTURE *) timeStamp;
11836 if (t == NULL)
11837 return -1.0;
11838
11839 if (strcmp(t->key, "UTL STAMP") != 0)
11840 return -1.0;
11841
11842 delta = timeNow.tv_sec - t->t.tv_sec;
11843 delta += (timeNow.tv_usec - t->t.tv_usec) / 1000000.;
11844
11845 return delta;
11846 }
|
|
|
Definition at line 11763 of file l_mri_dicom_hdr.c.
11764 {
11765
11766 struct tm
11767 *tf;
11768 time_t
11769 loctime;
11770
11771 loctime = time((time_t *) NULL);
11772 tf = localtime(&loctime);
11773
11774 sprintf(datestr, "%04d%02d%02d", (tf->tm_year) + 1900, (tf->tm_mon) + 1, tf->tm_mday);
11775 return;
11776
11777 }
|
|
|
Definition at line 11783 of file l_mri_dicom_hdr.c.
11784 {
11785
11786 struct tm
11787 *tf;
11788 time_t
11789 loctime;
11790
11791 loctime = time((time_t *) NULL);
11792 tf = localtime(&loctime);
11793
11794 sprintf(timestr, "%02d%02d%02d.%06d", (tf->tm_hour), (tf->tm_min), (tf->tm_sec), 0);
11795 return;
11796 }
|
|
|
Definition at line 11811 of file l_mri_dicom_hdr.c. References AFMALL, UTL_TIMESTRUCTURE::key, and UTL_TIMESTRUCTURE::t.
11812 {
11813 UTL_TIMESTRUCTURE *t;
11814
11815 t = AFMALL( UTL_TIMESTRUCTURE, sizeof(*t));
11816 if (t == NULL)
11817 return NULL;
11818
11819 strcpy(t->key, "UTL STAMP");
11820
11821 gettimeofday(&t->t, NULL);
11822
11823 return t;
11824 }
|
|
|
Definition at line 11954 of file l_mri_dicom_hdr.c. References CTNBOOLEAN, i, and S_ISDIR.
11955 {
11956 int i;
11957 #ifdef _MSC_VER
11958 struct _stat buf;
11959 #else
11960 struct stat buf;
11961 #endif
11962
11963 int flag = 0;
11964
11965 #ifdef _MSC_VER
11966 i = _stat(path, &buf);
11967 #else
11968 i = stat(path, &buf);
11969 #endif
11970
11971
11972 if (i == 0) {
11973 #ifdef _MSC_VER
11974 flag = ((buf.st_mode & _S_IFDIR) != 0);
11975 #else
11976 flag = (S_ISDIR(buf.st_mode));
11977 #endif
11978 if (flag)
11979 return TRUE;
11980 }
11981 return FALSE;
11982 }
|
|
|
Definition at line 11849 of file l_mri_dicom_hdr.c. References free, and UTL_TIMESTRUCTURE::key.
11850 {
11851 UTL_TIMESTRUCTURE *t;
11852
11853 t = (UTL_TIMESTRUCTURE *) timeStamp;
11854 if (t == NULL)
11855 return;
11856
11857 if (strcmp(t->key, "UTL STAMP") != 0)
11858 return;
11859
11860 free(timeStamp);
11861 }
|
|
|
Definition at line 11637 of file l_mri_dicom_hdr.c. Referenced by UTL_DateMatch(), and UTL_TimeMatch().
11638 {
11639
11640 char
11641 *t1,
11642 *t2;
11643
11644 t1 = t2 = s;
11645 while (*t2 != '\000') {
11646 if (*t2 != ' ') {
11647 *t1 = *t2;
11648 t1++;
11649 }
11650 t2++;
11651 }
11652 *t1 = '\000';
11653
11654 return;
11655 }
|
|
||||||||||||
|
Definition at line 11711 of file l_mri_dicom_hdr.c. References free, malloc, UTL_ConvertTimetoFloat(), and UTL_SqueezeBlanks().
11712 {
11713
11714 int
11715 match;
11716 char
11717 *ntime;
11718 double
11719 start_time,
11720 end_time,
11721 time_in_question;
11722
11723 if ((ntime = (char *) malloc(strlen(timestring) + 2)) == (char *) NULL)
11724 return (UTL_NOMATCH);
11725
11726 strcpy(ntime, timestring);
11727 UTL_SqueezeBlanks(ntime);
11728 UTL_SqueezeBlanks(stm);
11729
11730 match = 0;
11731 if (strchr(ntime, (int) '-') == (char *) NULL) {
11732 if (strcmp(ntime, stm) == 0)
11733 match = 1;
11734 } else {
11735 time_in_question = UTL_ConvertTimetoFloat(stm);
11736 if (ntime[0] == '-') {
11737 end_time = UTL_ConvertTimetoFloat(ntime + 1);
11738 if (time_in_question <= end_time)
11739 match = 1;
11740 } else if (ntime[strlen(ntime) - 1] == '-') {
11741 start_time = UTL_ConvertTimetoFloat(ntime);
11742 if (time_in_question >= start_time)
11743 match = 1;
11744 } else {
11745 start_time = UTL_ConvertTimetoFloat(ntime);
11746 end_time = UTL_ConvertTimetoFloat(strchr(ntime, (int) '-') + 1);
11747 if ((time_in_question >= start_time) &&
11748 (time_in_question <= end_time))
11749 match = 1;
11750 }
11751 }
11752 free(ntime);
11753 if (match)
11754 return (UTL_MATCH);
11755 else
11756 return (UTL_NOMATCH);
11757 }
|
|
|
Definition at line 11864 of file l_mri_dicom_hdr.c. References i, p, S_ISDIR, UTL_FILECREATEFAILED, UTL_NORMAL, and UTL_PATHNOTDIR.
11865 {
11866 int i;
11867 #ifdef _MSC_VER
11868 struct _stat buf;
11869 #else
11870 struct stat buf;
11871 #endif
11872 char
11873 *p,
11874 temp[1024];
11875 int flag = 0;
11876 static int statCount = 0;
11877
11878 #ifdef _MSC_VER
11879 statCount++;
11880 i = _stat(path, &buf);
11881 #else
11882 i = stat(path, &buf);
11883 #endif
11884
11885
11886 if (i == 0) {
11887 #ifdef _MSC_VER
11888 flag = ((buf.st_mode & _S_IFDIR) != 0);
11889 #else
11890 flag = (S_ISDIR(buf.st_mode));
11891 #endif
11892 if (flag)
11893 return UTL_NORMAL;
11894 else
11895 return UTL_PATHNOTDIR;
11896 }
11897 p = temp;
11898
11899 while (*path != '\0') {
11900 *p++ = *path++;
11901 while (*path != '/' && *path != '\\' && *path != '\0') {
11902 #ifdef _MSC_VER
11903 if (*path == ':') {
11904 *p++ = *path++;
11905 if (*path == '\0') /* We should not get C:\0, but test
11906 * it */
11907 break;
11908 }
11909 #endif
11910 *p++ = *path++;
11911 }
11912
11913 *p = '\0';
11914 #ifdef _MSC_VER
11915 statCount++;
11916 i = _stat(temp, &buf);
11917 #else
11918 i = stat(temp, &buf);
11919 #endif
11920
11921 if (i == 0) {
11922 #ifdef _MSC_VER
11923 flag = ((buf.st_mode & _S_IFDIR) != 0);
11924 #else
11925 flag = (S_ISDIR(buf.st_mode));
11926 #endif
11927 if (!flag)
11928 return UTL_PATHNOTDIR;
11929 } else {
11930 #ifdef _MSC_VER
11931 int e1;
11932 e1 = errno;
11933 memset(&buf, 0, sizeof(buf));
11934 /*fprintf(stderr, "Stat Count = %d\n", statCount);*/
11935 statCount++;
11936 i = _stat(temp, &buf);
11937 e1 = errno;
11938 i = _mkdir(temp);
11939 #else
11940 i = mkdir(temp, 0777);
11941 #endif
11942 if (i != 0) {
11943 int e1;
11944 e1 = errno;
11945 fprintf(stderr, "Stat Count = %d\n", statCount);
11946 perror(temp);
11947 return UTL_FILECREATEFAILED;
11948 }
11949 }
11950 }
11951 return UTL_NORMAL;
11952 }
|
|
|
Definition at line 5529 of file l_mri_dicom_hdr.c. References CTNBOOLEAN, DCM_ELEMENT::d, DCM_AS, DCM_CS, DCM_DA, DCM_DS, DCM_IS, DCM_LO, DCM_LT, DCM_NORMAL, DCM_PN, DCM_SH, DCM_ST, DCM_TM, DCM_UI, DCM_UT, PRV_ELEMENT_ITEM::element, i, l, DCM_ELEMENT::length, p, PRV_ELEMENT_ITEM::paddedDataLength, and DCM_ELEMENT::representation. Referenced by readData(), and readFile().
05530 {
05531 int
05532 i,
05533 l;
05534 char
05535 *src,
05536 *dst,
05537 *p;
05538 DCM_ELEMENT
05539 * element;
05540 CTNBOOLEAN
05541 stopFlag = FALSE;
05542
05543 element = &item->element;
05544 if (element->length > 0) {
05545 switch (element->representation) {
05546 case DCM_DA:
05547 src = dst = element->d.string;
05548 l = (int) element->length;
05549 for (i = 0; i < l; i++) {
05550 if (isdigit(*src) || (*src == '-') || (*src == '\\')) {
05551 *dst++ = *src++;
05552 } else {
05553 src++;
05554 element->length--;
05555 }
05556 }
05557 item->paddedDataLength = element->length;
05558 if (element->length & 1) {
05559 *dst = ' ';
05560 item->paddedDataLength++;
05561 }
05562 break;
05563 case DCM_TM:
05564 l = (int) element->length;
05565 src = dst = element->d.string;
05566 for (i = 0; i < l; i++) {
05567 if (isdigit(*src) || (*src == '.') || (*src == '-') || (*src == '\\')) {
05568 *dst++ = *src++;
05569 } else {
05570 src++;
05571 element->length--;
05572 }
05573 }
05574 item->paddedDataLength = element->length;
05575 if (element->length & 1) {
05576 *dst = ' ';
05577 item->paddedDataLength++;
05578 }
05579 break;
05580 /*
05581 * Both the leading and trailing spaces are non-significant.
05582 */
05583 case DCM_CS:
05584 case DCM_AS:
05585 case DCM_DS:
05586 case DCM_IS:
05587 case DCM_LO:
05588 case DCM_SH:
05589 case DCM_UT:
05590 l = (int) element->length;
05591 src = dst = element->d.string;
05592 for (i = 0; i < l; i++) {
05593 if ((*src == ' ') && !stopFlag) {
05594 src++;
05595 element->length--;
05596 } else {
05597 stopFlag = TRUE;
05598 *dst++ = *src++;
05599 }
05600 }
05601 /*
05602 * Right now, dst points to the char follows the last char in the
05603 * string.
05604 */
05605 stopFlag = FALSE;
05606 l = (int) element->length;
05607 p = dst - 1;
05608 for (i = l; (i > 0) && !stopFlag; i--) {
05609 if ((*p == ' ') && !stopFlag) {
05610 p--;
05611 dst--;
05612 element->length--;
05613 } else
05614 stopFlag = TRUE;
05615 }
05616 item->paddedDataLength = element->length;
05617 if (element->length & 1) {
05618 *dst = ' ';
05619 item->paddedDataLength++;
05620 }
05621 break;
05622 /*
05623 * The trailing spaces are non-significant.
05624 */
05625 case DCM_LT:
05626 case DCM_ST:
05627 l = (int) element->length;
05628 src = element->d.string + l - 1;
05629 for (i = l; (i > 0) && !stopFlag; i--) {
05630 if ((*src == ' ') && !stopFlag) {
05631 src--;
05632 element->length--;
05633 } else
05634 stopFlag = TRUE;
05635 }
05636 item->paddedDataLength = element->length;
05637 if (element->length & 1) {
05638 *++src = ' ';
05639 item->paddedDataLength++;
05640 }
05641 break;
05642 case DCM_PN:
05643 /*
05644 * Strip off the trailing spaces.
05645 */
05646 l = (int) element->length;
05647 src = element->d.string + l - 1;
05648 for (i = l; (i > 0) && !stopFlag; i--) {
05649 if ((*src == ' ') && !stopFlag) {
05650 src--;
05651 element->length--;
05652 } else
05653 stopFlag = TRUE;
05654 }
05655 /*
05656 * Convert the name to the standard V3 format.
05657 */
05658 src = dst = element->d.string;
05659 l = element->length;
05660 for (i = 0; i < l;) {
05661 if ((src[i] == ',') || (src[i] == '^')) {
05662 *dst++ = '^';
05663 i++;
05664 while ((i < l) && (src[i] == ' ')) {
05665 element->length--;
05666 i++;
05667 }
05668 } else {
05669 *dst++ = src[i++];
05670 }
05671 }
05672
05673 item->paddedDataLength = element->length;
05674 if (element->length & 1) {
05675 *dst = ' ';
05676 item->paddedDataLength++;
05677 }
05678 break;
05679 case DCM_UI:
05680 if (element->d.string[element->length - 1] == '\0')
05681 element->length--;
05682 if (element->d.string[element->length - 1] == ' ') {
05683 element->d.string[element->length - 1] = '\0';
05684 element->length--;
05685 }
05686 break;
05687 default:
05688 break;
05689 }
05690 }
05691 return DCM_NORMAL;
05692 }
|
|
||||||||||||||||||||
|
Definition at line 5028 of file l_mri_dicom_hdr.c. References COND_PushCondition(), DCM_FILEIOERROR, DCM_Message(), DCM_NORMAL, fd, strerror(), U32, and write(). Referenced by DCM_WriteFile().
05030 {
05031 int
05032 bytesWritten;
05033 int *fd;
05034
05035 fd = (int *) fdPtr;
05036
05037 bytesWritten = write(*fd, buffer, (int) length);
05038 if (bytesWritten != (int) length)
05039 return COND_PushCondition(DCM_FILEIOERROR,
05040 DCM_Message(DCM_FILEIOERROR), "", strerror(errno),
05041 "writeFile");
05042 else
05043 return DCM_NORMAL;
05044 }
|
Variable Documentation
|
|
Definition at line 8659 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_BABGROUPLENGTH, DCM_UL, "BAB Group Length"},
{DCM_BABANNOTATIONPOSITION, DCM_US, "BAB posn of the annot. box in parent film box"},
{DCM_BABTEXTSTRING, DCM_LO, "BAB text string"}
}Definition at line 9686 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_DIRFILESETID, DCM_CS, "DIR File-set ID"},
{DCM_DIRFILESETDESCRFILEID, DCM_CS, "DIR File-set descriptor ID"},
{DCM_DIRSPECIFICCHARACTER, DCM_CS, "DIR Specific character set"},
{DCM_DIRFIRSTOFFSET, DCM_UL, "DIR Offset of the first dir of root dir entity"},
{DCM_DIRLASTOFFSET, DCM_UL, "DIR Offset of the last dir of root dir entity"},
{DCM_DIRFILESETCONSISTENCY, DCM_US, "DIR File-set consistency flag"},
{DCM_DIRRECORDSEQUENCE, DCM_SQ, "DIR Directory record sequence"},
{DCM_DIRNEXTRECORDOFFSET, DCM_UL, "DIR Offset of next directory record"},
{DCM_DIRRECORDINUSE, DCM_US, "DIR Record in use flag"},
{DCM_DIRLOWERLEVELOFFSET, DCM_UL, "DIR Offset of referenced lower-level dir entity"},
{DCM_DIRRECORDTYPE, DCM_CS, "DIR Directory Record Type"},
{DCM_DIRPRIVATERECORDUID, DCM_UI, "DIR Private Record UID"},
{DCM_DIRREFERENCEDFILEID, DCM_CS, "DIR Referenced File ID"},
{DCM_DIRMRDRRECORDOFFSET, DCM_UL, "DIR Directory Record Offset"},
{DCM_DIRREFSOPCLASSUID, DCM_UI, "DIR Referenced SOP Class UID in File"},
{DCM_DIRREFSOPINSTANCEUID, DCM_UI, "DIR Referenced SOP Instance UID in File"},
{DCM_DIRREFTRANSFERSYNTAXUID, DCM_UI, "DIR Referenced Transfer Syntax in File"},
{DCM_DIRNUMREFERENCES, DCM_UL, "DIR Number of References"}
}Definition at line 8471 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_BFBGROUPLENGTH, DCM_UL, "BFB Group Length"},
{DCM_BFBIMAGEDISPLAYFORMAT, DCM_ST, "BFB Type of image display format"},
{DCM_BFBANNOTATIONDISPLAYFORMAT, DCM_CS, "BFB Id of annotation display format"},
{DCM_BFBFILMORIENTATION, DCM_CS, "BFB Film orientation"},
{DCM_BFBFILMSIZEID, DCM_CS, "BFB Film size identification"},
{DCM_BFBMAGNIFICATIONTYPE, DCM_CS, "BFB Interpol. type by which printer mag image"},
{DCM_BFBSMOOTHINGTYPE, DCM_CS, "BFB Specifies type of interpolation function"},
{DCM_BFBBORDERDENSITY, DCM_CS, "BFB density of film areas around/between images"},
{DCM_BFBEMPTYIMAGEDENSITY, DCM_CS, "BFB density of image box area having no image"},
{DCM_BFBMINDENSITY, DCM_US, "BFB Minimum density of images on the film"},
{DCM_BFBMAXDENSITY, DCM_US, "BFB Maximum density of images on the film"},
{DCM_BFBTRIM, DCM_CS, "BFB specifies whether to trim or not"},
{DCM_BFBCONFIGURATIONINFO, DCM_ST, "BFB ID of configuration table"},
{DCM_BFBREFBASICFILMSESSIONSEQ, DCM_SQ, "BFB seq. of film session instance"},
{DCM_BFBREFBASICIMAGEBOXSEQ, DCM_SQ, "BFB seq. of basic image box SOP instance"},
{DCM_BFBREFBASICANNOTBOXSEQ, DCM_SQ, "BFB seq. of basic annotation box SOP instance"},
}Definition at line 9652 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_BFSGROUPLENGTH, DCM_UL, "BFS Group Length"},
{DCM_BFSCOPIES, DCM_IS, "BFS Number of copies printed for each film"},
{DCM_BFSPRINTPRIORITY, DCM_CS, "BFS Specifies priority of print job"},
{DCM_BFSMEDIUMTYPE, DCM_CS, "BFS Medium on which page will be printed"},
{DCM_BFSFILMDESTINATION, DCM_CS, "BFS Film destination"},
{DCM_BFSFILMSESSIONLABEL, DCM_LO, "BFS Human readable label to identify film"},
{DCM_BFSMEMORYALLOCATION, DCM_IS, "BFS Amount of mem allocated for film session"},
{DCM_BFSREFERENCEDFILMBOXSEQ, DCM_SQ, "BFS seq of UIDs of diff FILMBOX instances"}
}Definition at line 9639 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_BIBGROUPLENGTH, DCM_UL, "BIB Group Length"},
{DCM_BIBIMAGEPOSITION, DCM_US, "BIB Specifies position of the image in the film"},
{DCM_BIBPOLARITY, DCM_CS, "BIB Specifies image polarity"},
{DCM_BIBREQUESTEDIMAGESIZE, DCM_DS, "BIB Requested image size"},
{DCM_BIBPREFORMATGREYSCALEIMAGESEQ, DCM_SQ, "BIB Preformatted Greyscale image"},
{DCM_BIBPREFORMATCOLORIMAGESEQ, DCM_SQ, "BIB Preformatted Color image"},
{DCM_BIBREFIMAGEOVERLAYBOXSEQ, DCM_SQ, "BIB Referenced Image Overlay Box seq"},
{DCM_BIBREFVOILUTSEQ, DCM_SQ, "BIB Referenced VOI LUT seq."}
}Definition at line 9673 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 84 of file l_mri_dicom_hdr.c. Referenced by DCM_GetCompressedValue(), exportStream(), extractFileOptions(), readFile(), readFile1(), and RWC_set_endianosity(). |
|
|
Definition at line 4437 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_CMDGROUPLENGTH, DCM_UL, "CMD Group Length"},
{DCM_CMDAFFECTEDCLASSUID, DCM_UI, "CMD Affected SOP Class UID"},
{DCM_CMDREQUESTEDCLASSUID, DCM_UI, "CMD Requested SOP Class UID"},
{DCM_CMDCOMMANDFIELD, DCM_US, "CMD Command Field"},
{DCM_CMDMSGID, DCM_US, "CMD Message ID"},
{DCM_CMDMSGIDRESPOND, DCM_US, "CMD Message ID Responded to"},
{DCM_CMDMOVEDESTINATION, DCM_AE, "CMD Move Destination"},
{DCM_CMDPRIORITY, DCM_US, "CMD Priority"},
{DCM_CMDDATASETTYPE, DCM_US, "CMD Data Set Type"},
{DCM_CMDSTATUS, DCM_US, "CMD Status"},
{DCM_CMDOFFENDINGELEMENT, DCM_AT, "CMD Offending Element"},
{DCM_CMDERRORCOMMENT, DCM_LO, "CMD Error Comment"},
{DCM_CMDERRORID, DCM_US, "CMD Error ID"},
{DCM_CMDREQUESTEDINSTANCEUID, DCM_UI, "CMD SOP Requested Instance UID"},
{DCM_CMDAFFECTEDINSTANCEUID, DCM_UI, "CMD SOP Affected Instance UID"},
{DCM_CMDEVENTTYPEID, DCM_US, "CMD Event Type ID"},
{DCM_CMDACTIONTYPEID, DCM_US, "CMD Action Type ID"},
{DCM_CMDREMAININGSUBOPERATIONS, DCM_US, "CMD Remaining Suboperations"},
{DCM_CMDCOMPLETEDSUBOPERATIONS, DCM_US, "CMD Completed Suboperations"},
{DCM_CMDFAILEDSUBOPERATIONS, DCM_US, "CMD Failed Suboperations"},
{DCM_CMDWARNINGSUBOPERATIONS, DCM_US, "CMD Warning Suboperations"},
{DCM_CMDMOVEAETITLE, DCM_AE, "CMD AE Title"},
{DCM_CMDMOVEMESSAGEID, DCM_US, "CMD Message ID"},
{DCM_CMDATTRIBUTEIDLIST, DCM_AT, "CMD Attribute Identifier List"},
}Definition at line 8425 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_CURVEGROUPLENGTH, DCM_UL, "CRV Group Length"},
{DCM_CURVEDIMENSIONS, DCM_US, "CRV Curve Dimensions"},
{DCM_CURVENUMBEROFPOINTS, DCM_US, "CRV Number of points"},
{DCM_CURVETYPEOFDATA, DCM_CS, "CRV Type of Data"},
{DCM_CURVEDESCRIPTION, DCM_LO, "CRV Curve Description"},
{DCM_CURVEAXISUNITS, DCM_SH, "CRV Axis Units"},
{DCM_CURVEAXISLABELS, DCM_SH, "CRV Axis Labels"},
{DCM_CURVEDATAVALUEREPRESENTATION, DCM_US, "CRV Data Value Representation"},
{DCM_CURVEMINCOORDINATEVALUE, DCM_US, "CRV Minimum Coordinate Value"},
{DCM_CURVEMAXCOORDINATEVALUE, DCM_US, "CRV Maximum Coordinate Value"},
{DCM_CURVERANGE, DCM_SH, "CRV Curve Range"},
{DCM_CURVEDATADESCRIPTOR, DCM_US, "CRV Data Descriptor"},
{DCM_CURVECOORDINATESTARTVALUE, DCM_US, "CRV Coordinate Start Value"},
{DCM_CURVECOORDINATESTEPVALUE, DCM_US, "CRV Coordinate Step Value"},
{DCM_CURVEAUDIOTYPE, DCM_US, "CRV Audio Type"},
{DCM_CURVEAUDIOSAMPLEFORMAT, DCM_US, "CRV Audio Sample Format"},
{DCM_CURVENUMBEROFCHANNELS, DCM_US, "CRV Number of Channels"},
{DCM_CURVENUMBEROFSAMPLES, DCM_UL, "CRV Number of Samples"},
{DCM_CURVESAMPLERATE, DCM_UL, "CRV Sample Rate"},
{DCM_CURVETOTALTIME, DCM_UL, "CRV Total Time"},
{DCM_CURVEAUDIOSAMPLEDATA, DCM_OW, "CRV Audio Sample Data"},
{DCM_CURVEAUDIOCOMMENTS, DCM_LT, "CRV Audio Comments"},
{DCM_CURVELABEL, DCM_LO, "CRV Curve Label"},
{DCM_CURVEREFOVERLAYSEQUENCE, DCM_SQ, "CRV Referenced Overlay Sequence"},
{DCM_CURVEREFOVERLAYGROUP, DCM_US, "CRV Referenced Overlay Group"},
{DCM_CURVEDATA, DCM_OW, "CRV Curve Data"}
}Definition at line 9439 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 865 of file l_mri_dicom_hdr.c. Referenced by DCM_Debug(). |
|
|
Initial value: {
{DCM_DEVCALIBRATIONOBJECT, DCM_CS, "DEV Calibration Object"},
{DCM_DEVDEVICESEQUENCE, DCM_SQ, "DEV Device Sequence"},
{DCM_DEVDEVICELENGTH, DCM_DS, "DEV Device Length"},
{DCM_DEVDEVICEDIAMETER, DCM_DS, "DEV Device Diameter"},
{DCM_DEVDEVICEDIAMETERUNITS, DCM_CS, "DEV Device Diameter Units"},
{DCM_DEVDEVICEVOLUME, DCM_DS, "DEV Device Volume"},
{DCM_DEVINTERMARKERDISTANCE, DCM_DS, "DEV Inter-Marker Distance"},
{DCM_DEVDEVICEDESCRIPTION, DCM_LO, "DEV Device Description"},
}Definition at line 9394 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_DLMITEM, DCM_DLM, "DELIMITER Item"},
{DCM_DLMITEMDELIMITATIONITEM, DCM_DLM, "DELIMITER Item Delimitation Item"},
{DCM_DLMSEQUENCEDELIMITATIONITEM, DCM_DLM, "DELIMITER Sequence Delimitation Item"}
}Definition at line 10129 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_MAKETAG(0x3004, 0x0000), DCM_UL, "DVH Group Length"},
{DCM_MAKETAG(0x3004, 0x0001), DCM_CS, "DVH Type"},
{DCM_MAKETAG(0x3004, 0x0002), DCM_CS, "DVH Dose Units"},
{DCM_MAKETAG(0x3004, 0x0004), DCM_CS, "DVH Dose Type"},
{DCM_MAKETAG(0x3004, 0x0006), DCM_LO, "DVH Dose Comment"},
{DCM_MAKETAG(0x3004, 0x0008), DCM_DS, "DVH Normalization Point"},
{DCM_MAKETAG(0x3004, 0x000a), DCM_CS, "DVH Dose Summation Type"},
{DCM_MAKETAG(0x3004, 0x000c), DCM_DS, "DVH Grid Frame Offset Vector"},
{DCM_MAKETAG(0x3004, 0x000e), DCM_DS, "DVH Dose Grid Scaling"},
{DCM_MAKETAG(0x3004, 0x0010), DCM_SQ, "DVH RT Dose ROI Sequence"},
{DCM_MAKETAG(0x3004, 0x0012), DCM_DS, "DVH Dose Value"},
{DCM_MAKETAG(0x3004, 0x0040), DCM_DS, "DVH Normalization Point"},
{DCM_MAKETAG(0x3004, 0x0042), DCM_DS, "DVH Normalization Dose Value"},
{DCM_MAKETAG(0x3004, 0x0050), DCM_SQ, "DVH Sequence"},
{DCM_MAKETAG(0x3004, 0x0052), DCM_DS, "DVH Dose Scaling"},
{DCM_MAKETAG(0x3004, 0x0054), DCM_CS, "DVH Volume Units"},
{DCM_MAKETAG(0x3004, 0x0056), DCM_IS, "DVH Number of Bins"},
{DCM_MAKETAG(0x3004, 0x0058), DCM_DS, "DVH Data"},
{DCM_MAKETAG(0x3004, 0x0060), DCM_SQ, "DVH Referenced ROI Sequence"},
{DCM_MAKETAG(0x3004, 0x0062), DCM_CS, "DVH ROI Contribution Type"},
{DCM_MAKETAG(0x3004, 0x0070), DCM_DS, "DVH Minimum Dose"},
{DCM_MAKETAG(0x3004, 0x0072), DCM_DS, "DVH Maximum Dose"},
{DCM_MAKETAG(0x3004, 0x0074), DCM_DS, "DVH Mean Dose"}
}Definition at line 9763 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 356 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 357 of file l_mri_dicom_hdr.c. Referenced by COND_EstablishCallback(), and COND_PushCondition(). |
|
|
Initial value: {
{DCM_MAKETAG(0x3002, 0x0000), DCM_UL, "RT Group Length"},
{DCM_MAKETAG(0x3002, 0x0002), DCM_SH, "RT Image Label"},
{DCM_MAKETAG(0x3002, 0x0003), DCM_LO, "RT Image Name"},
{DCM_MAKETAG(0x3002, 0x0004), DCM_ST, "RT Image Description"},
{DCM_MAKETAG(0x3002, 0x000a), DCM_CS, "RT Reported Values Origin"},
{DCM_MAKETAG(0x3002, 0x000c), DCM_CS, "RT Image Plane"},
{DCM_MAKETAG(0x3002, 0x000e), DCM_DS, "RT X-Ray Image Receptor Angle"},
{DCM_MAKETAG(0x3002, 0x0010), DCM_DS, "RT Image Orientation"},
{DCM_MAKETAG(0x3002, 0x0011), DCM_DS, "RT Image Plane Pixel Spacing"},
{DCM_MAKETAG(0x3002, 0x0012), DCM_DS, "RT Image Position"},
{DCM_MAKETAG(0x3002, 0x0020), DCM_SH, "RT Radiation Machine Name"},
{DCM_MAKETAG(0x3002, 0x0022), DCM_DS, "RT Radiation Machine SAD"},
{DCM_MAKETAG(0x3002, 0x0024), DCM_DS, "RT Radiation Machine SSD"},
{DCM_MAKETAG(0x3002, 0x0026), DCM_DS, "RT Image SID"},
{DCM_MAKETAG(0x3002, 0x0028), DCM_DS, "RT Source to Reference Object Distance"},
{DCM_MAKETAG(0x3002, 0x0029), DCM_IS, "RT Fraction Number"},
{DCM_MAKETAG(0x3002, 0x0030), DCM_SQ, "RT Exposure Sequence"},
{DCM_MAKETAG(0x3002, 0x0032), DCM_DS, "RT Meterset Exposure"}
}Definition at line 9739 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 9842 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_MAKETAG(0x300c, 0x0000), DCM_UL, " Group Length"},
{DCM_MAKETAG(0x300c, 0x0002), DCM_SQ, " Referenced RT Plan Sequence"},
{DCM_MAKETAG(0x300c, 0x0004), DCM_SQ, " Referenced Beam Sequence"},
{DCM_MAKETAG(0x300c, 0x0006), DCM_IS, " Referenced Beam Number"},
{DCM_MAKETAG(0x300c, 0x0007), DCM_IS, " Referenced Reference Image Number"},
{DCM_MAKETAG(0x300c, 0x0008), DCM_DS, " Start Cumulative Meterset Weight"},
{DCM_MAKETAG(0x300c, 0x0009), DCM_DS, " End Cumulative Meterset Weight"},
{DCM_MAKETAG(0x300c, 0x000a), DCM_SQ, " Referenced Brachy Application Setup Seq"},
{DCM_MAKETAG(0x300c, 0x000c), DCM_IS, " Referenced Brachy Application Setup Number"},
{DCM_MAKETAG(0x300c, 0x000e), DCM_IS, " Referenced Source Number"},
{DCM_MAKETAG(0x300c, 0x0020), DCM_SQ, " Referenced Fraction Group Sequence"},
{DCM_MAKETAG(0x300c, 0x0022), DCM_IS, " Referenced Fraction Group Number"},
{DCM_MAKETAG(0x300c, 0x0040), DCM_SQ, " Referenced Verification Image Sequence"},
{DCM_MAKETAG(0x300c, 0x0042), DCM_SQ, " Referenced Reference Image Sequence"},
{DCM_MAKETAG(0x300c, 0x0050), DCM_SQ, " Referenced Dose Reference Sequence"},
{DCM_MAKETAG(0x300c, 0x0051), DCM_IS, " Referenced Dose Reference Numer"},
{DCM_MAKETAG(0x300c, 0x0055), DCM_SQ, " Brachy Referenced Dose Reference Sequence"},
{DCM_MAKETAG(0x300c, 0x0060), DCM_SQ, " Referenced Structure Set Sequence"},
{DCM_MAKETAG(0x300c, 0x006a), DCM_IS, " Referenced Patient Setup Number"},
{DCM_MAKETAG(0x300c, 0x0080), DCM_SQ, " Referenced Dose Sequence"},
{DCM_MAKETAG(0x300c, 0x00a0), DCM_IS, " Referenced Tolerance Table Number"},
{DCM_MAKETAG(0x300c, 0x00b0), DCM_SQ, " Referenced Bolus Sequence"},
{DCM_MAKETAG(0x300c, 0x00c0), DCM_IS, " Referenced Wedge Number"},
{DCM_MAKETAG(0x300c, 0x00d0), DCM_IS, " Referenced Compensator Number"},
{DCM_MAKETAG(0x300c, 0x00e0), DCM_IS, " Referenced Block Number"},
{DCM_MAKETAG(0x300c, 0x00f0), DCM_IS, " Referenced Control Point Index"}
}Definition at line 10072 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_MAKETAG(0x300e, 0x0000), DCM_UL, " Group Length"},
{DCM_MAKETAG(0x300e, 0x0002), DCM_CS, " Approval Status"},
{DCM_MAKETAG(0x300e, 0x0004), DCM_DA, " Review Date"},
{DCM_MAKETAG(0x300e, 0x0005), DCM_TM, " Review Time"},
{DCM_MAKETAG(0x300e, 0x0008), DCM_PN, " Reviewer Name"}
}Definition at line 10104 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 10139 of file l_mri_dicom_hdr.c. |
|
|
Referenced by exportData(). |
|
|
Definition at line 10316 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_MAKETAG(0x0070, 0x0000), DCM_UL, "GRP Group Length"},
{DCM_MAKETAG(0x0070, 0x0022), DCM_FL, "GRP Graphic Data"},
{DCM_MAKETAG(0x0070, 0x0023), DCM_CS, "GRP Graphic Type"},
{DCM_MAKETAG(0x0070, 0x0024), DCM_CS, "GRP Graphic Filled"},
{DCM_MAKETAG(0x0070, 0x0041), DCM_CS, "GRP Image Horizontal Flip"},
{DCM_MAKETAG(0x0070, 0x0042), DCM_US, "GRP Image Rotation"},
{DCM_MAKETAG(0x0070, 0x0052), DCM_SL, "GRP Displayed Area Top LH Corner"},
{DCM_MAKETAG(0x0070, 0x0053), DCM_SL, "GRP Displayed Area Bottom RH Corner"},
{DCM_MAKETAG(0x0070, 0x005a), DCM_SQ, "GRP Display Area Selection Seq"},
{DCM_MAKETAG(0x0070, 0x0060), DCM_SQ, "GRP Graphic Layer Sequence"},
{DCM_MAKETAG(0x0070, 0x0062), DCM_IS, "GRP Graphic Layer Order"},
{DCM_MAKETAG(0x0070, 0x0066), DCM_US, "GRP Graphic Layer Rec Disp GS Val"},
{DCM_MAKETAG(0x0070, 0x0067), DCM_US, "GRP Graphic Layer Rec Disp RGB Val"},
{DCM_MAKETAG(0x0070, 0x0068), DCM_LO, "GRP Graphic Layer Description"},
{DCM_MAKETAG(0x0070, 0x0080), DCM_CS, "GRP Presentation Label"},
{DCM_MAKETAG(0x0070, 0x0081), DCM_LO, "GRP Presentation Description"},
{DCM_MAKETAG(0x0070, 0x0082), DCM_DA, "GRP Presentation Creation Date"},
{DCM_MAKETAG(0x0070, 0x0083), DCM_TM, "GRP Presentation Creation Time"},
{DCM_MAKETAG(0x0070, 0x0084), DCM_PN, "GRP Presentation Creators Name"},
{DCM_MAKETAG(0x0070, 0x0100), DCM_CS, "GRP Presentation Size Mode"},
{DCM_MAKETAG(0x0070, 0x0101), DCM_DS, "GRP Presentation Pixel Spacing"},
{DCM_MAKETAG(0x0070, 0x0102), DCM_IS, "GRP Presentation Pixel Aspect Ratio"},
{DCM_MAKETAG(0x0070, 0x0103), DCM_FL, "GRP Presentation Pixel Magnification Ratio"},
}Definition at line 9557 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 8494 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 9016 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_IOBGROUPLENGTH, DCM_UL, "IOB Group Length"},
{DCM_IOBREFOVERLAYPLANESEQ, DCM_SQ, "IOB Ref Overlay Plane Sequence"},
{DCM_IOBREFOVERLAYPLANEGROUPS, DCM_US, "IOB Ref Overlay Plane Groups"},
{DCM_IOBOVERLAYMAGNIFICATIONTYPE, DCM_CS, "IOB Overlay Magnification Type"},
{DCM_IOBOVERLAYSMOOTHINGTYPE, DCM_CS, "IOB Overlay Smoothing Type"},
{DCM_IOBOVERLAYFOREGROUNDDENSITY, DCM_CS, "IOB Overlay Foreground Density"},
{DCM_IOBOVERLAYMODE, DCM_CS, "IOB Overlay Mode"},
{DCM_IOBTHRESHOLDDENSITY, DCM_CS, "IOB Threshold Density"},
{DCM_IOBREFIMAGEBOXSEQUENCE, DCM_SQ, "IOB Ref Image Box Sequence (RET)"}
}Definition at line 9694 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 85 of file l_mri_dicom_hdr.c. Referenced by RWC_set_endianosity(). |
|
|
Definition at line 83 of file l_mri_dicom_hdr.c. Referenced by DCM_GetCompressedValue(), exportEncapsulatedPixels(), exportStream(), extractFileOptions(), readFile(), readFile1(), and RWC_set_endianosity(). |
|
|
Initial value: {
{DCM_MEDIAGROUPLENGTH, DCM_UL, "MED Media Group Length "},
{DCM_MEDIASTORAGEFILESETID, DCM_SH, "MED Storage Media File-set ID"},
{DCM_MEDIASTORAGEFILESETUID, DCM_UI, "MED Storage Media File-setUID"},
{DCM_MEDIAICONIMAGE, DCM_SQ, "MED Icon Image Sequence"},
{DCM_MEDIATOPICTITLE, DCM_LO, "MED Topic Title"},
{DCM_MEDIATOPICSUBJECT, DCM_ST, "MED Topic Subject"},
{DCM_MEDIATOPICAUTHOR, DCM_LO, "MED Topic Author"},
{DCM_MEDIATOPICKEYWORD, DCM_LO, "MED Topic Keywords"}
}Definition at line 9626 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 8244 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_METAGROUPLENGTH, DCM_UL, "META Group Length"},
{DCM_METAINFORMATIONVERSION, DCM_OB, "META File Meta Information Version"},
{DCM_METAMEDIASTORAGESOPCLASS, DCM_UI, "META Media Stored SOP Class UID"},
{DCM_METAMEDIASTORAGESOPINSTANCE, DCM_UI, "META Media Stored SOP Instance UID"},
{DCM_METATRANSFERSYNTAX, DCM_UI, "META Transfer Syntax UID"},
{DCM_METAIMPLEMENTATIONCLASS, DCM_UI, "META Implementation Class UID"},
{DCM_METAIMPLEMENTATIONVERSION, DCM_SH, "META Implementation Version Name"},
{DCM_METASOURCEAETITLE, DCM_AE, "META Source Application Entity Title"},
{DCM_METAPRIVATEINFORMATIONCREATOR, DCM_UI, "META Private Information Creator"},
{DCM_METAPRIVATEINFORMATION, DCM_OB, "META Private Information"}
}Definition at line 8456 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 9469 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 111 of file l_mri_dicom_hdr.c. Referenced by RWC_clear_pbuf(), and RWC_printf(). |
|
|
Definition at line 9585 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_PADITEM, DCM_OB, "Pad item"}
}Definition at line 10122 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 8620 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 110 of file l_mri_dicom_hdr.c. Referenced by mri_dicom_header(), RWC_clear_pbuf(), and RWC_printf(). |
|
|
Initial value: {
{DCM_PJGROUPLENGTH, DCM_UL, "PJ Group Length"},
{DCM_PJEXECUTIONSTATUS, DCM_CS, "PJ execution status of print job"},
{DCM_PJEXECUTIONSTATUSINFO, DCM_CS, "PJ additional information"},
{DCM_PJCREATIONDATE, DCM_DA, "PJ date of print job creation"},
{DCM_PJCREATIONTIME, DCM_TM, "PJ time of print job creation"},
{DCM_PJORIGINATOR, DCM_AE, "PJ Appln entity title that issued the print opn"},
{DCM_PJREFPRINTJOBSEQ, DCM_SQ, "PJ Referenced print job seq."}
}Definition at line 9717 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_MAKETAG(0x2050, 0x0000), DCM_UL, "PLUT Group Length"},
{DCM_MAKETAG(0x2050, 0x0010), DCM_SQ, "PLUT Presentation LUT Sequence"},
{DCM_MAKETAG(0x2050, 0x0020), DCM_CS, "PLUT Presentation LUT Shape"},
{DCM_MAKETAG(0x2050, 0x0500), DCM_SQ, "PLUT Referenced Presentation LUT Sequence"}
}Definition at line 9708 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 9206 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_PRINTERGROUPLENGTH, DCM_UL, "PRINTER Group Length"},
{DCM_PRINTERSTATUS, DCM_CS, "PRINTER printer device status"},
{DCM_PRINTERSTATUSINFO, DCM_CS, "PRINTER additional information"},
{DCM_PRINTERNAME, DCM_LO, "PRINTER printer name"},
{DCM_PRINTERQUEUEID, DCM_SH, "Printer Queue ID"}
}Definition at line 9729 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_PXLGROUPLENGTH, DCM_UL, "PXL Group Length"},
{DCM_PXLPIXELDATA, DCM_OT, "PXL Pixel Data"}
}Definition at line 9620 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 152 of file l_mri_dicom_hdr.c. Referenced by mri_dicom_header(), mri_dicom_pxlarr(), and readData(). |
|
|
Definition at line 151 of file l_mri_dicom_hdr.c. Referenced by mri_dicom_header(), mri_dicom_pxlarr(), and readData(). |
|
|
Definition at line 8953 of file l_mri_dicom_hdr.c. |
|
|
Initial value: {
{DCM_RESGROUPLENGTH, DCM_UL, "RES Group Length"},
{DCM_RESID, DCM_SH, "RES Results ID"},
{DCM_RESIDISSUER, DCM_LO, "RES Results ID Issuer"},
{DCM_RESREFERENCEDINTERPSEQ, DCM_SQ, "RES Referenced Interpretation Sequence"},
{DCM_RESINTERPRECORDEDDATE, DCM_DA, "RES Interpretation Recorded Date"},
{DCM_RESINTERPRECORDEDTIME, DCM_TM, "RES Interpretation Recorded Time"},
{DCM_RESINTERPRECORDER, DCM_PN, "RES Interpretation Recorder"},
{DCM_RESREFERENCETORECORDEDSOUND, DCM_LO, "RES Reference to Recorded Sound"},
{DCM_RESINTERPTRANSCRIPTIONDATE, DCM_DA, "RES Interpretation Transcription Date"},
{DCM_RESINTERPTRANSCRIPTIONTIME, DCM_TM, "RES Interpretation Transcription Time"},
{DCM_RESINTERPTRANSCRIBER, DCM_PN, "RES Interpretation Transcriber"},
{DCM_RESINTERPTEXT, DCM_ST, "RES Interpretation Text"},
{DCM_RESINTERPAUTHOR, DCM_PN, "RES Interpretation Author"},
{DCM_RESINTERPAPPROVERSEQUENCE, DCM_SQ, "RES Interpretation Approver Sequence"},
{DCM_RESINTERPAPPROVALDATE, DCM_DA, "RES Interpretation Approval Date"},
{DCM_RESINTERPAPPROVALTIME, DCM_TM, "RES Interpretation Approval Time"},
{DCM_RESPHYSICIANAPPROVINGINTERP, DCM_PN, "RES Physician Approving Interpretation"},
{DCM_RESDIAGNOSIS, DCM_LT, "RES Diagnosis"},
{DCM_RESDIAGNOSISCODESEQ, DCM_SQ, "RES Diagnosis Code Sequence"},
{DCM_RESDISTRIBUTIIONLISTSEQUENCE, DCM_SQ, "RES Results Distribution List Sequence"},
{DCM_RESDISTRIBUTIONNAME, DCM_PN, "RES Distribution Name"},
{DCM_RESDISTRIBUTIONADDRESS, DCM_LO, "RES Distribution Address"},
{DCM_RESINTERPID, DCM_SH, "RES Interpretation ID"},
{DCM_RESINTERPIDISSUER, DCM_LO, "RES Interpretation ID Issuer"},
{DCM_RESINTERPTYPEID, DCM_CS, "RES Interpretation Type ID"},
{DCM_RESINTERPSTATUSID, DCM_CS, "RES Interpretation Status ID"},
{DCM_RESIMPRESSIONS, DCM_ST, "RES Impressions"},
{DCM_RESCOMMENTS, DCM_ST, "RES Comments"}
}Definition at line 9407 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 193 of file l_mri_dicom_hdr.c. Referenced by mri_dicom_seterr(), and readVRLength(). |
|
|
Definition at line 202 of file l_mri_dicom_hdr.c. Referenced by DCM_OpenFile(), and mri_dicom_header(). |
|
|
Definition at line 161 of file l_mri_dicom_hdr.c. Referenced by DCM_DumpElements(), mri_dicom_nohex(), and mri_dicom_noname(). |
|
|
Definition at line 184 of file l_mri_dicom_hdr.c. Referenced by DCM_DumpElements(), mri_dicom_header(), and mri_dicom_setvm(). |
|
|
Initial value: {
{DCM_SDYGROUPLENGTH, DCM_UL, "SDY Study Group length"},
{DCM_SDYSTATUSID, DCM_CS, "SDY Study Status ID"},
{DCM_SDYPRIORITYID, DCM_CS, "SDY Study Priority ID"},
{DCM_SDYIDISSUER, DCM_LO, "SDY Study ID Issuer"},
{DCM_SDYVERIFIEDDATE, DCM_DA, "SDY Study Verified Date"},
{DCM_SDYVERIFIEDTIME, DCM_TM, "SDY Study Verified Time"},
{DCM_SDYREADDATE, DCM_DA, "SDY Study Read Date"},
{DCM_SDYREADTIME, DCM_TM, "SDY Study Read Time"},
{DCM_SDYSCHEDULEDSTARTDATE, DCM_DA, "SDY Scheduled Study Start Date"},
{DCM_SDYSCHEDULEDSTARTTIME, DCM_TM, "SDY Scheduled Study Start Time"},
{DCM_SDYSCHEDULEDSTOPDATE, DCM_DA, "SDY Scheduled Study Stop Date"},
{DCM_SDYSCHEDULEDSTOPTIME, DCM_TM, "SDY Scheduled Study Stop Time"},
{DCM_SDYSCHEDULEDLOCATION, DCM_LO, "SDY Scheduled Study Location"},
{DCM_SDYSCHEDULEDLOCATIONAETITLE, DCM_AE,
"SDY Scheduled Study Location AE Title(s)"},
{DCM_SDYREASON, DCM_LO, "SDY Study Reason"},
{DCM_SDYREQUESTINGPHYSICIAN, DCM_PN, "SDY Requesting Physician "},
{DCM_SDYREQUESTINGSERVICE, DCM_LO, "SDY Requesting Service"},
{DCM_SDYARRIVALDATE, DCM_DA, "SDY Study Arrival Date"},
{DCM_SDYARRIVALTIME, DCM_TM, "SDY Study Arrival Time"},
{DCM_SDYCOMPLETIONDATE, DCM_DA, "SDY Study Completion Date"},
{DCM_SDYCOMPLETIONTIME, DCM_TM, "SDY Study Completion Time"},
{DCM_SDYSTUDYCOMPONENTSTATUSID, DCM_CS, "SDY Study Component Status ID"},
{DCM_SDYREQUESTEDPRODESCRIPTION, DCM_LO, "SDY Requested Procedure Description"},
{DCM_SDYREQUESTEDPROCODESEQ, DCM_SQ, "SDY Requested Procedure Code Seq"},
{DCM_SDYREQUESTEDCONTRASTAGENT, DCM_LO, "SDY Requested Contrast Agent"},
{DCM_SDYCOMMENTS, DCM_LT, "SDY Comments"}
}Definition at line 9111 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 4436 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 9792 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 355 of file l_mri_dicom_hdr.c. Referenced by COND_CopyText(), COND_DumpConditions(), COND_ExtractConditions(), COND_PopCondition(), COND_PushCondition(), COND_TopCondition(), COND_WriteConditions(), and dumpstack(). |
|
|
Initial value: {
{DCM_VISGROUPLENGTH, DCM_UL, "VIS Group Length"},
{DCM_VISREFERENCEDPATALIASSEQ, DCM_SQ, "VIS Referenced Patient Alias Sequence"},
{DCM_VISSTATUSID, DCM_CS, "VIS Visit Status ID"},
{DCM_VISADMISSIONID, DCM_LO, "VIS Admission ID"},
{DCM_VISISSUEROFADMISSIONID, DCM_LO, "VIS Issuer of Admission ID"},
{DCM_VISROUTEOFADMISSION, DCM_LO, "VIS Route of Admission"},
{DCM_VISSCHEDULEDADMISSIONDATE, DCM_DA, "VIS Scheduled Admission Date"},
{DCM_VISSCHEDULEDADMISSIONTIME, DCM_TM, "VIS Scheduled Admission Time"},
{DCM_VISSCHEDULEDDISCHARGEDATE, DCM_DA, "VIS Scheduled Discharge Date"},
{DCM_VISSCHEDULEDDISCHARGETIME, DCM_TM, "VIS Scheduled Discharge Time"},
{DCM_VISSCHEDULEDPATINSTRESIDENCE, DCM_LO, "VIS Scheduled Patient Institution Residence"},
{DCM_VISADMITTINGDATE, DCM_DA, "VIS Admitting Date"},
{DCM_VISADMITTINGTIME, DCM_TM, "VIS Admitting Time"},
{DCM_VISDISCHARGEDATE, DCM_DA, "VIS Discharge Date"},
{DCM_VISDISCHARGETIME, DCM_TM, "VIS Discharge Time"},
{DCM_VISDISCHARGEDIAGDESCRIPTION, DCM_LO, "VIS Discharge Diagnosis Description"},
{DCM_VISDISCHARGEDIAGNOSISCODESEQ, DCM_SQ, "VIS Discharge Diagnosis Code Sequence"},
{DCM_VISSPECIALNEEDS, DCM_LO, "VIS Special Needs"},
{DCM_VISCURRENTPATIENTLOCATION, DCM_LO, "VIS Current Patient Location"},
{DCM_VISPATIENTSINSTRESIDENCE, DCM_LO, "VIS Patient's Institution Residence"},
{DCM_VISPATIENTSTATE, DCM_LO, "VIS Patient State"},
{DCM_VISCOMMENTS, DCM_LT, "VIS Comments"}
}Definition at line 9143 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 4131 of file l_mri_dicom_hdr.c. |
|
|
Definition at line 9170 of file l_mri_dicom_hdr.c. |