-
Notifications
You must be signed in to change notification settings - Fork 2
/
Help.cpp
92 lines (73 loc) · 2.33 KB
/
Help.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**********************************************************************/
/*** FILE : Help.c ***/
/*** AUTHOR: Trent Whiteley ***/
/*** MODIFIED: ***/
/*** ***/
/*** PUBLIC ROUTINES: ***/
/*** int Help(); ***/
/*** PRIVATE ROUTINES: ***/
/*** char * getHelp(); ***/
/*** void displayHelp(); ***/
/*** MODULE DESCRIPTION: ***/
/*** This module contains routines used to handle the help ***/
/*** system for albert. ***/
/**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Help.h"
#include "Help_pri.h"
#include "Get_Command.h"
static const char *getHelp(const char *helpRqst);
static void displayHelp(const char *helpPtr);
void initHelp(void)
{
helpLines = 24; /* resonable defaults */
helpCols = 80;
}
int Help(char */*topic[]*/)
{
char *str = NULL;
const char *helpPtr = NULL; /*, *test;*/
displayHelp(getHelp("H"));
str = rl_gets("HELP-->");
while(strlen(str)){
if(str && strlen(str) > 0) {
helpPtr = getHelp(str);
if(helpPtr) {
displayHelp(helpPtr);
} else {
printf("No help is available for %s\n", str);
}
}
printf(" Type a letter for help, or carriage return to\n return\
to the Albert session.\n\n\n");
str = rl_gets("HELP-->");
}
return 1;
}
const char *getHelp(const char *helpRqst)
{
int i;
for(i = 0; i < NUM_COMMANDS; ++i){
if(!strncmp(helpRqst, Help_lines[i].help_topic, strlen(helpRqst))){
return(Help_lines[i].help_text);
}
}
return(NULL);
}
void displayHelp(const char *helpPtr)
{
puts(helpPtr);
}
void more(int *lines)
{
return;
if(*lines >= helpLines-2){
*lines = 0;
printf("\nHit Return to continue-->"); /* print more message at bottom left of screen */
fflush(stdout);
getchar();
printf("\n");
}
}