8 Commits

Author SHA1 Message Date
bch
3d431ec0b6 Summary: remove variables that are not used 2017-02-26 16:05:52 +00:00
bch
38f147b166 Summary: fix warning 2017-02-26 16:03:48 +00:00
bch
9484298c47 Summary: update function definitions 2017-02-26 16:02:48 +00:00
bch
a63975b5f9 Summary: simplify makefile 2017-02-26 16:02:24 +00:00
bch
1cbabd26de Summary: remove comments 2017-02-26 15:36:52 +00:00
bch
3e0ff42f52 updated makefile 2017-02-19 10:44:11 +00:00
bch
f5ebd29a7c Summary: renamed 2017-02-18 21:44:46 +00:00
bch
d9b4a0be07 Summary: renamed manual file 2017-02-18 21:44:12 +00:00
5 changed files with 38 additions and 69 deletions

View File

@@ -1,21 +1,28 @@
CFLAGS += -I/usr/X11R6/include/
CFLAGS += -Wall -I/usr/X11R6/include/
BINDIR=/usr/local/bin
MANDIR=/usr/local/man/man1
LDFLAGS=-L/usr/X11R6/lib -lX11 -lXt -lXaw -lXmu
xmem: xmem.o get_mem.o MemStripChart.o
gcc $(CFLAGS) -o xmem xmem.o get_mem.o MemStripChart.o -L/usr/X11R6/lib -lX11 -lXt -lXaw -lXmu
$(CC) -o xmem xmem.o get_mem.o MemStripChart.o $(LDFLAGS)
xmem.o: xmem.c
gcc $(CFLAGS) -c xmem.c
$(CC) $(CFLAGS) -c xmem.c
get_mem.o: get_mem.c
gcc $(CFLAGS) -c get_mem.c
$(CC) $(CFLAGS) -c get_mem.c
MemStripChart.o: MemStripChart.c
gcc $(CFLAGS) -c MemStripChart.c
$(CC) $(CFLAGS) -c MemStripChart.c
clean:
-rm xmem *.o *~
install: xmem
install -d -m 755 $(DESTDIR)/usr/local/bin/
install -d -m 755 $(DESTDIR)/etc/X11/app-defaults/
install -m 755 xmem $(DESTDIR)/usr/local/bin/
install -m 644 XMem.ad $(DESTDIR)/etc/X11/app-defaults/XMem
all: xmem
install: all
/usr/bin/install -c -m 0555 xmem $(DESTDIR)$(BINDIR)
/usr/bin/install -c -m 0444 xmem.1 $(DESTDIR)$(MANDIR)
/usr/bin/install -c -m 0644 XMem.ad $(DESTDIR)/usr/local/lib/X11/app-defaults/XMem
/usr/bin/install -d -m 0755 $(DESTDIR)/usr/local/share/xmem/
/usr/bin/install -c -m 0644 xmem.bit $(DESTDIR)/usr/local/share/xmem/

View File

