1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)mbufs.c	5.2 (Berkeley) 12/11/85";
   9: #endif not lint
  10: 
  11: #include "systat.h"
  12: #include <sys/mbuf.h>
  13: 
  14: WINDOW *
  15: openmbufs()
  16: {
  17: 
  18:     return (subwin(stdscr, LINES-5-1, 0, 5, 0));
  19: }
  20: 
  21: closembufs(w)
  22:     WINDOW *w;
  23: {
  24: 
  25:     if (w == NULL)
  26:         return;
  27:     wclear(w);
  28:     wrefresh(w);
  29:     delwin(w);
  30: }
  31: 
  32: struct  mbstat *mb;
  33: 
  34: labelmbufs()
  35: {
  36: 
  37:         wmove(wnd, 0, 0); wclrtoeol(wnd);
  38:         mvwaddstr(wnd, 0, 10,
  39:            "/0   /5   /10  /15  /20  /25  /30  /35  /40  /45  /50  /55  /60");
  40: }
  41: 
  42: char *mtnames[] = {
  43:     "free",
  44:     "data",
  45:     "headers",
  46:     "sockets",
  47:     "pcbs",
  48:     "routes",
  49:     "hosts",
  50:     "arps",
  51:     "socknames",
  52:     "zombies",
  53:     "sockopts",
  54:     "frags",
  55:     "rights",
  56:     "ifaddrs",
  57: };
  58: #define NNAMES  (sizeof (mtnames) / sizeof (mtnames[0]))
  59: 
  60: showmbufs()
  61: {
  62:     register int i, j, max, index;
  63:     char buf[10];
  64: 
  65:     if (mb == 0)
  66:         return;
  67:     for (j = 0; j < wnd->_maxy; j++) {
  68:         max = 0, index = -1;
  69:         for (i = 0; i < wnd->_maxy; i++)
  70:             if (mb->m_mtypes[i] > max) {
  71:                 max = mb->m_mtypes[i];
  72:                 index = i;
  73:             }
  74:         if (max == 0)
  75:             break;
  76:         if (j > NNAMES)
  77:             mvwprintw(wnd, 1+j, 0, "%10d", index);
  78:         else
  79:             mvwprintw(wnd, 1+j, 0, "%-10.10s", mtnames[index]);
  80:         wmove(wnd, 1 + j, 10);
  81:         if (max > 60) {
  82:             sprintf(buf, " %d", max);
  83:             max = 60;
  84:             while (max--)
  85:                 waddch(wnd, 'X');
  86:             waddstr(wnd, buf);
  87:         } else {
  88:             while (max--)
  89:                 waddch(wnd, 'X');
  90:             wclrtoeol(wnd);
  91:         }
  92:         mb->m_mtypes[index] = 0;
  93:     }
  94:     wmove(wnd, 1+j, 0); wclrtobot(wnd);
  95: }
  96: 
  97: static struct nlist nlst[] = {
  98: #define X_MBSTAT    0
  99:     { "_mbstat" },
 100:         { "" }
 101: };
 102: 
 103: initmbufs()
 104: {
 105: 
 106:     if (nlst[X_MBSTAT].n_type == 0) {
 107:         nlist("/vmunix", nlst);
 108:         if (nlst[X_MBSTAT].n_type == 0) {
 109:             error("namelist on /vmunix failed");
 110:             return(0);
 111:         }
 112:     }
 113:     if (mb == 0)
 114:         mb = (struct mbstat *)calloc(1, sizeof (*mb));
 115:     return(1);
 116: }
 117: 
 118: fetchmbufs()
 119: {
 120: 
 121:     if (nlst[X_MBSTAT].n_type == 0)
 122:         return;
 123:     lseek(kmem, nlst[X_MBSTAT].n_value, L_SET);
 124:     read(kmem, mb, sizeof (*mb));
 125: }

Defined functions

closembufs defined in line 21; used 2 times
fetchmbufs defined in line 118; used 2 times
initmbufs defined in line 103; used 2 times
labelmbufs defined in line 34; used 2 times
openmbufs defined in line 14; used 2 times
showmbufs defined in line 60; used 2 times

Defined variables

mb defined in line 32; used 9 times
mtnames defined in line 42; used 3 times
nlst defined in line 97; used 5 times
sccsid defined in line 8; never used

Defined macros

NNAMES defined in line 58; used 1 times
  • in line 76
X_MBSTAT defined in line 98; used 4 times
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2780
Valid CSS Valid XHTML 1.0 Strict