| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- --- src/aapm.cc.orig Sat Jan 4 01:25:45 2003
- +++ src/aapm.cc Mon Jan 6 19:00:50 2003
- @@ -26,6 +26,13 @@
- #include <string.h>
- #include <stdio.h>
-
- +#ifdef __FreeBSD__
- +#include <sys/file.h>
- +#include <sys/ioctl.h>
- +#include <sys/types.h>
- +#include <machine/apm_bios.h>
- +#endif
- +
- YColor *YApm::apmBg = 0;
- YColor *YApm::apmFg = 0;
- YFont *YApm::apmFont = 0;
- @@ -47,8 +54,12 @@
-
-
- void ApmStr(char *s, bool Tool) {
- +#ifdef __FreeBSD__
- + struct apm_info ai;
- +#else
- char buf[80];
- - int len, i, fd = open("/proc/apm", O_RDONLY);
- +#endif
- + int len, i, fd = open(APMDEV, O_RDONLY);
- char driver[16];
- char apmver[16];
- int apmflags;
- @@ -60,9 +71,27 @@
- char units[16];
-
- if (fd == -1) {
- + static int error = 0;
- + if (!error)
- + perror("Can't open the apm device");
- + error = 1;
- return ;
- }
- -
- +#ifdef __FreeBSD__
- + if (ioctl(fd,APMIO_GETINFO, &ai) == -1)
- + {
- + static int error = 0;
- + if (!error)
- + perror("Can't ioctl the apm device");
- + error = 1;
- + close(fd);
- + return;
- + }
- + close(fd);
- + BATlife = ai.ai_batt_life;
- + ACstatus = ai.ai_acline ;
- + BATflag = ai.ai_batt_stat == 3 ? 8 : 0;
- +#else
- len = read(fd, buf, sizeof(buf) - 1);
- close(fd);
-
- @@ -76,10 +105,11 @@
- static int error = 1;
- if (error) {
- error = 0;
- - warn(_("/proc/apm - unknown format (%d)"), i);
- + warn(_("%s - unknown format (%d)"), APMDEV, i);
- }
- return ;
- }
- +#endif
- if (BATlife == -1)
- BATlife = 0;
-
- --- src/apppstatus.cc.orig Sat Mar 17 00:17:37 2001
- +++ src/apppstatus.cc Thu Apr 5 22:45:29 2001
- @@ -270,6 +270,7 @@
- return isUpIsdn();
- #endif
-
- +#ifndef __FreeBSD__
- char buffer[32 * sizeof(struct ifreq)];
- struct ifconf ifc;
- struct ifreq *ifr;
- @@ -301,6 +302,38 @@
- }
-
- close(s);
- +
- +#else // __FreeBSD__
- + // FreeBSD code by Ronald Klop <ronald@cs.vu.nl>
- + struct ifmibdata ifmd;
- + size_t ifmd_size=sizeof(ifmibdata);
- + int nr_network_devs;
- + size_t int_size=sizeof(int);
- + int name[6];
- + name[0] = CTL_NET;
- + name[1] = PF_LINK;
- + name[2] = NETLINK_GENERIC;
- + name[3] = IFMIB_IFDATA;
- + name[5] = IFDATA_GENERAL;
- +
- + if(sysctlbyname("net.link.generic.system.ifcount",&nr_network_devs,
- + &int_size,(void*)0,0) == -1) {
- + printf("%s@%d: %s\n",__FILE__,__LINE__,strerror(errno));
- + } else {
- + for(int i=1;i<=nr_network_devs;i++) {
- + name[4] = i; /* row of the ifmib table */
- +
- + if(sysctl(name, 6, &ifmd, &ifmd_size, (void *)0, 0) == -1) {
- + printf(_("%s@%d: %s\n"),__FILE__,__LINE__,strerror(errno));
- + continue;
- + }
- +
- + if (strcmp(ifmd.ifmd_name, netDevice) == 0 && (ifmd.ifmd_flags & IFF_RUNNING)) {
- + return true;
- + }
- + }
- + }
- +#endif // __FreeBSD__
- return false;
- #endif // if 0
- }
- --- src/ylocale.cc.orig Tue Oct 9 23:54:04 2001
- +++ src/ylocale.cc Wed Feb 20 17:32:28 2002
- @@ -18,7 +18,9 @@
-
- #ifdef CONFIG_I18N
- #include <errno.h>
- +#if __FreeBSD__ >= 5
- #include <langinfo.h>
- +#endif
- #include <locale.h>
- #include <stdlib.h>
- #include <string.h>
- @@ -31,6 +33,41 @@
- YLocale * YLocale::locale(NULL);
- #endif
-
- +#ifdef CONFIG_I18N
- +#if __FreeBSD__ < 5
- +#undef CONFIG_NL_CODESETS
- +#define CONFIG_NL_CODESETS 0
- +char* icewm_nl_langinfo(void* item) {
- + char* mylocale = setlocale(LC_ALL, "");
- +
- + if( mylocale == NULL || *mylocale == '\0' )
- + return NULL;
- +
- + if( strncmp(mylocale, "ja", strlen("ja")) == 0 ) {
- + return strdup("EUC-JP");
- + } if( strncmp(mylocale, "zh_TW", strlen("zh_TW")) == 0 ) {
- + return strdup("BIG5");
- + } if( strncmp(mylocale, "ko", strlen("ko")) == 0 ) {
- + return strdup("EUC-KR");
- + } if( strncmp(mylocale, "ru", strlen("ru")) == 0 ) {
- + return "KOI8-R";
- + } if( strncmp(mylocale, "ro", strlen("ro")) == 0 ) {
- + return "ISO-8859-2";
- + } if( strncmp(mylocale, "hr", strlen("hr")) == 0 ) {
- + return "ISO-8859-2";
- + } if( strncmp(mylocale, "hu", strlen("hu")) == 0 ) {
- + return "ISO-8859-2";
- + } if( strncmp(mylocale, "pl", strlen("pl")) == 0 ) {
- + return "ISO-8859-2";
- + } if( strncmp(mylocale, "lt", strlen("lt")) == 0 ) {
- + return "ISO-8859-13";
- + }
- +
- + return NULL;
- +}
- +#endif
- +#endif /* CONFIG_I18N */
- +
- #ifndef CONFIG_I18N
- YLocale::YLocale(char const * ) {
- #else
- @@ -45,8 +82,12 @@
- char const * codeset("");
- int const codesetItems[] = { CONFIG_NL_CODESETS };
-
- +#if __FreeBSD__ >= 5
- for (int const * csi(codesetItems); *csi &&
- NULL != (codeset = nl_langinfo(*csi)) && '\0' == *codeset; ++csi);
- +#else
- + codeset = icewm_nl_langinfo(NULL);
- +#endif
-
- if (NULL == codeset || '\0' == *codeset) {
- warn(_("Failed to determinate the current locale's codeset. "
- --- src/sysdep.h.orig Tue Oct 9 23:54:03 2001
- +++ src/sysdep.h Wed Feb 20 15:22:43 2002
- @@ -57,7 +57,9 @@
-
- #ifdef CONFIG_I18N
- #include <locale.h>
- +#if __FreeBSD__ >= 5
- #include <langinfo.h>
- +#endif
- #endif
-
- #endif
- --- src/acpustatus.cc.orig Sun Mar 9 04:37:52 2003
- +++ src/acpustatus.cc Thu Apr 24 05:09:50 2003
- @@ -26,7 +26,16 @@
-
- #include "intl.h"
-
- -#if (defined(linux) || defined(HAVE_KSTAT_H))
- +#if (defined(linux) || defined(HAVE_KSTAT_H) || defined(__FreeBSD__))
- +
- +#ifdef __FreeBSD__
- +#include <fcntl.h>
- +#include <kvm.h>
- +#include <nlist.h>
- +#include <sys/dkstat.h>
- +#include <sys/resource.h>
- +#include <devstat.h>
- +#endif
-
- #define UPDATE_INTERVAL 500
-
- @@ -49,13 +58,42 @@
- color[IWM_SYS] = new YColor(clrCpuSys);
- color[IWM_IDLE] = *clrCpuIdle
- ? new YColor(clrCpuIdle) : NULL;
- -
- +#ifdef __FreeBSD__
- + color[IWM_INTR] = new YColor(clrCpuIntr);
- + for (unsigned int i = 0; i < taskBarCPUSamples; i++) {
- + cpu[i][IWM_USER] = cpu[i][IWM_NICE] =
- + cpu[i][IWM_SYS] = cpu[i][IWM_INTR] = 0;
- + cpu[i][IWM_IDLE] = 1;
- + }
- + setSize(taskBarCPUSamples, 20);
- + last_cpu[IWM_USER] = last_cpu[IWM_NICE] = last_cpu[IWM_SYS] =
- + last_cpu[IWM_IDLE] = last_cpu[IWM_INTR] = 0;
- + if( setegid( 2 ) == 0 ) {
- + char errbuf[_POSIX2_LINE_MAX];
- + kd = kvm_openfiles( NULL, NULL, NULL, O_RDONLY, errbuf );
- + setegid( getgid() );
- + if( kd == NULL )
- + fprintf( stderr, "kvm_openfiles: %s\n", errbuf );
- + else {
- + memset( namelist, 0, sizeof(namelist) );
- + namelist[0].n_name = (char*)("_cp_time");
- + if( kvm_nlist( kd, namelist ) != 0 ) {
- + kvm_close( kd );
- + kd = NULL;
- + }
- + }
- + } else {
- + fprintf( stderr, "can't setegid(2), I'm not a setgid exec ?\n" );
- + kd = NULL;
- + }
- +#else
- for (int i(0); i < taskBarCPUSamples; i++) {
- cpu[i][IWM_USER] = cpu[i][IWM_NICE] = cpu[i][IWM_SYS] = 0;
- cpu[i][IWM_IDLE] = 1;
- }
- setSize(taskBarCPUSamples, 20);
- last_cpu[IWM_USER] = last_cpu[IWM_NICE] = last_cpu[IWM_SYS] = last_cpu[IWM_IDLE] = 0;
- +#endif
- getStatus();
- updateStatus();
- updateToolTip();
- @@ -70,6 +108,13 @@
- delete color[IWM_NICE]; color[IWM_NICE] = 0;
- delete color[IWM_SYS]; color[IWM_SYS] = 0;
- delete color[IWM_IDLE]; color[IWM_IDLE] = 0;
- +#ifdef __FreeBSD__
- + delete color[IWM_INTR]; color[IWM_INTR] = 0;
- + if( kd != NULL ) {
- + kvm_close( kd );
- + kd = NULL;
- + }
- +#endif
- }
-
- void CPUStatus::paint(Graphics &g, const YRect &/*r*/) {
- @@ -80,13 +125,34 @@
- int nice = cpu[i][IWM_NICE];
- int sys = cpu[i][IWM_SYS];
- int idle = cpu[i][IWM_IDLE];
- +#ifdef __FreeBSD__
- + int intr = cpu[i][IWM_INTR];
- + int total = user + sys + intr + nice + idle;
- + int totald = total;
- +#else
- int total = user + sys + nice + idle;
- +#endif
-
- int y = height() - 1;
-
- if (total > 0) {
- +#ifdef __FreeBSD__
- + if (intr) {
- + totald -= intr;
- + n = (h * totald) / total; // check rounding
- + if (n >= y) n = y;
- + g.setColor(color[IWM_INTR]);
- + g.drawLine(i, y, i, n);
- + y = n - 1;
- + }
- +#endif
- if (sys) {
- +#ifdef __FreeBSD__
- + totald -= nice;
- + n = (h * totald)/ total;
- +#else
- n = (h * (total - sys)) / total; // check rounding
- +#endif
- if (n >= y) n = y;
- g.setColor(color[IWM_SYS]);
- g.drawLine(i, y, i, n);
- @@ -102,7 +168,12 @@
- }
-
- if (user) {
- +#ifdef __FreeBSD__
- + totald -= user;
- + n = (h * totald)/ total;
- +#else
- n = (h * (total - sys - nice - user))/ total;
- +#endif
- if (n >= y) n = y;
- g.setColor(color[IWM_USER]);
- g.drawLine(i, y, i, n);
- @@ -152,6 +223,14 @@
- sprintf(load, _("CPU Load: %3.2f %3.2f %3.2f, %d processes."),
- l1, l5, l15, sys.procs);
- setToolTip(load);
- +#elif defined(__FreeBSD__)
- + char load[31]; // enough for "CPU Load: 999.99 999.99 999.99\0"
- + double loadavg[3];
- + if( kd != NULL && kvm_getloadavg( kd, loadavg, 3 ) != 3 )
- + return;
- + snprintf(load, sizeof(load), "CPU Load: %3.2f %3.2f %3.2f",
- + loadavg[0], loadavg[1], loadavg[2]);
- + setToolTip(load);
- #endif
- }
-
- @@ -169,13 +248,43 @@
- cpu[i - 1][IWM_NICE] = cpu[i][IWM_NICE];
- cpu[i - 1][IWM_SYS] = cpu[i][IWM_SYS];
- cpu[i - 1][IWM_IDLE] = cpu[i][IWM_IDLE];
- +#ifdef __FreeBSD__
- + cpu[i - 1][IWM_INTR] = cpu[i][IWM_INTR];
- +#endif
- }
- getStatus(),
- repaint();
- }
-
- void CPUStatus::getStatus() {
- -#ifdef linux
- +#ifdef __FreeBSD__
- +
- + cpu[taskBarCPUSamples-1][IWM_USER] = 0;
- + cpu[taskBarCPUSamples-1][IWM_NICE] = 0;
- + cpu[taskBarCPUSamples-1][IWM_SYS] = 0;
- + cpu[taskBarCPUSamples-1][IWM_INTR] = 0;
- + cpu[taskBarCPUSamples-1][IWM_IDLE] = 0;
- +
- + if( kd == NULL ) return;
- +
- + long cp_time[CPUSTATES];
- + int c = sizeof( cp_time );
- + if (kvm_read(kd, namelist[0].n_value, &cp_time, c) != c)
- + return;
- +
- + long cur[IWM_STATES];
- + cur[IWM_USER] = cp_time[CP_USER];
- + cur[IWM_NICE] = cp_time[CP_NICE];
- + cur[IWM_SYS] = cp_time[CP_SYS];
- + cur[IWM_INTR] = cp_time[CP_INTR];
- + cur[IWM_IDLE] = cp_time[CP_IDLE];
- +
- + for (int i = 0; i < IWM_STATES; i++) {
- + cpu[taskBarCPUSamples-1][i] = cur[i] - last_cpu[i];
- + last_cpu[i] = cur[i];
- + }
- +
- +#elif defined(linux)
- char *p, buf[128];
- long cur[IWM_STATES];
- int len, fd = open("/proc/stat", O_RDONLY);
- @@ -209,8 +318,8 @@
- cpu[taskBarCPUSamples-1][IWM_USER], cpu[taskBarCPUSamples-1][IWM_NICE],
- cpu[taskBarCPUSamples-1][IWM_SYS], cpu[taskBarCPUSamples-1][IDLE]);
- #endif
- -#endif /* linux */
- -#ifdef HAVE_KSTAT_H
- +
- +#elif defined(HAVE_KSTAT_H)
- #ifdef HAVE_OLD_KSTAT
- #define ui32 ul
- #endif
- --- src/acpustatus.h.orig Sun Mar 9 04:37:52 2003
- +++ src/acpustatus.h Sun Apr 13 12:02:47 2003
- @@ -1,19 +1,29 @@
- #ifndef __CPUSTATUS_H
- #define __CPUSTATUS_H
-
- -#if defined(linux) || defined(HAVE_KSTAT_H)
- +#if (defined(linux) || defined(HAVE_KSTAT_H)) || defined (__FreeBSD__)
-
- #ifdef HAVE_KSTAT_H
- #include <kstat.h>
- #include <sys/sysinfo.h>
- #endif /* have_kstat_h */
-
- +#ifdef __FreeBSD__
- +#include <kvm.h>
- +#include <nlist.h>
- +#endif
-
- #define IWM_USER (0)
- #define IWM_NICE (1)
- #define IWM_SYS (2)
- +#ifdef __FreeBSD__
- +#define IWM_INTR (3)
- +#define IWM_IDLE (4)
- +#define IWM_STATES (5)
- +#else
- #define IWM_IDLE (3)
- #define IWM_STATES (4)
- +#endif
-
- #include "ywindow.h"
- #include "ytimer.h"
- @@ -38,6 +48,10 @@
- long last_cpu[IWM_STATES];
- YColor *color[IWM_STATES];
- YTimer *fUpdateTimer;
- +#ifdef __FreeBSD__
- + struct nlist namelist[2];
- + kvm_t *kd;
- +#endif
- };
- #else
- #undef CONFIG_APPLET_CPU_STATUS
- --- src/default.h.orig Thu May 16 14:00:02 2002
- +++ src/default.h Tue May 28 04:44:02 2002
- @@ -455,6 +455,7 @@
- XSV(const char *, clrLabelText, "rgb:00/00/00")
- XSV(const char *, clrCpuUser, "rgb:00/FF/00")
- XSV(const char *, clrCpuSys, "rgb:FF/00/00")
- +XSV(const char *, clrCpuIntr, "rgb:FF/FF/00")
- XSV(const char *, clrCpuNice, "rgb:00/00/FF")
- XSV(const char *, clrCpuIdle, "rgb:00/00/00")
- XSV(const char *, clrNetSend, "rgb:FF/FF/00")
- @@ -837,6 +838,7 @@
- #ifdef CONFIG_APPLET_CPU_STATUS
- OSV("ColorCPUStatusUser", &clrCpuUser, "User load on the CPU monitor"),
- OSV("ColorCPUStatusSystem", &clrCpuSys, "System load on the CPU monitor"),
- + OSV("ColorCPUStatusInterrupts", &clrCpuIntr, "Interrupts on the CPU monitor"),
- OSV("ColorCPUStatusNice", &clrCpuNice, "Nice load on the CPU monitor"),
- OSV("ColorCPUStatusIdle", &clrCpuIdle, "Idle (non) load on the CPU monitor, leave empty to force transparency"),
- #endif
- --- src/wmapp.cc.orig Sun Mar 9 04:37:52 2003
- +++ src/wmapp.cc Sun Apr 13 00:09:19 2003
- @@ -1503,6 +1503,9 @@
- #endif
-
- int main(int argc, char **argv) {
- +#ifdef __FreeBSD__
- + setegid( getgid() );
- +#endif
- YLocale locale;
-
- #ifndef NO_CONFIGURE
- --- src/wmclient.h.orig Tue Mar 26 14:29:05 2002
- +++ src/wmclient.h Tue Mar 26 14:29:13 2002
- @@ -5,6 +5,8 @@
- #include "ymenu.h"
- #include "MwmUtil.h"
-
- +#include <X11/Xutil.h>
- +
- class YFrameWindow;
- class WindowListItem;
-
|