Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ftpd rewrite method of traversing facttab[]; use siz...



details:   https://anonhg.NetBSD.org/src/rev/06251eb6c599
branches:  trunk
changeset: 488145:06251eb6c599
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Jun 19 17:08:05 2000 +0000

description:
rewrite method of traversing facttab[]; use size of list to terminate
not NULL terminated entry (since we need to know the size of other
reasons...)

diffstat:

 libexec/ftpd/cmds.c |  19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diffs (79 lines):

diff -r 596a0dda7234 -r 06251eb6c599 libexec/ftpd/cmds.c
--- a/libexec/ftpd/cmds.c       Mon Jun 19 15:15:03 2000 +0000
+++ b/libexec/ftpd/cmds.c       Mon Jun 19 17:08:05 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.3 2000/06/19 15:15:03 lukem Exp $   */
+/*     $NetBSD: cmds.c,v 1.4 2000/06/19 17:08:05 lukem Exp $   */
 
 /*
  * Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cmds.c,v 1.3 2000/06/19 15:15:03 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.4 2000/06/19 17:08:05 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -161,9 +161,10 @@
        /* "Lang" */
        /* "Media-Type" */
        /* "CharSet" */
-       { NULL, NULL, },
 };
 
+#define FACTTABSIZE    (sizeof(facttab) / sizeof(struct ftpfact))
+
 
 void
 cwd(const char *path)
@@ -198,7 +199,7 @@
        reply(-211, "Features supported");
        cprintf(stdout, " MDTM\r\n");
        cprintf(stdout, " MLST ");
-       for (i = 0; facttab[i].name; i++)
+       for (i = 0; i < FACTTABSIZE; i++)
                cprintf(stdout, "%s%s;", facttab[i].name,
                    facttab[i].enabled ? "*" : "");
        cprintf(stdout, "\r\n");
@@ -335,7 +336,7 @@
 
                        /* special case: MLST */
        if (strcasecmp(command, "MLST") == 0) {
-               int      enabled[sizeof(facttab) / sizeof(struct ftpfact)];
+               int      enabled[FACTTABSIZE];
                int      i, onedone;
                size_t   len;
                char    *p;
@@ -356,7 +357,7 @@
                while ((p = strsep(&ep, ";")) != NULL) {
                        if (*p == '\0')
                                goto badmlstopt;
-                       for (i = 0; facttab[i].name; i++)
+                       for (i = 0; i < FACTTABSIZE; i++)
                                if (strcasecmp(p, facttab[i].name) == 0) {
                                        enabled[i] = 1;
                                        break;
@@ -364,10 +365,10 @@
                }
 
  displaymlstopts:
-               for (i = 0; facttab[i].name; i++)
+               for (i = 0; i < FACTTABSIZE; i++)
                        facttab[i].enabled = enabled[i];
                cprintf(stdout, "200 MLST OPTS");
-               for (i = onedone = 0; facttab[i].name; i++) {
+               for (i = onedone = 0; i < FACTTABSIZE; i++) {
                        if (facttab[i].enabled) {
                                cprintf(stdout, "%s%s;", onedone ? "" : " ",
                                    facttab[i].name);
@@ -763,7 +764,7 @@
 {
        int i;
 
-       for (i = 0; facttab[i].name; i++) {
+       for (i = 0; i < FACTTABSIZE; i++) {
                if (facttab[i].enabled)
                        (facttab[i].display)(facttab[i].name, fp, fe);
        }



Home | Main Index | Thread Index | Old Index