static void printDescrip( FileInfo *info) { char *buf; HelpFp fp; char tmp[ _MAX_PATH ]; HelpHdl hdl; strcpy( tmp, info->fpath ); #ifdef __UNIX__ strcat( tmp, "/" ); #else strcat( tmp, "\\" ); #endif strcat( tmp, info->fname ); strcat( tmp, DEF_EXT ); fp = HelpOpen( tmp, HELP_OPEN_RDONLY | HELP_OPEN_BINARY ); if( fp != -1 ) { hdl = InitHelpSearch( fp ); buf = GetDescrip( hdl ); if( buf != NULL ) { printf( "%s", buf ); } FiniHelpSearch( hdl ); } printf( "\n" ); HelpClose( fp ); }
int Help(char *name, void (*print)(char *buffer)) { char buffer[MBUFFER]; char start[MBUFFER]; int count; int found; if(print!=0) { count=0; found=0; if(HelpFile==0) { HelpOpen("nart.help"); } if(HelpFile!=0) { SformatOutput(start,MBUFFER-1,"<tag=%s>",name); buffer[MBUFFER-1]=0; HelpRewind(); // // look for start of documentation section, <tag=name> // while(HelpRead(buffer,MBUFFER-1)>=0) { if(Smatch(buffer,start)) { found=1; break; } } // // print all lines up to the next <tag=anything> // if(found) { ErrorPrint(ParseHelpDescriptionStart); while(HelpRead(buffer,MBUFFER-1)>=0) { if(strncmp(buffer,"<tag=",5)==0) { break; } ErrorPrint(ParseHelp,buffer); count++; } ErrorPrint(ParseHelpDescriptionEnd); return count; } } } return -1; }
void main( int argc, char *argv[] ) { HelpFp fp; HelpHdl hdl; char name[_MAX_PATH]; char *cur; HelpSrchInfo cursor; unsigned i; if( argc != 2 ) { printf( "USAGE:\n" ); printf( "exename <help file>\n" ); return; } fp = HelpOpen( argv[1], HELP_OPEN_RDONLY | HELP_OPEN_BINARY ); if( fp == -1 ) { printf( "Unable to open %s\n", argv[1] ); return; } TRMemOpen(); hdl = InitHelpSearch( fp ); for( ;; ) { gets( name ); if( !strcmp( name, "bob" ) ) break; cur = HelpFindFirst( hdl, name, &cursor ); for( i=0; i < 5; i++ ) { if( cur == NULL ) break; printf( " %s\n", cur ); HelpMemFree( cur ); cur = HelpFindNext( &cursor ); } if( cur != NULL ) { HelpMemFree( cur ); } } FiniHelpSearch( hdl ); HelpClose( fp ); TRMemClose(); }
int HelpIndex(void (*print)(char *buffer)) { char buffer[MBUFFER]; int count; char *end; if(print!=0) { count=0; if(HelpFile==0) { HelpOpen("nart.help"); } if(HelpFile!=0) { HelpRewind(); // // look for start of documentation section, <tag=name> // while(HelpRead(buffer,MBUFFER-1)>=0) { if(strncmp(buffer,"<tag=",5)==0) { end=strchr(buffer,'>'); if(end!=0) { *end=0; } ErrorPrint(ParseHelp,&buffer[5]); count++; } } } } return count; }
/* * help_open - open a help file at a topic location */ static help_file *help_open( char *buffer ) { help_file *h; char *newtopic; for( h = HelpFiles; h->name != NULL; ++h ) { if( h->f == 0 ) { /* text files screw up ctrl z */ h->f = HelpOpen( h->name, HELP_OPEN_RDONLY | HELP_OPEN_BINARY ); h->searchhdl = InitHelpSearch( h->f ); } if( helpStack->word[0] == '\0' ) { newtopic = GetDefTopic( h->searchhdl ); replacetopic( newtopic ); } if( OpenTopicInFile( h, helpStack->word, buffer ) ) { break; } } if( h->name == NULL ) return( NULL ); return( h ); }