summaryrefslogtreecommitdiff
path: root/x11/xfce4-taskmanager
diff options
context:
space:
mode:
authorOliver Lehmann <oliver@FreeBSD.org>2007-02-01 11:47:48 +0000
committerOliver Lehmann <oliver@FreeBSD.org>2007-02-01 11:47:48 +0000
commitc0bbe7788f468595be029a5fe1227bbf7c893a54 (patch)
treeee95ba23cfe7e017020108645c29d22cdb6cb7c4 /x11/xfce4-taskmanager
parentUpdate to 1.10. (diff)
implement FreeBSD support with KVM proc infos
bump PORTREVISION
Notes
Notes: svn path=/head/; revision=183855
Diffstat (limited to 'x11/xfce4-taskmanager')
-rw-r--r--x11/xfce4-taskmanager/Makefile4
-rw-r--r--x11/xfce4-taskmanager/files/patch-src-functions.c12
-rw-r--r--x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.c173
-rw-r--r--x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.h27
4 files changed, 216 insertions, 0 deletions
diff --git a/x11/xfce4-taskmanager/Makefile b/x11/xfce4-taskmanager/Makefile
index a1778ddc2a3e..d30ab52da21d 100644
--- a/x11/xfce4-taskmanager/Makefile
+++ b/x11/xfce4-taskmanager/Makefile
@@ -7,6 +7,7 @@
PORTNAME= xfce4-taskmanager
PORTVERSION= 0.4.0.r2
+PORTREVISION= 1
CATEGORIES= x11 xfce
MASTER_SITES= http://xfce4-taskmanager.nebulon.de/
DISTNAME= ${PORTNAME}-${PORTVERSION:S/.r/-rc/}
@@ -26,6 +27,9 @@ USE_GNOME= gnometarget gtk20 intltool intlhack pkgconfig
USE_XFCE= configenv libgui
USE_XLIB= yes
+post-patch:
+ @${REINPLACE_CMD} -e 's|linux|freebsd|g; s|^CFLAGS = |&-lkvm -lm |' ${WRKSRC}/src/Makefile.in
+
.include <bsd.port.pre.mk>
.include "${PORTSDIR}/x11-wm/xfce4/bsd.xfce.mk"
.include <bsd.port.post.mk>
diff --git a/x11/xfce4-taskmanager/files/patch-src-functions.c b/x11/xfce4-taskmanager/files/patch-src-functions.c
new file mode 100644
index 000000000000..f1752441354e
--- /dev/null
+++ b/x11/xfce4-taskmanager/files/patch-src-functions.c
@@ -0,0 +1,12 @@
+--- src/functions.c.orig Wed Aug 23 20:55:58 2006
++++ src/functions.c Thu Feb 1 11:04:42 2007
+@@ -45,7 +45,9 @@
+ tmp->time = new_tmp->time;
+
+
++#ifndef __FreeBSD__
+ tmp->time_percentage = (gdouble)(tmp->time - tmp->old_time) * (gdouble)(1000.0 / REFRESH_INTERVAL);
++#endif
+
+ if((gint)tmp->ppid != (gint)new_tmp->ppid || strcmp(tmp->state,new_tmp->state) || (unsigned int)tmp->size != (unsigned int)new_tmp->size || (unsigned int)tmp->rss != (unsigned int)new_tmp->rss || (unsigned int)tmp->time != (unsigned int)tmp->old_time)
+ {
diff --git a/x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.c b/x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.c
new file mode 100644
index 000000000000..e69f52eeeabc
--- /dev/null
+++ b/x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.c
@@ -0,0 +1,173 @@
+--- src/xfce-taskmanager-freebsd.c.orig Thu Jan 1 01:00:00 1970
++++ src/xfce-taskmanager-freebsd.c Thu Feb 1 12:17:27 2007
+@@ -0,0 +1,170 @@
++/*
++ Copyright (c) 2006 Oliver Lehmann <oliver@FreeBSD.org>
++ All rights reserved.
++
++ Redistribution and use in source and binary forms, with or without
++ modification, are permitted provided that the following conditions
++ are met:
++ 1. Redistributions of source code must retain the above copyright
++ notice, this list of conditions and the following disclaimer
++ 2. Redistributions in binary form must reproduce the above copyright
++ notice, this list of conditions and the following disclaimer in the
++ documentation and/or other materials provided with the distribution.
++
++ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
++ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
++ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ SUCH DAMAGE.
++
++ $Id: index.php,v 1.24 2006/12/21 23:09:25 olivleh1 Exp $
++*/
++
++
++#include "xfce-taskmanager-freebsd.h"
++
++#define fxtofl(fixpt) ((double)(fixpt) / fscale)
++
++struct task get_task_details(struct kinfo_proc *kp)
++{
++ struct task task;
++ size_t size;
++ fixpt_t ccpu;
++ long fracmem;
++ int pagesize, flag, sflag, tdflags, fscale;
++ char *cp;
++ char buf[16];
++
++ task.pid = -1;
++
++ size = sizeof(ccpu);
++ if (sysctlbyname("kern.ccpu", &ccpu, &size, NULL, 0) == -1)
++ return (task);
++ size = sizeof(fscale);
++ if (sysctlbyname("kern.fscale", &fscale, &size, NULL, 0) == -1)
++ return (task);
++ size = sizeof(pagesize);
++ if (sysctlbyname("hw.pagesize",&pagesize,&size,NULL,0) == -1)
++ return (task);
++
++ task.pid = kp->ki_pid;
++ task.ppid = kp->ki_ppid;
++ task.size = (kp->ki_size/1024);
++ task.rss = (kp->ki_rssize*pagesize)/1024;
++ task.time_percentage = 100.0 * fxtofl(kp->ki_pctcpu) / (1.0 - exp(kp->ki_swtime * log(fxtofl(ccpu))));
++ task.uid = kp->ki_uid;
++ g_strlcpy(task.uname, user_from_uid(kp->ki_uid, 0), sizeof task.uname);
++
++
++ flag = kp->ki_flag;
++ sflag = kp->ki_sflag;
++ tdflags = kp->ki_tdflags;
++ cp = buf;
++
++ switch (kp->ki_stat) {
++
++ case SSTOP:
++ *cp = 'T';
++ break;
++
++ case SSLEEP:
++ if (tdflags & TDF_SINTR)
++ *cp = kp->ki_slptime >= MAXSLP ? 'I' : 'S';
++ else
++ *cp = 'D';
++ break;
++
++ case SRUN:
++ case SIDL:
++ *cp = 'R';
++ break;
++
++ case SWAIT:
++ *cp = 'W';
++ break;
++
++ case SLOCK:
++ *cp = 'L';
++ break;
++
++ case SZOMB:
++ *cp = 'Z';
++ break;
++
++ default:
++ *cp = '?';
++ }
++ cp++;
++ if (!(sflag & PS_INMEM))
++ *cp++ = 'W';
++ if (kp->ki_nice < NZERO)
++ *cp++ = '<';
++ else if (kp->ki_nice > NZERO)
++ *cp++ = 'N';
++ if (flag & P_TRACED)
++ *cp++ = 'X';
++ if (flag & P_WEXIT && kp->ki_stat != SZOMB)
++ *cp++ = 'E';
++ if (flag & P_PPWAIT)
++ *cp++ = 'V';
++ if ((flag & P_SYSTEM) || kp->ki_lock > 0)
++ *cp++ = 'L';
++ if (kp->ki_kiflag & KI_SLEADER)
++ *cp++ = 's';
++ if ((flag & P_CONTROLT) && kp->ki_pgid == kp->ki_tpgid)
++ *cp++ = '+';
++ if (flag & P_JAILED)
++ *cp++ = 'J';
++ *cp = '\0';
++
++ g_strlcpy(task.state, buf, sizeof task.state);
++ g_strlcpy(task.name, kp->ki_comm, sizeof task.name);
++
++ if(g_str_has_suffix(task.name, ")"))
++ *g_strrstr(task.name, ")") = '\0';
++
++ return task;
++}
++
++GArray *get_task_list()
++{
++ GArray *task_list;
++ struct task task;
++ int nentries, what, flag, i;
++ struct kinfo_proc *kp;
++ const char *nlistf, *memf;
++ static kvm_t *kd;
++ char *state;
++ char errbuf[_POSIX2_LINE_MAX];
++
++ nentries = -1;
++ memf = nlistf = _PATH_DEVNULL;
++ kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
++ if (kd == 0) {
++ fprintf(stderr, "Error: %s\n", errbuf);
++ return NULL;
++ }
++ kp = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nentries);
++ if ((kp == NULL && nentries > 0) || (kp != NULL && nentries < 0)) {
++ fprintf(stderr, "Error: %s\n", kvm_geterr(kd));
++ return NULL;
++ }
++
++ task_list = g_array_new (FALSE, FALSE, sizeof (struct task));
++ if (nentries > 0) {
++
++ for (i = nentries; --i >= 0; ++kp) {
++ struct task task = get_task_details(kp);
++ if(task.pid != -1)
++ g_array_append_val(task_list, task);
++ }
++
++ }
++ return task_list;
++}
diff --git a/x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.h b/x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.h
new file mode 100644
index 000000000000..1c6584c16877
--- /dev/null
+++ b/x11/xfce4-taskmanager/files/patch-src-xfce-taskmanager-freebsd.h
@@ -0,0 +1,27 @@
+--- src/xfce-taskmanager-freebsd.h.orig Thu Jan 1 01:00:00 1970
++++ src/xfce-taskmanager-freebsd.h Thu Feb 1 11:54:05 2007
+@@ -0,0 +1,24 @@
++#ifndef FREEBSD_H
++#define FREEBSD_H
++
++#include <glib.h>
++#include <pwd.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <stdlib.h>
++#include <string.h>
++#include <limits.h>
++#include <fcntl.h>
++#include <paths.h>
++#include <nlist.h>
++#include <kvm.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <sys/user.h>
++
++#include "types.h"
++
++struct task get_task_details(struct kinfo_proc *);
++GArray *get_task_list();
++
++#endif