TPCCLIB
Loading...
Searching...
No Matches
dcmdict.c
Go to the documentation of this file.
1
7/*****************************************************************************/
8#include "tpcclibConfig.h"
9/*****************************************************************************/
10#include <stdio.h>
11#include <stdlib.h>
12#include <math.h>
13#include <time.h>
14#include <string.h>
15/*****************************************************************************/
16#include "tpcextensions.h"
17#include "tpcdcm.h"
18/*****************************************************************************/
19
20/*****************************************************************************/
21static char *info[] = {
22 "List the DICOM dictionary that is used by TPCCLIB.",
23 "The data is printed in TSV format.",
24 " ",
25 "Usage: @P [options] [> dcmdict.tsv]",
26 " ",
27 "Options:",
28 " -uid",
29 " Instead of dictionary, list the transfer syntax UIDs.",
30 " -sop",
31 " Instead of dictionary, list the SOP UIDs.",
32 " -stdoptions", // List standard options like --help, -v, etc
33 " ",
34 "See also: dcmlhdr, lmhdr, ana_lhdr",
35 " ",
36 "Keywords: DICOM, header, UID, dictionary",
37 0};
38/*****************************************************************************/
39
40/*****************************************************************************/
44int main(int argc, char **argv)
45{
46 int ai, help=0, version=0, verbose=1;
47 char *cptr;
48 int listWhat=0; // 0=dictionary, 1=transfer UIDs, 2=SOP UIDs
49
50 /*
51 * Get arguments
52 */
53 /* Options */
54 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
55 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
56 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
57 if(strcasecmp(cptr, "UID")==0) {
58 listWhat=1; continue;
59 } else if(strcasecmp(cptr, "SOP")==0) {
60 listWhat=2; continue;
61 }
62 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
63 return(1);
64 } else break;
65 /* Non-options */
66 for(; ai<argc; ai++) if(*argv[ai]!='-') {
67 fprintf(stderr, "Error: invalid argument '%s'\n", argv[ai]);
68 return(1);
69 }
70 /* Print help or version? */
71 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
72 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
73 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
74
75
76 /* Print DICOM transfer syntax UIDs, if requested */
77 if(listWhat==1) {
78 unsigned int i=1;
79 while(i<DCM_TRUID_INVALID) {
80 printf("%s\t%s\n", dcmTrUIDString(i), dcmTrUIDDescr(i));
81 i++;
82 }
83 fflush(stdout);
84 return(0);
85 }
86
87 /* Print DICOM SOP UIDs, if requested */
88 if(listWhat==2) {
89 char *uid;
90 unsigned int i=1;
91 while(1) {
92 uid=dcmSOPUID(i); if(strcasecmp(uid, "unknown")==0) break;
93 printf("%s\t%s\n", uid, dcmSOPName(i));
94 i++;
95 }
96 fflush(stdout);
97 return(0);
98 }
99
100 /* Print DICOM dictionary contents */
101 unsigned int n=dcmDictSize();
102 if(verbose>1) {printf("Dictionary size := %u\n", n); fflush(stdout);}
103 unsigned short int group, element;
104 printf("Group\tElement\tVR\tDescription\n");
105 for(unsigned int i=0; i<n; i++) {
106 if(dcmDictIndexTag(i, &group, &element)) continue;
107 printf("%04x\t%04x\t%s\t%s", group, element, dcmDictIndexVR(i), dcmDictIndexDescr(i));
108 if(verbose>1) {
109 unsigned int usi;
110 char buf[4];
111 memcpy(buf+2, &group, 2); memcpy(&buf, &element, 2); memcpy(&usi, buf, 4);
112 printf("\t%u", usi);
113 }
114 printf("\n");
115 }
116 fflush(stdout);
117 return(0);
118}
119/*****************************************************************************/
120
121/*****************************************************************************/
char * dcmDictIndexVR(unsigned int i)
char * dcmDictIndexDescr(unsigned int i)
unsigned int dcmDictSize()
int dcmDictIndexTag(unsigned int i, unsigned short int *group, unsigned short int *element)
char * dcmSOPUID(unsigned int i)
Definition dcmsop.c:101
char * dcmSOPName(unsigned int i)
Definition dcmsop.c:83
char * dcmTrUIDDescr(dcmtruid id)
Definition dcmuid.c:87
char * dcmTrUIDString(dcmtruid id)
Definition dcmuid.c:105
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:169
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:339
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:114
Header file for libtpcdcm.
@ DCM_TRUID_INVALID
Invalid Transfer Syntax UID.
Definition tpcdcm.h:78
Header file for library libtpcextensions.