]> andersk Git - moira.git/blame - clients/mmoira/help.c
*** empty log message ***
[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);
b2d21e59 24 filename = getenv("MOIRAHELPFILE");
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");
49 msg = realloc(msg, strlen(msg) + strlen(buf));
50 strcat(msg, buf);
51 } else
52 msg = strsave(buf);
53 }
58b9d8ef 54 fclose(helpfile);
b2d21e59 55 if (msg) {
56 PopupHelpWindow(msg);
57 free(msg);
58 }
58b9d8ef 59 return;
60}
61
62help_form_callback(dummy, form)
63int dummy;
64EntryForm *form;
65{
66 help(form->formname);
67}
68
This page took 0.094879 seconds and 5 git commands to generate.