File: help.c

package info (click to toggle)
mh 6.8.4-28
  • links: PTS
  • area: main
  • in suites: slink
  • size: 7,012 kB
  • ctags: 7,496
  • sloc: ansic: 75,211; sh: 3,112; lisp: 2,205; ml: 1,894; makefile: 724; perl: 482; csh: 150; tcl: 66; sed: 43; awk: 7
file content (55 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* help.c - print the usage line */
#ifndef lint
static char ident[] = "@(#)$Id: help.c,v 1.4 1994/04/21 19:56:24 jromine Exp $";
#endif	/*  lint */

#include "../h/mh.h"
#include <stdio.h>


extern char *options[];


void help (str, swp)
register char  *str;
register struct swit   *swp;
{
    int     nameoutput,
            len,
            linepos,
            outputlinelen;
    register char  *cp,
                  **ap;

    printf ("syntax: %s\n", str);
    printf ("  switches are:\n");
    printsw (ALL, swp, "-");
    if ((cp = m_find (invo_name)) != NULL)
	printf ("profile: %s\n", cp);

    if (ssequal ("@(#)", cp = version))
	cp += 4;
    printf ("\nversion: %s\n", cp);

    nameoutput = linepos = 0;
    outputlinelen = OUTPUTLINELEN;
    for (ap = options; *ap; ap++) {
	if (!nameoutput) {
	    fprintf (stdout, "%s: ", cp = "options");
	    linepos += (nameoutput = strlen (cp) + 2);
	}
	len = strlen (cp = *ap);
	if (linepos != nameoutput)
	    if (len + linepos + 3 > outputlinelen)
		fprintf (stdout, "\n%*s", linepos = nameoutput, "");
	    else {
		fputs (" ", stdout);
		linepos++;
	    }
	fprintf (stdout, "[%s]", cp);
	linepos += len + 2;
    }

    if (linepos)
	(void) fputc ('\n', stdout);
}