Sun-Spots Digest, v6n35

William LeFebvre Sun-Spots-Request at RICE.EDU
Wed Mar 23 09:07:26 AEST 1988


SUN-SPOTS DIGEST          Monday, 21 March 1988        Volume 6 : Issue 35

Today's Topics:
                           This issue: source!
                     New version of vttool available
           rastoimp: yet another rasterfile->imPress converter
                        screendump(5) from fig(1)
             A patch to SUN3 init to make DTR more detectable
                           NEW 3.5 UPGRADE diff
                      Iconedit to PostScript Filter

Send contributions to:  sun-spots at rice.edu
Send subscription add/delete requests to:  sun-spots-request at rice.edu
Bitnet readers can subscribe directly with the CMS command:
    TELL LISTSERV AT RICE SUBSCRIBE SUNSPOTS My Full Name
Recent backissues are stored on "titan.rice.edu".  For volume X, issue Y,
"get sun-spots/vXnY".  They are also accessible through the archive
server:  mail the word "help" to "archive-server at rice.edu".

----------------------------------------------------------------------

Date:    Mon, 21 Mar 88 16:18:14 CST
From:    William LeFebvre <phil at Rice.edu>
Subject: This issue:  source!

This issue contains nothing but source code and references to source code.
I have included two programs and a shar file that are both almost large
enough to justify putting in the archives instead of a digest.  So I
decided to wrap it all up into one digest instead.  Enjoy!

William LeFebvre

------------------------------

Date:    Fri, 11 Mar 88 13:54:52 EST
From:    steinmetz!barnett%crd at uunet.uu.net
Subject: New version of vttool available

I am including my new version of vttool - the vt100 emulator for SunView.
Note that this program doesn't handle graphics or special characacters. 

The new version contains two programs:

	vtem - a vt100 emulator that uses termcap and will run
		on any reasonable terminal
	vttool - a general purpose tool that provides a flexible
		set of mousable-buttons for use with any tty-based 
		program. samples are included for vtem, csh, and moria.

The new version provides greater flexibility, allowing the program, button
file, and arguments to be specified from the command line.

I am sending it to sun-spots. In a few weeks I will send it to
comp.sources.misc. 

Bruce G. Barnett  <barnett at ge-crd.ARPA> <barnett at steinmetz.UUCP>

[[ It has been placed in the archives in two separate files:
"sun-source/vttool.shar.1" and "sun-source/vttool.shar.2" (52602 and 28014
bytes, respectively).  It can be retrieved via anonymous FTP from the host
"titan.rice.edu" or via the archive server.  For more information about
the archive server, send a mail message containing the word "help" to the
address "archive-server at rice.edu".  Note that this program is in no way
related to the "vt100tool" that appeared on the last SUG tape.  --wnl ]]

------------------------------

Date:    Sun, 20 Mar 88 16:11:44 CST
From:    William LeFebvre <phil at Rice.edu>
Subject: rastoimp: yet another rasterfile->imPress converter

This is a little quickie program I cooked up after I installed dumpregion.
It seems that all the rasterfile to imPress converters in existence assume
that the width of the original image is already padded out to a multiple
of 32 bits.  This program makes no such assumption, so it will work with
any image that dumpregion creates.  So, I have added it to the archives as
"sun-source/rastoimp.shar" for all who are interested.  By the way,
imPress is the language that all Imagen laser printers speak.

It can be retrieved via anonymous FTP from the host "titan.rice.edu" or
via the archive server with the request "send sun-source/rastoimp.shar".
For more information about the archive server, send a mail message
containing the word "help" to the address "archive-server at rice.edu".

William LeFebvre
<phil at Rice.edu>

------------------------------

Date:    Fri, 11 Mar 88 14:07:01 EST
From:    ufnmr!gareth at bikini.cis.ufl.edu (Gareth J. Barker)
Subject: screendump(5) from fig(1)

I recently picked up a copy of fig from the archive server, but was unable
to produce hardcopy as we don't have 'ditroff' or 'pic'.  The program
below was written to overcome this and coverts a fig 'bitmap' file
(produced by selecting the bottom item in the fig popup menu) into
screendump(5) format for printing with lpr -v.  It takes the bitmap
filename as its single argument and reads from stdin if no filename is
given.  Output is always to stdout and can be piped to the printer or
redirected for some other use.

