]> andersk Git - moira.git/blame - clients/mmoira/help.c
only list options once in usage message to be less confusing
[moira.git] / clients / mmoira / help.c
CommitLineData
58b9d8ef 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>
b2d21e59 12#include <moira.h>
58b9d8ef 13#include "mmoira.h"
14
15
16help(node)
17char *node;
18{
19 FILE *helpfile = NULL;
b2d21e59 20 char buf[1024], key[32], *msg, helpbuf[10240], *filename;
21 char *realloc(), *getenv();
58b9d8ef 22
23 sprintf(key, "*%s\n", node);
6967895d 24 filename = resources.help_file;
b2d21e59 25 if (filename == NULL)
26 filename = HELPFILE;
27 helpfile = fopen(filename, "r");
58b9d8ef 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 }
b2d21e59 41 msg = NULL;
58b9d8ef 42 while (fgets(buf, sizeof(buf), helpfile))
43 if (buf[0] == '*')
44 break;
b2d21e59 45 else {
46 if (msg) {
47 if (!strcmp(buf, "\n"))
48 strcpy(buf, " \n");
079b495a 49 msg = realloc(msg, strlen(msg) + strlen(buf) + 2);
b2d21e59 50 strcat(msg, buf);
51 } else
52 msg = strsave(buf);
53 }
58b9d8ef 54 fclose(helpfile);
b2d21e59 55 if (msg) {
ca5beb9a 56 if (tty)
57 printf("%s\r\n", msg);
58 else
59 PopupHelpWindow(msg);
b2d21e59 60 free(msg);
61 }
58b9d8ef 62 return;
63}
64
65help_form_callback(dummy, form)
66int dummy;
67EntryForm *form;
68{
f7c9217f 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++)
25eb6a33 80 if (!((*p)->insensitive))
f7c9217f 81 count++;
82 while (count-- > 1)
83 _XmMgrTraversal(form->formpointer, XmTRAVERSE_PREV_TAB_GROUP);
58b9d8ef 84 help(form->formname);
85}
86
This page took 0.069818 seconds and 5 git commands to generate.