Add patches which contain some tweaks and new useful features

like i.e possibility to set up geometry.
Assign maintainership to submitter.

PR:		ports/70576
Submitted by:	Roman Bogorodskiy <bogorodskiy@inbox.ru>
This commit is contained in:
Kirill Ponomarev 2004-08-17 21:25:20 +00:00
parent a81bacb2d8
commit 35916104d5
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=116546
5 changed files with 398 additions and 1 deletions

View File

@ -7,10 +7,11 @@
PORTNAME= wmnet
PORTVERSION= 1.2
PORTREVISION= 1
CATEGORIES= net windowmaker
MASTER_SITES= ftp://ftp.enteract.com/users/rneswold/
MAINTAINER= ports@FreeBSD.org
MAINTAINER= bogorodskiy@inbox.ru
COMMENT= A network bandwidth monitor intended for the WindowMaker dock
USE_XPM= yes

View File

@ -0,0 +1,242 @@
--- main.c.orig Sat Jun 5 15:28:39 2004
+++ main.c Sat Jun 5 15:28:46 2004
@@ -32,11 +32,11 @@
#define LED_SZE_Y (4)
#define LED_ON_NET_X (87)
-#define LED_ON_NET_Y (66)
+#define LED_ON_NET_Y (92)
#define LED_OFF_NET_X (93)
-#define LED_OFF_NET_Y (66)
+#define LED_OFF_NET_Y (92)
#define LED_ERR_NET_X (81)
-#define LED_ERR_NET_Y (66)
+#define LED_ERR_NET_Y (92)
#define LED_PWR_X (53)
#define LED_PWR_Y (7)
@@ -52,6 +52,7 @@
static unsigned findInterface(char const*);
static void printversion(void);
static char const *rateToStr(unsigned long);
+static double getRate(unsigned long, char *);
static void SetErrLED(int);
static void SetOffLED(int);
static void SetOnLED(int);
@@ -68,7 +69,7 @@
------------------------------------------------------------------------------*/
static void DrawActiveIFS(char const* name)
{
- copyXPMArea(5, 84, 30, 10, 5, 5);
+ copyXPMArea(5, 110, 30, 10, 5, 5);
if (name) {
int ii, kk = 5;
@@ -77,9 +78,9 @@
int const ch = toupper(name[ii]);
if (ch >= 'A' && ch <= 'Z')
- copyXPMArea((ch - 'A') * 6, 74, 6, 9, kk, 5);
+ copyXPMArea((ch - 'A') * 6, 100, 6, 9, kk, 5);
else
- copyXPMArea((ch - '0') * 6, 64, 6, 9, kk, 5);
+ copyXPMArea((ch - '0') * 6, 90, 6, 9, kk, 5);
kk += 6;
}
}
@@ -91,25 +92,22 @@
static void DrawStats(unsigned ifCurr, int height, int x_left, int y_bottom)
{
unsigned baseLine = y_bottom - height / 2;
- unsigned maxVal = 0, ii;
+ unsigned maxVal = 0, ii, currVal = 0;
char const* ptr = 0;
/* Find the maximum value. We'll scale the graph to this value. */
+ unsigned long rcv, xmt;
for (ii = 0; ii < G_WIDTH; ++ii) {
- unsigned long rcv, xmt;
ifGetData(ifCurr, ii, &xmt, &rcv);
xmt /= delay;
rcv /= delay;
-
- if (rcv > maxVal)
- maxVal = rcv;
- if (xmt > maxVal)
- maxVal = xmt;
+ currVal = xmt > rcv ? xmt : rcv ;
+ if (currVal > maxVal)
+ maxVal = currVal;
}
- ptr = rateToStr(maxVal);
/* Now draw the data points. */
@@ -127,27 +125,58 @@
}
for (jj = 0; jj < height; ++jj)
if (y_bottom - jj <= start && y_bottom - jj >= stop)
- copyXPMArea(100 + 1, 68, 1, 1, ii + x_left, y_bottom - jj);
+ copyXPMArea(99 + 1, 106, 1, 1, ii + x_left, y_bottom - jj);
else
- copyXPMArea(100, 68, 1, 1, ii + x_left, y_bottom - jj);
+ copyXPMArea(99, 106, 1, 1, ii + x_left, y_bottom - jj);
/* Draw the base line. */
- copyXPMArea(100 + 3, 68, 1, 1, ii + x_left, baseLine);
+ copyXPMArea(100, 106, 1, 1, ii + x_left, baseLine);
}
- /* Now draw the data rate... */
+ /* Now draw the download data rate... */
+
+ /* Clear area */
+ copyXPMArea( 6, 111, 54 , 9 , 6, 63);
+
+ ptr = rateToStr(rcv);
+ copyXPMArea(('D' - 'A') * 6, 100, 6, 9, 6,
+ 62);
+ copyXPMArea(64, 90, 4, 9, 12,
+ 62);
+ for (ii = 20; *ptr; ++ptr)
+ if (isdigit(*ptr)) {
+ copyXPMArea((*ptr - '0') * 6, 90, 6, 9, 1 + ii, 62 );
+ ii += 6;
+ } else if ('.' == *ptr) {
+ copyXPMArea(60, 90, 4, 9, 1 + ii, 62);
+ ii += 4;
+ } else {
+ copyXPMArea((toupper(*ptr) - 'A') * 6, 100, 6, 9, 1 + ii,
+ 62);
+ ii += 6;
+ }
+
+ /* Now draw the upload data rate... */
+
+ /* Clear area */
+ copyXPMArea( 6, 111, 54 , 9 , 6, 76);
- for (ii = 5; *ptr; ++ptr)
+ ptr = rateToStr(xmt);
+ copyXPMArea(('U' - 'A') * 6, 100, 6, 9, 6,
+ 75);
+ copyXPMArea(64, 90, 4, 9, 12,
+ 75);
+ for (ii = 20; *ptr; ++ptr)
if (isdigit(*ptr)) {
- copyXPMArea((*ptr - '0') * 6, 64, 6, 9, 1 + ii, y_bottom - 10);
+ copyXPMArea((*ptr - '0') * 6, 90, 6, 9, 1 + ii, 75 );
ii += 6;
} else if ('.' == *ptr) {
- copyXPMArea(60, 64, 4, 9, 1 + ii, y_bottom - 10);
+ copyXPMArea(60, 90, 4, 9, 1 + ii, 75);
ii += 4;
} else {
- copyXPMArea((toupper(*ptr) - 'A') * 6, 74, 6, 9, 1 + ii,
- y_bottom - 10);
+ copyXPMArea((toupper(*ptr) - 'A') * 6, 100, 6, 9, 1 + ii,
+ 75);
ii += 6;
}
@@ -205,41 +234,39 @@
------------------------------------------------------------------------------*/
static char const* rateToStr(unsigned long rate)
{
- static char buffer[7];
- char scaleFactor, *ptr = buffer;
+ static char buffer[14];
+ char scaleFactor='\0', *ptr = buffer;
- /* Based upon its magnitude, determine how much 'rate' needs to be
- scaled and also indicate its unit of scale. */
-
- if (rate > 1000000) {
- rate /= 100000;
- scaleFactor = 'M';
- } else if (rate > 1000) {
- rate /= 100;
- scaleFactor = 'K';
- } else {
- rate *= 10;
- scaleFactor = '\0';
- }
+ double drate = getRate(rate,&scaleFactor);
- /* Transform the value into a left - justified string. */
-
- if (rate >= 1000)
- *ptr++ = rate / 1000 + '0';
- if (rate >= 100)
- *ptr++ = (rate / 100) % 10 + '0';
- if (rate >= 10)
- *ptr++ = (rate / 10) % 10 + '0';
- if (scaleFactor) {
- *ptr++ = '.';
- *ptr++ = rate % 10 + '0';
- }
+ /* Transform the rate value into a left - justified string. */
+ ptr+=sprintf(ptr,"%.1f",drate);
*ptr++ = scaleFactor;
*ptr = '\0';
return buffer;
}
/*------------------------------------------------------------------------------
+ getRate
+------------------------------------------------------------------------------*/
+static double getRate(unsigned long rate, char *scaleFactor)
+{
+ double drate = rate;
+
+ /* Based upon its magnitude, determine how much 'rate' needs to be
+ scaled and also indicate its unit of scale. */
+
+ if (rate > 1048576) {
+ drate /= 1048576;
+ *scaleFactor = 'M';
+ } else if (rate > 1024) {
+ drate /= 1024;
+ *scaleFactor = 'K';
+ }
+ return drate;
+}
+
+/*------------------------------------------------------------------------------
SetErrLED
------------------------------------------------------------------------------*/
static void SetErrLED(int led)
@@ -314,10 +341,11 @@
{
static char const txt[] =
"\nwmnet, v1p2 - A network interface monitor for WindowMaker.\n\n"
- "\t-h this help screen\n"
- "\t-i name start with interface 'name'\n"
- "\t-u delay seconds between samples (defaults to 1)\n"
- "\t-v print the version number\n";
+ "\t-h this help screen\n"
+ "\t-i name start with interface 'name'\n"
+ "\t-u delay seconds between samples (defaults to 1)\n"
+ "\t-geom <geometry> geometry to use\n"
+ "\t-v print the version number\n";
fputs(txt, stderr);
}
@@ -425,6 +453,13 @@
case 'v':
printversion();
return 0;
+
+ case 'g':
+ if (ii + 1 == argc) {
+ printf("wmnet: must specify geometry\n");
+ return 0;
+ }
+ break;
default:
usage();

