From d336d4435c8c5f4b4d5edec13b95f2f277c17535 Mon Sep 17 00:00:00 2001 From: Joe Marcus Clarke Date: Sat, 7 Feb 2004 04:49:34 +0000 Subject: [PATCH] Remove the dependency on libgtop. --- x11-wm/epplets/Makefile | 3 +- x11-wm/epplets/files/patch-epplets::E-Cpu.c | 92 ------- x11-wm/epplets/files/patch-epplets::E-Load.c | 75 ------ x11-wm/epplets/files/patch-epplets::E-Net.c | 36 --- .../epplets/files/patch-epplets::Makefile.in | 33 +-- x11-wm/epplets/files/patch-epplets::net.c | 247 ------------------ 6 files changed, 18 insertions(+), 468 deletions(-) delete mode 100644 x11-wm/epplets/files/patch-epplets::E-Cpu.c delete mode 100644 x11-wm/epplets/files/patch-epplets::E-Load.c delete mode 100644 x11-wm/epplets/files/patch-epplets::E-Net.c delete mode 100644 x11-wm/epplets/files/patch-epplets::net.c diff --git a/x11-wm/epplets/Makefile b/x11-wm/epplets/Makefile index c6ffadcf8852..4453e47e4ed1 100644 --- a/x11-wm/epplets/Makefile +++ b/x11-wm/epplets/Makefile @@ -7,7 +7,7 @@ PORTNAME= epplets PORTVERSION= 0.7 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= x11-wm MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= enlightenment @@ -17,7 +17,6 @@ COMMENT= A collection of Enlightenment dock applications BUILD_DEPENDS= enlightenment:${PORTSDIR}/x11-wm/enlightenment LIB_DEPENDS= cdaudio.1:${PORTSDIR}/audio/libcdaudio \ - gtop.1:${PORTSDIR}/devel/libgtop \ epplet.1:${PORTSDIR}/x11-wm/libepplet RUN_DEPENDS= import:${PORTSDIR}/graphics/ImageMagick \ enlightenment:${PORTSDIR}/x11-wm/enlightenment diff --git a/x11-wm/epplets/files/patch-epplets::E-Cpu.c b/x11-wm/epplets/files/patch-epplets::E-Cpu.c deleted file mode 100644 index 513f4fd2aaa3..000000000000 --- a/x11-wm/epplets/files/patch-epplets::E-Cpu.c +++ /dev/null @@ -1,92 +0,0 @@ ---- 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 -+#include -+ -+#ifndef KERN_CP_TIME -+#define KERN_CP_TIME 106 -+#endif -+ -+int cpu_old[CPUSTATES]; -+ -+#elif defined(HAVE_LIBGTOP) -+ - #include - #include - #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 -+ -+#elif defined(HAVE_LIBGTOP) -+ - #include - #include - #include - #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); -- bits= (int)cpu.xcpu_flags; -+ bits= (int)cpu.flags; - for (i=0; i/dev/null | grep -v CVS)` -@@ -407,7 +371,7 @@ - CONFIG_HEADER = ../config.h - CONFIG_CLEAN_FILES = - bin_PROGRAMS = E-Load.epplet E-Clock.epplet E-Time.epplet E-Net.epplet \ --E-Cpu.epplet E-Biff.epplet E-Power.epplet @TEST_PROGS@ @MIXER_PROGS@ \ -+E-Cpu.epplet E-Biff.epplet @APM_PROGS@ @TEST_PROGS@ @MIXER_PROGS@ \ - @GL_PROGS@ E-MemWatch.epplet E-Disk.epplet E-Areas.epplet \ - E-Magic.epplet E-Toolbox.epplet E-NetFlame.epplet E-Sys.epplet \ - E-ScreenShoot.epplet E-Slides.epplet E-Xss.epplet E-Mountbox.epplet \ diff --git a/x11-wm/epplets/files/patch-epplets::net.c b/x11-wm/epplets/files/patch-epplets::net.c deleted file mode 100644 index 709c13c821fb..000000000000 --- a/x11-wm/epplets/files/patch-epplets::net.c +++ /dev/null @@ -1,247 +0,0 @@ ---- epplets/net.c.orig Wed Dec 22 02:52:54 1999 -+++ epplets/net.c Tue Nov 18 22:57:45 2003 -@@ -35,6 +35,23 @@ - # include - # include - #endif -+ -+#ifdef __FreeBSD__ -+ -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#endif -+ - #include "epplet.h" - #include "net.h" - -@@ -51,6 +68,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 +109,70 @@ - 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 __FreeBSD_version < 501113 -+ 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); -+#else -+ strlcpy(name, ifnet.if_xname, sizeof(name)); -+#endif -+ -+ 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 +190,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 +259,108 @@ - } - 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 __FreeBSD_version < 501113 -+ 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'; -+ snprintf(name, 32, "%s%d", tname, ifnet.if_unit); -+#else -+ strlcpy(name, ifnet.if_xname, sizeof(name)); -+#endif -+ ifnetaddr = (unsigned long)TAILQ_NEXT(&ifnet, if_link); -+ -+ 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) {