/* BITDUMP 1.1 - Convert fig(1) bitmap to screendump(5) format *
 *                                                             *
 * Gareth J Barker - University of Florida - 3/11/88           * 
 *                                                             *
 * GJBARKER at UFFSC.BITNET                                       *
 * ufnmr!gareth at BIKINI.CIS.UFL.EDU                             */


#include <stdio.h>
#include <pixrect/pixrect_hs.h>

main(argc, argv)
	int             argc;
	char           *argv[];
{

	FILE           *fp, *fopen();
	int             width, height, i;
	char            temp1[30], *temp2, *malloc();
	short          *data;
	struct picrect *mp;
	colormap_t     *colormap;
	int             type, copy_flag;
	unsigned        alignment, size;


	/* Check for a single argument. If it exists use it as the input
	   filename, otherwise read from stdin. */

	if (argc >= 3)
	{
		fprintf(stderr, "Use: bitdump [filename] \n\n");
		exit(1);
	}

	if (argc == 2)
	{
		if ((fp = fopen(argv[1], "r")) == NULL)
		{
			fprintf(stderr, "bitdump: can't open %s \n", argv[1]);
			exit(1);
		}
	}
	else
	{
		fp = stdin;
	}


	/* Read bitmap header */

	if (fscanf(fp, "WIDTH %d HEIGHT %d", &width, &height) != 2)
	{
		fprintf(stderr, "bitdump: incorrect file format \n");
		exit(1);
	}


	/* Round width to a whole number of words, and get enough memory to
	   hold the bitmap (starting at an even address). */

	width = 16 * (((width - 1) / 16) + 1);
	size = (unsigned) height *width * sizeof(short);
	alignment = (unsigned) 2 *sizeof(short);
	if ((data = memalign(alignment, size)) == NULL)
	{
		fprintf(stderr, "bitdump: file too big");
	}


	/* Read the bitmap, which is in the form 0xABCD, 0xDCBA, .... */

	i = 0;
	while (fscanf(fp, "%s", temp1) >= 1)
	{
		temp2 = temp1 + 2;
		sscanf(temp2, "%hx", (data + i));
		i++;
	}


	/* Setup a pixrect, and write it out in screendump(5) format */

	mp = mem_point(width, height, 1, data);

	colormap = NULL;
	type = RT_STANDARD;
	copy_flag = 0;
	pr_dump(mp, stdout, colormap, type, copy_flag);

}

Gareth J. Barker,
University of Florida,
Department of Radiology.

BITNET   : GJBARKER at UFFSC.BITNET
INTERNET : ufnmr!gareth at BIKINI.CIS.UFL.EDU
UUCP     : ...gatech!uflorida!ufnmr!gareth

------------------------------

Date:    Sat, 12 Mar 88 18:11:20 +0100 (MET)
From:    "Bernard Sieloff" <unido!sbsvax!bs at uunet.uu.net>
Subject: A patch to SUN3 init to make DTR more detectable

Here is a hack to pach /etc/init for SUN3 running SunOS 3.4 or SunOS 3.5.
In SUN's original init little time is between exiting of a shell and
forking of a new init/getty/shell.

Therefore some modems will not properly detect a DTR transition.  As a
result, e.g. a UUCP login --although it's finished-- won't shut down the
transmission line. This can cause mad situations.  The following patch
inserts in init's handling of multiuser service (multiple()) between the
call of rmut(p) and dfork(p) a call of sleep(2).  This delay forces DTR
staying down long enough to be detected even by the worst modem hardware.

People with SUN sources only have to recompile and install the above
augmented init; the rest of the world (like me) must patch (sigh)...

__________ cut here __________
#include <stdio.h>
/*
 * Hack to delay forking of a new init/getty/shell.
 * CAUTION: work on a copy of /etc/init in a safe place!
 * This program will generate a file "init.x" which you
 * have to install in /etc/init. Then reboot.
 * The use of this program and all following events are at
 * YOUR OWN risk and responsability.
 * Paul Keller & Bernard Sieloff
 * Universitaet des Saarlandes
 * Bau 36 - Informatik (Dept. of CS)
 * Im Stadtwald 15
 * D-6600 Saarbruecken 11 - West Germany
 */

#define HOOK   0x0780L
#define INSERT 0x22a0L

