~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/file/dicom.old/CTN/dcmsupport.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2           Copyright (C) 1993, 1994, RSNA and Washington University
  3 
  4           The software and supporting documentation for the Radiological
  5           Society of North America (RSNA) 1993, 1994 Digital Imaging and
  6           Communications in Medicine (DICOM) Demonstration were developed
  7           at the
  8                   Electronic Radiology Laboratory
  9                   Mallinckrodt Institute of Radiology
 10                   Washington University School of Medicine
 11                   510 S. Kingshighway Blvd.
 12                   St. Louis, MO 63110
 13           as part of the 1993, 1994 DICOM Central Test Node project for, and
 14           under contract with, the Radiological Society of North America.
 15 
 16           THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER RSNA NOR
 17           WASHINGTON UNIVERSITY MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS
 18           PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
 19           USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY
 20           SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF
 21           THE SOFTWARE IS WITH THE USER.
 22 
 23           Copyright of the software and supporting documentation is
 24           jointly owned by RSNA and Washington University, and free access
 25           is hereby granted as a license to use this software, copy this
 26           software and prepare derivative works based upon this software.
 27           However, any distribution of this software source code or
 28           supporting documentation or derivative works (source code and
 29           supporting documentation) must include the three paragraphs of
 30           the copyright notice.
 31 */
 32 /* Copyright marker.  Copyright will be inserted above.  Do not remove */
 33 
 34 /*
 35 **                              DICOM 93
 36 **                   Electronic Radiology Laboratory
 37 **                 Mallinckrodt Institute of Radiology
 38 **              Washington University School of Medicine
 39 **
 40 ** Module Name(s):
 41 **                      DCM_ListToString
 42 **                      DCM_IsString
 43 ** Author, Date:        Stephen M. Moore, 13-Jun-93
 44 ** Intent:              This file contains more DCM routines which are used
 45 **                      as support for the DCM facility and for applications.
 46 **                      These routines help parse strings and other data
 47 **                      values that are encoded in DICOM objects.
 48 ** Last Update:         $Author: smm $, $Date: 1998/07/31 19:39:56 $
 49 ** Source File:         $RCSfile: dcmsupport.c,v $
 50 ** Revision:            $Revision: 1.15 $
 51 ** Status:              $State: Exp $
 52 */
 53 
 54 static char rcsid[] = "$Revision: 1.15 $ $RCSfile: dcmsupport.c,v $";
 55 #include <stdio.h>
 56 #include <errno.h>
 57 #include <string.h>
 58 #include <sys/types.h>
 59 #ifndef MACOS
 60 #include <stdlib.h>
 61 #endif
 62 #ifdef MALLOC_DEBUG
 63 #include "malloc.h"
 64 #endif
 65 
 66 #include "dicom.h"
 67 #include "condition.h"
 68 #include "lst.h"
 69 #include "dicom_objects.h"
 70 #include "dcmprivate.h"
 71 
 72 /* DCM_ListToString
 73 **
 74 ** Purpose:
 75 **      Convert the list of strings into a single string separated by '\'
 76 **
 77 ** Parameter Dictionary:
 78 **      list            Handle to the list of strings
 79 **      offset          The actual string starts at "offset" offset in
 80 **                      each individual structure chained in the list
 81 **      string          The single large string returned to the caller
 82 **
 83 ** Return Values:
 84 **      DCM_NORMAL
 85 **      DCM_LISTFAILURE
 86 **      DCM_MALLOCFAILURE
 87 **
 88 ** Notes:
 89 **
 90 ** Algorithm:
 91 **      Description of the algorithm (optional) and any other notes.
 92 */
 93 typedef struct {
 94     void *reserved[2];
 95     char *s;
 96 }   GENERIC;
 97 
 98 CONDITION
 99 DCM_ListToString(LST_HEAD * list, long offset, char **string)
