1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
diff -urN wmcpu-1.4.orig/wmcpu.c wmcpu-1.4/wmcpu.c
--- wmcpu-1.4.orig/wmcpu.c 2007-01-03 15:14:44.000000000 +0530
+++ wmcpu-1.4/wmcpu.c 2007-01-03 15:37:14.000000000 +0530
@@ -25,7 +25,6 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
-#include <getopt.h>
#include <X11/Xlib.h>
#include <X11/xpm.h>
@@ -45,7 +44,7 @@
"usage:\n" \
"\t-display <display name>\n" \
"\t-h\tthis screen\n" \
- "\t-v\tprint the version number\n" \
+ "\t-v\tprint the version number and exit\n" \
"\t-l\tshow load as numbers\n" \
"\t-t\ttime between refresh in usec (def=250000)\n"
@@ -65,31 +64,25 @@
int main(int argc, char **argv)
{
- int ch;
-
- while ((ch = getopt(argc, argv, "d:hvlt:")) != EOF) {
- switch (ch) {
- case 'd':
- if (optarg)
- display_name = strdup(optarg);
- break;
- case 'v':
- fprintf(stdout, "%s\n", WMCPU_VERSION);
- exit(0);
- break;
- case 'l':
- gfx_loadbar = 0;
- break;
- case 't':
- if (optarg)
- udelay = atol(optarg);
- break;
- default:
- fputs(HELP_TEXT, stdout);
- exit(0);
- break;
+ int par = 1;
+ while( par < argc ) {
+ if( !strcmp( argv[par], "-display" ) && par+1 < argc )
+ display_name = argv[++par];
+ else if( !strcmp( argv[par], "-v" ) ) {
+ fprintf(stderr, "%s\n", WMCPU_VERSION);
+ exit(0);
+ } else if( !strcmp( argv[par], "-l" ) )
+ gfx_loadbar = 0;
+ else if( !strcmp( argv[par], "-t" ) && par+1 < argc )
+ udelay = atol(argv[++par]);
+ else {
+ fputs(HELP_TEXT, stdout);
+ exit(0);
}
+
+ ++par;
}
+
if ((display = XOpenDisplay(display_name)) == NULL) {
fprintf(stderr, "Unable to open display \"%s\"\n", display_name);
|