char patch[] = "\
4e 56 00 00 2f 2e 00 08 4e b9 00 00 2e 7a 58 4f \
48 78 00 02 4e b9 00 00 3c 70 58 4f 4e 5e 4e 75 ";

/*
 * linkw a6,#0		patch(p)
 * movl  a6@(8),sp at -	int *p;
 * jsr   _rmut:l	{
 * addqw #4,sp			rmut(p);
 * pea   2:w			sleep(2);
 * jsr   _sleep:l	}
 * addqw #4,sp
 * unlk  a6
 * rts
 */

char ks[] = "4280"; /* start address of knapsack */

#define  N  sizeof(patch)/3
#define  byte(p) (xtn((p)++) | xtn((p)++)<<4)

char buffer[N];

main()
{
	int fd;
	int i,x;
	char rs[2];
	char *kptr=ks;
	char *pptr=patch;

	stretch(); /* make room... */

	if ((fd = open("init.x", 2)) < 0) {
		perror("init.x");
		exit(1);
	}
	/* first: change header */
	lseek(fd, 4L, 0);
	read(fd, &x, sizeof(int));
	x += 200;
	lseek(fd, 4L, 0);
	write(fd, &x, sizeof(int));
	/* 2nd: patch in start address of knapsack */
	rs[0] = byte(kptr);
	rs[1] = byte(kptr);
	lseek(fd, HOOK, 0);
	write(fd, rs, 2);
	/* 3rd: write knapsack in file */
	for (i=0; i<N; i++) {
		buffer[i] = byte(pptr);
		++pptr;
	}
	lseek(fd, INSERT, 0);
	write(fd, buffer, N);
	close(fd);
}

xtn(hex)
	char *hex;
{
	char nibble;
	switch (*hex) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9': nibble = *hex - '0'; break;
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f': nibble = 10 + *hex - 'a'; break;
	default : perror("convert"); exit(1);
	}
	return(nibble);
}

#define CUT  0x2288

stretch()
{
	FILE *fp, *fp1;

	int c;
	int i;

	if ((fp = fopen("init", "r")) == NULL) {
		perror("init");
		exit(1);
	}
	if ((fp1 = fopen("init.x", "w+")) == NULL) {
		perror("init.x");
		exit(1);
	}

	for (i = 0;i < CUT;i++) {
		c = getc(fp);
		putc(c, fp1);
	}
	for (i = 0;i < 200;i++)
		putc(0, fp1);
	while ((c = getc(fp)) != EOF)
		putc(c, fp1);
	fflush(fp1);
	fclose(fp);
	fclose(fp1);
}
__________

UUCP:  ...!uunet!unido!sbsvax!bs    |  Bernard Sieloff
       or bs at sbsvax.UUCP            |  Universitaet des Saarlandes
CSNET: bs%sbsvax.uucp at Germany.CSnet |  FB 10 - Informatik (Dept. of CS)
ARPA:  bs%sbsvax.uucp at uunet.UU.NET  |  Bau 36, Im Stadtwald 15
Phone: +49 681 302 2434             |  D-6600 Saarbruecken 11, West Germany

[[ All I can say is: "YUCK!"  --wnl ]]

------------------------------

Date:    11 Mar 88 23:25:20 GMT
From:    cyrus at hi.unm.edu (Tait Cyrus)
Subject: NEW 3.5 UPGRADE diff

I found some bugs, I mean features :-) in the diff file I sent you for the
3.5 UPGRADE shellscript.  Here is a NEW diff.

[[ I hope the mistakes in the last diff didn't cause anyone any serious
problems.  --wnl ]]

*** UPGRADE	Fri Mar 11 16:22:51 1988
--- UPGRADE.org	Mon Feb 15 21:31:37 1988
***************
*** 542,554 ****
          fi
  	#
          # Create CLIENTLIST from /etc/nd.local
! 	#
! 	for CLIENT in `awk -f ./get_client_names < $NDLOCAL `
          do
! 		mkdir /${CLIENT} 2> /dev/null
!                 CLIENTLIST="${CLIENTLIST} ${CLIENT}"
!  		set `grep $CLIENT $NDLOCAL | awk '$3 == "0" { print $0 }'`
!                 ndl=ndl${7}
                  cd /dev
                  /dev/MAKEDEV ${ndl} 2> /dev/null
          done
--- 542,605 ----
          fi
  	#
          # Create CLIENTLIST from /etc/nd.local