View File

@ -0,0 +1,38 @@
--- wmgeneral.c.orig Wed Aug 26 18:58:57 1998
+++ wmgeneral.c Sat Jun 5 13:53:35 2004
@@ -221,7 +221,7 @@
char const* pixmask_bits, int pixmask_width,
int pixmask_height)
{
- static char const Geometry[] = "";
+ static char *Geometry = 0;
unsigned int borderwidth = 1;
XClassHint classHint;
@@ -245,6 +245,17 @@
display_name = argv[i + 1];
}
+ /* Look to see if the caller specified the geometry. If so, we will
+ use it to place window */
+
+ for (i = 1; argv[i]; i++) {
+ if (!strcmp(argv[i], "-geom"))
+ Geometry = argv[i + 1];
+ }
+
+ if (!Geometry)
+ Geometry = "";
+
if (!(display = XOpenDisplay(display_name))) {
fprintf(stderr, "%s: can't open display %s\n", wname,
XDisplayName(display_name));
@@ -272,7 +283,7 @@
&mysizehints.height, &dummy);
mysizehints.width = 64;
- mysizehints.height = 64;
+ mysizehints.height = 90;
win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
mysizehints.width, mysizehints.height,

View File

@ -0,0 +1,48 @@
--- wmnet-mask.xbm.orig Wed Aug 26 00:07:56 1998
+++ wmnet-mask.xbm Sat Jun 5 13:52:40 2004
@@ -1,5 +1,5 @@
#define wmnet_mask_width 64
-#define wmnet_mask_height 64
+#define wmnet_mask_height 90
static char const wmnet_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -68,5 +68,37 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};

