From 979f289914b694e9e85f7c1c3050fb300e41191c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Bl=C3=A4ttermann?= Date: Thu, 4 Aug 2011 18:11:24 +0200 Subject: [PATCH] Initial commit --- .gitignore | 1 + sources | 1 + wmwave-Makefile.patch | 11 ++ wmwave-fsf-address.patch | 126 ++++++++++++++++++++ wmwave.patch | 243 +++++++++++++++++++++++++++++++++++++++ wmwave.spec | 65 +++++++++++ 6 files changed, 447 insertions(+) create mode 100644 wmwave-Makefile.patch create mode 100644 wmwave-fsf-address.patch create mode 100644 wmwave.patch create mode 100644 wmwave.spec diff --git a/.gitignore b/.gitignore index e69de29..d6ed0c6 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/wmwave-0-4.tgz diff --git a/sources b/sources index e69de29..2495cfa 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +8728507eccb01a9749336f53ac4182c5 wmwave-0-4.tgz diff --git a/wmwave-Makefile.patch b/wmwave-Makefile.patch new file mode 100644 index 0000000..2e2e3d8 --- /dev/null +++ b/wmwave-Makefile.patch @@ -0,0 +1,11 @@ +--- Makefile 1999-08-19 19:58:51.000000000 +0200 ++++ Makefile 2011-08-04 10:55:41.001818278 +0200 +@@ -7,7 +7,7 @@ + # Added wmwave project to repository + + LIBDIR = -L/usr/X11R6/lib +-LIBS = -lXpm -lXext -lX11 -lm ++LIBS = -lXpm -lXext -lX11 -lm -liw + FLAGS = -O6 + OBJS = \ + wmgeneral.o \ diff --git a/wmwave-fsf-address.patch b/wmwave-fsf-address.patch new file mode 100644 index 0000000..a3fbfec --- /dev/null +++ b/wmwave-fsf-address.patch @@ -0,0 +1,126 @@ +--- COPYING 2011-07-03 12:38:34.775000106 +0200 ++++ COPYING 2011-07-03 12:44:06.881209097 +0200 +@@ -1,12 +1,12 @@ +- GNU GENERAL PUBLIC LICENSE +- Version 2, June 1991 ++ GNU GENERAL PUBLIC LICENSE ++ Version 2, June 1991 + +- Copyright (C) 1989, 1991 Free Software Foundation, Inc. +- 675 Mass Ave, Cambridge, MA 02139, USA ++ Copyright (C) 1989, 1991 Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +- Preamble ++ Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public +@@ -15,7 +15,7 @@ + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by +-the GNU Library General Public License instead.) You can apply it to ++the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not +@@ -55,8 +55,8 @@ + + The precise terms and conditions for copying, distribution and + modification follow. +- +- GNU GENERAL PUBLIC LICENSE ++ ++ GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +@@ -110,7 +110,7 @@ + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) +- ++ + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in +@@ -168,7 +168,7 @@ + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. +- ++ + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is +@@ -225,7 +225,7 @@ + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. +- ++ + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License +@@ -255,7 +255,7 @@ + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + +- NO WARRANTY ++ NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +@@ -277,9 +277,9 @@ + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + +- END OF TERMS AND CONDITIONS +- +- Appendix: How to Apply These Terms to Your New Programs ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it +@@ -291,7 +291,7 @@ + the "copyright" line and a pointer to where the full notice is found. + + +- Copyright (C) 19yy ++ Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +@@ -303,16 +303,16 @@ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +- You should have received a copy of the GNU General Public License +- along with this program; if not, write to the Free Software +- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ You should have received a copy of the GNU General Public License along ++ with this program; if not, write to the Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + +- Gnomovision version 69, Copyright (C) 19yy name of author ++ Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. +@@ -335,5 +335,5 @@ + This General Public License does not permit incorporating your program into + proprietary programs. If your program is a subroutine library, you may + consider it more useful to permit linking proprietary applications with the +-library. If this is what you want to do, use the GNU Library General ++library. If this is what you want to do, use the GNU Lesser General + Public License instead of this License. diff --git a/wmwave.patch b/wmwave.patch new file mode 100644 index 0000000..f0fb530 --- /dev/null +++ b/wmwave.patch @@ -0,0 +1,243 @@ +--- wmwave.c ++++ wmwave.c +@@ -1,11 +1,11 @@ + /* +- * wmtop.c -- WindowMaker process view dock app ++ * wmwave.c -- WindowMaker wireless statistics view dock app + * Derived by Carsten Schuermann carsten@schuermann.org + * http://www.schuermann.org/~carsten + * from + * Dan Piponi dan@tanelorn.demon.co.uk + * http://www.tanelorn.demon.co.uk +- * who derived it ++ * who derived it + * from code originally contained in wmsysmon by Dave Clark (clarkd@skynet.ca) + * This software is licensed through the GNU General Public License. + * $Log: wmwave.c,v $ +@@ -50,9 +50,11 @@ + #include + #include + #include +-#include ++#include + #include + ++#include ++ + #include + #include + #include +@@ -76,7 +78,6 @@ + time_t prevtime; + + int mode = 0; // default: no card detected +-int screen = 0; // default: Quality screen is displayed + + void usage(void); + void printversion(void); +@@ -85,11 +86,12 @@ + void wmwave_routine(int, char **); + void DrawBar(float percent, int dx, int dy); + void DrawGreenBar(float percent, int dx, int dy); ++int iw_getinf_stats(const char *ifname, struct iw_range *range, struct iw_statistics *stats); + + inline void DrawBar(float percent, int dx, int dy) { + int tx; + +- tx = (float)((float)54 * ((float)percent / (float)100.0)); ++ tx = (int)(54.0 * (percent * 0.01)); + copyXPMArea(67, 36, tx, 4, dx, dy); + copyXPMArea(67, 43, 54-tx, 4, dx+tx, dy); + } +@@ -98,7 +100,7 @@ + inline void DrawGreenBar(float percent, int dx, int dy) { + int tx; + +- tx = (float)((float)54 * ((float)percent / (float)100.0)); ++ tx = (int)(54.0 * (percent * 0.01)); + copyXPMArea(67, 58, tx, 4, dx, dy); + copyXPMArea(67, 43, 54-tx, 4, dx+tx, dy); + } +@@ -124,50 +126,101 @@ + else {return y;} + } + +-/* +- * Find CPU times for all processes +- */ + void DisplayWireless(void) { ++ ++ struct iw_range range; ++ struct iw_statistics stats; ++ ++ float link; ++ float level; ++ float noise; ++ ++ + FILE *wireless; // File handle for /proc/net/wireless +- + char line[255]; +- char iface[5]; ++ char iface[6]; + char status [3]; +- float link = 0; +- float level = 0; +- float noise = 0; + int nwid = 0; + int crypt = 0; + int misc = 0; +- ++ + if ((wireless = fopen ("/proc/net/wireless", "r")) != NULL) + { + fgets(line,sizeof(line),wireless); + fgets(line,sizeof(line),wireless); + if (fgets(line,sizeof(line),wireless) == NULL) { + mode = 0; +- } +- else { ++ } else { + sscanf(line,"%s %s %f %f %f %d %d %d", + iface,status,&link,&level,&noise,&nwid,&crypt,&misc); ++ iface[strlen(iface)-1] = 0; /* remove ':' */ ++ if( (!iw_getinf_stats(iface, &range, &stats)) || (!range.max_qual.qual) ) ++ range.max_qual.qual = 100; + mode = 1; + } + fclose(wireless); +- +- ++ ++ ++ /* dBm values need a special treatment */ ++ if ((stats.qual.updated & IW_QUAL_DBM) || ++ (stats.qual.level > range.max_qual.level)) ++ { ++ /* some cards (like the atheros) simply don't give a floor */ ++ float noise_floor = range.max_qual.noise ? (float)(range.max_qual.noise - 0x100) : -128.0; ++ float level_floor = range.max_qual.level ? (float)(range.max_qual.level - 0x100) : -128.0; ++ ++ level = (float)(stats.qual.level - 0x100); ++ noise = (float)(stats.qual.noise - 0x100); ++ ++ level = 100.0 * ( 1.0 - (level / level_floor)); ++ noise = 100.0 * ( 1.0 - (noise / noise_floor)); ++ } ++ else ++ { ++ float max_level = (float)range.max_qual.level; ++ float max_noise = (float)range.max_qual.noise; ++ ++ level = (float)stats.qual.level; ++ noise = (float)stats.qual.noise; ++ ++ level = 100.0 * level / max_level; ++ noise = 100.0 * noise / max_noise; ++ } ++ ++ if ((stats.qual.updated & IW_QUAL_LEVEL_INVALID) ++ || level < 0.0 || level > 100.0 ) ++ level = 0.0; ++ ++ if ((stats.qual.updated & IW_QUAL_NOISE_INVALID) ++ || noise < 0.0 || noise > 100.0 ) ++ noise = 0.0; ++ ++ if (!(stats.qual.updated & IW_QUAL_QUAL_INVALID) ++ && (abs(stats.qual.qual) <= abs(range.max_qual.qual))) ++ { ++ link = stats.qual.qual; ++ link /= (float) range.max_qual.qual; ++ link *= 100.0; ++ } ++ else ++ link = 0.0; ++ + /* Print channel information, and signal ratio */ +- + switch (mode) { + case 1: BlitString("Quality",4,4); +- if (link<=10) {DrawRedDot ();} +- else if (link<=20) {DrawYellowDot ();} +- else {DrawGreenDot();}; ++ if (link<=0.1 * range.max_qual.qual) { ++ DrawRedDot (); ++ } else if (link<=0.2 * range.max_qual.qual) { ++ DrawYellowDot (); ++ } else { ++ DrawGreenDot(); ++ } + BlitString("Link ", 4,18); +- DrawBar(min ((int)(link * 1.8), 100.0), 4, 27); ++ DrawBar(min(link, 100.0), 4, 27); + BlitString("Level ", 4,32); +- DrawGreenBar(min ((int)(level * 0.3), 100.0), 4, 41); ++ DrawGreenBar(min(level, 100.0), 4, 41); + BlitString("Noise ", 4,46); +- DrawGreenBar(min ((int)(noise * 0.3), 100.0), 4, 55); ++ DrawGreenBar(min(noise, 100.0), 4, 55); + break; + case 0: BlitString("NO CARD",4,4); + DrawEmptyDot(); +@@ -181,7 +234,8 @@ + }; + } + else { +- printf ("Wirless device /proc/net/wireless not found\nEnable radio networking and recompile your kernel\n"); ++ printf ("Wirless device /proc/net/wireless not found\n" ++ "Enable radio networking and recompile your kernel\n"); + exit (0); + } + } +@@ -237,7 +291,7 @@ + } + } + } +- ++ + wmwave_routine(argc, argv); + + return 0; +@@ -285,11 +339,6 @@ + case DestroyNotify: + XCloseDisplay(display); + exit(0); +- case ButtonPress: +- switch (screen) { +- case 0: screen=1; break; +- case 1: screen=0; break; +- }; + break; + } + } +@@ -298,6 +347,29 @@ + } + } + ++/* get stats & range information */ ++int iw_getinf_stats(const char *ifname, struct iw_range *range, struct iw_statistics *stats) ++{ ++ int skfd; ++ int has_range; ++ ++ memset(range, 0, sizeof(struct iw_range)); ++ memset(stats, 0, sizeof(struct iw_statistics)); ++ ++ if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { ++ return 0; ++ } ++ ++ has_range = (iw_get_range_info(skfd, ifname, range) >= 0); ++ ++ if(iw_get_stats(skfd, ifname, stats, range, has_range) < 0) { ++ close(skfd); ++ return 0; ++ }; ++ close(skfd); ++ return 1; ++} ++ + /* + * Blits a string at given co-ordinates + */ diff --git a/wmwave.spec b/wmwave.spec new file mode 100644 index 0000000..772739c --- /dev/null +++ b/wmwave.spec @@ -0,0 +1,65 @@ +Name: wmwave +Version: 0.4 +Release: 3%{?dist} +Summary: Statistics about a current wireless Ethernet connection +Summary(de): Statistiken zur aktuellen drahtlosen Ethernet-Verbindung +Group: User Interface/X + +License: GPLv2+ +URL: http://wmwave.sourceforge.net/ +Source0: http://downloads.sourceforge.net/%{name}/%{name}-0-4.tgz +# The FSF snail address is incorrect +Patch0: %{name}-fsf-address.patch +# Patch comes from the Debian package, it avoids stack smashing +Patch1: %{name}-Makefile.patch +Patch2: %{name}.patch +BuildRequires: libXext-devel +BuildRequires: libXpm-devel +BuildRequires: wireless-tools-devel + +%description +wmwave is a dockapp for Windowmaker to display statistical information +about a current wireless Ethernet connection. + +%description -l de +wmwave ist ein Dockapp für Windowmaker, welches statistische Informationen +zur aktuellen drahtlosen Ethernet-Verbindung anzeigt. + +%prep +%setup -q -n %{name} +%patch0 -p0 +%patch1 -p0 +%patch2 -p0 +find . -type f -exec chmod -x {} \; + +%build +make FLAGS='%{optflags}' %{?_smp_mflags} + + +%install +mkdir -p %{buildroot}%{_bindir} +mkdir -p %{buildroot}%{_mandir}/man1 +install -p %{name} %{buildroot}%{_bindir} +install -p -m 644 %{name}.1 %{buildroot}%{_mandir}/man1 + +%files +%doc COPYING README +%{_bindir}/%{name} +%{_mandir}/man1/%{name}.1.* + + +%changelog +* Thu Aug 04 2011 Mario Blättermann 0.4-3 +- Moved "find" statement from %%build to %%prep +- Added patch for wmwave.c +- Renamed patch0 +- Dropped %%defattr from %%files +- Replaced $RPM_BUILD_ROOT with %%{buildroot} +- Added extra dependency for wireless-tools-devel, Makefile patched + to detect iwlib.h + +* Mon Jul 04 2011 Mario Blättermann 0.4-2 +- Added group + +* Sun Jul 03 2011 Mario Blättermann 0.4-1 +- initial version