]> andersk Git - moira.git/blob - clients/mmoira/help.c
typo
[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 = resources.help_file;
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) + 2);
50               strcat(msg, buf);
51           } else
52             msg = strsave(buf);
53       }
54     fclose(helpfile);
55     if (msg) {
56         if (tty)
57           printf("%s\r\n", msg);
58         else
59           PopupHelpWindow(msg);
60         free(msg);
61     }
62     return;
63 }
64
65 help_form_callback(dummy, form)
66 int dummy;
67 EntryForm *form;
68 {
69     UserPrompt **p;
70     int count;
71
72     /* undocumented Motif internal routine to advance in tab group.
73      * In this case we're going backwards because for some reason
74      * the form advances whenever this button is pressed.
75      * However, it doesn't seem to go backwards even though source 
76      * implies that it should.  So we go forward until we wrap.
77      */
78     count = 0;
79     for (p = form->inputlines; *p; p++)
80       if (!((*p)->insensitive))
81         count++;
82     while (count-- > 1)
83       _XmMgrTraversal(form->formpointer, XmTRAVERSE_PREV_TAB_GROUP);
84     help(form->formname);
85 }
86
This page took 0.040009 seconds and 5 git commands to generate.