!         # Looks ugly but handles all possible cases
!         # nd.local format
!         #   user hostname hisunit mydev myoff mysize mylunit maxpkts
!         #
!         endsym=$
!         ind=0
! 	CLIENTLIST=""
!         while true; do
! 		grep " $ind $endsym" $NDLOCAL > /dev/null 2>&1
!                 case "$?" in
!                    0)
!                       set `grep " $ind $endsym" $NDLOCAL` ;;
!                    1)
!                       grep " $ind    $endsym" $NDLOCAL > /dev/null 2>&1
!                       case "$?" in
!                          0)
!                             set `grep " $ind $endsym" $NDLOCAL` ;;
!                          1)
!                             grep " $ind$endsym" $NDLOCAL > /dev/null 2>&1
!                             case "$?" in
!                                0)
!                                   set `grep " $ind$endsym" $NDLOCAL` ;;
!                                1)
!                                   grep " $ind [0-9]$endsym" $NDLOCAL > /dev/null 2>&1
!                                   case "$?" in
!                                      0)
!                                         set `grep " $ind [0-9]$endsym" $NDLOCAL` ;;
!                                      1)
! 		   			grep " $ind  [0-9]$endsym" $NDLOCAL > /dev/null 2>&1
!                                         case "$?" in
!                                            0)
!                                               set `grep " $ind       [0-9]$endsym" $NDLOCAL` ;;
!                                            1)
!                                               break ;;
!                                         esac ;;
!                                   esac ;;
!                             esac ;;
!                       esac ;;
!                 esac
! 		if [ "$1" = "version" ]  ; then
! 			shift 2
! 		fi
!                 CLIENT=$2
!                 case "$1" in
!                      "#user" )
!                              ;;
!                      "user"  )
! 			     mkdir /${CLIENT} 2> /dev/null
!                              CLIENTLIST="${CLIENTLIST} ${CLIENT}" ;;
!                      * )
!                              ;;
!                 esac
!                 ind=`expr ${ind} + 1`
!         done
! 	for CLIENT in $CLIENTLIST
          do
!                 set `grep "user $CLIENT 0" $NDLOCAL | sed s,\/," ",g`
!                 ndl=ndl${8}
                  cd /dev
                  /dev/MAKEDEV ${ndl} 2> /dev/null
          done
***************
*** 561,568 ****
                  fi
  	elif [ "$SERVERTYPE" = "heter" ]; then
  		for HOSTNAME in ${CLIENTLIST}; do
! 			set `grep $HOSTNAME $NDLOCAL | awk '$3 == "0" { print $0 }'`
!                         DISK=ndl${7}
  			fsck -p /dev/${DISK} > /dev/null
                          if mount /dev/${DISK} /${HOSTNAME}; then
                                  cd /${HOSTNAME}
--- 612,619 ----
                  fi
  	elif [ "$SERVERTYPE" = "heter" ]; then
  		for HOSTNAME in ${CLIENTLIST}; do
!                         set `grep "user $HOSTNAME 0" $NDLOCAL | sed s,\/," ",g`
!                         DISK=ndl${8}
  			fsck -p /dev/${DISK} > /dev/null
                          if mount /dev/${DISK} /${HOSTNAME}; then
                                  cd /${HOSTNAME}
***************
*** 729,736 ****
                  	CLIENTLIST=${CLIENTLIST20}
  		fi
          	for HOSTNAME in ${CLIENTLIST}; do
! 			set `grep $HOSTNAME $NDLOCAL | awk '$3 == "0" { print $0 }'`
!                 	DISK=ndl${7}
                  	if mount /dev/${DISK} /${HOSTNAME}; then

  				#
--- 780,787 ----
                  	CLIENTLIST=${CLIENTLIST20}
  		fi
          	for HOSTNAME in ${CLIENTLIST}; do
! 			set `grep "user $HOSTNAME 0" ${NDLOCAL}.OLD | sed s,\/," ",g`
!                 	DISK=ndl${8}
                  	if mount /dev/${DISK} /${HOSTNAME}; then

  				#

W. Tait Cyrus   (505) 277-0806
University of New Mexico
Dept of Electrical & Computer Engineering 
  Parallel Processing Research Group (PPRG)
  UNM/LANL Hypercube Project
Albuquerque, New Mexico 87131

e-mail:      
  cyrus at hc.dspo.gov

------------------------------

