17 #define realpath( a, b ) GetFullPathName( a, PATH_MAX, b, NULL )
22 #if defined __cplusplus
28 const char *evaluation,
const char *projectile,
const char *
target );
30 int projectile_PoPID,
int target_PoPID );
32 int projectile_PoPID,
int target_PoPID );
37 #if defined __cplusplus
42 #if defined __cplusplus
75 char const *aliases[] = {
"Co58m1",
"Ag110m1",
"Cd115m1",
"Te127m1",
"Te129m1",
"Pm148m1",
"Ho166m1",
"Am242m1",
"Am244m1",
"Es254m1" };
76 char const *targets[] = {
"Co58_e1",
"Ag110_e2",
"Cd115_e1",
"Te127_e2",
"Te129_e1",
"Pm148_e2",
"Ho166_e1",
"Am242_e2",
"Am244_e1",
"Es254_e2" };
77 int i1, n1 =
sizeof( aliases ) /
sizeof( aliases[1] );
80 for( i1 = 0; i1 < n1; i1++ ) {
102 const char *evaluation, *projectile, *targetName, *path, *schema;
107 if( ( basePath == NULL ) || ( mapFileName[0] ==
'/' ) ) {
108 strcpy( realPath, mapFileName ); }
110 strcpy( realPath, basePath );
111 strcat( realPath,
"/" );
112 strcat( realPath, mapFileName );
114 if( realpath( realPath,
p ) == NULL ) {
118 n = (
int) strlen(
p ) + 2;
122 strcpy( map->
path,
p );
123 if( (
p = strrchr( map->
path,
'/' ) ) != NULL ) {
126 strcpy( map->
path,
"." );
133 if( strcmp( child->
name,
"path" ) == 0 ) {
139 else if( strcmp( child->
name,
"target" ) == 0 ) {
187 for( entry = map->
mapEntries; entry != NULL; entry = next ) {
213 return( entry->
next );
229 if( entry != NULL ) {
232 return( entry != NULL );
238 const char *path,
const char *evaluation,
const char *projectile,
const char *targetName ) {
256 if( ( entry->
path = (
char *)
smr_malloc2( smr, strlen( path ) + 1, 0,
"path" ) ) == NULL )
goto err;
257 strcpy( entry->
path, path );
260 if( evaluation != NULL ) {
261 if( ( entry->
evaluation = (
char *)
smr_malloc2( smr, strlen( evaluation ) + 1, 0,
"evaluation" ) ) == NULL )
goto err;
265 if( projectile != NULL ) {
267 if( ( entry->
projectile = (
char *)
smr_malloc2( smr, strlen( projectile ) + 1, 0,
"projectile" ) ) == NULL )
goto err;
271 if( targetName != NULL ) {
273 if( ( entry->
targetName = (
char *)
smr_malloc2( smr, strlen( targetName ) + 1, 0,
"target" ) ) == NULL )
goto err;
277 if( schema != NULL ) {
278 if( ( entry->
schema = (
char *)
smr_malloc2( smr, strlen( schema ) + 1, 0,
"schema" ) ) == NULL )
goto err;
279 strcpy( entry->
schema, schema );
303 int projectile_PoPID,
int target_PoPID ) {
311 if( !
smr_isOk( smr ) )
return( NULL );
315 if( ( path == NULL ) &&
smr_isOk( smr ) ) {
316 if( evaluation == NULL ) {
318 targetName, projectileName ); }
321 targetName, projectileName, evaluation );
330 int projectile_PoPID,
int target_PoPID ) {
336 if( evaluation != NULL ) {
337 if( strlen( evaluation ) == 0 ) evaluation = NULL;
340 for( entry = map->
mapEntries; entry != NULL; entry = entry->
next ) {
341 switch( entry->
type ) {
344 if( evaluation == NULL ) {
347 status = strcmp( evaluation, entry->
evaluation ) == 0;
350 n = (
int) strlen( map->
path ) + 1 + (
int) strlen( entry->
path ) + 1;
351 if( ( path = (
char * )
smr_malloc2( smr, n, 0,
"path" ) ) == NULL )
return( NULL );
352 strcpy( path, map->
path );
354 if( entry->
path[0] ==
'/' ) {
355 strcpy( path, entry->
path ); }
357 strcat( path, entry->
path );
378 int projectile_PoPID, target_PoPID;
396 if( ( mapAllOfTarget =
MCGIDI_map_new( smr ) ) == NULL )
return( NULL );
399 return( mapAllOfTarget );
405 int projectile_PoPID,
int target_PoPID ) {
409 for( entry = map->
mapEntries; entry != NULL; entry = entry->
next ) {
410 switch( entry->
type ) {
432 int projectile_PoPID, target_PoPID;
445 if( endPath[0] ==
'/' ) {
446 if( ( path = (
char *)
smr_malloc2( smr, strlen( endPath ) + 1, 0,
"path" ) ) == NULL )
return( NULL );
449 if( ( path = (
char *)
smr_malloc2( smr, strlen( map->
path ) + strlen( endPath ) + 2, 0,
"path" ) ) == NULL )
return( NULL );
450 strcpy( path, map->
path );
453 strcat( path, endPath );
464 switch( target->
type ) {
485 for( entry = map->
mapEntries; entry != NULL; entry = entry->
next ) {
486 if( handler( entry, level, userData ) != 0 )
return( 1 );
505 char targetFormat[] =
"<target schema=\"%s\" evaluation=\"%s\" projectile=\"%s\" target=\"%s\" path=\"%s\"/>\n";
506 char pathFormat[] =
"<path projectile=\"%s\" path=\"%s\"/>\n";
507 char start[] =
"<map>\n";
508 char end[] =
"</map>";
509 int n = 0, nStart = (
int) strlen( start ), nEnd = (
int) strlen( end );
510 int nTarget = (
int) strlen( targetFormat ) - 10, nPath = (
int) strlen( pathFormat ) - 4;
514 n = nStart + nEnd + 1;
515 for( entry = map->
mapEntries; entry != NULL; entry = entry->
next ) {
516 switch( entry->
type ) {
529 if( ( s = (
char *)
smr_malloc2( smr, n, 0,
"xml string" ) ) == NULL )
return( NULL );
533 for( entry = map->
mapEntries; entry != NULL; entry = entry->
next ) {
534 switch( entry->
type ) {
558 int n = (
int ) strlen( sLevel ) / 4;
561 fprintf( f,
"Bad map status = %d\n", map->
status );
564 if( level < n ) sLevel[4 * level] = 0;
565 fprintf( f,
"%smap->path = %s\n", sLevel, map->
path );
566 fprintf( f,
"%smap->mapFileName = %s\n", sLevel, map->
mapFileName );
567 for( entry = map->
mapEntries; entry != NULL; entry = entry->
next ) {
568 switch( entry->
type ) {
570 fprintf( f,
"%sType = target: schema = %s: evaluation = %s: projectile = %s: target = %s: path = %s\n", sLevel, entry->
schema,
574 fprintf( f,
"%sType = path: path = %s\n", sLevel, entry->
path );
578 fprintf( f,
"%sUnknown type = %d\n", sLevel, entry->
type );
592 #if defined __cplusplus
MCGIDI_mapEntry * mapEntries
enum MCGIDI_mapEntry_type type
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
static MCGIDI_mapEntry * _MCGIDI_map_addEntry(statusMessageReporting *smr, MCGIDI_map *map, enum MCGIDI_mapEntry_type type, const char *schema, const char *path, const char *evaluation, const char *projectile, const char *target)
xDataXML_element * xDataXML_getFirstElement(xDataXML_element *element)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int globalPoPsIndexTarget
xDataXML_element * xDataXML_getNextElement(xDataXML_element *element)
MCGIDI_map * MCGIDI_map_findAllOfTargetViaPoPIDs(statusMessageReporting *smr, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
void MCGIDI_map_simpleWrite(FILE *f, MCGIDI_map *map)
int globalPoPsIndexProjectile
xDataXML_document * xDataXML_importFile2(statusMessageReporting *smr, char const *fileName)
char * MCGIDI_map_findTargetViaPoPIDs(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
static char * _MCGIDI_map_findTargetViaPoPIDs2(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
PoP * PoPs_addAliasIfNeeded(statusMessageReporting *smr, char const *name, char const *alias)
#define smr_malloc2(smr, size, zero, forItem)
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
smr_userInterface smrUserInterface
char * MCGIDI_map_getTargetsFullPath(statusMessageReporting *smr, MCGIDI_mapEntry *target)
char * MCGIDI_map_findTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, const char *projectile, const char *targetName)
MCGIDI_map * MCGIDI_map_new(statusMessageReporting *smr)
int smr_isOk(statusMessageReporting *smr)
static char * _MCGIDI_map_smrUserInterface(void *userData)
static int _MCGIDI_map_walkTree2(statusMessageReporting *smr, MCGIDI_map *map, int level, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
MCGIDI_map * MCGIDI_map_findAllOfTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *projectile, const char *targetName)
char * MCGIDI_map_toXMLString(statusMessageReporting *smr, MCGIDI_map *map)
int MCGIDI_map_addTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *method, const char *path, const char *evaluation, const char *projectile, const char *targetName)
char * MCGIDI_map_getFullPath(statusMessageReporting *smr, MCGIDI_map *map, const char *endPath)
void * xDataXML_freeDoc(statusMessageReporting *smr, xDataXML_document *doc)
static int _MCGIDI_map_findAllOfTargetViaPoPIDs2(statusMessageReporting *smr, MCGIDI_map *mapAllOfTarget, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
void * smr_freeMemory(void **p)
int MCGIDI_map_addPath(statusMessageReporting *smr, MCGIDI_map *map, const char *path)
#define smr_setReportInfo3p(smr, userInterface, libraryID, code, fmt)
static void _MCGIDI_map_simpleWrite2(FILE *f, MCGIDI_map *map, int level)
xDataXML_element * xDataXML_getDocumentsElement(xDataXML_document *doc)
MCGIDI_mapEntry * MCGIDI_map_getFirstEntry(MCGIDI_map *map)
int MCGIDI_map_initialize(statusMessageReporting *smr, MCGIDI_map *map)
MCGIDI_mapEntry * MCGIDI_map_getNextEntry(MCGIDI_mapEntry *entry)
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)
char * smr_allocateFormatMessage(char const *fmt,...)
char const * PoPs_getName_atIndex(statusMessageReporting *smr, int index)
MCGIDI_map * MCGIDI_map_readFile(statusMessageReporting *smr, const char *basePath, const char *mapFileName)
#define smr_setReportError3p(smr, userInterface, libraryID, code, fmt)
void MCGIDI_map_release(statusMessageReporting *smr, MCGIDI_map *map)
#define smr_setReportError3(smr, userInterface, libraryID, code, fmt,...)
int MCGIDI_map_walkTree(statusMessageReporting *smr, MCGIDI_map *map, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
char const * xDataXML_getAttributesValueInElement(xDataXML_element *element, char const *name)
MCGIDI_map_smr smrUserInterface
enum MCGIDI_map_status status