diff --git a/wmtetris/wmtetris/wmmon.c b/wmtetris/wmtetris/wmmon.c deleted file mode 100644 index da5242f..0000000 --- a/wmtetris/wmtetris/wmmon.c +++ /dev/null @@ -1,739 +0,0 @@ -/* - Code based on wmppp/wmifs - - [Orig WMPPP comments] - - This code was mainly put together by looking at the - following programs: - - asclock - A neat piece of equip, used to display the date - and time on the screen. - Comes with every AfterStep installation. - - Source used: - How do I create a not so solid window? - How do I open a window? - How do I use pixmaps? - - ------------------------------------------------------------ - - Authors: Martijn Pieterse (pieterse@xs4all.nl) - Antoine Nulle (warp@xs4all.nl) - - This program is distributed under the GPL license. - (as were asclock and pppstats) - - ---- - Changes: - ---- - - 18/05/1998 (Antoine Nulle, warp@xs4all.nl) - * MEM/SWAP/UPTIME only updated when visible - * Using global file descriptors to reduce file - system overhead, both updates are based on a diff - supplied by Dave Harden (dharden@wisewire.com) - 15/05/1998 (Antoine Nulle, warp@xs4all.nl) - * Fixed memory overflow in the MEM gaugebar - * MEM gauge displays now real used mem - (buffered + cached mem removed) - 14/05/1998 (Antoine Nulle, warp@xs4all.nl) - * Added -i & -s kludge for selecting startupmode, - tijno, don't hate me for this :) - 12/05/1998 (Antoine Nulle, warp@xs4all.nl) - * Finetuned master-xpm, tijno don't worry, no - reprogramming needed this time ;-) - 07/05/1998 (Martijn Pieterse, pieterse@xs4all.nl) - * Added disk i/o - 03/05/1998 (Antoine Nulle, warp@xs4all.nl) - * Added new master-xpm which contains the gfx - for the upcoming SysInfo part :P - 02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl) - * Removed a lot of code, that was put in wmgeneral - 23/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) - * Added zombie destroying code (aka wait :) ) - 18/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) - * Added CPU-on-screen. - * Added -display command line - 15/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) - * Fixed a bug in the stats routine - (Top 3 bright pixels were not shown when 100% loaded) - * Changed xpm to a no-title one. - This included the reprogramming of all positions. - warpstah, i hate you! ;) - 05/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) - * First Working Version -*/ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "../wmgeneral/wmgeneral.h" -#include "../wmgeneral/misc.h" - -#include "wmmon-master.xpm" -#include "wmmon-mask.xbm" - - /***********/ - /* Defines */ -/***********/ - -#define LEFT_ACTION (NULL) -#define RIGHT_ACTION (NULL) -#define MIDDLE_ACTION (NULL) - -#define WMMON_VERSION "1.0.b2" - - /********************/ - /* Global Variables */ -/********************/ - -char *ProgName; -int stat_current = 0; /* now global */ -FILE *fp_meminfo; -FILE *fp_stat; -FILE *fp_loadavg; - -/* functions */ -void usage(void); -void printversion(void); -void DrawStats(int *, int, int, int, int); -void DrawStats_io(int *, int, int, int, int); - -void wmmon_routine(int, char **); - -void main(int argc, char *argv[]) { - - int i; - - - /* Parse Command Line */ - - ProgName = argv[0]; - if (strlen(ProgName) >= 5) - ProgName += (strlen(ProgName) - 5); - - for (i=1; i 32) j = 32; - copyXPMArea(32, 64, j, 12, 28, 4); - } else { - /* Nu zal ie wel 3 zijn. */ - - copyXPMArea(0, 64, 32, 12, 28+64, 4); - copyXPMArea(0, 64, 32, 12, 28+64, 18); - - j = stat_device[2].rt_idle; - if (j != 0) { - j = (stat_device[2].rt_stat * 100) / j; - } - j = j * 0.32; - if (j > 32) j = 32; - copyXPMArea(32, 64, j, 12, 28+64, 4); - /*--------------------- ------------------*/ - j = stat_device[3].rt_idle; - if (j != 0) { - j = (stat_device[3].rt_stat * 100) / j; - } - j = j * 0.32; - if (j > 32) j = 32; - copyXPMArea(32, 64, j, 12, 28+64, 18); - - /*----------- online tijd neerzetten! ----------*/ - - cnt_time = time(0) - ref_time + online_time; - - /* cnt_time = uptime in seconden */ - /* - secs = 108,47 - mins = 89,47 - uren = 70,47 - digits = 40,78, 6breed, 9hoog - */ - i = cnt_time % 60; - cnt_time /= 60; - copyXPMArea(40 + (i % 10)*7, 78, 6, 9, 115, 47); - copyXPMArea(40 + (i / 10)*7, 78, 6, 9, 108, 47); - - i = cnt_time % 60; - cnt_time /= 60; - copyXPMArea(40 + (i % 10)*7, 78, 6, 9, 96, 47); - copyXPMArea(40 + (i / 10)*7, 78, 6, 9, 89, 47); - - i = cnt_time % 24; - cnt_time /= 24; - copyXPMArea(40 + (i % 10)*7, 78, 6, 9, 77, 47); - copyXPMArea(40 + (i / 10)*7, 78, 6, 9, 70, 47); - - /* De rest is dagen! 5x7*/ - - i = cnt_time; - copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 88, 35); - i /= 10; - copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 82, 35); - i /= 10; - copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 76, 35); - i /= 10; - copyXPMArea(66 + (i % 10)*6, 66, 5, 7, 70, 35); - } - - if (curtime >= nexttime) { - nexttime+=10; - - for (i=0; i= 0) { - switch (but_stat) { - case 0: - switch (Event.xbutton.button) { - case 1: - if (left_action) - execCommand(left_action); - break; - case 2: - if (middle_action) - execCommand(middle_action); - break; - case 3: - if (right_action) - execCommand(right_action); - break; - } - case 1: - stat_current++; - printf("current stat is :%d\n", stat_current); - if (stat_current == stat_online) - stat_current = 0; - - DrawActive(stat_device[stat_current].name); - if (stat_current == 0) DrawStats(stat_device[stat_current].his, 54, 40, 5, 58); - if (stat_current == 1) { - DrawStats_io(stat_device[stat_current].his, 54, 40, 5, 58); - } - if (stat_current == 2) { - xpm_X = 64; - setMaskXY(-64, 0); - } else { - xpm_X = 0; - setMaskXY(0, 0); - } - RedrawWindowXY(xpm_X, xpm_Y); - break; - } - } - break; - } - } - - usleep( stat_current == 0 ? 100000L : 200000L); - } -} - -void update_stat_cpu(stat_dev *st) { - - long k, istat, idle; - - get_statistics(st->name, &k, &istat, &idle); - - st->rt_idle = idle - st->idlelast; - st->idlelast = idle; - - st->rt_stat = istat - st->statlast; - st->statlast = istat; - - st->his[54] += k; - st->hisaddcnt += 1; -} - -void update_stat_io(stat_dev *st) { - - long j, k, istat, idle; - static long maxdiskio = 0; - - get_statistics(st->name, &k, &istat, &idle); - - st->rt_idle = idle - st->idlelast; - st->idlelast = idle; - - st->rt_stat = istat - st->statlast; - st->statlast = istat; - - j = st->rt_stat; - if (maxdiskio < j) { - maxdiskio = j; - } - st->rt_idle = maxdiskio - j; - - st->his[54] += st->rt_stat; - st->hisaddcnt += 1; -} - -void update_stat_mem(stat_dev *st, stat_dev *st2) { - - char temp[128]; - unsigned long free, shared, buffers, cached; - - freopen("/proc/meminfo", "r", fp_meminfo); - while (fgets(temp, 128, fp_meminfo)) { - if (strstr(temp, "Mem:")) { - sscanf(temp, "Mem: %ld %ld %ld %ld %ld %ld", - &st->rt_idle, &st->rt_stat, - &free, &shared, &buffers, &cached); - st->rt_idle >>= 10; - st->rt_stat -= buffers+cached; - st->rt_stat >>= 10; -// break; - } - if (strstr(temp, "Swap:")) { - sscanf(temp, "Swap: %ld %ld", &st2->rt_idle, &st2->rt_stat); - st2->rt_idle >>= 10; - st2->rt_stat >>= 10; - break; - } - } -} - -void update_stat_swp(stat_dev *st) { - - char temp[128]; - - fseek(fp_meminfo, 0, SEEK_SET); - while (fgets(temp, 128, fp_meminfo)) { - if (strstr(temp, "Swap:")) { - sscanf(temp, "Swap: %ld %ld", &st->rt_idle, &st->rt_stat); - st->rt_idle >>= 10; - st->rt_stat >>= 10; - break; - } - } - -} - -/*******************************************************************************\ -|* get_statistics *| -\*******************************************************************************/ - -void get_statistics(char *devname, long *is, long *ds, long *idle) { - - int i; - char temp[128]; - char *p; - char *tokens = " \t\n"; - float f; - long maxdiskio=0; - - *is = 0; - *ds = 0; - *idle = 0; - - if (!strncmp(devname, "cpu", 3)) { - fseek(fp_stat, 0, SEEK_SET); - while (fgets(temp, 128, fp_stat)) { - if (strstr(temp, "cpu")) { - p = strtok(temp, tokens); - /* 1..3, 4 == idle, we don't want idle! */ - for (i=0; i<3; i++) { - p = strtok(NULL, tokens); - *ds += atol(p); - } - p = strtok(NULL, tokens); - *idle = atol(p); - } - } - fp_loadavg = freopen("/proc/loadavg", "r", fp_loadavg); - fscanf(fp_loadavg, "%f", &f); - *is = (long) (100 * f); - } - - if (!strncmp(devname, "i/o", 3)) { - - fseek(fp_stat, 0, SEEK_SET); - while (fgets(temp, 128, fp_stat)) { - if (strstr(temp, "disk_rio") || strstr(temp, "disk_wio")) { - p = strtok(temp, tokens); - /* 1..4 */ - for (i=0; i<4; i++) { - p = strtok(NULL, tokens); - *ds += atol(p); - } - } - } - if (*ds > maxdiskio) maxdiskio = *ds; - } -} - -/*******************************************************************************\ -|* checksysdevs *| -\*******************************************************************************/ - -int checksysdevs(void) { - - strcpy(stat_device[0].name, "cpu0"); - strcpy(stat_device[1].name, "i/o"); - strcpy(stat_device[2].name, "sys"); - - return 3; -} - - -/*******************************************************************************\ -|* void DrawActive(char *) *| -\*******************************************************************************/ - -void DrawActive(char *name) { - - /* Alles op X,77 - CPU: 0 - I/O: 21 - - 20 Breed, 10 hoog - Destinatie: 5,5 - */ - - if (name[0] == 'c') { - copyXPMArea(0, 77, 19, 10, 5, 5); - } else if (name[0] == 'i') { - copyXPMArea(19, 77, 19, 10, 5, 5); - } - -} - -/*******************************************************************************\ -|* DrawStats *| -\*******************************************************************************/ - -void DrawStats(int *his, int num, int size, int x_left, int y_bottom) { - - int pixels_per_byte; - int j,k; - int *p; - int d; - - pixels_per_byte = 100; - p = his; - for (j=0; j pixels_per_byte) - pixels_per_byte += 100; - p += 1; - } - - p = his; - - for (k=0; k 0; j-=100) { - for (k=0; k global_io_scale) global_io_scale = p[j]; - } - - pixels_per_byte = 1.0 * global_io_scale / size; - if (pixels_per_byte == 0) pixels_per_byte = 1; - - for (k=0; k\n"); - fprintf(stderr, "\t-h\tthis screen\n"); - fprintf(stderr, "\t-v\tprint the version number\n"); - fprintf(stderr, "\t-i\tstartup in DiskIO mode\n"); - fprintf(stderr, "\t-s\tstartup in SysInfo mode\n"); - fprintf(stderr, "\n"); -} - -/*******************************************************************************\ -|* printversion *| -\*******************************************************************************/ - -void printversion(void) { - - if (!strcmp(ProgName, "wmmon")) { - fprintf(stderr, "%s\n", WMMON_VERSION); - } -} diff --git a/wmtetris/wmtetris/wmtetris.h b/wmtetris/wmtetris/wmtetris.h deleted file mode 100644 index 16d612a..0000000 --- a/wmtetris/wmtetris/wmtetris.h +++ /dev/null @@ -1,40 +0,0 @@ -/* wmapm.h -- Header file for WMAPM - * - * wmapm-1.2 (C) 1998 Chris D. Faulhaber - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program (see the file COPYING); if not, write to the - * Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - ***********************************************************************/ - -#define DELAY 250000 /* Delay between refreshes (in microseconds) */ - -#define WMAPM_VERSION "1.2" - -typedef struct apm_info { - const char driver_version[10]; - int apm_version_major; - int apm_version_minor; - int apm_flags; - int ac_line_status; - int battery_status; - int battery_flags; - int battery_percentage; - int battery_time; - int using_minutes; -} apm_info; - -#ifndef APM_32_BIT_SUPPORT -#define APM_32_BIT_SUPPORT 0x0002 -#endif