17#if defined __cplusplus
22#define nameValueLength 1024
25static int xDataTOM_getLinksElement3(
statusMessageReporting *smr,
char const *nameValue,
char *name,
char *value,
char const *fullLink );
33 int n = (int) strlen( fileName ) + 1, nCwd = 0;
34 char *absPath, cwd[4 * 1024] =
"", *p, *needle;
36 if( fileName[0] !=
'/' ) {
39 if( getcwd( cwd,
sizeof( cwd ) ) == NULL ) {
43 nCwd = (int) strlen( cwd );
46 if( ( absPath = (
char *)
smr_malloc2( smr, n, 0,
"absPath" ) ) == NULL )
return( NULL );
47 if( fileName[0] !=
'/' ) {
48 strcpy( absPath, cwd );
49 strcat( absPath,
"/" );
50 strcat( absPath, fileName ); }
52 strcpy( absPath, fileName );
56 if( ( needle = strstr( absPath,
"/./" ) ) == NULL )
break;
58 for( needle += 2; *needle; p++, needle++ ) *p = *needle;
63 if( ( needle = strstr( absPath,
"/../" ) ) == NULL )
break;
65 while( ( p > absPath ) && ( *p !=
'/' ) ) p--;
66 if( *p !=
'/' )
break;
67 if( p == absPath )
break;
68 for( needle += 3; *needle; p++, needle++ ) *p = *needle;
77 const char *fmt, ... ) {
81 va_start( args, fmt );
93 if( link[0] ==
'/' ) {
94 for( linkedElement = element; linkedElement->
parent != NULL; ) linkedElement = linkedElement->
parent;
95 linkedElement = xDataTOM_getLinksElement2( smr, linkedElement, &(link[1]), link ); }
99 return( linkedElement );
106 int n = (int) strlen( link );
107 char const *slash = strchr( link,
'/' ), *bracket = strchr( link,
'[' ), *attributesValue;
111 if( bracket != NULL )
n = (int) ( bracket - link );
112 if( slash != NULL ) {
113 if( (
int) ( slash - link ) < n ) {
114 n = (int) ( slash - link );
118 for( child = element->
children; child != NULL; child = child->
next ) {
119 if( strncmp( link, child->
name, n ) == 0 ) {
120 if( bracket != NULL ) {
121 if( bracket[1] !=
'@' ) {
125 if( xDataTOM_getLinksElement3( smr, &(bracket[2]), name, value, fullLink ) )
return( NULL );
127 if( strcmp( value, attributesValue ) )
continue;
129 if( slash == NULL )
return( child );
130 return( xDataTOM_getLinksElement2( smr, child, &(slash[1]), fullLink ) );
138static int xDataTOM_getLinksElement3(
statusMessageReporting *smr,
char const *nameValue,
char *name,
char *value,
char const *fullLink ) {
141 char const *equal = strchr( nameValue,
'=' ), *p;
144 if( equal == NULL ) {
148 n = (int) ( equal - nameValue );
153 strncpy( name, nameValue, n );
157 if( *equal != quote ) quote =
'"';
158 if( *equal != quote ) {
164 p = strchr( equal, quote );
170 n = (int) ( p - equal );
175 strncpy( value, equal, n );
181#if defined __cplusplus
const char * name(G4int ptype)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
#define smr_setReportError2p(smr, libraryID, code, fmt)
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
#define smr_malloc2(smr, size, zero, forItem)
xDataTOM_element * children
xDataTOM_element * parent
xDataTOM_element * xDataTOM_getLinksElement(statusMessageReporting *smr, xDataTOM_element *element, char const *link)
int xDataTOM_setMessageError_ReturnInt(int value, statusMessageReporting *smr, void *userData, const char *file, int line, int code, const char *fmt,...)
char const * xDataTOM_getAttributesValueInElement(xDataTOM_element *element, char const *name)
char * xDataTOMMisc_getAbsPath(statusMessageReporting *smr, const char *fileName)
int xDataTOM_smrLibraryID