100 {
101     GENERIC
102         * g;
103     char
104        *c,
105        *p;
106     long
107         length;
108 
109     *string = NULL;
110     if (list == NULL)
111         return DCM_NORMAL;
112 
113     g = LST_Head(&list);
114     if (g == NULL)
115         return DCM_NORMAL;
116 
117     (void) LST_Position(&list, g);
118 
119     length = 0;
120     while (g != NULL) {
121         c = ((char *) g) + offset;
122         length += strlen(c) + 1;
123         g = LST_Next(&list);
124     }
125 
126     p = CTN_MALLOC(length);
127     if (p == NULL)
128         return COND_PushCondition(DCM_MALLOCFAILURE,
129                 DCM_Message(DCM_MALLOCFAILURE), length, "DCM_ListToString");
130 
131     *string = p;
132     g = LST_Head(&list);
133     if (g == NULL)
134         return COND_PushCondition(DCM_LISTFAILURE, DCM_Message(DCM_LISTFAILURE),
135                                   "DCM_ListToString");
136     (void) LST_Position(&list, g);
137 
138     length = 0;
139     while (g != NULL) {
140         c = ((char *) g) + offset;
141         length = strlen(c);
142         (void) memcpy(p, c, length);
143         p += length;
144         *p++ = '\\';
145         g = LST_Next(&list);
146     }
147     *--p = '\0';
148     return DCM_NORMAL;
149 }
150 
151 
152 /* DCM_IsString
153 **
154 ** Purpose:
155 **      Verify if the DICOM value representation is that of a string
156 **
157 ** Parameter Dictionary:
158 **      representation          One of the many DICOM value representations
159 **
160 ** Return Values:
161 **      TRUE
162 **      FALSE
163 **
164 ** Notes:
165 **
166 ** Algorithm:
167 **      Description of the algorithm (optional) and any other notes.
168 */
169 
170 CTNBOOLEAN
171 DCM_IsString(DCM_VALUEREPRESENTATION representation)
172 {
173     CTNBOOLEAN
174         flag = FALSE;
175 
176     switch (representation) {
177     case DCM_AE:                /* Application Entity */
178     case DCM_AS:                /* Age string */
179         flag = TRUE;
180         break;
181     case DCM_AT:                /* Attribute tag */
182         break;
183     case DCM_CS:                /* Control string */
184     case DCM_DA:                /* Date */
185         flag = TRUE;
186         break;
187     case DCM_DD:                /* Data set */
188         break;
189     case DCM_DS:                /* Decimal string */
190     case DCM_DT:                /* Old date/time */
191         flag = TRUE;
192         break;
193     case DCM_FD:                /* Floating double */
194     case DCM_FL:                /* Float */
195         break;
196     case DCM_IS:                /* Integer string */
197     case DCM_LO:                /* Long string */
198     case DCM_LT:                /* Long text */
199         flag = TRUE;
200         break;
201     case DCM_OB:                /* Other binary value (byte) */
202     case DCM_OT:                /* Other binary value */
203     case DCM_OW:                /* Other binary value (word) */
204         break;
205     case DCM_SH:                /* Short string */
206         flag = TRUE;
207         break;
208     case DCM_SL:                /* Signed long */
209     case DCM_SQ:                /* Sequence of items */
210     case DCM_SS:                /* Signed short */
211         break;
212     case DCM_ST:                /* Short text */
213     case DCM_TM:                /* Time */
214         flag = TRUE;
215         break;
216     case DCM_UL:                /* Unsigned long */
217     case DCM_US:                /* Unsigned short */
218     case DCM_UNKNOWN:           /* Unknown/unspecified */
219     case DCM_RET:               /* Retired */
220     case DCM_CTX:               /* Context sensitive */
221         break;
222     case DCM_PN:                /* Person Name */
223     case DCM_UI:                /* Unique identifier (UID) */
224         flag = TRUE;
225         break;
226     };
227     return flag;
228 }
229 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.