]>
Commit | Line | Data |
---|---|---|
3bd189cb JR |
1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | #include <descrip.h> | |
4 | #ifdef __GNUC__ | |
5 | #define HLP$M_PROMPT 1 | |
6 | #else | |
7 | #include <lbrdef.h> | |
8 | #include <hlpdef.h> | |
9 | #include <unixio.h> | |
10 | #endif | |
11 | #include "base_includes.h" | |
12 | #include "set.h" | |
13 | #include "inp.h" | |
14 | #include "irchelp.h" | |
15 | ||
16 | #ifndef R_OK | |
17 | #define R_OK 4 | |
18 | extern int access(); | |
19 | #endif | |
20 | ||
21 | extern int lbr$output_help(); /* not defined in header files */ | |
22 | ||
23 | static char help_file[MAXLEN]; | |
24 | static $DESCRIPTOR(help_file_d, help_file); | |
25 | ||
26 | extern server_ptr gsrv; | |
27 | ||
28 | static int help_output(out) | |
29 | struct dsc$descriptor *out; | |
30 | { | |
31 | char buffer[100]; | |
32 | if (!(int)out->dsc$w_length) return 1; | |
33 | (void)strncpy(buffer, out->dsc$a_pointer, out->dsc$w_length); | |
34 | buffer[(int)out->dsc$w_length] = 0; | |
35 | if (*buffer) | |
36 | say("%s", buffer); | |
37 | else | |
38 | say(" "); | |
39 | return 1; | |
40 | } | |
41 | ||
42 | static int help_input(str, prompt, len) | |
43 | struct dsc$descriptor *str, *prompt; | |
44 | unsigned long *len; | |
45 | { | |
46 | char buffer[100], input[100]; | |
47 | (void)strncpy(buffer, prompt->dsc$a_pointer, prompt->dsc$w_length); | |
48 | buffer[(int)prompt->dsc$w_length-1] = 32; | |
49 | buffer[(int)prompt->dsc$w_length] = 0; | |
50 | (void)read_input(input, 100, &buffer[2]); | |
51 | (void)strcpy(str->dsc$a_pointer, input); | |
52 | str->dsc$w_length = strlen(input); | |
53 | return 1; | |
54 | } | |
55 | ||
56 | int in_help = 0; | |
57 | ||
58 | void help(char *str, int varpar, char *subparams) | |
59 | { | |
60 | unsigned status; | |
61 | int loop, flags = HLP$M_PROMPT, context, width=77; | |
62 | struct dsc$descriptor keywords_d; | |
63 | keywords_d.dsc$a_pointer = (*str)?str:"help"; | |
64 | ||
65 | keywords_d.dsc$b_dtype = DSC$K_DTYPE_T; | |
66 | keywords_d.dsc$b_class = DSC$K_CLASS_S; | |
67 | keywords_d.dsc$w_length = strlen(keywords_d.dsc$a_pointer); | |
68 | get_variable("HELP_PATH", NULL, help_file); | |
69 | strcat(help_file, "irchelp.hlb"); | |
70 | help_file_d.dsc$w_length = strlen(help_file); | |
71 | if (strstr(help_file, ":") == NULL) | |
72 | say("*** The HELP_PATH must contain a full specification - include a device"); | |
73 | else if (access(help_file, R_OK) == -1) | |
74 | say("*** Could not find the help file."); | |
75 | else | |
76 | { | |
77 | in_help = 1; | |
78 | status = lbr$output_help(help_output, &width, &keywords_d, &help_file_d, | |
79 | &flags, help_input); | |
80 | in_help = 0; | |
81 | } | |
82 | } |