View File

@ -0,0 +1,68 @@
--- wmnet-master.xpm.orig Wed Aug 26 00:07:57 1998
+++ wmnet-master.xpm Sat Jun 5 15:06:26 2004
@@ -1,6 +1,6 @@
/* XPM */
static char const* wmnet_master_xpm[] = {
-"160 100 13 1",
+"160 124 13 1",
" c None",
". c #0000FF",
"+ c #202020",
@@ -76,6 +76,32 @@
"....########################################################....+...............................................................................................",
"................................................................+...............................................................................................",
"................................................................+...............................................................................................",
+"....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....########################################################....+...............................................................................................",
+"................................................................+...............................................................................................",
+"................................................................+...............................................................................................",
+"....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....@++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................",
+"....########################################################....+...............................................................................................",
+"................................................................+...............................................................................................",
+"................................................................+...............................................................................................",
"................................................................+...............................................................................................",
"................................................................+...............................................................................................",
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................",
@@ -99,15 +125,15 @@
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
"................................................................................................................................................................",
"....@+++++++++++++++++++++++++++++++#..@+++++++++++++++++++#....+...............................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
-".....+++++++++++++++++++++++++++++++............................................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
+".....+++++++++++++++++++++++++++++++++++++++++++++++++++++++....................................................................................................",
"................................................................................................................................................................",
"................................................................................................................................................................",
"................................................................................................................................................................",