Commit a8096801 authored by Claes Sjofors's avatar Claes Sjofors

Show crossreferences, searches in all crossreference files, not just in the...

 Show crossreferences, searches in all crossreference files, not just in the file for the current volume
parent 8e3467fe
...@@ -182,134 +182,162 @@ int NavCrr::crr_signal( ...@@ -182,134 +182,162 @@ int NavCrr::crr_signal(
char *filename, char *filename,
char *signalname) char *signalname)
{ {
pwr_tFileName default_filename; pwr_tFileName default_filename;
FILE *file; char line[1000];
char line[1000]; int object_spaces;
int object_spaces; pwr_tAName object;
pwr_tAName object; pwr_tAName objname;
pwr_tAName objname; int spaces;
int spaces; int first;
int first; int sts;
int sts; char *s;
char *s; int wildcard;
int wildcard; int signalcount = 0;
int signalcount = 0; int crossref_count = 0;
int crossref_count = 0; pwr_tFileName filestr;
pwr_tFileName filestr; int lines;
int lines; pwr_tVolumeId volid;
pwr_tVolumeId volid; pwr_tObjid objid;
pwr_tObjid objid; pwr_tAName line_part[2];
pwr_tAName line_part[2]; int nr;
int nr; int write;
int write; int single_file = 0;
pwr_tFileName file_spec;
if ( filename && strcmp( filename, "*") == 0) {
strcpy( file_spec, "$pwrp_load/rtt_crr_*.dat");
sts = dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_INIT);
if ( EVEN(sts)) return sts;
}
cdh_ToUpper( signalname, signalname);
/* Check if wildcard */
s = strchr( signalname, '*');
if ( s == 0)
wildcard = 0;
else
wildcard = 1;
/* Open file */
while ( 1) {
FILE *file;
/* Open file */
if ( filename && strcmp( filename, "*") == 0) {
file = fopen( filestr, "r");
}
else if ( filename == NULL) {
/* Open file, first get the volume id */
if ( !wildcard) {
sts = (name_to_objid_cb)( parent_ctx, signalname, &objid);
if ( EVEN(sts))
return NAV__OBJECTNOTFOUND;
volid = objid.vid;
}
else {
sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts;
}
sprintf( default_filename, "%srtt_crr_%s.dat",
dcli_pwr_dir("pwrp_load"), nav_VolumeIdToStr( volid));
dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r");
single_file = 1;
}
else {
dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r");
single_file = 1;
}
if ( file == 0)
return NAV__NOFILE;
/* Get the hierarchy */
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
object_spaces = spaces;
cdh_ToUpper( signalname, signalname);
/* Check if wildcard */ first = 1;
s = strchr( signalname, '*'); while ( 1) {
if ( s == 0) if ( (s = strchr( object, ':')))
wildcard = 0; strcpy( objname, s+1);
else else
wildcard = 1; strcpy( objname, object);
/* Open file */ cdh_ToUpper( objname, objname);
if ( filename == NULL) {
/* Open file, first get the volume id */
if ( !wildcard) {
sts = (name_to_objid_cb)( parent_ctx, signalname, &objid);
if ( EVEN(sts))
return NAV__OBJECTNOTFOUND;
volid = objid.vid;
}
else {
sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts;
}
sprintf( default_filename, "%srtt_crr_%s.dat", sts = dcli_wildcard( signalname, objname);
dcli_pwr_dir("pwrp_load"), nav_VolumeIdToStr( volid)); if ( !sts ) {
dcli_get_defaultfilename( default_filename, filestr, NULL); /* Hit, print this object */
file = fopen( filestr, "r"); signalcount++;
}
else {
dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r");
}
if ( file == 0)
return NAV__NOFILE;
/* Get the hierarchy */
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
object_spaces = spaces;
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
while( spaces > object_spaces) {
nav_remove_spaces( line, line);
first = 1; if ( line[0] == 'W' || line[0] == '>')
while ( 1) { write = 1;
if ( (s = strchr( object, ':')))
strcpy( objname, s+1);
else else
strcpy( objname, object); write = 0;
cdh_ToUpper( objname, objname); nr = dcli_parse( &line[2], " ", "", (char *)line_part,
sizeof( line_part) / sizeof( line_part[0]),
sts = dcli_wildcard( signalname, objname); sizeof( line_part[0]), 0);
if ( !sts ) { if ( strcmp( line_part[nr-1], "") == 0 && nr > 2)
/* Hit, print this object */ nr--;
signalcount++; (insert_cb)( parent_ctx, parent_node,
navc_eItemType_Crossref,
sts = nav_get_signal_line( file, line, sizeof( line), line_part[nr-2], line_part[nr-1],
&spaces, object, &lines); write);
if ( EVEN(sts)) goto finish; crossref_count++;
while( spaces > object_spaces) { sts = nav_get_signal_line( file, line, sizeof( line),
nav_remove_spaces( line, line); &spaces, object, &lines);
if ( EVEN(sts)) goto finish;
if ( line[0] == 'W' || line[0] == '>') }
write = 1; if ( !wildcard)
else goto finish;
write = 0; }
else {
nr = dcli_parse( &line[2], " ", "", (char *)line_part, sts = nav_get_signal_line( file, line, sizeof( line),
sizeof( line_part) / sizeof( line_part[0]), &spaces, object, &lines);
sizeof( line_part[0]), 0); if ( EVEN(sts)) goto finish;
if ( strcmp( line_part[nr-1], "") == 0 && nr > 2) while( spaces > object_spaces) {
nr--; sts = nav_get_signal_line( file, line, sizeof( line),
(insert_cb)( parent_ctx, parent_node, &spaces, object, &lines);
navc_eItemType_Crossref, if ( EVEN(sts)) goto finish;
line_part[nr-2], line_part[nr-1],
write);
crossref_count++;
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
if ( !wildcard)
goto finish;
}
else {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
while( spaces > object_spaces) {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
}
} }
}
}
finish: finish:
fclose( file); fclose( file);
if ( signalcount == 0) if ( single_file)
return NAV__OBJECTNOTFOUND; break;
if ( crossref_count == 0) if ( filename && strcmp( filename, "*") == 0) {
return NAV__NOCROSSREF; sts = dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_NEXT);
if ( EVEN(sts)) break;
}
}
return NAV__SUCCESS; if ( filename && strcmp( filename, "*") == 0)
dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_END);
if ( signalcount == 0)
return NAV__OBJECTNOTFOUND;
if ( crossref_count == 0)
return NAV__NOCROSSREF;
return NAV__SUCCESS;
} }
...@@ -330,150 +358,177 @@ int NavCrr::crr_object( ...@@ -330,150 +358,177 @@ int NavCrr::crr_object(
char *filename, char *filename,
char *objectname) char *objectname)
{ {
pwr_tFileName default_filename; pwr_tFileName default_filename;
FILE *file; char line[1000];
char line[1000]; int object_spaces;
int object_spaces; pwr_tAName object;
pwr_tAName object; pwr_tAName objname;
pwr_tAName objname; int spaces;
int spaces; int first;
int first; int sts;
int sts; char *s;
char *s; int wildcard;
int wildcard; pwr_tFileName filestr;
int signalcount = 0; int lines;
pwr_tFileName filestr; pwr_tVolumeId volid;
int lines; pwr_tObjid objid;
pwr_tVolumeId volid; int crossref_count = 0;
pwr_tObjid objid; pwr_tAName line_part[2];
int crossref_count = 0; int nr;
pwr_tAName line_part[2]; int write;
int nr; int single_file = 0;
int write; pwr_tFileName file_spec;
int signalcount = 0;
cdh_ToUpper( objectname, objectname);
if ( filename && strcmp( filename, "*") == 0) {
/* Check if wildcard */ strcpy( file_spec, "$pwrp_load/rtt_crro_*.dat");
s = strchr( objectname, '*'); sts = dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_INIT);
if ( s == 0) if ( EVEN(sts)) return sts;
wildcard = 0; }
else
wildcard = 1; cdh_ToUpper( objectname, objectname);
/* Open file */ /* Check if wildcard */
if ( filename == NULL) { s = strchr( objectname, '*');
/* Open file, first get the volume id */ if ( s == 0)
if ( !wildcard) { wildcard = 0;
sts = (name_to_objid_cb)( parent_ctx, objectname, &objid); else
if ( EVEN(sts)) wildcard = 1;
return NAV__OBJECTNOTFOUND;
volid = objid.vid; while ( 1) {
} FILE *file;
else {
sts = (get_volume_cb)( parent_ctx, &volid); /* Open file */
if ( EVEN(sts)) return sts; if ( filename && strcmp( filename, "*") == 0) {
} file = fopen( filestr, "r");
}
sprintf( default_filename, "%srtt_crro_%s.dat", else if ( filename == NULL) {
dcli_pwr_dir("pwrp_load"), nav_VolumeIdToStr( volid)); /* Open file, first get the volume id */
dcli_get_defaultfilename( default_filename, filestr, NULL); if ( !wildcard) {
file = fopen( filestr, "r"); sts = (name_to_objid_cb)( parent_ctx, objectname, &objid);
} if ( EVEN(sts))
else { return NAV__OBJECTNOTFOUND;
dcli_get_defaultfilename( filename, filestr, ".lis"); volid = objid.vid;
file = fopen( filestr, "r"); }
} else {
sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts;
}
sprintf( default_filename, "%srtt_crro_%s.dat",
dcli_pwr_dir("pwrp_load"), nav_VolumeIdToStr( volid));
dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r");
single_file = 1;
}
else {
dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r");
single_file = 1;
}
if ( file == 0) if ( file == 0)
return NAV__NOFILE; return NAV__NOFILE;
/* Get the object */ /* Get the object */
sts = nav_get_signal_line( file, line, sizeof( line), sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines); &spaces, object, &lines);
if ( EVEN(sts)) goto finish;
object_spaces = spaces;
first = 1;
while ( 1) {
if ( (s = strchr( object, ':')))
strcpy( objname, s+1);
else
strcpy( objname, object);
cdh_ToUpper( objname, objname);
sts = dcli_wildcard( objectname, objname);
if ( sts) {
pwr_tAName subname;
strcpy( subname, objectname);
strcat( subname, ".*");
sts = dcli_wildcard( subname, objname);
}
if ( !sts ) {
/* Hit, print this object */
signalcount++;
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish; if ( EVEN(sts)) goto finish;
object_spaces = spaces; while( spaces > object_spaces) {
nav_remove_spaces( line, line);
first = 1; if ( line[0] == 'W') {
while ( 1) { write = 1;
if ( (s = strchr( object, ':'))) }
strcpy( objname, s+1); else if ( line[0] == '>') {
write = 2;
}
else else
strcpy( objname, object); write = 0;
cdh_ToUpper( objname, objname); nr = dcli_parse( &line[2], " ", "", (char *)line_part,
sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0);
if ( strcmp( line_part[nr-1], "") == 0 && nr > 2)
nr--;
if ( nr > 2 && line_part[nr-3][0] == '#')
write = 1;
else if ( nr > 2 && line_part[nr-3][0] == '&')
write = 2;
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Crossref,
line_part[nr-2], line_part[nr-1], write);
crossref_count++;
sts = dcli_wildcard( objectname, objname); sts = nav_get_signal_line( file, line, sizeof( line),
if ( sts) { &spaces, object, &lines);
pwr_tAName subname; if ( EVEN(sts)) goto finish;
strcpy( subname, objectname); }
strcat( subname, ".*"); }
else {
sts = dcli_wildcard( subname, objname); if ( !wildcard && signalcount)
} goto finish;
if ( !sts ) {
/* Hit, print this object */
signalcount++;
sts = nav_get_signal_line( file, line, sizeof( line), sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines); &spaces, object, &lines);
if ( EVEN(sts)) goto finish; if ( EVEN(sts)) goto finish;
while( spaces > object_spaces) { }
nav_remove_spaces( line, line);
if ( line[0] == 'W') { while ( spaces != object_spaces) {
write = 1; sts = nav_get_signal_line( file, line, sizeof( line),
} &spaces, object, &lines);
else if ( line[0] == '>') { if ( EVEN(sts)) goto finish;
write = 2; }
} }
else
write = 0;
nr = dcli_parse( &line[2], " ", "", (char *)line_part,
sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0);
if ( strcmp( line_part[nr-1], "") == 0 && nr > 2)
nr--;
if ( nr > 2 && line_part[nr-3][0] == '#')
write = 1;
else if ( nr > 2 && line_part[nr-3][0] == '&')
write = 2;
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Crossref,
line_part[nr-2], line_part[nr-1], write);
crossref_count++;
sts = nav_get_signal_line( file, line, sizeof( line), finish:
&spaces, object, &lines); fclose( file);
if ( EVEN(sts)) goto finish;
}
}
else {
if ( !wildcard && signalcount)
goto finish;
sts = nav_get_signal_line( file, line, sizeof( line), if ( single_file)
&spaces, object, &lines); break;
if ( EVEN(sts)) goto finish;
}
while ( spaces != object_spaces) { if ( filename && strcmp( filename, "*") == 0) {
sts = nav_get_signal_line( file, line, sizeof( line), sts = dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_NEXT);
&spaces, object, &lines); if ( EVEN(sts)) break;
if ( EVEN(sts)) goto finish; }
} }
}
finish: if ( filename && strcmp( filename, "*") == 0)
fclose( file); dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_END);
if ( signalcount == 0) if ( signalcount == 0)
return NAV__OBJECTNOTFOUND; return NAV__OBJECTNOTFOUND;
if ( crossref_count == 0) if ( crossref_count == 0)
return NAV__NOCROSSREF; return NAV__NOCROSSREF;
return NAV__SUCCESS; return NAV__SUCCESS;
} }
......
...@@ -480,7 +480,8 @@ int ItemBaseObject::open_crossref( XNavBrow *brow, double x, double y) ...@@ -480,7 +480,8 @@ int ItemBaseObject::open_crossref( XNavBrow *brow, double x, double y)
int crossref_exist; int crossref_exist;
int sts; int sts;
pwr_tClassId classid; pwr_tClassId classid;
XNav *xnav; XNav *xnav;
char file[20] = "*";
if ( brow->usertype == brow_eUserType_XNav) if ( brow->usertype == brow_eUserType_XNav)
xnav = (XNav *) brow->userdata; xnav = (XNav *) brow->userdata;
...@@ -534,10 +535,10 @@ int ItemBaseObject::open_crossref( XNavBrow *brow, double x, double y) ...@@ -534,10 +535,10 @@ int ItemBaseObject::open_crossref( XNavBrow *brow, double x, double y)
case pwr_cClass_Ii: case pwr_cClass_Ii:
case pwr_cClass_Io: case pwr_cClass_Io:
case pwr_cClass_Co: case pwr_cClass_Co:
sts = xnav_crr_signal( brow, NULL, name, node); sts = xnav_crr_signal( brow, file, name, node);
break; break;
default: default:
sts = xnav_crr_object( brow, NULL, name, node); sts = xnav_crr_object( brow, file, name, node);
} }
if ( xnav && sts == NAV__OBJECTNOTFOUND) if ( xnav && sts == NAV__OBJECTNOTFOUND)
xnav->message('E', "Object not found in crossreferens file"); xnav->message('E', "Object not found in crossreferens file");
...@@ -1106,6 +1107,7 @@ int ItemAttrObject::open_crossref( XNavBrow *brow, double x, double y) ...@@ -1106,6 +1107,7 @@ int ItemAttrObject::open_crossref( XNavBrow *brow, double x, double y)
int sts; int sts;
XNav *xnav; XNav *xnav;
char aname[240]; char aname[240];
char file[20] = "*";
if ( brow->usertype == brow_eUserType_XNav) if ( brow->usertype == brow_eUserType_XNav)
xnav = (XNav *) brow->userdata; xnav = (XNav *) brow->userdata;
...@@ -1159,10 +1161,10 @@ int ItemAttrObject::open_crossref( XNavBrow *brow, double x, double y) ...@@ -1159,10 +1161,10 @@ int ItemAttrObject::open_crossref( XNavBrow *brow, double x, double y)
case pwr_cClass_Ii: case pwr_cClass_Ii:
case pwr_cClass_Io: case pwr_cClass_Io:
case pwr_cClass_Co: case pwr_cClass_Co:
sts = xnav_crr_signal( brow, NULL, aname, node); sts = xnav_crr_signal( brow, file, aname, node);
break; break;
default: default:
sts = xnav_crr_object( brow, NULL, aname, node); sts = xnav_crr_object( brow, file, aname, node);
} }
if ( xnav && sts == NAV__OBJECTNOTFOUND) if ( xnav && sts == NAV__OBJECTNOTFOUND)
xnav->message('E', "Object not found in crossreferens file"); xnav->message('E', "Object not found in crossreferens file");
...@@ -1882,7 +1884,8 @@ int ItemChannel::open_crossref( XNavBrow *brow, double x, double y) ...@@ -1882,7 +1884,8 @@ int ItemChannel::open_crossref( XNavBrow *brow, double x, double y)
int crossref_exist; int crossref_exist;
int sts; int sts;
pwr_tOName signal_name; pwr_tOName signal_name;
XNav *xnav; XNav *xnav;
char file[20] = "*";
if ( brow->usertype == brow_eUserType_XNav) if ( brow->usertype == brow_eUserType_XNav)
xnav = (XNav *) brow->userdata; xnav = (XNav *) brow->userdata;
...@@ -1919,7 +1922,7 @@ int ItemChannel::open_crossref( XNavBrow *brow, double x, double y) ...@@ -1919,7 +1922,7 @@ int ItemChannel::open_crossref( XNavBrow *brow, double x, double y)
sts = gdh_AttrrefToName( &signal_aref, signal_name, sizeof(signal_name), sts = gdh_AttrrefToName( &signal_aref, signal_name, sizeof(signal_name),
cdh_mNName); cdh_mNName);
sts = xnav_crr_signal( brow, NULL, signal_name, node); sts = xnav_crr_signal( brow, file, signal_name, node);
if ( sts == NAV__OBJECTNOTFOUND && xnav) if ( sts == NAV__OBJECTNOTFOUND && xnav)
xnav->message('E', "Object not found in crossreferens file"); xnav->message('E', "Object not found in crossreferens file");
......
...@@ -637,6 +637,7 @@ int XAttNav::crossref() ...@@ -637,6 +637,7 @@ int XAttNav::crossref()
int sts; int sts;
pwr_tAName name; pwr_tAName name;
pwr_tClassId classid; pwr_tClassId classid;
char file[20] = "*";
sts = gdh_AttrrefToName ( &objar, name, sizeof(name), cdh_mNName); sts = gdh_AttrrefToName ( &objar, name, sizeof(name), cdh_mNName);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
...@@ -657,11 +658,11 @@ int XAttNav::crossref() ...@@ -657,11 +658,11 @@ int XAttNav::crossref()
case pwr_cClass_Ii: case pwr_cClass_Ii:
case pwr_cClass_Io: case pwr_cClass_Io:
case pwr_cClass_Co: case pwr_cClass_Co:
sts = xnav_crr_signal( brow, NULL, name, NULL); sts = xnav_crr_signal( brow, file, name, NULL);
break; break;
default: default:
/* Not a signal */ /* Not a signal */
sts = xnav_crr_object( brow, NULL, name, NULL); sts = xnav_crr_object( brow, file, name, NULL);
} }
// if ( EVEN(sts)) // if ( EVEN(sts))
// xnav->message(' ', XNav::get_message(sts)); // xnav->message(' ', XNav::get_message(sts));
......
...@@ -4533,10 +4533,18 @@ static int xnav_crossref_func( void *client_data, ...@@ -4533,10 +4533,18 @@ static int xnav_crossref_func( void *client_data,
case pwr_cClass_Ii: case pwr_cClass_Ii:
case pwr_cClass_Io: case pwr_cClass_Io:
case pwr_cClass_Co: case pwr_cClass_Co:
if ( !file_ptr) {
strcpy( file_str, "*");
file_ptr = file_str;
}
sts = xnav_crr_signal( xnav->brow, file_ptr, name_ptr, NULL); sts = xnav_crr_signal( xnav->brow, file_ptr, name_ptr, NULL);
break; break;
default: default:
/* Not a signal */ /* Not a signal */
if ( !file_ptr) {
strcpy( file_str, "*");
file_ptr = file_str;
}
sts = xnav_crr_object( xnav->brow, file_ptr, name_ptr, NULL); sts = xnav_crr_object( xnav->brow, file_ptr, name_ptr, NULL);
} }
if ( EVEN(sts)) if ( EVEN(sts))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment