]> diplodocus.org Git - nmh/blobdiff - sbr/print_sw.c
Add basic support for the STLS command in POP
[nmh] / sbr / print_sw.c
index 426724b4415697b2972438b0dc4bd59579928d07..d8628b828a129df7635024eefd616b217a6327a6 100644 (file)
@@ -1,37 +1,36 @@
-
-/*
- * print_sw.c -- print switches
- *
- * $Id$
+/* print_sw.c -- print switches
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
  */
 
-#include <h/mh.h>
+#include "h/mh.h"
+#include "ssequal.h"
+#include "print_sw.h"
 
 
 void
-print_sw (char *substr, struct swit *swp, char *prefix)
+print_sw (const char *substr, const struct swit *swp, char *prefix, FILE *fp)
 {
-    int len, optno;
-    register int i;
-    register char *cp, *cp1, *sp;
+    int len;
+    bool optno;
+    int i;
+    char *cp, *cp1, *sp;
     char buf[128];
 
     len = strlen(substr);
     for (; swp->sw; swp++) {
        /* null matches all strings */
        if (!*substr || (ssequal (substr, swp->sw) && len >= swp->minchars)) {
-           optno = 0;
+           optno = false;
            /* next switch */
            if ((sp = (&swp[1])->sw)) {
                if (!*substr && sp[0] == 'n' && sp[1] == 'o' &&
                        strcmp (&sp[2], swp->sw) == 0 && (
                        ((&swp[1])->minchars == 0 && swp->minchars == 0) ||
                        ((&swp[1])->minchars == (swp->minchars) + 2)))
-                   optno++;
+                   optno = true;
            }
 
            if (swp->minchars > 0) {
@@ -45,10 +44,11 @@ print_sw (char *substr, struct swit *swp, char *prefix)
                    *cp++ = *cp1++;
                *cp++ = ')';
                while ((*cp++ = *cp1++));
-               printf ("  %s%s\n", prefix, buf);
+               fprintf (fp, "  %s%s\n", prefix, buf);
            } else {
                if (!swp->minchars)
-                   printf(optno ? "  %s[no]%s\n" : "  %s%s\n", prefix, swp->sw);
+                   fprintf(fp, optno ? "  %s[no]%s\n" : "  %s%s\n",
+                            prefix, swp->sw);
            }
            if (optno)
                swp++;  /* skip -noswitch */