summaryrefslogtreecommitdiff
path: root/x11-wm/epplets
diff options
context:
space:
mode:
authorDan Moschuk <dan@FreeBSD.org>2001-08-11 20:18:19 +0000
committerDan Moschuk <dan@FreeBSD.org>2001-08-11 20:18:19 +0000
commit90246d357c5ef9e3289ec2b7ca51da9a7382fbcb (patch)
tree963d597bb387d653f391172759900e84bd196f37 /x11-wm/epplets
parentUpdate to 20010812, just a minor update. (diff)
Make some of the linux-centric epplets work.
Submitted by: Chris McDermott <cmc@groupofnine.org> Unresponsive: nakai
Notes
Notes: svn path=/head/; revision=46092
Diffstat (limited to 'x11-wm/epplets')
-rw-r--r--x11-wm/epplets/files/patch-ad70
-rw-r--r--x11-wm/epplets/files/patch-ae87
-rw-r--r--x11-wm/epplets/files/patch-al48
-rw-r--r--x11-wm/epplets/files/patch-am36
-rw-r--r--x11-wm/epplets/files/patch-an238
5 files changed, 470 insertions, 9 deletions
diff --git a/x11-wm/epplets/files/patch-ad b/x11-wm/epplets/files/patch-ad
index 39abe3c18191..ba9cd874c724 100644
--- a/x11-wm/epplets/files/patch-ad
+++ b/x11-wm/epplets/files/patch-ad
@@ -1,6 +1,70 @@
---- epplets/E-Load.c.orig Thu Jan 13 15:01:17 2000
-+++ epplets/E-Load.c Thu Jan 13 15:01:37 2000
-@@ -95,7 +95,7 @@
+--- epplets/E-Load.c.orig Fri Nov 19 13:46:24 1999
++++ epplets/E-Load.c Fri Aug 3 18:45:55 2001
+@@ -1,11 +1,17 @@
+ #include "config.h"
+ #include "epplet.h"
+
+-#ifdef HAVE_LIBGTOP
++#ifdef __FreeBSD__
++
++#include <sys/sysctl.h>
++
++#elif defined(HAVE_LIBGTOP)
++
+ #include <glibtop.h>
+ #include <glibtop/loadavg.h>
+ #include <glibtop/cpu.h>
+ #include "proc.h"
++
+ #endif
+
+ int cpus = 0;
+@@ -20,7 +26,22 @@
+ static void
+ cb_timer(void *data)
+ {
+-#ifdef HAVE_LIBGTOP
++#ifdef __FreeBSD__
++
++ double val;
++
++ if(getloadavg(&val, 1) == -1)
++ return;
++
++ val *= 20;
++
++ if(val > 100)
++ val = 100;
++
++ load_val[0] = val;
++ Epplet_gadget_data_changed(load[0]);
++
++#elif defined(HAVE_LIBGTOP)
+
+ /* libgtop only handles total load, not per-CPU load */
+
+@@ -89,13 +110,27 @@
+ int
+ count_cpus(void)
+ {
+-#ifdef HAVE_LIBGTOP
++#ifdef __FreeBSD__
++
++ int ncpu, mib[2];
++ size_t size;
++
++ mib[0] = CTL_HW;
++ mib[1] = HW_NCPU;
++ size = sizeof(ncpu);
++
++ if(sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1)
++ return 1;
++
++ return ncpu;
++
++#elif HAVE_LIBGTOP
+ int i,c = 0;
+ int bits;
glibtop_cpu cpu;
glibtop_get_cpu (&cpu);
diff --git a/x11-wm/epplets/files/patch-ae b/x11-wm/epplets/files/patch-ae
index c113df6c7a46..513f4fd2aaa3 100644
--- a/x11-wm/epplets/files/patch-ae
+++ b/x11-wm/epplets/files/patch-ae
@@ -1,6 +1,87 @@
---- epplets/E-Cpu.c.orig Thu Jan 13 15:06:17 2000
-+++ epplets/E-Cpu.c Thu Jan 13 15:06:49 2000
-@@ -328,7 +328,7 @@
+--- epplets/E-Cpu.c.orig Wed Dec 29 06:08:09 1999
++++ epplets/E-Cpu.c Wed Aug 1 12:10:17 2001
+@@ -7,10 +7,23 @@
+ #include "config.h"
+ #include "epplet.h"
+
+-#ifdef HAVE_LIBGTOP
++#ifdef __FreeBSD__
++
++#include <sys/sysctl.h>
++#include <sys/dkstat.h>
++
++#ifndef KERN_CP_TIME
++#define KERN_CP_TIME 106
++#endif
++
++int cpu_old[CPUSTATES];
++
++#elif defined(HAVE_LIBGTOP)
++
+ #include <glibtop.h>
+ #include <glibtop/cpu.h>
+ #include "proc.h"
++
+ #endif
+
+ int cpus = 0;
+@@ -201,7 +214,33 @@
+ static void
+ cb_timer(void *data)
+ {
+-#ifdef HAVE_LIBGTOP
++#ifdef __FreeBSD__
++
++ int cpu_new[CPUSTATES];
++ int i, total, mib[2];
++ size_t cpu_size;
++ double val;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_CP_TIME;
++ cpu_size = sizeof(cpu_new);
++
++ if(sysctl(mib, 2, cpu_new, &cpu_size, NULL, 0) == 0)
++ {
++ total=0;
++ for(i=0;i<CPUSTATES;i++)
++ total += cpu_new[i] - cpu_old[i];
++
++ val = 100.00 - (double)(cpu_new[CP_IDLE]-cpu_old[CP_IDLE])/total*100;
++
++ for(i=0;i<CPUSTATES;i++)
++ cpu_old[i] = cpu_new[i];
++
++ for(i=0;i<cpus;i++)
++ prev_val[i] = load_val[i] = val;
++ }
++
++#elif HAVE_LIBGTOP
+
+ glibtop_cpu cpu;
+ double val, val2;
+@@ -322,13 +361,27 @@
+ static int
+ count_cpus(void)
+ {
+-#ifdef HAVE_LIBGTOP
++#ifdef __FreeBSD__
++
++ int ncpu, mib[2];
++ size_t size;
++
++ mib[0] = CTL_HW;
++ mib[1] = HW_NCPU;
++ size = sizeof(ncpu);
++
++ if(sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1)
++ return 1;
++
++ return ncpu;
++
++#elif defined(HAVE_LIBGTOP)
+ int i,c = 0;
+ int bits;
glibtop_cpu cpu;
glibtop_get_cpu (&cpu);
diff --git a/x11-wm/epplets/files/patch-al b/x11-wm/epplets/files/patch-al
index 91e4594eaf59..6a3a4fb3d11f 100644
--- a/x11-wm/epplets/files/patch-al
+++ b/x11-wm/epplets/files/patch-al
@@ -1,5 +1,5 @@
---- epplets/Makefile.in.orig Mon Jul 17 23:26:55 2000
-+++ epplets/Makefile.in Mon Jul 17 23:32:29 2000
+--- epplets/Makefile.in.orig Tue Jan 4 23:55:53 2000
++++ epplets/Makefile.in Fri Aug 10 13:38:45 2001
@@ -75,7 +75,7 @@
LD = @LD@
LDFLAGS = @LDFLAGS@
@@ -80,7 +80,43 @@
# You can use the following command to generate this line:
# ABOUT_DOCS = `(cd epplets && ls -1d *.ABOUT/* 2>/dev/null | grep -v CVS)`
-@@ -397,115 +397,115 @@
+@@ -275,7 +275,7 @@
+ E_Time_epplet_OBJECTS = E-Time.o
+ E_Time_epplet_LDADD = $(LDADD)
+ E_Net_epplet_OBJECTS = E-Net.o net.o
+-E_Net_epplet_LDADD = $(LDADD)
++E_Net_epplet_LDADD = $(LDADD) -lkvm
+ E_Cpu_epplet_OBJECTS = E-Cpu.o
+ E_Biff_epplet_OBJECTS = E-Biff.o mbox.o
+ E_Biff_epplet_LDADD = $(LDADD)
+@@ -289,7 +289,7 @@
+ E_Magic_epplet_OBJECTS = E-Magic.o
+ E_Magic_epplet_LDADD = $(LDADD)
+ E_NetFlame_epplet_OBJECTS = E-NetFlame.o net.o
+-E_NetFlame_epplet_LDADD = $(LDADD)
++E_NetFlame_epplet_LDADD = $(LDADD) -lkvm
+ E_Sys_epplet_OBJECTS = E-Sys.o
+ E_ScreenShoot_epplet_OBJECTS = E-ScreenShoot.o cloak.o utils.o
+ E_ScreenShoot_epplet_LDADD = $(LDADD)
+@@ -306,7 +306,7 @@
+ E_ScreenSave_epplet_OBJECTS = E-ScreenSave.o cloak.o utils.o
+ E_ScreenSave_epplet_LDADD = $(LDADD)
+ E_NetGraph_epplet_OBJECTS = E-NetGraph.o net.o
+-E_NetGraph_epplet_LDADD = $(LDADD)
++E_NetGraph_epplet_LDADD = $(LDADD) -lkvm
+ E_MoonClock_epplet_OBJECTS = E-MoonClock.o CalcEphem.o Moon.o
+ E_MoonClock_epplet_LDADD = $(LDADD)
+ E_UrlWatch_epplet_OBJECTS = E-UrlWatch.o utils.o
+@@ -352,6 +352,8 @@
+ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
++ chgrp kmem $(bindir)/E-Net.epplet $(bindir)/E-NetFlame.epplet $(bindir)/E-NetGraph.epplet
++ chmod 2755 $(bindir)/E-Net.epplet $(bindir)/E-NetFlame.epplet $(bindir)/E-NetGraph.epplet
+
+ uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+@@ -397,115 +399,121 @@
maintainer-clean-libtool:
@@ -128,6 +164,8 @@
+E-Net.epplet: $(E_Net_epplet_OBJECTS)
@rm -f E-Net.epplet
$(LINK) $(E_Net_epplet_LDFLAGS) $(E_Net_epplet_OBJECTS) $(E_Net_epplet_LDADD) $(LIBS)
++ @chgrp kmem E-Net.epplet
++ @chmod 2755 E-Net.epplet
-E-Cpu.epplet: $(E_Cpu_epplet_OBJECTS) $(E_Cpu_epplet_DEPENDENCIES)
+E-Cpu.epplet: $(E_Cpu_epplet_OBJECTS)
@@ -168,6 +206,8 @@
+E-NetFlame.epplet: $(E_NetFlame_epplet_OBJECTS)
@rm -f E-NetFlame.epplet
$(LINK) $(E_NetFlame_epplet_LDFLAGS) $(E_NetFlame_epplet_OBJECTS) $(E_NetFlame_epplet_LDADD) $(LIBS)
++ @chgrp kmem E-NetFlame.epplet
++ @chmod 2755 E-NetFlame.epplet
-E-Sys.epplet: $(E_Sys_epplet_OBJECTS) $(E_Sys_epplet_DEPENDENCIES)
+E-Sys.epplet: $(E_Sys_epplet_OBJECTS)
@@ -213,6 +253,8 @@
+E-NetGraph.epplet: $(E_NetGraph_epplet_OBJECTS)
@rm -f E-NetGraph.epplet
$(LINK) $(E_NetGraph_epplet_LDFLAGS) $(E_NetGraph_epplet_OBJECTS) $(E_NetGraph_epplet_LDADD) $(LIBS)
++ @chgrp kmem E-NetGraph.epplet
++ @chmod 2755 E-NetGraph.epplet
-E-MoonClock.epplet: $(E_MoonClock_epplet_OBJECTS) $(E_MoonClock_epplet_DEPENDENCIES)
+E-MoonClock.epplet: $(E_MoonClock_epplet_OBJECTS)
diff --git a/x11-wm/epplets/files/patch-am b/x11-wm/epplets/files/patch-am
new file mode 100644
index 000000000000..1fdecf40cef1
--- /dev/null
+++ b/x11-wm/epplets/files/patch-am
@@ -0,0 +1,36 @@
+--- epplets/E-Net.c.orig Wed Aug 1 19:46:50 2001
++++ epplets/E-Net.c Wed Aug 1 19:52:34 2001
+@@ -14,6 +14,7 @@
+
+ double upstream_max = 1540000;
+ double downstream_max = 1540000;
++char *netdev;
+ int up_val = 0;
+ int down_val = 0;
+ double up_last = 0;
+@@ -34,7 +35,7 @@
+ double val = -1.0, val2 = -1.0, dval, dval2;
+ unsigned char invalid;
+
+- invalid = net_get_bytes_inout("eth0", &val, &val2);
++ invalid = net_get_bytes_inout(netdev, &val, &val2);
+ if (invalid)
+ {
+ char err[255];
+@@ -74,6 +75,7 @@
+ Epplet_modify_config("upstream_max", s);
+ Esnprintf(s, sizeof(s), "%f", downstream_max);
+ Epplet_modify_config("downstream_max", s);
++ Epplet_modify_config("device", netdev);
+ Epplet_save_config();
+ }
+
+@@ -87,6 +89,8 @@
+
+ s = Epplet_query_config_def("downstream_max", "1540000");
+ downstream_max = (double)atof(s);
++
++ netdev = Epplet_query_config_def("device", "eth0");
+ }
+
+ static void
diff --git a/x11-wm/epplets/files/patch-an b/x11-wm/epplets/files/patch-an
new file mode 100644
index 000000000000..4585f1885d48
--- /dev/null
+++ b/x11-wm/epplets/files/patch-an
@@ -0,0 +1,238 @@
+--- epplets/net.c.orig Tue Jul 31 23:50:29 2001
++++ epplets/net.c Fri Aug 10 14:54:32 2001
+@@ -35,6 +35,22 @@
+ # include <kstat.h>
+ # include <sys/sysinfo.h>
+ #endif
++
++#ifdef __FreeBSD__
++
++#include <sys/types.h>
++#include <sys/socket.h>
++
++#include <net/if.h>
++#include <net/if_var.h>
++#include <netinet/in.h>
++#include <netinet/in_var.h>
++
++#include <kvm.h>
++#include <nlist.h>
++
++#endif
++
+ #include "epplet.h"
+ #include "net.h"
+
+@@ -51,6 +67,18 @@
+ char buff[256], **names = NULL, *s;
+ unsigned long i;
+
++#ifdef __FreeBSD__
++
++ kvm_t *kd;
++ struct nlist magicsymbol[] = { {"_ifnet"}, {""} };
++ char name[32], type[16];
++ int num;
++ unsigned long ifnetaddr;
++ struct ifnet ifnet;
++ struct ifnethead ifnethead;
++
++#endif
++
+ names = (char **) malloc(sizeof(char *));
+ memset(names, 0, sizeof(char *));
+
+@@ -80,6 +108,66 @@
+ return (names);
+ #elif defined(__sun__)
+ return ((char **) NULL);
++#elif defined(__FreeBSD__)
++
++ if((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) == NULL)
++ {
++ perror("kvm_open()");
++ return NULL;
++ }
++
++ if(kvm_nlist(kd, magicsymbol) == -1)
++ {
++ perror("kvm_nlist()");
++ kvm_close(kd);
++ return NULL;
++ }
++
++ if(kvm_read(kd, magicsymbol[0].n_value, &ifnethead, sizeof(ifnethead)) == -1)
++ {
++ perror("kread magic");
++ kvm_close(kd);
++ return NULL;
++ }
++
++ ifnetaddr = (unsigned long)TAILQ_FIRST(&ifnethead);
++
++ if(kvm_read(kd, ifnetaddr, &ifnet, sizeof(ifnet)) == -1)
++ {
++ perror("kvm_read ifnet\n");
++ kvm_close(kd);
++ return NULL;
++ }
++
++ num = 0;
++ while(ifnetaddr)
++ {
++ if(kvm_read(kd, ifnetaddr, &ifnet, sizeof(ifnet)) == -1 ||
++ kvm_read(kd, (long)ifnet.if_name, type, 16) == -1)
++ {
++ break;
++ }
++
++ type[15] = '\0';
++ ifnetaddr = (unsigned long)TAILQ_NEXT(&ifnet, if_link);
++
++ snprintf(name, 32, "%s%d", type, ifnet.if_unit);
++
++ if((names = (char **)realloc(names, (++num + 1)*sizeof(char *))) == NULL)
++ return NULL;
++
++ asprintf(&names[num-1], "%s", name);
++
++ names[num] = NULL;
++ }
++
++ kvm_close(kd);
++
++ if(count)
++ *count = num;
++
++ return names;
++
+ #else
+ return ((char **) NULL);
+ #endif
+@@ -97,6 +185,21 @@
+ unsigned char match = 0;
+ FILE *fp;
+ char buff[256], *colon = NULL, dev[64], in_str[64], out_str[64];
++#elif defined(__FreeBSD__)
++
++ kvm_t *kd;
++ struct nlist magicsymbol[] = { {"_ifnet"}, {""} };
++ char name[32], tname[16];
++ int match, net_layer;
++ struct sockaddr *sa;
++ unsigned long ifaddraddr, ifnetaddr, ifnetfound;
++ struct ifnet ifnet;
++ struct ifnethead ifnethead;
++ union {
++ struct ifaddr ifa;
++ struct in_ifaddr in;
++ } ifaddr;
++
+ #endif
+
+ if (device == NULL) {
+@@ -151,6 +254,104 @@
+ }
+ fclose(fp);
+ return ((match) ? (0) : (ENODEV));
++#elif defined(__FreeBSD__)
++
++ if((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) == NULL)
++ {
++ perror("kvm_open()");
++ return ENOENT;
++ }
++
++ if(kvm_nlist(kd, magicsymbol) == -1)
++ {
++ perror("kvm_nlist()");
++ kvm_close(kd);
++ return ENOENT;
++ }
++
++ if(kvm_read(kd, magicsymbol[0].n_value, &ifnethead, sizeof(ifnethead)) == -1)
++ {
++ perror("kread magic");
++ kvm_close(kd);
++ return ENOENT;
++ }
++
++ ifnetaddr = (unsigned long)TAILQ_FIRST(&ifnethead);
++
++ if(kvm_read(kd, ifnetaddr, &ifnet, sizeof(ifnet)) == -1)
++ {
++ perror("kvm_read ifnet\n");
++ kvm_close(kd);
++ return ENOENT;
++ }
++
++ ifaddraddr = 0;
++ while(ifnetaddr || ifaddraddr)
++ {
++ if(ifaddraddr == 0)
++ {
++ ifnetfound = ifnetaddr;
++ if(kvm_read(kd, ifnetaddr, &ifnet, sizeof(ifnet)) == -1 ||
++ kvm_read(kd, (long)ifnet.if_name, tname, 16) == -1)
++ {
++ perror("kread ifnet.if_name\n");
++ kvm_close(kd);
++ return ENOENT;
++ }
++
++ tname[15] = '\0';
++ ifnetaddr = (unsigned long)TAILQ_NEXT(&ifnet, if_link);
++ snprintf(name, 32, "%s%d", tname, ifnet.if_unit);
++
++ if(strncasecmp(name, device, 16) != 0)
++ continue;
++
++ ifaddraddr = (unsigned long)TAILQ_FIRST(&ifnet.if_addrhead);
++ }
++
++ *in_bytes = (double)ifnet.if_ibytes;
++ *out_bytes = (double)ifnet.if_obytes;
++
++ if(kvm_read(kd, ifaddraddr, &ifaddr, sizeof(ifaddr)) == -1)
++ {
++ printf("kread ifaddr\n");
++ ifaddraddr=0;
++ continue;
++ }
++
++ match = 1;
++
++ sa = (struct sockaddr *)((char *)ifaddr.ifa.ifa_addr -
++ (char *)ifaddraddr + (char *)&ifaddr);
++
++ switch(sa->sa_family)
++ {
++ case AF_INET:
++ net_layer = 1;
++ break;
++#ifdef AF_INET6
++ case AF_INET6:
++ net_layer = 1;
++ break;
++#endif
++ default:
++ net_layer = 0;
++ }
++
++ if(net_layer)
++ {
++ *in_bytes = (double)ifaddr.in.ia_ifa.if_ibytes;
++ *out_bytes = (double)ifaddr.in.ia_ifa.if_obytes;
++ }
++
++ break;
++ }
++
++ kvm_close(kd);
++
++ /* XXX: errno=ENODEV; return -1; ??? */
++ return (match ? 0 : ENODEV);
++
+ #else
+ /* Unsupported platform. */
+ if (in_bytes != NULL) {