Commit fffa6bd8 authored by claes's avatar claes

New crossref list format

parent d06de897
/** /**
* Proview $Id: co_nav_crr.cpp,v 1.3 2005-10-21 16:11:22 claes Exp $ * Proview $Id: co_nav_crr.cpp,v 1.4 2008-05-28 12:02:16 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -186,12 +186,9 @@ int NavCrr::crr_signal( ...@@ -186,12 +186,9 @@ int NavCrr::crr_signal(
pwr_tFileName default_filename; pwr_tFileName default_filename;
FILE *file; FILE *file;
char line[1000]; char line[1000];
int hierarchy_spaces;
pwr_tAName hierarchy;
int object_spaces; int object_spaces;
pwr_tAName object; pwr_tAName object;
pwr_tAName objname; pwr_tAName objname;
pwr_tAName show_objname;
int spaces; int spaces;
int first; int first;
int sts; int sts;
...@@ -203,7 +200,7 @@ int NavCrr::crr_signal( ...@@ -203,7 +200,7 @@ int NavCrr::crr_signal(
int lines; int lines;
pwr_tVolumeId volid; pwr_tVolumeId volid;
pwr_tObjid objid; pwr_tObjid objid;
pwr_tAName line_part[8]; pwr_tAName line_part[2];
int nr; int nr;
int write; int write;
...@@ -217,18 +214,15 @@ int NavCrr::crr_signal( ...@@ -217,18 +214,15 @@ int NavCrr::crr_signal(
wildcard = 1; wildcard = 1;
/* Open file */ /* Open file */
if ( filename == NULL) if ( filename == NULL) {
{
/* Open file, first get the volume id */ /* Open file, first get the volume id */
if ( !wildcard) if ( !wildcard) {
{
sts = (name_to_objid_cb)( parent_ctx, signalname, &objid); sts = (name_to_objid_cb)( parent_ctx, signalname, &objid);
if ( EVEN(sts)) if ( EVEN(sts))
return NAV__OBJECTNOTFOUND; return NAV__OBJECTNOTFOUND;
volid = objid.vid; volid = objid.vid;
} }
else else {
{
sts = (get_volume_cb)( parent_ctx, &volid); sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
...@@ -238,8 +232,7 @@ int NavCrr::crr_signal( ...@@ -238,8 +232,7 @@ int NavCrr::crr_signal(
dcli_get_defaultfilename( default_filename, filestr, NULL); dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r"); file = fopen( filestr, "r");
} }
else else {
{
dcli_get_defaultfilename( filename, filestr, ".lis"); dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r"); file = fopen( filestr, "r");
} }
...@@ -247,98 +240,63 @@ int NavCrr::crr_signal( ...@@ -247,98 +240,63 @@ int NavCrr::crr_signal(
if ( file == 0) if ( file == 0)
return NAV__NOFILE; return NAV__NOFILE;
/* First line is a header, skip it */
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
/* Get the hierarchy */ /* Get the hierarchy */
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;
hierarchy_spaces = spaces; object_spaces = spaces;
first = 1; first = 1;
while ( 1) while ( 1) {
{ if ( (s = strchr( object, ':')))
while ( spaces != hierarchy_spaces) strcpy( objname, s+1);
{ else
sts = nav_get_signal_line( file, line, sizeof( line), strcpy( objname, object);
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
strcpy( hierarchy, object);
/* Next line is an object */ cdh_ToUpper( objname, objname);
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
if ( first)
{
object_spaces = spaces;
first = 0;
}
while ( spaces == object_spaces) sts = dcli_wildcard( signalname, objname);
{ if ( !sts ) {
/* Put object and hierarchy together and check if this is /* Hit, print this object */
the object */ signalcount++;
strcpy( objname, hierarchy);
strcat( objname, "-"); sts = nav_get_signal_line( file, line, sizeof( line),
strcat( objname, object); &spaces, object, &lines);
strcpy( show_objname, objname); if ( EVEN(sts)) goto finish;
cdh_ToUpper( objname, objname); while( spaces > object_spaces) {
nav_remove_spaces( line, line);
sts = dcli_wildcard( signalname, objname);
if ( !sts )
{
/* Hit, print this object */
signalcount++;
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), 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] == '#')
{
write = 1;
strcpy( line, &line[2]);
}
else
write = 0;
nr = dcli_parse( line, " ", "", (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 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), 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)
{
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
} }
} }
} }
...@@ -376,12 +334,9 @@ int NavCrr::crr_object( ...@@ -376,12 +334,9 @@ int NavCrr::crr_object(
pwr_tFileName default_filename; pwr_tFileName default_filename;
FILE *file; FILE *file;
char line[1000]; char line[1000];
int hierarchy_spaces;
pwr_tAName hierarchy;
int object_spaces; int object_spaces;
pwr_tAName object; pwr_tAName object;
pwr_tAName objname; pwr_tAName objname;
pwr_tAName show_objname;
int spaces; int spaces;
int first; int first;
int sts; int sts;
...@@ -393,7 +348,7 @@ int NavCrr::crr_object( ...@@ -393,7 +348,7 @@ int NavCrr::crr_object(
pwr_tVolumeId volid; pwr_tVolumeId volid;
pwr_tObjid objid; pwr_tObjid objid;
int crossref_count = 0; int crossref_count = 0;
pwr_tAName line_part[8]; pwr_tAName line_part[2];
int nr; int nr;
int write; int write;
...@@ -407,18 +362,15 @@ int NavCrr::crr_object( ...@@ -407,18 +362,15 @@ int NavCrr::crr_object(
wildcard = 1; wildcard = 1;
/* Open file */ /* Open file */
if ( filename == NULL) if ( filename == NULL) {
{
/* Open file, first get the volume id */ /* Open file, first get the volume id */
if ( !wildcard) if ( !wildcard) {
{
sts = (name_to_objid_cb)( parent_ctx, objectname, &objid); sts = (name_to_objid_cb)( parent_ctx, objectname, &objid);
if ( EVEN(sts)) if ( EVEN(sts))
return NAV__OBJECTNOTFOUND; return NAV__OBJECTNOTFOUND;
volid = objid.vid; volid = objid.vid;
} }
else else {
{
sts = (get_volume_cb)( parent_ctx, &volid); sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
...@@ -428,8 +380,7 @@ int NavCrr::crr_object( ...@@ -428,8 +380,7 @@ int NavCrr::crr_object(
dcli_get_defaultfilename( default_filename, filestr, NULL); dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r"); file = fopen( filestr, "r");
} }
else else {
{
dcli_get_defaultfilename( filename, filestr, ".lis"); dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r"); file = fopen( filestr, "r");
} }
...@@ -437,68 +388,49 @@ int NavCrr::crr_object( ...@@ -437,68 +388,49 @@ int NavCrr::crr_object(
if ( file == 0) if ( file == 0)
return NAV__NOFILE; return NAV__NOFILE;
/* First line is a header, skip it */ /* Get the object */
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
/* Get the hierarchy */
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;
object_spaces = spaces; object_spaces = spaces;
first = 1; first = 1;
while ( 1) while ( 1) {
{ if ( (s = strchr( object, ':')))
while ( spaces != object_spaces) strcpy( objname, s+1);
{ else
sts = nav_get_signal_line( file, line, sizeof( line), strcpy( objname, object);
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
strcpy( objname, object);
strcpy( show_objname, objname);
cdh_ToUpper( objname, objname); cdh_ToUpper( objname, objname);
sts = dcli_wildcard( objectname, objname); sts = dcli_wildcard( objectname, objname);
if ( !sts ) if ( sts) {
{ pwr_tAName subname;
strcpy( subname, objectname);
strcat( subname, ".*");
sts = dcli_wildcard( subname, objname);
}
if ( !sts ) {
/* Hit, print this object */ /* Hit, print this object */
signalcount++; 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) while( spaces > object_spaces) {
{
nav_remove_spaces( line, line); nav_remove_spaces( line, line);
if ( line[0] == '#') if ( line[0] == 'W') {
{
write = 1; write = 1;
strcpy( line, &line[2]);
} }
else if ( line[0] == '&') else if ( line[0] == '>') {
{
write = 2; write = 2;
strcpy( line, &line[2]);
} }
else else
write = 0; write = 0;
nr = dcli_parse( line, " ", "", (char *)line_part, nr = dcli_parse( &line[2], " ", "", (char *)line_part,
sizeof( line_part) / sizeof( line_part[0]), sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0); sizeof( line_part[0]), 0);
if ( strcmp( line_part[nr-1], "") == 0 && nr > 2) if ( strcmp( line_part[nr-1], "") == 0 && nr > 2)
...@@ -516,13 +448,19 @@ int NavCrr::crr_object( ...@@ -516,13 +448,19 @@ int NavCrr::crr_object(
&spaces, object, &lines); &spaces, object, &lines);
if ( EVEN(sts)) goto finish; if ( EVEN(sts)) goto finish;
} }
if ( !wildcard) }
else {
if ( !wildcard && signalcount)
goto finish; goto finish;
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
} }
else
{ while ( spaces != object_spaces) {
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;
} }
} }
...@@ -565,9 +503,6 @@ int NavCrr::crr_code( ...@@ -565,9 +503,6 @@ int NavCrr::crr_code(
FILE *file; FILE *file;
char line[1000]; char line[1000];
char tst_line[1000]; char tst_line[1000];
int hierarchy_spaces;
pwr_tAName hierarchy;
int object_spaces;
pwr_tAName object; pwr_tAName object;
pwr_tAName objname; pwr_tAName objname;
int spaces; int spaces;
...@@ -584,8 +519,7 @@ int NavCrr::crr_code( ...@@ -584,8 +519,7 @@ int NavCrr::crr_code(
char *tst_char; char *tst_char;
/* Open file */ /* Open file */
if ( filename == NULL) if ( filename == NULL) {
{
sts = (get_volume_cb)( parent_ctx, &volid); sts = (get_volume_cb)( parent_ctx, &volid);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
...@@ -594,8 +528,7 @@ int NavCrr::crr_code( ...@@ -594,8 +528,7 @@ int NavCrr::crr_code(
dcli_get_defaultfilename( default_filename, filestr, NULL); dcli_get_defaultfilename( default_filename, filestr, NULL);
file = fopen( filestr, "r"); file = fopen( filestr, "r");
} }
else else {
{
dcli_get_defaultfilename( filename, filestr, ".lis"); dcli_get_defaultfilename( filename, filestr, ".lis");
file = fopen( filestr, "r"); file = fopen( filestr, "r");
} }
...@@ -605,43 +538,21 @@ int NavCrr::crr_code( ...@@ -605,43 +538,21 @@ int NavCrr::crr_code(
/* Case sensitive if any lowercase */ /* Case sensitive if any lowercase */
if ( !case_sensitive) if ( !case_sensitive)
for ( s = str; *s != 0; s++) for ( s = str; *s != 0; s++) {
{
if ( *s != '_' && !isupper(*s)) if ( *s != '_' && !isupper(*s))
case_sensitive = 1; case_sensitive = 1;
} }
/* First line is a header, skip it */ while ( strncmp( line, " _Obj_ ", 7) != 0) {
sts = nav_get_signal_line( file, line, sizeof( line), sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines); &spaces, object, &lines);
if ( EVEN(sts)) goto finish; if ( EVEN(sts)) goto finish;
sts = nav_get_signal_line( file, line, sizeof( line), }
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
sts = nav_get_signal_line( file, line, sizeof( line),
&hierarchy_spaces, hierarchy, &lines);
if ( EVEN(sts)) goto finish;
/* Get the hierarchy */
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
object_spaces = spaces;
first = 1; first = 1;
while ( 1) while ( 1) {
{
while ( strncmp( line, " _Obj_ ", 7) != 0)
{
sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines);
if ( EVEN(sts)) goto finish;
}
strcpy( objname, &line[7]); strcpy( objname, &line[7]);
for ( s = objname; !(*s == 32 || *s == 9 || *s == 0); s++); for ( s = objname; !(*s == 32 || *s == 9 || *s == 0); s++);
*s = 0; *s = 0;
...@@ -649,23 +560,19 @@ int NavCrr::crr_code( ...@@ -649,23 +560,19 @@ int NavCrr::crr_code(
sts = nav_get_signal_line( file, line, sizeof( line), sts = nav_get_signal_line( file, line, sizeof( line),
&spaces, object, &lines); &spaces, object, &lines);
objname_written = 0; objname_written = 0;
while ( strncmp( line, " _Obj_ ", 7) != 0) while ( strncmp( line, " _Obj_ ", 7) != 0) {
{
if ( !case_sensitive) if ( !case_sensitive)
cdh_ToUpper( tst_line, line); cdh_ToUpper( tst_line, line);
else else
strcpy( tst_line, line); strcpy( tst_line, line);
hit = 0; hit = 0;
if ( !func) if ( !func) {
{
if ( strstr( tst_line, str) != 0) if ( strstr( tst_line, str) != 0)
hit = 1; hit = 1;
} }
else else {
{ if ( (s = strstr( tst_line, str)) != 0) {
if ( (s = strstr( tst_line, str)) != 0)
{
hit = 1; hit = 1;
/* Check char after */ /* Check char after */
tst_char = s + strlen(str); tst_char = s + strlen(str);
...@@ -682,19 +589,15 @@ int NavCrr::crr_code( ...@@ -682,19 +589,15 @@ int NavCrr::crr_code(
} }
} }
} }
if ( hit) if ( hit) {
{
/* Hit, print this object */ /* Hit, print this object */
if ( signalcount == 0) if ( signalcount == 0) {
{ if ( func) {
if ( func)
{
sprintf( title, "Crossreferens list Function \"%s\"\n\n", str); sprintf( title, "Crossreferens list Function \"%s\"\n\n", str);
(insert_cb)( parent_ctx, parent_node, (insert_cb)( parent_ctx, parent_node,
navc_eItemType_Header, title, NULL, 0); navc_eItemType_Header, title, NULL, 0);
} }
else else {
{
sprintf( title, "Crossreferens list String \"%s\"\n\n", str); sprintf( title, "Crossreferens list String \"%s\"\n\n", str);
(insert_cb)( parent_ctx, parent_node, (insert_cb)( parent_ctx, parent_node,
navc_eItemType_Header, title, NULL, 0); navc_eItemType_Header, title, NULL, 0);
...@@ -702,8 +605,7 @@ int NavCrr::crr_code( ...@@ -702,8 +605,7 @@ int NavCrr::crr_code(
} }
signalcount++; signalcount++;
if ( !objname_written) if ( !objname_written) {
{
(insert_cb)( parent_ctx, parent_node, (insert_cb)( parent_ctx, parent_node,
navc_eItemType_Crossref, objname, "", 2); navc_eItemType_Crossref, objname, "", 2);
objname_written = 1; objname_written = 1;
...@@ -714,24 +616,20 @@ int NavCrr::crr_code( ...@@ -714,24 +616,20 @@ int NavCrr::crr_code(
(insert_cb)( parent_ctx, parent_node, (insert_cb)( parent_ctx, parent_node,
navc_eItemType_Text, tst_line, NULL, 0); navc_eItemType_Text, tst_line, NULL, 0);
if ( brief) if ( brief) {
{ while ( strncmp( line, " _Obj_ ", 7) != 0) {
while ( strncmp( line, " _Obj_ ", 7) != 0)
{
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;
} }
} }
else else {
{
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;
} }
} }
else else {
{
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;
...@@ -742,11 +640,9 @@ int NavCrr::crr_code( ...@@ -742,11 +640,9 @@ int NavCrr::crr_code(
finish: finish:
fclose( file); fclose( file);
if ( signalcount > 0) if ( signalcount > 0) {
{
} }
else else {
{
if ( func) if ( func)
return NAV__STRINGNOTFOUND; return NAV__STRINGNOTFOUND;
else else
......
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