Commit a2d2f629 authored by Claes Sjofors's avatar Claes Sjofors

Xtt crossref string and function didn't search in subvolumes (refs #194)

parent c4b557a6
......@@ -87,9 +87,9 @@ char *lng_get_language_str()
//
int crr_signal( void *parent_ctx, char *signalname,
void (*insert_cb)( void *, void *, navc_eItemType, char *, char *, int),
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *),
int (*get_volume_cb)( void *, pwr_tVolumeId *))
void (*insert_cb)( void *, void *, navc_eItemType, char *, char *, int),
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *),
int (*get_volume_cb)( void *, pwr_tVid *, pwr_tVid))
{
int sts;
NavCrr *navcrr = new NavCrr( parent_ctx, 0);
......@@ -103,9 +103,9 @@ int crr_signal( void *parent_ctx, char *signalname,
}
int crr_object( void *parent_ctx, char *objectname,
void (*insert_cb)( void *, void *, navc_eItemType, char *, char *, int),
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *),
int (*get_volume_cb)( void *, pwr_tVolumeId *))
void (*insert_cb)( void *, void *, navc_eItemType, char *, char *, int),
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *),
int (*get_volume_cb)( void *, pwr_tVid *, pwr_tVid))
{
int sts;
NavCrr *navcrr = new NavCrr( parent_ctx, 0);
......
......@@ -66,11 +66,11 @@ char *lng_get_language_str();
int crr_signal( void *parent_ctx, char *signalname,
void (*insert_cb)( void *, void *, navc_eItemType, char *, char *, int),
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *),
int (*get_volume_cb)( void *, pwr_tVolumeId *));
int (*get_volume_cb)( void *, pwr_tVid *, pwr_tVid));
int crr_object( void *parent_ctx, char *objectname,
void (*insert_cb)( void *, void *, navc_eItemType, char *, char *, int),
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *),
int (*get_volume_cb)( void *, pwr_tVolumeId *));
int (*get_volume_cb)( void *, pwr_tVid *, pwr_tVid));
#if defined __cplusplus
}
#endif
......
......@@ -253,7 +253,7 @@ int NavCrr::crr_signal(
volid = objid.vid;
}
else {
sts = (get_volume_cb)( parent_ctx, &volid);
sts = (get_volume_cb)( parent_ctx, &volid, 0);
if ( EVEN(sts)) return sts;
}
......@@ -428,7 +428,7 @@ int NavCrr::crr_object(
volid = objid.vid;
}
else {
sts = (get_volume_cb)( parent_ctx, &volid);
sts = (get_volume_cb)( parent_ctx, &volid, 0);
if ( EVEN(sts)) return sts;
}
......@@ -588,132 +588,162 @@ int NavCrr::crr_code(
int objname_written;
int hit;
char *tst_char;
pwr_tVid prev_volid = 0;
int vol_cnt = 0;
int end_of_file;
/* Open file */
if ( filename == NULL) {
sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts;
while (1) {
end_of_file = 0;
sprintf( default_filename, "%srtt_crrc_%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;
/* Case sensitive if any lowercase */
if ( !case_sensitive)
for ( s = str; *s != 0; s++) {
if ( *s != '_' && !isupper(*s))
case_sensitive = 1;
}
/* Open file */
if ( filename == NULL) {
sts = (get_volume_cb)( parent_ctx, &volid, prev_volid);
if ( EVEN(sts)) break;
while ( strncmp( line, " _Obj_ ", 7) != 0) {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
prev_volid = volid;
sprintf( default_filename, "%srtt_crrc_%s.dat",
dcli_pwr_dir("pwrp_load"), nav_VolumeIdToStr( volid));
dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r");
}
else {
if ( vol_cnt == 1)
break;
first = 1;
while ( 1) {
strcpy( objname, &line[7]);
for ( s = objname; !(*s == 32 || *s == 9 || *s == 0); s++);
*s = 0;
dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r");
}
vol_cnt++;
if ( file == 0)
continue;
/* Case sensitive if any lowercase */
if ( !case_sensitive)
for ( s = str; *s != 0; s++) {
if ( *s != '_' && !isupper(*s))
case_sensitive = 1;
}
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
objname_written = 0;
while ( strncmp( line, " _Obj_ ", 7) != 0) {
if ( !case_sensitive)
cdh_ToUpper( tst_line, line);
else
strcpy( tst_line, line);
hit = 0;
if ( !func) {
if ( strstr( tst_line, str) != 0)
hit = 1;
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) {
fclose( file);
end_of_file = 1;
break;
}
else {
if ( (s = strstr( tst_line, str)) != 0) {
hit = 1;
/* Check char after */
tst_char = s + strlen(str);
if ( isalpha( *tst_char) || isdigit( *tst_char) ||
*tst_char == '_')
hit = 0;
/* Check char before */
if ( s != tst_line)
{
tst_char = s - 1;
if ( isalpha( *tst_char) || isdigit( *tst_char) ||
*tst_char == '_')
hit = 0;
}
}
}
if ( hit) {
/* Hit, print this object */
if ( signalcount == 0) {
if ( func) {
sprintf( title, "Crossreferens list Function \"%s\"\n\n", str);
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Header, title, NULL, 0);
}
else {
sprintf( title, "Crossreferens list String \"%s\"\n\n", str);
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Header, title, NULL, 0);
}
}
signalcount++;
}
if ( end_of_file)
continue;
if ( !objname_written) {
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Crossref, objname, (char *)"", 2);
objname_written = 1;
first = 1;
while ( 1) {
strcpy( objname, &line[7]);
for ( s = objname; !(*s == 32 || *s == 9 || *s == 0); s++);
*s = 0;
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
objname_written = 0;
while ( strncmp( line, " _Obj_ ", 7) != 0) {
if ( !case_sensitive)
cdh_ToUpper( tst_line, line);
else
strcpy( tst_line, line);
hit = 0;
if ( !func) {
if ( strstr( tst_line, str) != 0)
hit = 1;
}
strcpy( tst_line, " ");
strcat( tst_line, line);
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Text, tst_line, NULL, 0);
if ( brief) {
while ( strncmp( line, " _Obj_ ", 7) != 0) {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
else {
if ( (s = strstr( tst_line, str)) != 0) {
hit = 1;
/* Check char after */
tst_char = s + strlen(str);
if ( isalpha( *tst_char) || isdigit( *tst_char) ||
*tst_char == '_')
hit = 0;
/* Check char before */
if ( s != tst_line)
{
tst_char = s - 1;
if ( isalpha( *tst_char) || isdigit( *tst_char) ||
*tst_char == '_')
hit = 0;
}
}
}
if ( hit) {
/* Hit, print this object */
if ( signalcount == 0) {
if ( func) {
sprintf( title, "Crossreferens list Function \"%s\"\n\n", str);
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Header, title, NULL, 0);
}
else {
sprintf( title, "Crossreferens list String \"%s\"\n\n", str);
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Header, title, NULL, 0);
}
}
signalcount++;
if ( !objname_written) {
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Crossref, objname, (char *)"", 2);
objname_written = 1;
}
strcpy( tst_line, " ");
strcat( tst_line, line);
(insert_cb)( parent_ctx, parent_node,
navc_eItemType_Text, tst_line, NULL, 0);
if ( brief) {
while ( strncmp( line, " _Obj_ ", 7) != 0) {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) {
end_of_file = 1;
break;
}
}
if ( end_of_file)
break;
}
else {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) {
end_of_file = 1;
break;
}
}
}
else {
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)) {
end_of_file = 1;
break;
}
}
}
else {
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
if ( end_of_file)
break;
}
if ( end_of_file)
break;
}
}
finish:
fclose( file);
if ( signalcount > 0) {
fclose( file);
}
else {
if ( signalcount == 0) {
if ( func)
return NAV__STRINGNOTFOUND;
else
......
......@@ -61,7 +61,7 @@ class NavCrr {
void (*insert_cb)( void *, void *, navc_eItemType,
char *, char *, int);
int (*name_to_objid_cb)( void *, char *, pwr_tObjid *);
int (*get_volume_cb)( void *, pwr_tVolumeId *);
int (*get_volume_cb)( void *, pwr_tVid *, pwr_tVid);
int crr_signal( char *filename, char *signalname);
int crr_object( char *filename, char *objectname);
int crr_code( char *filename, char *str, int brief, int func,
......
......@@ -74,4 +74,4 @@ notcollectw <Not collect window> /error
noclassgraph <No classgraph found> /error
notauthorized <Not authorized for this operation> /error
novalidcurve <No valid curve found> /error
nosuchvolume <No such volume> /error
......@@ -80,6 +80,7 @@ volnameexist <Volume name already exist> /error
createdbs <Create loadfile error> /error
edit <In edit mode> /error
notauthorized <User not authorized for requested operation> /error
nosuchvolume <No such volume> /error
......@@ -127,7 +127,7 @@ int wnav_crr_name_to_objid_cb( void *ctx, char *name, pwr_tObjid *objid)
return ldh_NameToObjid( cctx->ldhses, objid, name);
}
int wnav_crr_get_volume_cb( void *ctx, pwr_tVolumeId *volid)
int wnav_crr_get_volume_cb( void *ctx, pwr_tVid *vid, pwr_tVid prev_vid)
{
int sts;
ldh_sVolumeInfo info;
......@@ -135,7 +135,10 @@ int wnav_crr_get_volume_cb( void *ctx, pwr_tVolumeId *volid)
ldh_tVolContext volctx = ldh_SessionToVol( cctx->ldhses);
sts = ldh_GetVolumeInfo( volctx, &info);
*volid = info.Volume;
if ( prev_vid)
return WNAV__NOSUCHVOLUME;
*vid = info.Volume;
return WNAV__SUCCESS;
}
......
......@@ -99,16 +99,52 @@ int xnav_crr_name_to_objid_cb( void *ctx, char *name, pwr_tObjid *objid)
return gdh_NameToObjid( name, objid);
}
int xnav_crr_get_volume_cb( void *ctx, pwr_tVolumeId *volid)
int xnav_crr_get_volume_cb( void *ctx, pwr_tVid *vid, pwr_tVid prev_vid)
{
int sts;
pwr_tObjid objid;
pwr_tVid v;
gdh_sVolumeInfo info;
sts = gdh_GetNodeObject( 0, &objid);
if ( EVEN(sts)) return sts;
*volid = objid.vid;
return XNAV__SUCCESS;
if ( prev_vid == 0) {
*vid = objid.vid;
return XNAV__SUCCESS;
}
int next = 0;
for ( sts = gdh_GetVolumeList( &v); ODD(sts); sts = gdh_GetNextVolume( v, &v)) {
int volume_found = 0;
sts = gdh_GetVolumeInfo( v, &info);
if ( EVEN(sts)) return sts;
switch ( info.cid) {
case pwr_eClass_SubVolume:
case pwr_eClass_SharedVolume:
volume_found = 1;
break;
default: ;
}
if ( !volume_found)
continue;
if ( prev_vid == objid.vid) {
*vid = v;
return XNAV__SUCCESS;
}
if ( prev_vid == v) {
next = 1;
}
else if ( next) {
*vid = v;
return XNAV__SUCCESS;
}
}
return XNAV__NOSUCHVOLUME;
}
int xnav_crr_signal(
......
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