"Death Star" editor (repost from comp.sys.att)

Thad P Floryan thad at cup.portal.com
Fri Jan 12 22:35:41 AEST 1990


Ugh, the vagaries of Usenet distribution.  This is being re-posted on behalf
of Bill Mayhew.  The article never made it to PORTAL and wasn't posted to
unix-pc.sources (it NOW is :-).  I found it on another system whose Usenet
reliability is better than PORTAL's.  Enjoy!

Thad Floryan [ thad at cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ]
------------------------- reposting follows -------------------------
#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	wb.repost
# This archive created: Fri Jan 12 03:30:30 1990
echo shar: extracting wb.repost
sed 's/^X//' << \SHAR_EOF > wb.repost
XFrom wtm at neoucom.UUCP Thu Jan  4 21:03:40 1990
XRelay-Version: version Notes 2.8.2  87/11/24; site *****
XFrom: wtm at neoucom.UUCP (Bill Mayhew)
XDate: Fri, 5 Jan 1990 05:03:40 GMT
XDate-Received: Thu, 11 Jan 1990 00:31:51 GMT
XSubject: Here is how to edit the death star logo
XMessage-ID: <1866 at neoucom.UUCP>
XOrganization: Northeastern Ohio Universities College of Medicine
XPath: ...!ucsdhub!ucsd!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!cwjcc!\
X      neoucom!wtm
XNewsgroups: comp.sys.att
XKeywords: it really is pretty easy; c program enclosed
XLines: 157
X
XHi,
X
XIt really doesn't require fatbit and adb to edit the working icon.
XThe example below allows you to do it with your very own c program.
XYou do have to be root in order to edit the icon.  You could set
Xuid the program, but then any random l'user could hose your icon;
Xnot that it would make that much difference...
X
XCompile the program below.  Assuming you name the executable wb,
Xsimply type wb with no arguments.  Wb by itself will send the bit
Xpattern of the icon to stdout as ascii chars, which you may trap
Xand edit with vi or whatever.  I strongly suggest saving the
Xoriginal icon to a file for future reference.  After you've don't
Xyour Van Gogh immitation, type wb file_name, and wb will program
Xthe icon to the bit pattern specified in file_name.
X
XI didn't write the program, but I have tested it and it works.
XJohn is given credit in the header below.  As usual, use at your
Xown risk.   Sorry if this voilates net ettiquite to post this here,
Xbut our access to unix-pc is dicey; it isn't very long anyway.
X
X
XEnjoy,
XBill wtm at neoucom.edu  (...!lll-winken!scooter!neoucom!wtm)
X                      (...!uunet!aablue!neoucom!wtm)
X                      (...!cwjcc!neoucom!wtm)
X
X
X=========================cut for wb.c===============================
X/* wb -- Change "window/busy" indicator on bottom right of UNIX PC screen
X *	Copyright (c) 1988 by John Buck
X *	You may NOT include this program or its algorithm in any
X *	product designed for sale.  You can copy it for your own non-commercial
X *	use only; this entire copyright notice must be included.
X */
X#include <stdio.h>
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xstruct nlist nl[2] = {
X	{ "wbraster" },
X	{ NULL }
X};
X
X/* The "working" bitmap is 21 high by 80 wide */
Xunsigned short	wb[21][5];
Xint	fd;
X
Xmain(argc, argv)
Xchar **argv;
X{
X	FILE *fp;
X	struct stat wins, nms;
X
X	fp = NULL;
X	/* Is the window driver there? */
X	if(stat("/etc/lddrv/wind", &(wins)) == -1){
X		fprintf(stderr, "%s: Ooops -- can't stat ", argv[0]);
X		perror("/etc/lddrv/wind");
X		exit(5);
X	}
X	/* Quick name-list lookup, saves spending lots of CPU time
X	 * each invokation
X	 */
X	if(stat("/etc/lddrv/wbrast.nl", &nms) == -1 ||
X	   nms.st_mtime < wins.st_mtime ||
X	   (fp = fopen("/etc/lddrv/wbrast.nl", "r")) == NULL ||
X	   fread(&(nl[0]), sizeof (nl[0]), 1, fp) != 1){
X		if(fp) fclose(fp);
X		/* Too bad, have to do a lookup (once only?) */
X		if(nlist("/etc/lddrv/wind", nl) < 0 || nl[0].n_value <= 0){
X			fprintf(stderr, "%s: Bad namelist for %s\n", argv[0],
X				nl[0].n_name);
X			exit(2);
X		}
X		if((fp = fopen("/etc/lddrv/wbrast.nl", "w")) != NULL){
X			fwrite(&(nl[0]), sizeof (nl[0]), 1, fp);
X			fclose(fp);
X		}
X	}
X#ifdef DEBUG
X	fprintf(stdout, "wbraster @ 0x%x\n", nl[0].n_value);
X#endif
X	if((fd = open("/dev/kmem", 2)) == -1){
X		perror("/dev/kmem");
X		exit(3);
X	}
X	lseek(fd, nl[0].n_value, 0);
X	/* If args, must be a filename containing a bitmap */
X	if(argc > 1)
X		dofile(argv[1]);
X	else	{
X		/* Otherwise, just show us what is there */
X		if(read(fd, &(wb[0][0]), 21*5*(sizeof (short))) != 21*5*(sizeof(short))){
X			fprintf(stderr, "Error reading raster data\n");
X			close(fd);
X			exit(3);
X		}
X		printrast();
X	}
X	close(fd);
X	exit(0);
X}
X
Xprintrast()
X{
X	register unsigned short i, j, c, k;
X
X	for(i = 0; i < 21; i++){
X		for(j = 0; j < 5; j++){
X			c = wb[i][j];
X			for(k = 0; k < 16; k++, c >>= 1){
X				if(c & 1)
X					putchar('@');
X				else
X					putchar(' ');
X			}
X		}
X		putchar('\n');
X	}
X}
X
Xdofile(f)
Xchar *f;
X{
X	FILE *fp;
X	register unsigned short i, j, c, k;
X	register char *s;
X	char ibuf[258];
X
X	if((fp = fopen(f, "r")) == NULL){
X		fprintf(stderr, "Can't open ");
X		perror(f);
X		exit(3);
X	}
X	for(i = 0; i < 21; i++){
X		if(fgets(ibuf, 256, fp) == NULL){
X			fprintf(stderr, "Need 21 lines, only found %d\n", i);
X			exit(6);
X		}
X		s = ibuf;
X		for(j = 0; j < 5; j++){
X			c = 0;
X			for(k = 0; k < 16; k++, s++){
X				if(*s == ' '){
X					;
X				} else if(*s == '@'){
X					c |= (1<<k);
X				} else break;
X			}
X			wb[i][j] = c;
X		}
X	}
X	write(fd, &(wb[0][0]), 21*5*(sizeof (short)));
X} /* end of wb.c */
X====================end of transmission==========================
SHAR_EOF
if test 4664 -ne "`wc -c wb.repost`"
then
echo shar: error transmitting wb.repost '(should have been 4664 characters)'
fi
#	End of shell archive
exit 0



More information about the Unix-pc.sources mailing list