5#include "tpcclibConfig.h"
55 free(ip->
rd); free(ip); ip=NULL;
88 unsigned short int m=0, n=0;
106 if(df==NULL || df->
item==NULL)
return(0);
107 unsigned short int m=0, n=0;
126 if(d==NULL)
return(0);
127 unsigned short int n=0;
145 if(d==NULL)
return((
char*)NULL);
149 char *s=malloc(3); strcpy(s,
"na");
156 char *s=malloc(6); strcpy(s,
"empty");
158 }
else if(d->
rd==NULL) {
159 char *s=malloc(3); strcpy(s,
"na");
171 char *s=malloc(len+1);
172 memcpy(s, d->
rd, len); s[len]=(char)0;
182 char *s=malloc(len+1);
183 memcpy(s, d->
rd, len); s[len]=(char)0;
204 memcpy(&f, d->
rd, 4);
228 memcpy(&f, d->
rd, 8);
237 memcpy(&i, d->
rd, 4);
246 unsigned short int i;
247 memcpy(&i, d->
rd, 2);
257 memcpy(&i, d->
rd, 4);
267 memcpy(&i, d->
rd, 2);
284 char *s=malloc(3); strcpy(s,
"na");
299 if(d==NULL || d->
rd==NULL)
return(0);
306 unsigned short int i;
335 if(d==NULL || d->
rd==NULL)
return(0);
352 unsigned short int i;
364 r=(double)atol(d->
rd);
379 const short int omit,
385 if(d==NULL || tag==NULL)
return(NULL);
386 if(verbose>0) printf(
"%s((%04X,%04X),%d)\n", __func__, tag->
group, tag->
element, omit);
388 if(omit==0) iptr=d;
else iptr=d->
next_item;
393 if(verbose>2) printf(
" found!\n");
398 if(verbose>2) printf(
" going to search inside children...\n");
400 if(rptr!=NULL)
return(rptr);
401 if(verbose>3) printf(
" nothing found in any of the children\n");
406 if(iptr!=NULL)
return(iptr);
410 if(verbose>2) printf(
" going to search the parents sister...\n");
417 if(verbose>2) printf(
" going to search inside parent...\n");
432 const short int omit,
438 if(d==NULL || tag==NULL)
return(NULL);
439 if(verbose>0) printf(
"%s((%04X,%04X),%d)\n", __func__, tag->
group, tag->
element, omit);
441 if(omit==0) iptr=d;
else iptr=d->
next_item;
446 if(verbose>2) printf(
" found!\n");
451 if(verbose>2) printf(
" going to search inside children...\n");
453 if(rptr!=NULL)
return(rptr);
454 if(verbose>3) printf(
" nothing found in any of the children\n");
459 if(iptr!=NULL)
return(iptr);
471 if(d==NULL) {printf(
"(null)\n"); fflush(stdout);
return;}
473 printf(
" VR=%s",
dcmVRName(d->
vr)); fflush(stdout);
474 if(d->
vl==0xFFFFFFFF) printf(
" VL=%08X", d->
vl);
else printf(
" VL=%u", d->
vl);
477 printf(
"\n"); fflush(stdout);
487 unsigned short int group,
489 unsigned short int element
521 printf(
"%s(dcm, (%04X,%04X))", __func__, tag.
group, tag.
element);
522 if(d==NULL) printf(
", null");
else printf(
", ptr");
523 printf(
", %d, %s, 0x%08X, rd", aschild,
dcmVRName(vr), vl);
526 if(dcm==NULL)
return(1);
530 if(d!=NULL && dcm->
item==NULL)
return(3);
532 if(d!=NULL && aschild && d->
child_item!=NULL)
return(4);
539 if(verbose>1) printf(
" allocating memory for the item\n");
541 if(item==NULL)
return(11);
544 item->
rd=(
char*)NULL;
547 if(verbose>1) printf(
" setting item contents\n");
556 if(item->
vl==0xFFFFFFFF) item->
vl=(
unsigned int)s;
557 if(verbose>1) printf(
" allocating %u bytes for the item value\n", (
unsigned int)s);
558 item->
rd=(
char*)calloc(s,
sizeof(
char));
559 if(item->
rd==NULL) {free(item);
return(21);}
561 if(verbose>1) printf(
"zero size for item value\n");
563 if(verbose>1) printf(
"... which is ok since value is empty, too.\n");
565 if(verbose>0) printf(
"... which is not ok because we have value to store.\n");
566 if(item->
rd==NULL) {free(item);
return(22);}
570 if(rd!=NULL && s>0) {
571 if(verbose>1) printf(
" copying the item value\n");
575 unsigned int len=
strnlen(rd, s);
577 else memcpy(item->
rd, rd, s);
580 unsigned int len=
strnlen(rd, s);
582 else memcpy(item->
rd, rd, s);
584 memcpy(item->
rd, rd, s);
590 if(verbose>1) printf(
" link the item.\n");
607 }
else if(dcm->
item==NULL) {
621 if(verbose>1) printf(
" all done.\n");
643 if(d==NULL || tag==NULL)
return(1);
644 if(verbose>0) printf(
"%s(%04X,%04X)\n", __func__, tag->
group, tag->
element);
649 if(verbose>1) printf(
" tag not found.\n");
652 int iv=
dcmitemGetInt(iptr);
if(verbose>2) printf(
" value := %d\n", iv);
659 iv=
dcmitemGetInt(iptr);
if(verbose>2) printf(
" value := %d\n", iv);
660 if(iv>maxi) maxi=iv;
else if(iv<mini) mini=iv;
664 printf(
" minimum_value := %d\n", mini);
665 printf(
" maximum_value := %d\n", maxi);
667 if(mi!=NULL) *mi=mini;
668 if(ma!=NULL) *ma=maxi;
int dcmAddItem(DCMFILE *dcm, DCMITEM *d, short int aschild, DCMTAG tag, dcmvr vr, unsigned int vl, char *rd, const int verbose)
long int dcmitemGetInt(DCMITEM *d)
unsigned short int dcmitemMaxDepth(DCMITEM *d)
void dcmfileInit(DCMFILE *d)
void dcmTagSet(DCMTAG *tag, unsigned short int group, unsigned short int element)
DCMITEM * dcmFindTag(DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose)
DCMITEM * dcmFindDownTag(DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose)
void dcmfileFree(DCMFILE *d)
void dcmitemFree(DCMITEM *d)
int dcmTagIntRange(DCMITEM *d, DCMTAG *tag, int *mi, int *ma, const int verbose)
void dcmitemPrint(DCMITEM *d)
double dcmitemGetReal(DCMITEM *d)
unsigned short int dcmfileMaxDepth(DCMFILE *df)
unsigned short int dcmitemParentNr(DCMITEM *d)
char * dcmValueString(DCMITEM *d)
size_t dcmVRVLength(dcmvr id)
char * dcmVRName(dcmvr id)
void swap(void *from, void *to, int size)
size_t strnlen(const char *s, size_t n)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
char filename[FILENAME_MAX]
struct DCMITEM * child_item
struct DCMITEM * next_item
struct DCMITEM * prev_item
struct DCMITEM * parent_item
unsigned short int element
Header file for libtpcdcm.
@ DCM_VR_INVALID
Invalid DICOM value representation.
@ DCM_VR_DT
DICOM date time, max 26 bytes.
@ DCM_VR_UI
DICOM unique identifier (UID), max 64 bytes.
@ DCM_VR_FD
DICOM floating point double precision, 8 bytes fixed.
@ DCM_VR_PN
DICOM person name, max 64 chars per component group.
@ DCM_VR_CS
DICOM code (control) string, max 16 bytes.
@ DCM_VR_SS
DICOM signed short (16-bit integer), 2 bytes fixed.
@ DCM_VR_SH
DICOM short string, max 16 chars.
@ DCM_VR_UT
DICOM unlimited text, character string.
@ DCM_VR_US
DICOM unsigned short (16-bit) integer, 2 bytes fixed.
@ DCM_VR_TM
DICOM time HHMMSS.FFFFFF, max 14 bytes.
@ DCM_VR_AS
DICOM age string, 4 bytes fixed.
@ DCM_VR_ST
DICOM short text, max 1024 chars.
@ DCM_VR_AT
DICOM attribute tag, 4 bytes fixed.
@ DCM_VR_LT
DICOM long text, max 10240 chars.
@ DCM_VR_DA
DICOM date in format YYYYMMDD, 8 bytes fixed.
@ DCM_VR_UL
DICOM unsigned long (32-bit) integer, 4 bytes fixed.
@ DCM_VR_DS
DICOM decimal string, max 16 bytes.
@ DCM_VR_IS
DICOM integer string, max 12 bytes.
@ DCM_VR_AE
DICOM application entity, max 16 bytes.
@ DCM_VR_UR
DICOM URI or URL, string of characters.
@ DCM_VR_LO
DICOM long string, max 64 chars.
@ DCM_VR_SQ
DICOM sequence of zero or more elements (used for nested data).
@ DCM_VR_FL
DICOM floating point single precision, 4 bytes fixed.
@ DCM_VR_SL
DICOM signed long (32-bit integer), 4 bytes fixed.
@ DCM_TRUID_UNKNOWN
Unknown Transfer Syntax UID
@ DCM_TRUID_LEE
Little Endian Explicit VR.
Header file for library libtpcextensions.