17 #if defined __cplusplus
22 #define nameValueLength 1024
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;
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] !=
'@' ) {
127 if( strcmp( value, attributesValue ) )
continue;
129 if( slash == NULL )
return( child );
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