Date:    Mon, 14 Mar 88 8:19:48 PST
From:    dean at devvax.jpl.nasa.gov (Dean Okamura)
Subject: Iconedit to PostScript Filter

Psicon is a shell script that translates iconedit files to Encapsulated
PostScript (EPSF).  You could try this on dragon.icon for starters:

    (psicon dragon.ps; echo "showpage") | lpr -Plw

Dean Okamura
Jet Propulsion Laboratory, M/S 301-260A, 4800 Oak Grove Drive,
Pasadena, CA 91109, USA (818) 354-1490
Please send returned mail to dean at devvax.JPL.NASA.GOV.
There seems to be mail problems with jpl-devvax.

#!/bin/sh
# This is a shell archive.
echo 'If the files were unpacked, "End of SHAR" will be echoed'
echo Extracting psicon.sh
sed >psicon.sh <<'!Hello!Kitty!' -e 's/X//'
X#!/bin/sh
X##	@(#)psicon.sh 1.00 SFOC WSE <03/11/88>
X#ifdef Copyright
X##
X##	Copyright 1988 by Dean Okamura
X##
X##	Permission to use, copy, modify, and distribute this software
X##	and its documentation for any purpose and without fee is
X##	hereby granted, provided that the above copyright notice
X##	appear in all copies and that both that copyright notice and
X##	this permission notice appear in supporting documentation, and
X##	that the name of Dean Okamura not be used in advertising or
X##	publicity pertaining to distribution of the software without
X##	specific, written prior permission.  Dean Okamura makes no
X##	representations about the suitability of this software for
X##	any purpose.  It is provided "as is" without express or
X##	implied warranty.
X##
X#endif Copyright
X#ifdef Header
X##
X## MANUAL
X##	PSICON 1 "March 11, 1988"
X## NAME
X##	psicon -- iconedit to PostScript filter
X## SYNOPSIS
X##	psicon file
X## DESCRIPTION
X##	_ psicon translates iconedit _ file to Encapsulated PostScript
X##	File (EPSF) and writes to the standard output.
X## INPUTS
X##	_ file is a iconedit _ file.
X## OUTPUTS
X##	standard output.
X## RETURN VALUES
X##	[0] Successful.
X## NOTES
X##	The output from _ psicon can be printed on the LaserWriter
X##	by adding a line at the end of the file with the PostScript
X##	showpage operator.  A typical Unix command would be:
X##
X##	    (psicon file; echo "showpage") | lpr -Plw
X##
X##	PostScript is a trademark of Adobe Systems Incorporated.
X## SEE ALSO
X##	iconedit(1).
X##
X#endif Header
X# Assert: iconedit format
X# Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
Xfor i in `grep 'Format_version' $1 | sed 's/,//g'`
Xdo
X	case $i in
X	Width=*) Width=`echo "$i" | sed 's/Width=//'` ;;
X	Height=*) Height=`echo "$i" | sed 's/Height=//'` ;;
X	esac
Xdone
X
X# PostScript prologue
Xecho "%!PS-Adobe-1.0"
Xecho "%%Title:$1 icon"
Xecho "%%Creator:`basename $0`"
Xecho "%%For:`whoami`"
Xecho "%%CreationDate:`date`"
Xecho "%%BoundingBox:72 72 144 144"
Xecho "%%EndComments"
X
X# PostScript image printing procedure
Xecho "/picstr 16 string def"
Xecho "/Icon"
Xecho "{ 0 setgray"
Xecho "  $Width $Height true [$Width 0 0 -$Height 0 $Height]"
Xecho "  { currentfile picstr readhexstring pop } imagemask"
Xecho "} def"
Xecho "%%EndProlog"
Xecho "gsave"
X
X# lower left hand corner and scale
Xecho "72 72 translate"
Xecho "72 72 scale"
Xecho "Icon"
X
X# change to picstr by removing 0x prefix, spaces, tabs, and commas
Xgrep '0x.*0x.*0x.*0x' $1 | sed -e '
Xs/0x//g
Xs/[	, ]//g'
X#  ^---<tab><comma><space> pattern
X
X# PostScript end
Xecho "grestore"
Xecho "%%Trailer"
X# icon
!Hello!Kitty!
echo ""
echo "End of SHAR"
exit

------------------------------

End of SUN-Spots Digest
***********************



More information about the Comp.sys.sun mailing list