Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / help.c
1 /* help.c - print the usage line */
2 #ifndef lint
3 static char ident[] = "@(#)$Id: help.c,v 1.4 1994/04/21 19:56:24 jromine Exp $";
4 #endif  /*  lint */
5
6 #include "../h/mh.h"
7 #include <stdio.h>
8
9
10 extern char *options[];
11
12
13 void help (str, swp)
14 register char  *str;
15 register struct swit   *swp;
16 {
17     int     nameoutput,
18             len,
19             linepos,
20             outputlinelen;
21     register char  *cp,
22                   **ap;
23
24     printf ("syntax: %s\n", str);
25     printf ("  switches are:\n");
26     printsw (ALL, swp, "-");
27     if ((cp = m_find (invo_name)) != NULL)
28         printf ("profile: %s\n", cp);
29
30     if (ssequal ("@(#)", cp = version))
31         cp += 4;
32     printf ("\nversion: %s\n", cp);
33
34     nameoutput = linepos = 0;
35     outputlinelen = OUTPUTLINELEN;
36     for (ap = options; *ap; ap++) {
37         if (!nameoutput) {
38             fprintf (stdout, "%s: ", cp = "options");
39             linepos += (nameoutput = strlen (cp) + 2);
40         }
41         len = strlen (cp = *ap);
42         if (linepos != nameoutput)
43             if (len + linepos + 3 > outputlinelen)
44                 fprintf (stdout, "\n%*s", linepos = nameoutput, "");
45             else {
46                 fputs (" ", stdout);
47                 linepos++;
48             }
49         fprintf (stdout, "[%s]", cp);
50         linepos += len + 2;
51     }
52
53     if (linepos)
54         (void) fputc ('\n', stdout);
55 }