/*****************************************************************/
/* functions for the #help command */
/*****************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "tintin.h"
void help_command(arg)
char *arg;
{
FILE *myfile;
char *cptr, text[80], line[80], temp_ch;
int tmp,flag, counter;
flag=TRUE;
if((myfile=fopen("help.txt", "r"))==NULL) {
tintin_puts2("#help.txt not found, no help available.", NULL);
prompt(NULL);
return;
}
if (*arg) {
sprintf(text, "~%s", arg);
cptr=text;
while (*++cptr) {
*cptr=toupper(*cptr);
}
while (flag) {
fgets(line, sizeof(line), myfile);
if (*line=='~') {
if (*(line+1)=='*') {
tintin_puts2("#Sorry, no help on that word.", (struct session *)NULL);
flag=FALSE;
}
else if(is_abrev(text,line)) {
counter=0;
while (flag) {
fgets(line, sizeof(line), myfile);
if (*line=='~')
flag=FALSE;
else {
*(line+strlen(line)-1)='\0';
tintin_puts2(line, (struct session *)NULL);
}
if (flag && (counter++>23)) {
tintin_puts2("*****PRESS ANY KEY*****", (struct session *)NULL);
for(tmp=0;tmp<=50000;tmp++)
{}
counter=0;
}
}
}
}
}
}
else {
while(flag) {
fgets(line, sizeof(line), myfile);
if (*line=='~')
flag=FALSE;
else {
*(line+strlen(line)-1)='\0';
tintin_puts2(line, (struct session *)NULL);
}
}
}
prompt(NULL);
fclose(myfile);
}