@@ -51,7 +51,7 @@ static XtResource resources[] = {
#undef offset
static void Initialize(), Destroy(), Redisplay(), MoveChart(), SetPoints();
static void Initialize(), Destroy(), Redisplay(), MoveChart(MemStripChartWidget w, Boolean blit), SetPoints();
static Boolean SetValues();
static int repaint_window();
@@ -114,9 +114,7 @@ static void draw_it();
*/
static void
CreateGC(w, which)
MemStripChartWidget w;
unsigned int which;
CreateGC(MemStripChartWidget w, unsigned int which)
{
XGCValues myXGCV;
@@ -165,9 +163,7 @@ CreateGC(w, which)
*/
static void
DestroyGC(w, which)
MemStripChartWidget w;
unsigned int which;
DestroyGC(MemStripChartWidget w, unsigned int which)
{
if (which & FOREGROUND)
XtReleaseGC((Widget) w, w->mem_strip_chart.fgGC);
@@ -205,9 +201,7 @@ DestroyGC(w, which)
*/
static void
DrawMemStrip(w, x)
MemStripChartWidget w;
unsigned int x;
DrawMemStrip(MemStripChartWidget w, unsigned int x)
{
int top, bottom;
@@ -260,10 +254,7 @@ DrawMemStrip(w, x)
}
/* ARGSUSED */
static void Initialize (greq, gnew, args, num_args)
Widget greq, gnew;
ArgList args;
Cardinal *num_args;
static void Initialize (Widget greq, Widget gnew, ArgList args, Cardinal *num_args)
{
MemStripChartWidget w = (MemStripChartWidget)gnew;
@@ -281,8 +272,7 @@ static void Initialize (greq, gnew, args, num_args)
SetPoints(w);
}
static void Destroy (gw)
Widget gw;
static void Destroy (Widget gw)
{
MemStripChartWidget w = (MemStripChartWidget)gw;
@@ -300,10 +290,7 @@ static void Destroy (gw)
*/
/* ARGSUSED */
static void Redisplay(w, event, region)
Widget w;
XEvent *event;
Region region;
static void Redisplay(Widget w, XEvent *event, Region region)
{
if (event->type == GraphicsExpose)
(void) repaint_window ((MemStripChartWidget)w, event->xgraphicsexpose.x,
@@ -315,9 +302,7 @@ static void Redisplay(w, event, region)
/* ARGSUSED */
static void
draw_it(client_data, id)
XtPointer client_data;
XtIntervalId *id; /* unused */
draw_it(XtPointer client_data, XtIntervalId *id)
{
MemStripChartWidget w = (MemStripChartWidget)client_data;
MemStripChartCallbackData value;
@@ -356,7 +341,8 @@ draw_it(client_data, id)
w->mem_strip_chart.valuedata[w->mem_strip_chart.interval] = value;
if (XtIsRealized((Widget)w)) {
DrawMemStrip(w, w->mem_strip_chart.interval, value);
/* XXX DrawMemStrip(w, w->mem_strip_chart.interval, value); */
DrawMemStrip(w, w->mem_strip_chart.interval);
/*
* Fill in the graph lines we just painted over.
@@ -385,9 +371,7 @@ draw_it(client_data, id)
*/
static int
repaint_window(w, left, width)
MemStripChartWidget w;
int left, width;
repaint_window(MemStripChartWidget w, int left, int width)
{
int i, j;
int next = w->mem_strip_chart.interval;
@@ -425,7 +409,7 @@ repaint_window(w, left, width)
/* Draw data point lines. */
for (i = left; i < width; i++) {
DrawMemStrip(w, i, w->mem_strip_chart.valuedata[i]);
DrawMemStrip(w, i);
}
/* Draw graph reference lines */
@@ -445,9 +429,7 @@ repaint_window(w, left, width)
*/
static void
MoveChart(w, blit)
MemStripChartWidget w;
Boolean blit;
MoveChart(MemStripChartWidget w, Boolean blit)
{
double old_max;
int left, i, j;
@@ -509,10 +491,7 @@ MoveChart(w, blit)
}
/* ARGSUSED */
static Boolean SetValues (current, request, new, args, num_args)
Widget current, request, new;
ArgList args;
Cardinal *num_args;
static Boolean SetValues (Widget current, Widget request, Widget new, ArgList args, Cardinal *num_args)
{
MemStripChartWidget old = (MemStripChartWidget)current;
MemStripChartWidget w = (MemStripChartWidget)new;
@@ -583,8 +562,7 @@ static Boolean SetValues (current, request, new, args, num_args)
#define HEIGHT ( (unsigned int) w->core.height)
static void
SetPoints(widget)
Widget widget;
SetPoints(Widget widget)
{
MemStripChartWidget w = (MemStripChartWidget) widget;
XPoint * points;

View File

@@ -1,4 +1,4 @@
/* $Id: get_mem.c,v 1.3 2017/02/18 21:14:12 bch Exp $
/* $Id: get_mem.c,v 1.4 2017/02/26 16:03:48 bch Exp $
* Adapted: get memory usage on OpenBSD
* Author: Christian Barthel <bch@vcs.onfire.org>
*
@@ -14,11 +14,14 @@
#include <sys/swap.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <unistd.h>
#include <X11/Xos.h>
#include <X11/Intrinsic.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <err.h>
#include "MemStripChart.h"
static int pageshift = -1;

View File

21
xmem.c
View File

@@ -45,17 +45,6 @@ typedef struct _XLoadResources {
* pass over the remaining options after XtParseCommand is let loose.
*/
static XrmOptionDescRec options[] = {
{"-scale", "*load.minScale", XrmoptionSepArg, NULL},
{"-update", "*load.update", XrmoptionSepArg, NULL},
{"-hl", "*load.highlight", XrmoptionSepArg, NULL},
{"-highlight", "*load.highlight", XrmoptionSepArg, NULL},
{"-jumpscroll", "*load.jumpScroll", XrmoptionSepArg, NULL},
{"-label", "*label.label", XrmoptionSepArg, NULL},
{"-nolabel", "*showLabel", XrmoptionNoArg, "False"},
{"-lights", "*useLights", XrmoptionNoArg, "True"},
};
static XrmOptionDescRec options_mem[] = {
{"-scale", "*mem.minScale", XrmoptionSepArg, NULL},
{"-update", "*mem.update", XrmoptionSepArg, NULL},
@@ -79,13 +68,6 @@ static XrmOptionDescRec options_mem[] = {
#define Offset(field) (XtOffsetOf(XLoadResources, field))
static XtResource my_resources[] = {
{"showLabel", XtCBoolean, XtRBoolean, sizeof(Boolean),
Offset(show_label), XtRImmediate, (XtPointer) TRUE},
{"useLights", XtCBoolean, XtRBoolean, sizeof(Boolean),
Offset(use_lights), XtRImmediate, (XtPointer) FALSE},
};
static XtResource my_resources_mem[] = {
{"showLabel", XtCBoolean, XtRBoolean, sizeof(Boolean),
Offset(show_label), XtRImmediate, (XtPointer) TRUE},
@@ -99,7 +81,6 @@ static XtActionsRec xload_actions[] = {
{ "quit", quit },
};
static Atom wm_delete_window;
static int light_update = 10 * 1000;
/*
* Exit with message describing command line format.
@@ -154,7 +135,6 @@ int main(int argc, char **argv)
Arg args[1];
Pixmap icon_pixmap = None;
char *label, host[256];
char *lastslash;
/* For security reasons, we reset our uid/gid after doing the necessary
system initialization and before calling any X routines. */
@@ -227,6 +207,7 @@ int main(int argc, char **argv)
errx(1, "pledge failed: %s", strerror(errno));
XtAppMainLoop(app_con);
return 0;
}