[Pkg-wmaker-commits] [wmifinfo] 19/49: Remove trailing whitespace.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Tue Aug 18 02:07:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmifinfo.
commit ee50340a075309bfca274e1352dda41cfbeb8194
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Sun Oct 5 10:29:59 2014 -0500
Remove trailing whitespace.
---
Changelog | 3 +-
Makefile | 8 +--
README | 7 ++-
nwn.c | 18 +++----
wmifinfo.c | 162 ++++++++++++++++++++++++++++++-------------------------------
xutils.c | 48 +++++++++---------
xutils.h | 4 +-
7 files changed, 124 insertions(+), 126 deletions(-)
diff --git a/Changelog b/Changelog
index 8ee71b1..0184cf3 100644
--- a/Changelog
+++ b/Changelog
@@ -31,7 +31,7 @@
handling were fixed
0.06 Added openBSD support
-
+
- Peter Stromberg <wilfried at openbsd dot org> supplied a patch for
OpenBSD support. I have not tried this myself since I don't have
access to this OS. I will probably split the code into several
@@ -54,4 +54,3 @@
- the '-i' flag (initial interface) was broken. Thanks to Rod van
Meter.
-
\ No newline at end of file
diff --git a/Makefile b/Makefile
index acd90b7..bb935a8 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ LDOPTS = -lX11 -L/usr/X11R6/lib -lXpm -lXext
BINDIR = /usr/local/bin
BIN = wmifinfo
-FILES = wmifinfo.o xutils.o
+FILES = wmifinfo.o xutils.o
ifeq ("$(ENABLE_NWN_SUPPORT)", "y")
FILES += nwn.o
@@ -27,8 +27,8 @@ endif
all: $(BIN)
-.c.o:
- $(CC) $(COPTS) -c $<
+.c.o:
+ $(CC) $(COPTS) -c $<
$(BIN): $(FILES)
$(LD) -o $@ $(FILES) $(LDOPTS)
@@ -43,4 +43,4 @@ dist: clean
rm -rf /tmp/wmifinfo-$(VERSION)
cd .. && cp -a wmifinfo /tmp/wmifinfo-$(VERSION)
cd /tmp && tar --exclude CVS -zcvf wmifinfo-$(VERSION).tgz wmifinfo-$(VERSION)/
-
+
diff --git a/README b/README
index 121a14c..7ddee6f 100644
--- a/README
+++ b/README
@@ -10,15 +10,15 @@ DESCRIPTION
wmifinfo is a simple applet showing basic network info for all available
interfaces. It shows IP address, netmask, gateway and MAC address. A bit
- like ifconfig.
+ like ifconfig.
Runs on Linux and OpenBSD (for now)
Left-button click moves to the next interface, right-button click calls
- ifup/ifdown scripts. These can be set with the -u and -d options. The
+ ifup/ifdown scripts. These can be set with the -u and -d options. The
'%s' variable is replaced with the interface name.
- example :
+ example :
$ wmifinfo -i ppp0 -u "/sbin/ifup %s" -d "/sbin/ifdown %s"
@@ -93,4 +93,3 @@ COPYRIGHT
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
\ No newline at end of file
diff --git a/nwn.c b/nwn.c
index 6c23c64..0602b27 100644
--- a/nwn.c
+++ b/nwn.c
@@ -28,22 +28,22 @@ int nwn_get_link(char *ifname)
sprintf(buf, POLDHUPATH, ifname);
f = fopen(buf, "r");
-
+
if(f == NULL) {
sprintf(buf, SWALLOWPATH, ifname);
f = fopen(buf, "r");
}
-
+
if(f == NULL) {
return(0);
}
-
+
while(fgets(buf, sizeof(buf), f)) {
p = strchr(buf, '\n');
if(p) *p=0;
p = strchr(buf, ':');
-
+
if(p) {
*p=0;
key = buf;
@@ -53,16 +53,16 @@ int nwn_get_link(char *ifname)
*p=0;
p--;
}
-
+
if(strcmp(key, "Current BSSID") == 0) {
strcpy(bssid, val);
}
-
+
if((strcmp(key, "BSSID") == 0) &&
(strcmp(val, bssid) == 0)) {
inbssid = 1;
}
-
+
if((inbssid == 1) &&
(strcmp(key, "Quality") == 0)) {
sscanf(val, "%X", &link);
@@ -71,9 +71,9 @@ int nwn_get_link(char *ifname)
}
}
}
-
+
fclose(f);
-
+
return(link);
}
diff --git a/wmifinfo.c b/wmifinfo.c
index 0022bd9..c8d7871 100644
--- a/wmifinfo.c
+++ b/wmifinfo.c
@@ -1,7 +1,7 @@
/*
* $Id: wmifinfo.c,v 1.4 2004/07/11 12:00:46 ico Exp $
*/
-
+
#include <stdio.h>
#include <unistd.h>
#ifdef linux
@@ -107,28 +107,28 @@ void getifnames(void);
int getifinfo(char *ifname, struct ifinfo_t *info);
-
+
void drawtext(char *str, struct font_t *font, int x, int y)
{
int i = 0;
int ix, iy;
char *p;
-
+
while(str[i]) {
p = strchr(font->chars, str[i]);
ix = (p) ? (p - font->chars) : 0;
-
+
iy = (ix / font->charspline);
ix = (ix % font->charspline);
-
- copyXPMArea( font->sx + ix * font->dx,
+
+ copyXPMArea( font->sx + ix * font->dx,
font->sy + iy * font->dy,
- font->dx,
+ font->dx,
font->dy,
- x + font->dx * i,
+ x + font->dx * i,
y);
-
+
i++;
}
}
@@ -139,7 +139,7 @@ void drawipaddr(uint32_t a, int linenum)
char buf[4];
int i;
uint32_t addr = ntohl(a);
-
+
for(i=0; i<4; i++) {
snprintf(buf, 4, "%3d", (addr >> ((3-i)*8)) & 255);
drawtext(buf, &font1, 5 + i*14, 19 + linenum*9);
@@ -150,7 +150,7 @@ void drawhwaddr(unsigned char *addr)
{
char buf[4];
int i;
-
+
for(i=0; i<6; i++) {
snprintf(buf, 4, "%02X", addr[i]);
drawtext(buf, &font1, 6 + i*9, 46);
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
exec_up = exec_dflt;
exec_down = exec_dflt;
-
+
parse_cmdline(argc, argv);
initXwindow(argc, argv);
@@ -194,10 +194,10 @@ int main(int argc, char *argv[])
ifc.ifc_buf = malloc(ifc.ifc_len);
while(1) {
-
+
while (XPending(display)) {
XNextEvent(display, &event);
-
+
switch (event.type) {
case Expose:
RedrawWindow();
@@ -212,33 +212,33 @@ int main(int argc, char *argv[])
}
if ((d++ == 3) || (ifno != pifno) || (exec_busy != prev_exec_busy)) {
-
+
d=0;
-
+
copyXPMArea(64, 0, 64, 64, 0, 0);
getifnames();
if(ifaces>0) {
ifno = ifno % ifaces;
-
+
getifinfo(ifname[ifno], &ifinfo);
-
+
if(ifno != pifno) lastbytes = ifinfo.bytes;
-
- sprintf(buf, "%-7s", ifinfo.id);
+
+ sprintf(buf, "%-7s", ifinfo.id);
strupper(buf);
drawtext(buf, &font2, 6, 4);
if(memcmp(ifinfo.hw, "\x00\x00\x00\x00\x00\x00", 6) != 0) {
drawhwaddr(ifinfo.hw);
}
-
+
if(ifinfo.ip) drawipaddr(ifinfo.ip, 0);
if(ifinfo.nm) drawipaddr(ifinfo.nm, 1);
if(ifinfo.gw) drawipaddr(ifinfo.gw, 2);
// WLAN signal level
-
+
#ifdef linux
x = ifinfo.sl/4;
#elif defined(__OpenBSD__)
@@ -246,11 +246,11 @@ int main(int argc, char *argv[])
#endif
if(x>13) x=13;
copyXPMArea(4, 82, x*4, 4, 6, 53);
-
+
// LED
-
+
x=0;
- if(exec_busy) {
+ if(exec_busy) {
x=0;
} else {
if(ifinfo.state) x += 8;
@@ -258,7 +258,7 @@ int main(int argc, char *argv[])
}
copyXPMArea(64 + x, 81, 8, 8, 50, 4);
lastbytes = ifinfo.bytes;
-
+
}
RedrawWindow();
@@ -269,10 +269,10 @@ int main(int argc, char *argv[])
#ifdef linux
tv.tv_sec = 0;
tv.tv_usec = DELAY;
-
+
FD_ZERO(&fds);
FD_SET(ConnectionNumber(display), &fds);
-
+
select(ConnectionNumber(display)+1, &fds, NULL, NULL, &tv);
#elif defined(__OpenBSD__)
usleep(DELAY);
@@ -299,7 +299,7 @@ void print_usage()
void print_version()
{
printf("%s version %s, compile-time options: ", NAME, VERSION);
-
+
#ifdef ENABLE_NWN_SUPPORT
printf("ENABLE NWN SUPPORT ");
#endif
@@ -310,7 +310,7 @@ void print_version()
void parse_cmdline(int argc, char *argv[])
{
int c;
-
+
while((c = getopt(argc, argv, "d:i:lhu:v")) != EOF) {
switch(c) {
case 'd' :
@@ -345,7 +345,7 @@ void sigchldhandler(int a)
void exec_cmd(char *cmd)
{
int pid;
-
+
signal(SIGCHLD, sigchldhandler);
if(exec_busy) return;
@@ -355,23 +355,23 @@ void exec_cmd(char *cmd)
if(pid == 0) {
system(cmd);
exit(0);
- }
-
+ }
+
return;
}
void ButtonPressEvent(XButtonEvent * xev)
{
char buf[256];
-
+
if (xev->type != ButtonPress) return;
switch (xev->button) {
case Button1:
-
+
ifno++;
break;
-
+
case Button2:
case Button3:
@@ -380,9 +380,9 @@ void ButtonPressEvent(XButtonEvent * xev)
} else {
sprintf(buf, exec_down, ifinfo.id);
}
-
+
exec_cmd(buf);
-
+
break;
}
}
@@ -416,7 +416,7 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
struct ifconf ifc;
struct ifreq *ifrp, *ifend;
#endif
-
+
char parent[16];
char buf[1024];
char *p;
@@ -429,14 +429,14 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
if(fdev == NULL) fdev = fopen("/proc/net/dev", "r");
#endif
-
+
strcpy(parent, ifname);
p=strchr(parent, ':');
if(p) *p=0;
strcpy(info->id, ifname);
-
- strcpy(ifr.ifr_name, ifname);
+
+ strcpy(ifr.ifr_name, ifname);
// Get status (UP/DOWN)
@@ -446,9 +446,9 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
} else {
info->state = 0;
}
-
+
// Get mac address
-
+
#ifdef linux
if(ioctl(fd, SIOCGIFHWADDR, &ifr) != -1) {
memcpy(info->hw, ifr.ifr_hwaddr.sa_data, 6);
@@ -481,40 +481,40 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
}
}
#endif
-
- // Get IP address
-
+
+ // Get IP address
+
if(ioctl(fd, SIOCGIFADDR, &ifr) != -1) {
sa = (struct sockaddr_in *)&(ifr.ifr_addr);
info->ip = sa->sin_addr.s_addr;
} else {
info->ip = 0;
}
-
+
// Get netmask
-
+
if(ioctl(fd, SIOCGIFNETMASK, &ifr) != -1) {
sa = (struct sockaddr_in *)&(ifr.ifr_addr);
info->nm = sa->sin_addr.s_addr;
} else {
info->nm = 0;
}
-
+
// Get default gateway if on this interface
-
- info->gw = 0;
+
+ info->gw = 0;
#ifdef linux
if(froute != NULL) {
fseek(froute, 0, 0);
-
+
while(fgets(buf, sizeof(buf), froute)) {
r = sscanf(buf, "%s %x %x", a, &b, &c);
-
+
if((strcmp(a, info->id) == 0) && (b == 0)) {
info->gw = c;
}
}
-
+
}
#elif defined(__OpenBSD__)
{
@@ -566,12 +566,12 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
#endif
// Get wireless link status if wireless
-
+
info->sl = 0;
#ifdef linux
if(fwireless != NULL) {
fseek(fwireless, 0, 0);
-
+
while(fgets(buf, sizeof(buf), fwireless)) {
r = sscanf(buf, "%s %d %d ", a, &b, &c);
if(strchr(a, ':')) *(strchr(a, ':')) = 0;
@@ -580,7 +580,7 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
}
}
}
-
+
#ifdef ENABLE_NWN_SUPPORT
if (info->sl == 0) {
info->sl = nwn_get_link(parent);
@@ -601,13 +601,13 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
info->sl = letoh16(wreq.wi_val[0]);
}
#endif
-
- // Get Total tx/rx bytes
+
+ // Get Total tx/rx bytes
#ifdef linux
if(fdev != NULL) {
fseek(fdev, 0, 0);
-
+
while(fgets(buf, sizeof(buf), fdev)) {
r = sscanf(buf, "%s %d %d %d %d %d %d %d %d %d", a, &b, &d,&d,&d,&d,&d,&d,&d, &c);
if(strchr(a, ':')) *(strchr(a, ':')) = 0;
@@ -617,7 +617,7 @@ int getifinfo(char *ifname, struct ifinfo_t *info)
}
}
#endif
-
+
return(0);
}
@@ -628,35 +628,35 @@ void addifname(char *name)
if(strcmp(name, "lo") == 0) return;
if(strncmp(name, "vlan", 4) == 0) return;
-
+
for(i=0; i<ifaces; i++) {
if(strcmp(ifname[i], name) == 0) return;
}
strcpy(ifname[ifaces], name);
-
-
+
+
ifaces++;
-
+
return;
}
-/*
+/*
* get list of interfaces. First read /proc/net/dev, then do a SIOCGIFCONF
*/
-
+
void getifnames(void)
-{
+{
char pifname[MAXIFS][16];
int pifaces;
int i,j;
int isnew;
-
- /*
+
+ /*
* Copy list of interface names and clean the old list
*/
-
+
for(i=0; i<ifaces; i++) strncpy(pifname[i], ifname[i], sizeof(pifname[i]));
pifaces = ifaces;
ifaces = 0;
@@ -666,15 +666,15 @@ void getifnames(void)
char buf[128];
char *p1, *p2;
int ifcount;
-
+
f = fopen("/proc/net/dev", "r");
-
+
if(f == NULL) {
fprintf(stderr, "Can't open /proc/net/dev\n");
exit(1);
}
- fgets(buf, sizeof(buf),f);
+ fgets(buf, sizeof(buf),f);
while(fgets(buf, sizeof(buf), f)) {
p1=buf;
while(*p1 == ' ') p1++;
@@ -685,18 +685,18 @@ void getifnames(void)
addifname(p1);
}
}
-
+
fclose(f);
ifc.ifc_len = sizeof(struct ifreq) * 10;
-
+
if(ioctl(fd, SIOCGIFCONF, &ifc) == -1) {
fprintf(stderr, "SIOCGIFCONF : Can't get list of interfaces : %s\n", strerror(errno));
exit(1);
}
-
+
ifcount = ifc.ifc_len / sizeof(struct ifreq);
-
+
for(i=0; i<ifcount; i++) {
addifname(ifc.ifc_req[i].ifr_name);
}
@@ -734,7 +734,7 @@ void getifnames(void)
* Check if the new list contains interfaces that were not in the old list. If a new
* interface is found, make it the current one to display. (-i will override)
*/
-
+
for(i=0; i<ifaces; i++) {
isnew = 1;
for(j=0; j<pifaces; j++) if(strcmp(ifname[i], pifname[j]) == 0) isnew = 0;
@@ -747,5 +747,5 @@ void getifnames(void)
startif[0] = 0;
}
}
-
+
}
diff --git a/xutils.c b/xutils.c
index f038fcc..92050fd 100644
--- a/xutils.c
+++ b/xutils.c
@@ -1,10 +1,10 @@
/*
* xutils.c - A collection of X-windows utilties for creating WindowMAker
- * DockApps.
+ * DockApps.
*
* This file contains alot of the lower-level X windows routines. Origins with wmppp
* (by Martijn Pieterse (pieterse at xs4all.nl)), but its been hacked up quite a bit
- * and passed on from one new DockApp to the next.
+ * and passed on from one new DockApp to the next.
*
*
*
@@ -28,7 +28,7 @@
* $Id: xutils.c,v 1.2 2002/09/15 14:31:41 ico Exp $
*
*
- */
+ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -43,7 +43,7 @@
/*
- * X11 Variables
+ * X11 Variables
*/
int x_fd;
XSizeHints mysizehints;
@@ -86,7 +86,7 @@ static int flush_expose(Window w) {
* RedrawWindowXY
*/
void RedrawWindow(void) {
-
+
flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 0,0, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
@@ -96,7 +96,7 @@ void RedrawWindow(void) {
}
void RedrawWindowXY(int x, int y) {
-
+
flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, x,y, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
@@ -160,8 +160,8 @@ void initXwindow(int argc, char *argv[]){
/*
* openXwindow
*/
-void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits,
- int pixmask_width, int pixmask_height, char *BackColor, char *LabelColor,
+void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits,
+ int pixmask_width, int pixmask_height, char *BackColor, char *LabelColor,
char *WindGustColor, char *DataColor, char *StationTimeColor) {
unsigned int borderwidth = 1;
@@ -178,9 +178,9 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
{"StationTimeColor", NULL, 0} };
-
- /*
+
+ /*
* Create Pixmap
*/
cols[0].pixel = getColor(BackColor, 1.0);
@@ -192,9 +192,9 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
wmgen.attributes.colorsymbols = cols;
wmgen.attributes.exactColors = False;
wmgen.attributes.closeness = 40000;
- wmgen.attributes.valuemask = XpmReturnPixels | XpmReturnExtensions | XpmColorSymbols
+ wmgen.attributes.valuemask = XpmReturnPixels | XpmReturnExtensions | XpmColorSymbols
| XpmExactColors | XpmCloseness | XpmSize;
- if (XpmCreatePixmapFromData(display, Root, pixmap_bytes,
+ if (XpmCreatePixmapFromData(display, Root, pixmap_bytes,
&(wmgen.pixmap), &(wmgen.mask), &(wmgen.attributes)) != XpmSuccess){
fprintf(stderr, "Not enough free colorcells.\n");
exit(1);
@@ -203,8 +203,8 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
- /*
- * Create a window
+ /*
+ * Create a window
*/
mysizehints.flags = USSize | USPosition;
mysizehints.x = 0;
@@ -218,19 +218,19 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
mysizehints.width = 64;
mysizehints.height = 64;
-
+
win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
-
+
iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
- /*
- * Activate hints
+ /*
+ * Activate hints
*/
XSetWMNormalHints(display, win, &mysizehints);
classHint.res_name = wname;
@@ -245,11 +245,11 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
* effect. I.e. for some you will need to Grab the focus and then return
* it after you are done...
*/
- XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask
- | PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask
+ XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask
+ | PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask
| KeyPressMask | KeyReleaseMask);
- XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask
- | PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask
+ XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask
+ | PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask
| KeyPressMask | KeyReleaseMask);
@@ -261,8 +261,8 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
XSetWMName(display, win, &name);
- /*
- * Create Graphics Context (GC) for drawing
+ /*
+ * Create Graphics Context (GC) for drawing
*/
gcm = GCForeground | GCBackground | GCGraphicsExposures;
gcv.foreground = fore_pix;
diff --git a/xutils.h b/xutils.h
index 5b6231f..fcd25f6 100644
--- a/xutils.h
+++ b/xutils.h
@@ -4,7 +4,7 @@
/*
- * Typedefs
+ * Typedefs
*/
typedef struct {
Pixmap pixmap;
@@ -21,7 +21,7 @@ typedef struct {
Display *display;
Window Root;
Window iconwin, win;
-int screen;
+int screen;
int DisplayDepth;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmifinfo.git
More information about the Pkg-wmaker-commits
mailing list