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(
char *filename,
char *signalname)
{
pwr_tFileName default_filename;
FILE *file;
char line[1000];
int object_spaces;
pwr_tAName object;
pwr_tAName objname;
int spaces;
int first;
int sts;
char *s;
int wildcard;
int signalcount = 0;
int crossref_count = 0;
pwr_tFileName filestr;
int lines;
pwr_tVolumeId volid;
pwr_tObjid objid;
pwr_tAName line_part[2];
int nr;
int write;
pwr_tFileName default_filename;
char line[1000];
int object_spaces;
pwr_tAName object;
pwr_tAName objname;
int spaces;
int first;
int sts;
char *s;
int wildcard;
int signalcount = 0;
int crossref_count = 0;
pwr_tFileName filestr;
int lines;
pwr_tVolumeId volid;
pwr_tObjid objid;
pwr_tAName line_part[2];
int nr;
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 */
s = strchr( signalname, '*');
if ( s == 0)
wildcard = 0;
else
wildcard = 1;
first = 1;
while ( 1) {
if ( (s = strchr( object, ':')))
strcpy( objname, s+1);
else
strcpy( objname, object);
/* Open file */
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;
}
cdh_ToUpper( objname, objname);
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");
}
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 = dcli_wildcard( signalname, 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;
while( spaces > object_spaces) {
nav_remove_spaces( line, line);
first = 1;
while ( 1) {
if ( (s = strchr( object, ':')))
strcpy( objname, s+1);
if ( line[0] == 'W' || line[0] == '>')
write = 1;
else
strcpy( objname, object);
cdh_ToUpper( objname, objname);
sts = dcli_wildcard( signalname, 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;
while( spaces > object_spaces) {
nav_remove_spaces( line, line);
if ( line[0] == 'W' || line[0] == '>')
write = 1;
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--;
(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),
&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;
}
}
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--;
(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),
&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:
fclose( file);
finish:
fclose( file);
if ( signalcount == 0)
return NAV__OBJECTNOTFOUND;
if ( single_file)
break;
if ( crossref_count == 0)
return NAV__NOCROSSREF;
if ( filename && strcmp( filename, "*") == 0) {
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(
char *filename,
char *objectname)
{
pwr_tFileName default_filename;
FILE *file;
char line[1000];
int object_spaces;
pwr_tAName object;
pwr_tAName objname;
int spaces;
int first;
int sts;
char *s;
int wildcard;
int signalcount = 0;
pwr_tFileName filestr;
int lines;
pwr_tVolumeId volid;
pwr_tObjid objid;
int crossref_count = 0;
pwr_tAName line_part[2];
int nr;
int write;
cdh_ToUpper( objectname, objectname);
/* Check if wildcard */
s = strchr( objectname, '*');
if ( s == 0)
wildcard = 0;
else
wildcard = 1;
/* Open file */
if ( filename == NULL) {
/* Open file, first get the volume id */
if ( !wildcard) {
sts = (name_to_objid_cb)( parent_ctx, objectname, &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_crro_%s.dat",
dcli_pwr_dir("pwrp_load"), nav_VolumeIdToStr( volid));
dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r");
}
else {
dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r");
}
pwr_tFileName default_filename;
char line[1000];
int object_spaces;
pwr_tAName object;
pwr_tAName objname;
int spaces;
int first;
int sts;
char *s;
int wildcard;
pwr_tFileName filestr;
int lines;
pwr_tVolumeId volid;
pwr_tObjid objid;
int crossref_count = 0;
pwr_tAName line_part[2];
int nr;
int write;
int single_file = 0;
pwr_tFileName file_spec;
int signalcount = 0;
if ( filename && strcmp( filename, "*") == 0) {
strcpy( file_spec, "$pwrp_load/rtt_crro_*.dat");
sts = dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_INIT);
if ( EVEN(sts)) return sts;
}
cdh_ToUpper( objectname, objectname);
/* Check if wildcard */
s = strchr( objectname, '*');
if ( s == 0)
wildcard = 0;
else
wildcard = 1;
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, objectname, &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_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)
return NAV__NOFILE;
if ( file == 0)
return NAV__NOFILE;
/* Get the object */
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
/* Get the object */
sts = nav_get_signal_line( file, line, sizeof( line),
&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;
object_spaces = spaces;
while( spaces > object_spaces) {
nav_remove_spaces( line, line);
first = 1;
while ( 1) {
if ( (s = strchr( object, ':')))
strcpy( objname, s+1);
if ( line[0] == 'W') {
write = 1;
}
else if ( line[0] == '>') {
write = 2;
}
else
strcpy( objname, object);
cdh_ToUpper( objname, objname);
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 = 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;
}
}
else {
if ( !wildcard && signalcount)
goto finish;
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);
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
if ( line[0] == 'W') {
write = 1;
}
else if ( line[0] == '>') {
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++;
while ( spaces != object_spaces) {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
}
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
}
else {
if ( !wildcard && signalcount)
goto finish;
finish:
fclose( file);
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
if ( single_file)
break;
while ( spaces != object_spaces) {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
}
if ( filename && strcmp( filename, "*") == 0) {
sts = dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_NEXT);
if ( EVEN(sts)) break;
}
}
finish:
fclose( file);
if ( filename && strcmp( filename, "*") == 0)
dcli_search_file( file_spec, filestr, DCLI_DIR_SEARCH_END);
if ( signalcount == 0)
return NAV__OBJECTNOTFOUND;
if ( signalcount == 0)
return NAV__OBJECTNOTFOUND;
if ( crossref_count == 0)
return NAV__NOCROSSREF;
if ( crossref_count == 0)
return NAV__NOCROSSREF;
return NAV__SUCCESS;
return NAV__SUCCESS;
}
......
......@@ -480,7 +480,8 @@ int ItemBaseObject::open_crossref( XNavBrow *brow, double x, double y)
int crossref_exist;
int sts;
pwr_tClassId classid;
XNav *xnav;
XNav *xnav;
char file[20] = "*";
if ( brow->usertype == brow_eUserType_XNav)
xnav = (XNav *) brow->userdata;
......@@ -534,10 +535,10 @@ int ItemBaseObject::open_crossref( XNavBrow *brow, double x, double y)
case pwr_cClass_Ii:
case pwr_cClass_Io:
case pwr_cClass_Co:
sts = xnav_crr_signal( brow, NULL, name, node);
sts = xnav_crr_signal( brow, file, name, node);
break;
default:
sts = xnav_crr_object( brow, NULL, name, node);
sts = xnav_crr_object( brow, file, name, node);
}
if ( xnav && sts == NAV__OBJECTNOTFOUND)
xnav->message('E', "Object not found in crossreferens file");
......@@ -1106,6 +1107,7 @@ int ItemAttrObject::open_crossref( XNavBrow *brow, double x, double y)
int sts;
XNav *xnav;
char aname[240];
char file[20] = "*";
if ( brow->usertype == brow_eUserType_XNav)
xnav = (XNav *) brow->userdata;
......@@ -1159,10 +1161,10 @@ int ItemAttrObject::open_crossref( XNavBrow *brow, double x, double y)
case pwr_cClass_Ii:
case pwr_cClass_Io:
case pwr_cClass_Co:
sts = xnav_crr_signal( brow, NULL, aname, node);
sts = xnav_crr_signal( brow, file, aname, node);
break;
default:
sts = xnav_crr_object( brow, NULL, aname, node);
sts = xnav_crr_object( brow, file, aname, node);
}
if ( xnav && sts == NAV__OBJECTNOTFOUND)
xnav->message('E', "Object not found in crossreferens file");
......@@ -1882,7 +1884,8 @@ int ItemChannel::open_crossref( XNavBrow *brow, double x, double y)
int crossref_exist;
int sts;
pwr_tOName signal_name;
XNav *xnav;
XNav *xnav;
char file[20] = "*";
if ( brow->usertype == brow_eUserType_XNav)
xnav = (XNav *) brow->userdata;
......@@ -1919,7 +1922,7 @@ int ItemChannel::open_crossref( XNavBrow *brow, double x, double y)
sts = gdh_AttrrefToName( &signal_aref, signal_name, sizeof(signal_name),
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)
xnav->message('E', "Object not found in crossreferens file");
......
......@@ -637,6 +637,7 @@ int XAttNav::crossref()
int sts;
pwr_tAName name;
pwr_tClassId classid;
char file[20] = "*";
sts = gdh_AttrrefToName ( &objar, name, sizeof(name), cdh_mNName);
if ( EVEN(sts)) return sts;
......@@ -657,11 +658,11 @@ int XAttNav::crossref()
case pwr_cClass_Ii:
case pwr_cClass_Io:
case pwr_cClass_Co:
sts = xnav_crr_signal( brow, NULL, name, NULL);
sts = xnav_crr_signal( brow, file, name, NULL);
break;
default:
/* Not a signal */
sts = xnav_crr_object( brow, NULL, name, NULL);
sts = xnav_crr_object( brow, file, name, NULL);
}
// if ( EVEN(sts))
// xnav->message(' ', XNav::get_message(sts));
......
......@@ -4533,10 +4533,18 @@ static int xnav_crossref_func( void *client_data,
case pwr_cClass_Ii:
case pwr_cClass_Io:
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);
break;
default:
/* Not a signal */
if ( !file_ptr) {
strcpy( file_str, "*");
file_ptr = file_str;
}
sts = xnav_crr_object( xnav->brow, file_ptr, name_ptr, NULL);
}
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