Removed the undocumented `select' option of slocal(1) and thus removed utmp.
[mmh] / sbr / print_sw.c
1 /*
2 ** print_sw.c -- print switches
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11
12 void
13 print_sw(char *substr, struct swit *swp, char *prefix, FILE *fp)
14 {
15         int len, optno;
16         register int i;
17         register char *cp, *cp1, *sp;
18         char buf[128];
19
20         len = strlen(substr);
21         for (; swp->sw; swp++) {
22                 /* null matches all strings */
23                 if (!*substr || (strncmp(swp->sw, substr, len)==0 &&
24                                 len >= swp->minchars)) {
25                         optno = 0;
26                         /* next switch */
27                         if ((sp = (&swp[1])->sw)) {
28                                 if (!*substr && sp[0] == 'n' && sp[1] == 'o' &&
29                                                 strcmp(&sp[2], swp->sw) == 0 && (
30                                                 ((&swp[1])->minchars == 0 && swp->minchars == 0) ||
31                                                 ((&swp[1])->minchars == (swp->minchars) + 2)))
32                                         optno++;
33                         }
34
35                         if (swp->minchars > 0) {
36                                 cp = buf;
37                                 *cp++ = '(';
38                                 if (optno) {
39                                         strcpy(cp, "[no]");
40                                         cp += strlen(cp);
41                                 }
42                                 for (cp1 = swp->sw, i = 0; i < swp->minchars; i++)
43                                         *cp++ = *cp1++;
44                                 *cp++ = ')';
45                                 while ((*cp++ = *cp1++));
46                                 fprintf(fp, "  %s%s\n", prefix, buf);
47                         } else {
48                                 if (!swp->minchars)
49                                         fprintf(fp, optno ? "  %s[no]%s\n" : "  %s%s\n",
50                                                 prefix, swp->sw);
51                         }
52                         if (optno)
53                                 swp++;  /* skip -noswitch */
54                 }
55         }
56 }