]> andersk Git - moira.git/blob - clients/mmoira/help.c
*** empty log message ***
[moira.git] / clients / mmoira / help.c
1 /* $Header$
2  *
3  *      Copyright 1991 by the Massachusetts Institute of Technology.
4  *
5  *      For further information on copyright and distribution 
6  *      see the file mit-copyright.h
7  */
8
9 #include        <mit-copyright.h>
10 #include        <stdio.h>
11 #include        <Xm/Xm.h>
12 #include        <moira.h>
13 #include        "mmoira.h"
14
15
16 help(node)
17 char *node;
18 {
19     FILE *helpfile = NULL;
20     char buf[1024], key[32], *msg, helpbuf[10240], *filename;
21     char *realloc(), *getenv();
22
23     sprintf(key, "*%s\n", node);
24     filename = getenv("MOIRAHELPFILE");
25     if (filename == NULL)
26       filename = HELPFILE;
27     helpfile = fopen(filename, "r");
28     if (helpfile == NULL) {
29         display_error("Sorry, help is currently unavailable.\n");
30         return;
31     }
32     while (fgets(buf, sizeof(buf), helpfile))
33       if (!strcmp(buf, key))
34         break;
35     if (strcmp(buf, key)) {
36         sprintf(buf, "Sorry, unable to find help on topic \"%s\".\n", node);
37         display_error(buf);
38         fclose(helpfile);
39         return;
40     }
41     msg = NULL;
42     while (fgets(buf, sizeof(buf), helpfile))
43       if (buf[0] == '*')
44         break;
45       else {
46           if (msg) {
47               if (!strcmp(buf, "\n"))
48                 strcpy(buf, " \n");
49               msg = realloc(msg, strlen(msg) + strlen(buf));
50               strcat(msg, buf);
51           } else
52             msg = strsave(buf);
53       }
54     fclose(helpfile);
55     if (msg) {
56         PopupHelpWindow(msg);
57         free(msg);
58     }
59     return;
60 }
61
62 help_form_callback(dummy, form)
63 int dummy;
64 EntryForm *form;
65 {
66     help(form->formname);
67 }
68
This page took 0.057436 seconds and 5 git commands to generate.