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 ) {
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