install with -s
[unix-history] / usr / src / usr.bin / systat / mbufs.c
index 558436a..6838cc6 100644 (file)
@@ -1,6 +1,12 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mbufs.c    1.2 (Lucasfilm) %G%";
-#endif
+static char sccsid[] = "@(#)mbufs.c    5.1 (Berkeley) %G%";
+#endif not lint
 
 #include "systat.h"
 #include <sys/mbuf.h>
 
 #include "systat.h"
 #include <sys/mbuf.h>
@@ -8,11 +14,8 @@ static char sccsid[] = "@(#)mbufs.c   1.2 (Lucasfilm) %G%";
 WINDOW *
 openmbufs()
 {
 WINDOW *
 openmbufs()
 {
-       static WINDOW *w = NULL;
 
 
-       if (w == NULL)
-               w = newwin(20, 70, 3, 5);
-       return (w);
+       return (subwin(stdscr, LINES-5-1, 0, 5, 0));
 }
 
 closembufs(w)
 }
 
 closembufs(w)
@@ -21,10 +24,9 @@ closembufs(w)
 
        if (w == NULL)
                return;
 
        if (w == NULL)
                return;
-       move(5, 0);
-       clrtobot();
        wclear(w);
        wrefresh(w);
        wclear(w);
        wrefresh(w);
+       delwin(w);
 }
 
 struct mbstat *mb;
 }
 
 struct mbstat *mb;
@@ -32,9 +34,9 @@ struct        mbstat *mb;
 labelmbufs()
 {
 
 labelmbufs()
 {
 
-        move(5, 0); clrtoeol();
-        mvaddstr(5, 20,
-                "/0   /5   /10  /15  /20  /25  /30  /35  /40  /45  /50");
+        wmove(wnd, 0, 0); wclrtoeol(wnd);
+        mvwaddstr(wnd, 0, 10,
+           "/0   /5   /10  /15  /20  /25  /30  /35  /40  /45  /50  /55  /60");
 }
 
 char *mtnames[] = {
 }
 
 char *mtnames[] = {
@@ -50,7 +52,10 @@ char *mtnames[] = {
        "zombies",
        "sockopts",
        "frags",
        "zombies",
        "sockopts",
        "frags",
+       "rights",
+       "ifaddrs",
 };
 };
+#define        NNAMES  (sizeof (mtnames) / sizeof (mtnames[0]))
 
 showmbufs()
 {
 
 showmbufs()
 {
@@ -59,21 +64,23 @@ showmbufs()
 
        if (mb == 0)
                return;
 
        if (mb == 0)
                return;
-       for (j = 0; j < 15; j++) {
+       for (j = 0; j < wnd->_maxy; j++) {
                max = 0, index = -1; 
                max = 0, index = -1; 
-               for (i = 0; i < 15; i++)
+               for (i = 0; i < wnd->_maxy; i++)
                        if (mb->m_mtypes[i] > max) {
                                max = mb->m_mtypes[i];
                                index = i;
                        }
                if (max == 0)
                        break;
                        if (mb->m_mtypes[i] > max) {
                                max = mb->m_mtypes[i];
                                index = i;
                        }
                if (max == 0)
                        break;
-               wmove(wnd, 3 + j, 0);
-               waddstr(wnd, mtnames[index]);
-               wmove(wnd, 3 + j, 15);
-               if (max > 50) {
+               if (j > NNAMES)
+                       mvwprintw(wnd, 1+j, 0, "%10d", index);
+               else
+                       mvwprintw(wnd, 1+j, 0, "%-10.10s", mtnames[index]);
+               wmove(wnd, 1 + j, 10);
+               if (max > 60) {
                        sprintf(buf, " %d", max);
                        sprintf(buf, " %d", max);
-                       max = 50;
+                       max = 60;
                        while (max--)
                                waddch(wnd, 'X');
                        waddstr(wnd, buf);
                        while (max--)
                                waddch(wnd, 'X');
                        waddstr(wnd, buf);
@@ -84,10 +91,7 @@ showmbufs()
                }
                mb->m_mtypes[index] = 0;
        }
                }
                mb->m_mtypes[index] = 0;
        }
-       while (j++ < 15) {
-               wmove(wnd, 3 + j, 0);
-               wclrtoeol(wnd);
-       }
+       wmove(wnd, 1+j, 0); wclrtobot(wnd);
 }
 
 static struct nlist nlst[] = {
 }
 
 static struct nlist nlst[] = {