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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/xDataTOM.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/xDataTOM.cc (Version 8.1.p1)


  1 /*                                                  1 
  2 # <<BEGIN-copyright>>                             
  3 # <<END-copyright>>                               
  4 */                                                
  5                                                   
  6 #include <stdlib.h>                               
  7 #include <string.h>                               
  8 #include <ctype.h>                                
  9 #include <sys/types.h>                            
 10 #include <sys/stat.h>                             
 11 #include <fcntl.h>                                
 12 #include <errno.h>                                
 13                                                   
 14 #if defined(WIN32) || defined(__MINGW32__)        
 15 #include <windows.h>                              
 16 #define realpath( a, b ) GetFullPathName( a, P    
 17 #define strtoll _strtoi64                         
 18 #else                                             
 19 #include <unistd.h>                               
 20 #endif                                            
 21                                                   
 22 #include "xDataTOM_importXML_private.h"           
 23 #include "xDataTOM_private.h"                     
 24                                                   
 25 #if defined __cplusplus                           
 26 namespace GIDI {                                  
 27 using namespace GIDI;                             
 28 #endif                                            
 29                                                   
 30 #ifndef PATH_MAX                                  
 31 #define PATH_MAX 4096                             
 32 #endif                                            
 33                                                   
 34 int xDataTOM_smrLibraryID = smr_unknownID;        
 35                                                   
 36 static int xDataTOME_initializeElement( status    
 37     char const *name );                           
 38 static void xDataTOME_displayTree( statusMessa    
 39                                                   
 40 static int xDataTOM_initialize_xData( statusMe    
 41 /*                                                
 42 **********************************************    
 43 */                                                
 44 xDataTOM_TOM *xDataTOM_importFile( statusMessa    
 45 /*                                                
 46 *   Returns NULL is an error occurred.            
 47 */                                                
 48                                                   
 49     return( xDataXML_importFile( smr, fileName    
 50 }                                                 
 51 /*                                                
 52 **********************************************    
 53 */                                                
 54 xDataTOM_TOM *xDataTOM_mallocTOM( statusMessag    
 55 /*                                                
 56 *   Returns NULL is an error occurred.            
 57 */                                                
 58     xDataTOM_TOM *TOM;                            
 59                                                   
 60     if( ( TOM = (xDataTOM_TOM *) smr_malloc2(     
 61         if( xDataTOM_initializeTOM( smr, TOM )    
 62     }                                             
 63     return( TOM );                                
 64 }                                                 
 65 /*                                                
 66 **********************************************    
 67 */                                                
 68 int xDataTOM_initializeTOM( statusMessageRepor    
 69                                                   
 70     TOM->fileName = NULL;                         
 71     TOM->realFileName = NULL;                     
 72     xDataTOME_initializeElement( smr, &(TOM->r    
 73     return( !smr_isOk( smr ) );                   
 74 }                                                 
 75 /*                                                
 76 **********************************************    
 77 */                                                
 78 void *xDataTOM_freeTOM( statusMessageReporting    
 79                                                   
 80     xDataTOM_TOM *TOMp;                           
 81                                                   
 82     if( TOM == NULL ) return( NULL );             
 83     TOMp = *TOM;                                  
 84     if( TOMp == NULL ) return( NULL );            
 85     xDataTOM_releaseElement( &(TOMp->root) );     
 86     smr_freeMemory( (void **) &(TOMp->fileName    
 87     smr_freeMemory( (void **) &(TOMp->realFile    
 88     smr_freeMemory( (void **) TOM );              
 89     return( NULL );                               
 90 }                                                 
 91 /*                                                
 92 **********************************************    
 93 */                                                
 94 int xDataTOM_setFileNameTOM( statusMessageRepo    
 95 /*                                                
 96 *   Returns not zero value if error occurred.     
 97 */                                                
 98                                                   
 99     char realPath[PATH_MAX+1];                    
100                                                   
101     smr_freeMemory( (void **) &(TOM->fileName)    
102     smr_freeMemory( (void **) &(TOM->realFileN    
103         if( fileName != NULL ) {                  
104         if( ( TOM->fileName = smr_allocateCopy    
105         if( realpath( fileName, realPath ) !=     
106             if( ( TOM->realFileName = smr_allo    
107         }                                         
108     }                                             
109     return( 0 );                                  
110 }                                                 
111 /*                                                
112 **********************************************    
113 */                                                
114 void xDataTOM_displayTree( statusMessageReport    
115                                                   
116     if( TOM->root.children != NULL ) xDataTOME    
117 }                                                 
118                                                   
119 /****************************************         
120 *       Element functions.                        
121 ****************************************/         
122 /*                                                
123 **********************************************    
124 */                                                
125 xDataTOM_element *xDataTOM_mallocElement( stat    
126 /*                                                
127 *   Returns NULL is an error occurred.            
128 */                                                
129     xDataTOM_element *element;                    
130                                                   
131     if( ( element = (xDataTOM_element *) smr_m    
132         if( xDataTOME_initializeElement( smr,     
133     }                                             
134     return( element );                            
135 }                                                 
136 /*                                                
137 **********************************************    
138 */                                                
139 void xDataTOM_freeElement( xDataTOM_element **    
140                                                   
141     if( element == NULL ) return;                 
142     xDataTOM_releaseElement( *element );          
143     smr_freeMemory( (void **) element );          
144 }                                                 
145 /*                                                
146 **********************************************    
147 */                                                
148 void xDataTOM_releaseElement( xDataTOM_element    
149                                                   
150     xDataTOM_element *child, *nextChild;          
151                                                   
152     if( element == NULL ) return;                 
153     xDataTOMAL_release( &(element->attributes)    
154     for( child = element->children; child != N    
155         nextChild = child->next;                  
156         xDataTOM_freeElement( &child );           
157     }                                             
158     if( element->xDataInfo.ID != NULL ) {         
159         xDataTOM_axes_release( &(element->xDat    
160         if( strcmp( element->xDataInfo.ID, xDa    
161             xDataTOM_XYs_free( &(element->xDat    
162         else if( strcmp( element->xDataInfo.ID    
163             xDataTOM_regionsXYs_free( &(elemen    
164         else if( strcmp( element->xDataInfo.ID    
165             xDataTOM_W_XYs_freeFrom_xDataInfo(    
166         else if( strcmp( element->xDataInfo.ID    
167             xDataTOM_V_W_XYs_free( &(element->    
168         else if( strcmp( element->xDataInfo.ID    
169             xDataTOM_W_XYs_LegendreSeries_free    
170         else if( strcmp( element->xDataInfo.ID    
171             xDataTOM_regionsW_XYs_LegendreSeri    
172         else if( strcmp( element->xDataInfo.ID    
173             xDataTOM_V_W_XYs_LegendreSeries_fr    
174         else if( strcmp( element->xDataInfo.ID    
175             xDataTOM_KalbachMann_free( &(eleme    
176         else if( strcmp( element->xDataInfo.ID    
177             xDataTOM_polynomial_free( &(elemen    
178         else {                                    
179             printf( "not freed for %s\n", elem    
180         }                                         
181     }                                             
182     element->parent = NULL;                       
183     smr_freeMemory( (void **) &(element->name)    
184 }                                                 
185 /*                                                
186 **********************************************    
187 */                                                
188 xDataTOM_element *xDataTOM_addElementInElement    
189                                                   
190     xDataTOM_element *element;                    
191                                                   
192     if( ( element = xDataTOM_mallocElement( sm    
193     if( parent->children == NULL ) {              
194         parent->children = element; }             
195     else {                                        
196         xDataTOM_element *last;                   
197                                                   
198         for( last = parent->children; last->ne    
199         last->next = element;                     
200     }                                             
201     (parent->numberOfChildren)++;                 
202     return( element );                            
203 }                                                 
204 /*                                                
205 **********************************************    
206 */                                                
207 static int xDataTOME_initializeElement( status    
208         char const *name ) {                      
209                                                   
210     element->ordinal = ordinal;                   
211     element->index = index;                       
212     element->parent = parent;                     
213     element->next = NULL;                         
214     element->name = smr_allocateCopyString2( s    
215     xDataTOMAL_initial( smr, &(element->attrib    
216     element->numberOfChildren = 0;                
217     element->children = NULL;                     
218     return( ( xDataTOM_initialize_xData( smr,     
219 }                                                 
220 /*                                                
221 **********************************************    
222 */                                                
223 xDataTOM_element *xDataTOM_getDocumentsElement    
224                                                   
225     return( TOM->root.children );                 
226 }                                                 
227 /*                                                
228 **********************************************    
229 */                                                
230 xDataTOM_element *xDataTOME_getFirstElement( x    
231                                                   
232     if( element != NULL ) element = element->c    
233     return( element );                            
234 }                                                 
235 /*                                                
236 **********************************************    
237 */                                                
238 xDataTOM_element *xDataTOME_getNextElement( xD    
239                                                   
240     if( element != NULL ) element = element->n    
241     return( element );                            
242 }                                                 
243 /*                                                
244 **********************************************    
245 */                                                
246 xDataTOM_element *xDataTOME_getOneElementByNam    
247                                                   
248     int n = 0;                                    
249     xDataTOM_element *child, *desired = NULL;     
250                                                   
251     for( child = xDataTOME_getFirstElement( el    
252         if( strcmp( child->name, name ) == 0 )    
253             if( n == 0 ) desired = child;         
254             n++;                                  
255         }                                         
256     }                                             
257     if( n == 0 ) {                                
258         if( required ) smr_setReportError2( sm    
259     else if( n > 1 ) {                            
260         smr_setReportError2( smr, smr_unknownI    
261         desired = NULL;                           
262     }                                             
263     return( desired );                            
264 }                                                 
265 /*                                                
266 **********************************************    
267 */                                                
268 int xDataTOM_numberOfElementsByName( statusMes    
269                                                   
270     int n = 0;                                    
271     xDataTOM_element *child;                      
272                                                   
273     for( child = xDataTOME_getFirstElement( el    
274     return( n );                                  
275 }                                                 
276 /*                                                
277 **********************************************    
278 */                                                
279 int xDataTOME_addAttribute( statusMessageRepor    
280                                                   
281     return( xDataTOMAL_addAttribute( smr, &(el    
282 }                                                 
283 /*                                                
284 **********************************************    
285 */                                                
286 char const *xDataTOM_getAttributesValueInEleme    
287                                                   
288     return( xDataTOMAL_getAttributesValue( &(e    
289 }                                                 
290 /*                                                
291 **********************************************    
292 */                                                
293 int xDataTOME_copyAttributionList( statusMessa    
294                                                   
295     return( xDataTOMAL_copyAttributionList( sm    
296 }                                                 
297 /*                                                
298 **********************************************    
299 */                                                
300 int xDataTOME_convertAttributeToInteger( statu    
301                                                   
302     return( xDataTOMAL_convertAttributeToInteg    
303 }                                                 
304 /*                                                
305 **********************************************    
306 */                                                
307 int xDataTOME_convertAttributeToDouble( status    
308                                                   
309     return( xDataTOMAL_convertAttributeToDoubl    
310 }                                                 
311 /*                                                
312 **********************************************    
313 */                                                
314 int xDataTOME_getInterpolation( statusMessageR    
315     enum xDataTOM_interpolationFlag *dependent    
316                                                   
317     xDataTOM_xDataInfo *xDI = &(element->xData    
318                                                   
319     if( xDI->ID == NULL ) return( 1 );            
320                                                   
321     return( xDataTOM_axes_getInterpolation( sm    
322 }                                                 
323 /*                                                
324 **********************************************    
325 */                                                
326 static void xDataTOME_displayTree( statusMessa    
327                                                   
328     int i;                                        
329     xDataTOM_element *child;                      
330                                                   
331     for( i = 0; i < level; i++ ) printf( "        
332     printf( "/%s", element->name );               
333     if( element->index >= 0 ) printf( " (%d)",    
334     if( printAttributes ) {                       
335         xDataTOM_attribute *attribute;            
336                                                   
337         for( attribute = element->attributes.a    
338             printf( " (%s, \"%s\")", attribute    
339         }                                         
340     }                                             
341     printf( "\n" );                               
342     for( child = xDataTOME_getFirstElement( el    
343         xDataTOME_displayTree( smr, child, pri    
344     }                                             
345 }                                                 
346                                                   
347 /****************************************         
348 *       Attribute functions.                      
349 ****************************************/         
350 /*                                                
351 **********************************************    
352 */                                                
353 void xDataTOMAL_initial( statusMessageReportin    
354                                                   
355     attributes->number = 0;                       
356     attributes->attributes = NULL;                
357 }                                                 
358 /*                                                
359 **********************************************    
360 */                                                
361 void xDataTOMAL_release( xDataTOM_attributionL    
362                                                   
363     xDataTOM_attribute *attribute, *next;         
364                                                   
365     for( attribute = attributes->attributes; a    
366         next = attribute->next;                   
367         smr_freeMemory( (void **) &(attribute-    
368         smr_freeMemory( (void **) &(attribute-    
369         smr_freeMemory( (void **) &(attribute)    
370     }                                             
371     xDataTOMAL_initial( NULL, attributes );       
372 }                                                 
373 /*                                                
374 **********************************************    
375 */                                                
376 int xDataTOMAL_addAttribute( statusMessageRepo    
377                                                   
378     xDataTOM_attribute *attribute;                
379                                                   
380     if( ( attribute = (xDataTOM_attribute *) s    
381     if( ( attribute->name = smr_allocateCopySt    
382     if( ( attribute->value = smr_allocateCopyS    
383     if( attributes->attributes == NULL ) {        
384         attributes->attributes = attribute; }     
385     else {                                        
386         xDataTOM_attribute *last;                 
387                                                   
388         for( last = attributes->attributes; la    
389         last->next = attribute;                   
390     }                                             
391     attributes->number++;                         
392     return( 0 );                                  
393                                                   
394 err:                                              
395     smr_freeMemory( (void **) &(attribute->nam    
396     smr_freeMemory( (void **) &(attribute->val    
397     smr_freeMemory( (void **) &(attribute) );     
398     return( 1 );                                  
399 }                                                 
400 /*                                                
401 **********************************************    
402 */                                                
403 char const *xDataTOMAL_getAttributesValue( xDa    
404                                                   
405     xDataTOM_attribute *attribute;                
406                                                   
407     for( attribute = attributes->attributes; a    
408         if( !strcmp( attribute->name, name ) )    
409     }                                             
410     return( NULL );                               
411 }                                                 
412 /*                                                
413 **********************************************    
414 */                                                
415 int xDataTOMAL_copyAttributionList( statusMess    
416                                                   
417     xDataTOM_attribute *attribute;                
418                                                   
419     xDataTOMAL_initial( smr, desc );              
420     for( attribute = src->attributes; attribut    
421         if( xDataTOMAL_addAttribute( smr, desc    
422                                                   
423     }                                             
424     return( 0 );                                  
425                                                   
426 err:                                              
427     xDataTOMAL_release( desc );                   
428     return( 1 );                                  
429 }                                                 
430 /*                                                
431 **********************************************    
432 */                                                
433 int xDataTOMAL_convertAttributeToInteger( stat    
434                                                   
435     char const *value = xDataTOMAL_getAttribut    
436     char *e;                                      
437                                                   
438     if( value != NULL ) {                         
439         *n = (int) strtoll( value, &e, 10 );      
440         if( *e == 0 ) return( 0 );                
441         smr_setReportError2( smr, xDataTOM_smr    
442     else {                                        
443         smr_setReportError2( smr, xDataTOM_smr    
444     }                                             
445     return( 1 );                                  
446 }                                                 
447 /*                                                
448 **********************************************    
449 */                                                
450 int xDataTOMAL_convertAttributeToDouble( statu    
451                                                   
452     char const *value = xDataTOMAL_getAttribut    
453     char *e;                                      
454                                                   
455     if( value != NULL ) {                         
456         *d = strtod( value, &e );                 
457         if( *e == 0 ) return( 0 );                
458         smr_setReportError2( smr, xDataTOM_smr    
459     else {                                        
460         smr_setReportError2( smr, xDataTOM_smr    
461     }                                             
462     return( 1 );                                  
463 }                                                 
464                                                   
465                                                   
466 /****************************************         
467 *       xData functions.                          
468 ****************************************/         
469 /*                                                
470 **********************************************    
471 */                                                
472 static int xDataTOM_initialize_xData( statusMe    
473                                                   
474     return( 0 );                                  
475 }                                                 
476 /*                                                
477 **********************************************    
478 */                                                
479 void *xData_initializeData( statusMessageRepor    
480                                                   
481     xDataTOM_xDataInfo *xDI = &(TE->xDataInfo)    
482                                                   
483     xDI->data = NULL;                             
484     xDI->ID = ID;                                 
485     xDI->element = TE;                            
486     return( xDI->data = (void *) smr_malloc2(     
487 }                                                 
488 /*                                                
489 **********************************************    
490 */                                                
491 int xDataTOM_isXDataID( xDataTOM_element *TE,     
492                                                   
493     xDataTOM_xDataInfo *xDI = &(TE->xDataInfo)    
494                                                   
495     if( xDI->ID != NULL ) {                       
496         return( !strcmp( xDI->ID, ID ) );         
497     }                                             
498                                                   
499     return( 0 );                                  
500 }                                                 
501 /*                                                
502 **********************************************    
503 */                                                
504 xDataTOM_xDataInfo *xDataTOME_getXData( xDataT    
505                                                   
506     if( TE->xDataInfo.ID == NULL ) return( NUL    
507     return( &(TE->xDataInfo) );                   
508 }                                                 
509 /*                                                
510 **********************************************    
511 */                                                
512 void *xDataTOME_getXDataIfID( statusMessageRep    
513                                                   
514     xDataTOM_xDataInfo *xDI = xDataTOME_getXDa    
515                                                   
516     if( xDI == NULL ) {                           
517         smr_setReportError2( smr, xDataTOM_smr    
518         return( NULL );                           
519     }                                             
520     if( strcmp( ID, xDI->ID ) ) {                 
521         smr_setReportError2( smr, xDataTOM_smr    
522         return( NULL );                           
523     }                                             
524     return( xDI->data );                          
525                                                   
526 }                                                 
527                                                   
528 #if defined __cplusplus                           
529 }                                                 
530 #endif                                            
531