[comp.sys.atari.st.tech] Using curses and termcap

pietrzak@skybridge.SCL.CWRU.Edu (John Pietrzak) (03/24/91)

   I've recently been attempting to move a program which uses curses
to my atari.  I set up the GCC package from atari.archive, and (amazingly)
everything went smoothly from there.  The only problem I've
encountered so far is apparently with getting curses to read from
the termcap information.  I've tried setting a TERMCAP environment
variable, putting the termcap file in a /etc folder, putting it in
the current directory, etc., but I still can't seem to get it (my 
tabs aren't working properly).  Anyone know what I'm doing wrong?  

   (I'm using the termcap file found with the curses distribution,
and setting a variable TERM=atari.  Also, I'm running under msh of
Mark Williams C fame.)

Thanks

John Pietrzak
pietrzak@ces.cwru.edu

bammi@acae127.cadence.com (Jwahar R. Bammi) (03/29/91)

In article <1991Mar23.174530.23356@usenet.ins.cwru.edu> pietrzak@skybridge.SCL.CWRU.Edu (John Pietrzak) writes:

> 
>    I've recently been attempting to move a program which uses curses
> to my atari.  I set up the GCC package from atari.archive, and (amazingly)

> the current directory, etc., but I still can't seem to get it (my 
> tabs aren't working properly).  Anyone know what I'm doing wrong?  

	I am replying here since i suspect lots of people are having
this problem. Unfortunately, it is due to a small bug in addbytes.c,
and is not connected to the termcap entry. i am including some diffs
(from Patchlevel 5) and new Makefiles below . There us even a test now
(testtab.c included below) for this bug.

BTW: i did send these patches to A.A to be included in the UPDATE
sub-dir. somehow, it must have bit the old bit bucket. (i dont have
FTP access anymore to send up things directly myself).

>   Also, I'm running under msh of
> Mark Williams C fame.)
	Shame on you :-) CWRU was the home of gulam, gcc and other
neat hacks when we were around. we would have never stooped that
low :-) :-)


#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile
#	Makefile.mint
#	diffs
#	makefile.16
#	makefile.32
#	mincl
#	testtab.c
# This archive created: Thu Mar 28 13:19:31 1991
# By:	Jwahar R. Bammi(Cadence Design Systems)
#     Usenet:	 uunet!cadence!bammi
#   Internet:	 bammi@cadence.com
#
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(1164 characters)'
if test -f 'Makefile'
then
	echo shar: over-writing existing file "'Makefile'"
fi
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X#
X# Top level Makefile for TOS-Gcc curses library in unix hosted cross dev env.
X#
X
XCROSSDIR = /net/acae127/home/bammi/atari/cross-gcc
XCROSSLIB = $(CROSSDIR)/lib
XCROSSBIN = $(CROSSDIR)/bin
XCROSSINC = $(CROSSDIR)/include
X
XAR	= $(CROSSBIN)/car
XCC	= cgcc
XCPP	= /lib/cpp
XAS 	= $(CC)
XLIB     = $(CROSSLIB)
XINC	= $(CROSSINC)
XMAKE	= /util/gnu/bin/make
X
XMAKEFLAGS = CC=$(CC) CPP=$(CPP) AS=$(AS) AR=$(AR) XFLAGS=$(XFLAGS) \
X LIB=$(LIB) INC=$(INC)
X
X#all: lshort llong lgshort lglong
Xall: lshort llong
X
Xlshort:
X	$(MAKE) -f makefile.16 clean
X	$(MAKE) -f makefile.16 $(MAKEFLAGS) all 
X	$(MAKE) -f makefile.16 $(MAKEFLAGS) install
X
Xllong:
X	$(MAKE) -f makefile.32 clean
X	$(MAKE) -f makefile.32 $(MAKEFLAGS) all
X	$(MAKE) -f makefile.32 $(MAKEFLAGS) install
X
Xlgshort:
X	$(MAKE) -f gmakefile.16 clean
X	$(MAKE) -f gmakefile.16 $(MAKEFLAGS) all
X	$(MAKE) -f gmakefile.16 $(MAKEFLAGS) install
X
Xlglong:
X	$(MAKE) -f gmakefile.32 clean
X	$(MAKE) -f gmakefile.32 $(MAKEFLAGS) all
X	$(MAKE) -f gmakefile.32 $(MAKEFLAGS) install
X
Xclean:
X	$(MAKE) -f makefile.16 clean
X	$(MAKE) -f makefile.32 clean
X
Xrealclean:
X	$(MAKE) -f makefile.16 realclean
X	$(MAKE) -f makefile.32 realclean
X	rm -f core report
SHAR_EOF
if test 1164 -ne "`cat 'Makefile' | wc -c`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 1164 characters)'
fi
echo shar: extracting "'Makefile.mint'" '(1261 characters)'
if test -f 'Makefile.mint'
then
	echo shar: over-writing existing file "'Makefile.mint'"
fi
sed 's/^X//' << \SHAR_EOF > 'Makefile.mint'
X#
X# Top level Makefile for TOS-Gcc curses library in unix hosted cross dev env.
X#
X
XCROSSDIR = /net/acae127/home/bammi/atari/cross-gcc
XCROSSLIB = $(CROSSDIR)/lib
XCROSSBIN = $(CROSSDIR)/bin
XCROSSINC = $(CROSSDIR)/include
X
XAR	= $(CROSSBIN)/car
XCC	= cgcc -nostdinc -I/net/acae127/home/bammi/atari/mint/mintlib/include -I.
XCPP	= /lib/cpp
XAS 	= $(CC)
XLIB     = $(CROSSLIB)
XINC	= $(CROSSINC)
XMAKE	= /util/gnu/bin/make
X
XMAKEFLAGS = CC='$(CC)' CPP='$(CPP)' AS='$(AS)' AR='$(AR)' \
X XFLAGS='$(XFLAGS)' LIB='$(LIB)' INC='$(INC)'
X
X#all: lshort llong lgshort lglong
Xall: lshort llong
X
Xlshort:
X	$(MAKE) -f Mmakefile.16 clean
X	$(MAKE) -f Mmakefile.16 $(MAKEFLAGS) all 
X	$(MAKE) -f Mmakefile.16 $(MAKEFLAGS) install
X
Xllong:
X	$(MAKE) -f Mmakefile.32 clean
X	$(MAKE) -f Mmakefile.32 $(MAKEFLAGS) all
X	$(MAKE) -f Mmakefile.32 $(MAKEFLAGS) install
X
Xlgshort:
X	$(MAKE) -f gMmakefile.16 clean
X	$(MAKE) -f gMmakefile.16 $(MAKEFLAGS) all
X	$(MAKE) -f gMmakefile.16 $(MAKEFLAGS) install
X
Xlglong:
X	$(MAKE) -f gMmakefile.32 clean
X	$(MAKE) -f gMmakefile.32 $(MAKEFLAGS) all
X	$(MAKE) -f gMmakefile.32 $(MAKEFLAGS) install
X
Xclean:
X	$(MAKE) -f Mmakefile.16 clean
X	$(MAKE) -f Mmakefile.32 clean
X
Xrealclean:
X	$(MAKE) -f Mmakefile.16 realclean
X	$(MAKE) -f Mmakefile.32 realclean
X	rm -f core report
SHAR_EOF
if test 1261 -ne "`cat 'Makefile.mint' | wc -c`"
then
	echo shar: error transmitting "'Makefile.mint'" '(should have been 1261 characters)'
fi
echo shar: extracting "'diffs'" '(13190 characters)'
if test -f 'diffs'
then
	echo shar: over-writing existing file "'diffs'"
fi
sed 's/^X//' << \SHAR_EOF > 'diffs'
X*** 1.3	1990/02/23 17:55:21
X--- ChangeLog	1990/11/28 14:12:18
X***************
X*** 25,27 ****
X--- 25,47 ----
X  
X  tstp.c:: ++jrb
X  	#if 0'ed out for now till be get the new signal code together
X+ 
X+ xconsole.c: ers
X+ 	Re-written to be compatible with lib/console.c. It should now
X+ 	work over the RS232 (not tested).
X+ 
X+ addbytes.c:: ++jrb
X+ 	corrected handling of tabs.
X+ 
X+ makefile* :: ++jrb
X+ 	adjusted to use common include file mincl (as per lib etc)
X+ 	(Delete old CMakefile.*). makefile.?? and gmakefile.?? new
X+ 	files.
X+ 
X+ tgetent.c:: ers
X+ 	allowed TERMCAP to have a drive specification, and got rid of
X+ 	the silly "strcmp(TERMCAP, TERM)" test when TERMCAP contains
X+ 	the definition directly (I think what's wanted is a check that
X+ 	the name in TERM matches the name in TERMCAP, but it shouldn't
X+ 	normally be a problem anyways)
X+ 	also: cleaned up the default definition somewhat.
X*** 1.3	1990/02/23 17:55:23
X--- PatchLevel.h	1990/11/28 14:12:19
X***************
X*** 1,5 ****
X  /*
X!  *	PathLevel: 5
X   *
X   *	the Patch Level above is to identify the version
X   *	of the all the files in this directory. given the above
X--- 1,5 ----
X  /*
X!  *	PathLevel: 7
X   *
X   *	the Patch Level above is to identify the version
X   *	of the all the files in this directory. given the above
X*** 1.2	1989/08/07 00:19:43
X--- addbytes.c	1990/11/28 14:12:20
X***************
X*** 46,56 ****
X  	    c = *bytes++;
X  	    switch (c) {
X  	      case '\t':
X! 		    SYNCH_IN();
X  		    if (waddbytes(win, blanks, 8-(x%8)) == ERR) {
X  			return ERR;
X  		    }
X! 		    SYNCH_OUT();
X  		    break;
X  
X  	      default:
X--- 46,56 ----
X  	    c = *bytes++;
X  	    switch (c) {
X  	      case '\t':
X! 		    SYNCH_OUT();
X  		    if (waddbytes(win, blanks, 8-(x%8)) == ERR) {
X  			return ERR;
X  		    }
X! 		    SYNCH_IN();
X  		    break;
X  
X  	      default:
X*** 1.1	1989/07/19 15:04:48
X--- termcap	1991/03/20 23:26:55
X***************
X*** 2,15 ****
X  # Termcap entries for Atari STs' built in VT52 emulation.
X  #
X  s0|st52|Atari ST:\
X! 	:al=\EL:am:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:dl=\EM:\
X  	:do=^J:eo:ho=\EH:is=\Eq\EE\Ee\Ev:it#8:le=^H:li#25:ll=\EY9!:\
X  	:me=\Eq:mr=\Ep:nd=\EC:rc=\Ek:sc=\Ej:se=\Eq:so=\Ep:ta=^I:\
X! 	:up=\EA:ve=\Ee:vi=\Ef:
X  #
X  # Atari ST with Hi50 hack
X  s1|st52l|Atari ST, 50 line screen:\
X! 	:al=\EL:am:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+!%+!:co#80:dl=\EM:\
X  	:do=^J:eo:ho=\EH:is=\Eq\EE\Ee\Ev:it#8:le=^H:li#50:ll=\EY9!:\
X  	:me=\Eq:mr=\Ep:nd=\EC:rc=\Ek:sc=\Ej:se=\Eq:so=\Ep:ta=^I:\
X! 	:up=\EA:ve=\Ee:vi=\Ef:
X--- 2,62 ----
X  # Termcap entries for Atari STs' built in VT52 emulation.
X  #
X  s0|st52|Atari ST:\
X! 	:al=\EL:am:bl=^G:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:dl=\EM:\
X  	:do=^J:eo:ho=\EH:is=\Eq\EE\Ee\Ev:it#8:le=^H:li#25:ll=\EY9!:\
X  	:me=\Eq:mr=\Ep:nd=\EC:rc=\Ek:sc=\Ej:se=\Eq:so=\Ep:ta=^I:\
X! 	:ti=\Eq\Ev\Ee:up=\EA:ve=\Ee:vi=\Ef:
X  #
X  # Atari ST with Hi50 hack
X  s1|st52l|Atari ST, 50 line screen:\
X! 	:al=\EL:am:bl=^G:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+!%+!:co#80:dl=\EM:\
X  	:do=^J:eo:ho=\EH:is=\Eq\EE\Ee\Ev:it#8:le=^H:li#50:ll=\EY9!:\
X  	:me=\Eq:mr=\Ep:nd=\EC:rc=\Ek:sc=\Ej:se=\Eq:so=\Ep:ta=^I:\
X! 	:ti=\Eq\Ev\Ee:up=\EA:ve=\Ee:vi=\Ef:
X! #
X! # Termcap entry contributed by Lars Bo Nielsen (lbn@iesd.auc.dk)
X! #	Thanks!
X! #
X! #atari|vt52|AtariST:\
X! # (Meta key) (Auto margin (see :ti=)) (cols) (rows) (bell) (CR)
X! #	:km:am:co#80:li#25:bl=^G:cr=^M:\
X! # Position cursor (x, y)
X! #	:cm=\EY%+ %+ :\
X! # Cursor movement (Down) (Up) (Left) (Right)
X! #	:do=\EB:up=\EA:le=\ED:nd=\EC:\
X! # Home cursor (clear screen) (don't clear screen)
X! #	:cl=\EE:ho=\EH:\
X! # Send by BS key
X! #	:kb=^H:\
X! # Save and restore cursor position
X! #	:sc=\Ej:rc=\Ek:\
X! # Cursor appearance (normal) (invisible)
X! #	:ve=\Ee:vi=\Ef:\
X! # Stand out mode (reverse video on) (reverse video off)
X! #	:so=\Ep:se=\Eq:\
X! # Lines (Add line) (Clear to EOL) (Delete line)
X! #	:al=\EL:ce=\EK:dl=\EM:\
X! # Clear to end of display
X! #	:cd=\EJ:\
X! # Terminal initialization (auto-wrap since :am: set, cursor on)
X! #	:ti=\Ev\Ee:\
X! # Scroll text down
X! #        :sr=\EI:\
X! # Hardware tabs (send CTRL I) (8 space/tab) (has hardware tabs)
X! #	:ta=^I:it#8:pt:
X! #
X! # ATARI ST termcap entry (without comments)
X! atari|vt52|AtariST:\
X! 	:km:am:co#80:li#25:bl=^G:cr=^M:\
X! 	:cm=\EY%+ %+ :\
X! 	:do=\EB:up=\EA:le=\ED:nd=\EC:\
X! 	:cl=\EE:ho=\EH:\
X! 	:kb=^H:\
X! 	:sc=\Ej:rc=\Ek:\
X! 	:ve=\Ee:vi=\Ef:\
X! 	:so=\Ep:se=\Eq:\
X! 	:al=\EL:ce=\EK:dl=\EM:\
X! 	:cd=\EJ:\
X! 	:ti=\Ev\Ee:\
X!         :sr=\EI:\
X! 	:ta=^I:it#8:pt:
X*** 1.2	1989/08/07 00:20:23
X--- tgetent.c	1990/11/28 14:12:46
X***************
X*** 51,61 ****
X--- 51,65 ----
X   *	variable called TERMCAP to be the pathname of the desired
X   *	termcap file.  This is useful for debugging new entries.
X   *	NOTE: the pathname MUST begin with a '/' character.
X+  *      (Atari ST specific change: the pathname may begin with '\',
X+  *       or with a drive letter followed by ':').
X   *
X   *	Also, if the string assigned to TERMCAP does not begin with
X   *	a '/' and if the environment variable TERM matches <name> then
X   *	the string assigned to TERMCAP is copied to buffer <bp> 
X   *	instead of reading a termcap file.
X+  *      (Atari ST specific change: TERM is no longer checked (the
X+  *       check was buggy).
X   *
X   *	Modification by ERS: if no termcap file can be found, then
X   *	a default termcap is used (this is for GEMDOS).
X***************
X*** 224,232 ****
X   *
X   */
X  
X! static char term_default[] = "s0|st52|Atari ST\
X  :al=\\EL:am:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%+ %+ :co#80:dl=\\EM\
X! :do=^J:eo:ho=\\EH:is=\\Eq\\EE\\Ee\\Ev:it#8:le=^H:li#25:ll=\\EY9!\
X  :me=\\Eq:mr=\\Ep:nd=\\EC:rc=\\Ek:sc=\\Ej:se=\\Eq:so=\\Ep:ta=^I\
X  :up=\\EA:ve=\\Ee:vi=\\Ef:";
X  
X--- 228,236 ----
X   *
X   */
X  
X! static char term_default[] = "df|default|Atari default\
X  :al=\\EL:am:bs:cd=\\EJ:ce=\\EK:cl=\\EE:cm=\\EY%+ %+ :co#80:dl=\\EM\
X! :do=\\EB:eo:ho=\\EH:is=\\Eq\\EE\\Ee\\Ev:it#8:le=^H:li#25:ll=\\EY9!\
X  :me=\\Eq:mr=\\Ep:nd=\\EC:rc=\\Ek:sc=\\Ej:se=\\Eq:so=\\Ep:ta=^I\
X  :up=\\EA:ve=\\Ee:vi=\\Ef:";
X  
X***************
X*** 238,253 ****
X  
X      if ((cp = getenv("TERMCAP")) != NULL) {
X  	if (*cp != '\0') {
X! 	    if (*cp == '/' || *cp == '\\') {
X  		if ((fp = fopen(cp,"r")) != NULL) {
X  		    return(fp);
X  		}
X  	    } else {
X  		if ((ncp = getenv("TERM")) != NULL) {
X- 		    if (strcmp(cp,ncp) == 0) {
X  			strcpy(bp,cp);
X  			return((FILE *)NULL);
X- 		    }
X  		}
X  	    }
X  	}
X--- 242,255 ----
X  
X      if ((cp = getenv("TERMCAP")) != NULL) {
X  	if (*cp != '\0') {
X! 	    if (*cp == '/' || *cp == '\\' || (cp[1] == ':')) {
X  		if ((fp = fopen(cp,"r")) != NULL) {
X  		    return(fp);
X  		}
X  	    } else {
X  		if ((ncp = getenv("TERM")) != NULL) {
X  			strcpy(bp,cp);
X  			return((FILE *)NULL);
X  		}
X  	    }
X  	}
X*** 1.2	1989/08/07 00:20:27
X--- tgoto.c	1990/11/28 14:12:48
X***************
X*** 134,139 ****
X--- 134,140 ----
X  		process();
X  	    }
X  	}
X+  	*out = 0;
X  	return(output);
X      }
X  }
X*** 1.1	1989/07/19 15:04:55
X--- xconsole.c	1990/11/28 14:12:52
X***************
X*** 1,20 ****
X  /* Replacement console read/write routines that allow for key
X     remappings */
X! /* Written by Eric R. Smith for the Atari ST computer, and placed
X!    in the public domain */
X  
X  #include <osbind.h>
X  #include <support.h>
X- #include <keycodes.h>
X  #include <stdlib.h>
X! #include <string.h>
X  
X  #define S_SHIFT 0x03
X  #define S_CNTRL	0x04
X  #define S_ALT	0x08
X  
X! static char *__strdup(char **, char *);
X! #define STRDUP(x, y) __strdup(&x, y)
X  
X  /* arrays to hold keyboard strings */
X  
X--- 1,33 ----
X  /* Replacement console read/write routines that allow for key
X     remappings */
X! /* 
X!  * console input/output routines.
X!  * written by Eric R. Smith and placed in the public domain
X!  */
X! 
X! /*
X!  * BUGS: assumes all input is coming from the same place;
X!  * this bug shows up only when keys are remapped, though.
X!  */
X  
X  #include <osbind.h>
X  #include <support.h>
X  #include <stdlib.h>
X! #include <ioctl.h>
X! #include <tchars.h>
X! #include <signal.h>
X! #include <unixlib.h>
X! #include <keycodes.h>
X! 
X! extern char *strdup();
X! #define STRDUP(x,y) if (x) free(x); x = strdup(y);
X  
X  #define S_SHIFT 0x03
X  #define S_CNTRL	0x04
X  #define S_ALT	0x08
X  
X! extern int _console_dev;	/* in main.c */
X! int __check_signals = 0;
X  
X  /* arrays to hold keyboard strings */
X  
X***************
X*** 30,36 ****
X  
X  	if (regular) {
X  		if (!*regular) regular = 0;
X! 		STRDUP(kb_unshft[keycode], regular);
X  	}
X  	if (shifted) {
X  		if (!*shifted) shifted = 0;
X--- 43,49 ----
X  
X  	if (regular) {
X  		if (!*regular) regular = 0;
X! 		STRDUP(kb_unshft[keycode],regular);
X  	}
X  	if (shifted) {
X  		if (!*shifted) shifted = 0;
X***************
X*** 48,61 ****
X  	}
X  }
X  
X! /* NOTE: all input is assumed to come from the standard input */
X  
X  unsigned int console_read_byte(handle)
X  int handle;
X  {
X! 	long r;
X  	unsigned scan, key, shft;
X  
X  	if (_str) {
X  		if (*_str)
X  			return *(unsigned char *)_str++;
X--- 61,164 ----
X  	}
X  }
X  
X! #define KBUFSIZ 80
X! #define NUMDEV	3
X! 	/* 0 == prn:, 1 == aux:, 2 == con: */
X! 
X! typedef struct _buffer {
X! 	short head, tail;
X! 	long  buffer[KBUFSIZ];
X! } k_buf;
X! 
X! k_buf in_buf[NUMDEV];
X! #define IN_BUF(dev) (&in_buf[(dev) > 2 ? _console_dev : (dev)])
X! 
X! /*
X!  * what handle means:: 0-2: BIOS handle, 3: stdout, 4: stderr
X!  */
X! 
X! static short
X! LOOKUP(handle)
X! short handle;
X! {
X! 	switch(handle) {
X! 	case -3:
X! 	case -2:
X! 	case -1:
X! 	case 0:
X! 		return handle + 3;
X! 	case 2:
X! 		return 4;
X! 	case 1:
X! 		if (isatty(0)) return 3;
X! 		if (isatty(2)) return 4;
X! 		/* else fall through */
X! 	default:
X! 		return _console_dev;
X! 	}
X! }
X! 
X! /*
X!  * raw i/o routines
X!  */
X! 
X! static long
X! raw_in(dev)
X! int dev;
X! {
X! 	if (dev < 3)
X! 		return Bconin(dev);
X! 	else if (dev == 3)
X! 		return Crawcin();
X! 	else
X! 		return Cauxin();
X! }
X! 
X! static void
X! raw_out(dev, c)
X! int dev, c;
X! {
X! 	if (dev < 3)
X! 		Bconout(dev, c);
X! 	else if (dev == 3)
X! 		Crawio(c);
X! 	else
X! 		Cauxout(c);
X! }
X! 
X! static long
X! raw_instat(dev)
X! int dev;
X! {
X! 	if (dev < 3)
X! 		return Bconstat(dev);
X! 	else if (dev == 3)
X! 		return Cconis();
X! 	else
X! 		return Cauxis();
X! }
X! 
X! /*
X!  * somewhat less raw i/o routines. The main difference is that these ones
X!  * will check for pending input before doing output, to see if a signal
X!  * needs to be raised. This is only done if __check_signals is non-zero;
X!  * signal() should set __check_signals when the user attempts to catch
X!  * SIGINT or SIGQUIT. We don't do this checking all the time because
X!  * the user may be typing ahead input for another program (e.g. if this
X!  * is a little utility of some sort) and we shouldn't steal keystrokes
X!  * unless necessary.
X!  */
X  
X  unsigned int console_read_byte(handle)
X  int handle;
X  {
X! 	k_buf *p;
X! 	short i, j, dev;
X  	unsigned scan, key, shft;
X+ 	long r;
X  
X+ 	dev = LOOKUP(handle);
X+ 
X  	if (_str) {
X  		if (*_str)
X  			return *(unsigned char *)_str++;
X***************
X*** 62,68 ****
X  		else
X  			_str = 0;
X  	}
X! 	r = Crawcin();
X  	scan = (r & 0x00ff0000) >> 16;
X  	key = r & 0x00ff;
X  	if (scan > 0 && scan < N_KEYCODES) {
X--- 165,182 ----
X  		else
X  			_str = 0;
X  	}
X! 
X! 	p = IN_BUF(dev);
X! 	if ( p->head != (i = p->tail)) {
X! 		j = p->tail + 1;
X! 		if (j >= KBUFSIZ)
X! 			j = 0;
X! 		p->tail = j;
X! 		r = p->buffer[i];
X! 	}
X! 	else
X! 		r = raw_in(dev);
X! 
X  	scan = (r & 0x00ff0000) >> 16;
X  	key = r & 0x00ff;
X  	if (scan > 0 && scan < N_KEYCODES) {
X***************
X*** 81,90 ****
X  int console_input_status(handle)
X  int handle;
X  {
X! 	return (_str && *_str) ? 1 : Cconis();
X! }
X  
X! /* The write routine, on the other hand, is completely general */
X  
X  void
X  console_write_byte(handle, n)
X--- 195,208 ----
X  int console_input_status(handle)
X  int handle;
X  {
X! 	short dev;
X! 	k_buf *p;
X  
X! 	if (_str && *_str) return 1;
X! 	dev = LOOKUP(handle);
X! 	p = IN_BUF(dev);
X! 	return (p->head != p->tail) || raw_instat(dev);
X! }
X  
X  void
X  console_write_byte(handle, n)
X***************
X*** 91,113 ****
X  int handle;
X  int n;
X  {
X!   char c = (char) n;
X!   Fwrite(handle, 1L, &c);
X! }
X! 
X! /* routine to duplicate a string for the console input routines */
X! 
X! static
X! char *__strdup(char **x, char *y)
X! {
X! 	char *s = *x;
X! 
X! 	if (s) free(s);
X! 	if (y) {
X! 		s = malloc(strlen(y)+1);
X! 		strcpy(s, y);
X  	}
X! 	else
X! 		s = 0;
X! 	*x = s;
X  }
X--- 209,253 ----
X  int handle;
X  int n;
X  {
X! 	long c;
X! 	short i, j, waiting = 0;
X! 	char ch;
X! 	k_buf *p;
X! 	short dev;
X! 
X! 	dev = LOOKUP(handle);
X! 	p = IN_BUF(dev);
X! restart:
X! 	while (__check_signals && (raw_instat(dev) || waiting)) {
X! 		c = raw_in(dev);
X! 		if (!(__ttymode & RAW)) {
X! 			ch = c & 0xff;
X! 			if (ch == ('S'-'@')) {
X! 				waiting = 1;
X! 			}
X! 			else if (ch == ('Q'-'@')) {
X! 				waiting = 0;
X! 			}
X! 			else if (ch == __tchars[TC_INTRC]) {
X! 				p->head = p->tail;
X! 				raise(SIGINT);
X! 			}
X! 			else if (ch == __tchars[TC_QUITC]) {
X! 				p->head = p->tail;
X! 				raise(SIGQUIT);
X! 			}
X! 			else if (!waiting) {
X! 				i = p->head;
X! 				j = i + 1;
X! 				if (j >= KBUFSIZ) j = 0;
X! 				if (j != p->tail) {
X! 					p->buffer[i] = c;
X! 					p->head = j;
X! 				}
X! 			}
X! 		}
X  	}
X! /*	raw_out(dev, n); */
X! 	ch = n;
X! 	Fwrite(handle, 1L, &ch);
X  }
SHAR_EOF
if test 13190 -ne "`cat 'diffs' | wc -c`"
then
	echo shar: error transmitting "'diffs'" '(should have been 13190 characters)'
fi
echo shar: extracting "'makefile.16'" '(832 characters)'
if test -f 'makefile.16'
then
	echo shar: over-writing existing file "'makefile.16'"
fi
sed 's/^X//' << \SHAR_EOF > 'makefile.16'
X# Makefile for the GCC curses/termcap library (16 bit int default)
X
XCC= d:\gnu\bin\gcc.ttp
XCPP=d:\gnu\bin\gcc-cpp.ttp
XAR= d:\gnu\bin\gcc-ar.ttp
XAS= $(CC)
XLIB = d:\gnu\lib
XINC = d:\gnu\include
X
XMODEL = -mshort
XDEFINES = -DDGK -DGEMDOS
XCOPTS= -O -fomit-frame-pointer -fcombine-regs -fstrength-reduce \
X -DNDEBUG $(DEFINES) $(XFLAGS)
X
X# normal CFLAGS
XCFLAGS= $(MODEL) $(COPTS)
X
X# CFLAGS sans -fomit-frame-pointer
XCFFLAGS = $(MODEL) -O -DNDEBUG $(DEFINES)
X
X# cflags for stuff that needs to be compiled with 32 bit ints
XCLFLAGS= $(COPTS) -DSHORTLIB
X
X# flags to $(CC) when it runs the assembler only
XASFLAGS= -c
X
X# pre-processor flags
XPPFLAGS= -P -D__MSHORT__ -DNDEBUG
X
X# library targets
XCURSES= curses16.olb
XTERMCAP = termcap16.olb
X
X# the stuff to make
XALL= $(CURSES) $(TERMCAP)
X
XTESTS = testtcp.ttp twinkle.ttp worms.ttp
X
Xinclude mincl
SHAR_EOF
if test 832 -ne "`cat 'makefile.16' | wc -c`"
then
	echo shar: error transmitting "'makefile.16'" '(should have been 832 characters)'
fi
echo shar: extracting "'makefile.32'" '(837 characters)'
if test -f 'makefile.32'
then
	echo shar: over-writing existing file "'makefile.32'"
fi
sed 's/^X//' << \SHAR_EOF > 'makefile.32'
X# Makefile for the GCC curses/termcap library (32 bit int default)
X
XCC= d:\gnu\bin\gcc.ttp
XCPP=d:\gnu\bin\gcc-cpp.ttp
XAR= d:\gnu\bin\gcc-ar.ttp
XAS= $(CC)
XLIB = d:\gnu\lib
XINC = d:\gnu\include
X
XMODEL =
XDEFINES = -DDGK -DGEMDOS
XCOPTS= -O -fomit-frame-pointer -fcombine-regs -fstrength-reduce \
X -DNDEBUG $(DEFINES) $(XFLAGS)
X
X# normal CFLAGS
XCFLAGS= $(MODEL) $(COPTS)
X
X# CFLAGS sans -fomit-frame-pointer
XCFFLAGS = $(MODEL) -O -DNDEBUG
X
X# cflags for stuff that needs to be compiled with 32 bit ints
X# (this def is needed for the common include file)
XCLFLAGS= $(CFLAGS)
X
X# flags to $(CC) when it runs the assembler only
XASFLAGS= -c
X
X# pre-processor flags
XPPFLAGS= -P -DNDEBUG
X
X# library targets
XCURSES= curses.olb
XTERMCAP = termcap.olb
X
X# the stuff to make
XALL= $(CURSES) $(TERMCAP)
X
XTESTS = testtcp.ttp twinkle.ttp worms.ttp
X
Xinclude mincl
SHAR_EOF
if test 837 -ne "`cat 'makefile.32' | wc -c`"
then
	echo shar: error transmitting "'makefile.32'" '(should have been 837 characters)'
fi
echo shar: extracting "'mincl'" '(1111 characters)'
if test -f 'mincl'
then
	echo shar: over-writing existing file "'mincl'"
fi
sed 's/^X//' << \SHAR_EOF > 'mincl'
XCURSEOBJ = addbytes.o addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o \
X	cr_put.o cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o \
X	erase.o fullname.o getch.o getstr.o id_subwin.o idlok.o \
X	initscr.o insch.o insertln.o longname.o move.o mvprintw.o \
X	mvscanw.o mvwin.o newwin.o overlay.o overwrite.o printw.o \
X	putchar.o refresh.o scanw.o scroll.o standout.o toucholap.o \
X	touchwin.o tstp.o unctrl.o
X
XTERMOBJ =	tgetent.o tgetflag.o tgetnum.o tgetstr.o tgoto.o \
X		tputs.o isdigit.o fgetlr.o
X
XOTHER = xconsole.o
X
Xall: $(ALL)
X
X$(CURSES) : $(CURSEOBJ) $(TERMOBJ) $(OTHER)
X	rm -f $@
X	$(AR) rs $@ $^
X
X$(TERMCAP): $(TERMOBJ) $(OTHER)
X	rm -f $@
X	$(AR) rs $@ $^
X
Xinstall: $(ALL)
X	cp $(ALL) $(LIB)
X	cp curses.h $(INC)
X
X
Xclean :
X	rm -f $(CURSEOBJ) $(TERMOBJ) $(OTHER) $(TESTS)
X
Xrealclean : clean
X	rm -f $(ALL) report core
X
Xtests: $(TESTS)
X
Xtesttcp.ttp: testtcp.o
X	$(CC) $(MODEL) -o testtcp.ttp testtcp.o -l$(CURSES)
X
Xtwinkle.ttp: twinkle.o
X	$(CC) $(MODEL) -o twinkle.ttp twinkle.o -l$(CURSES)
X
Xworms.ttp: worms.o
X	$(CC) $(MODEL) -o worms.ttp worms.o -l$(CURSES)
X
X.PHONY: install clean realclean tests all
SHAR_EOF
if test 1111 -ne "`cat 'mincl' | wc -c`"
then
	echo shar: error transmitting "'mincl'" '(should have been 1111 characters)'
fi
echo shar: extracting "'testtab.c'" '(409 characters)'
if test -f 'testtab.c'
then
	echo shar: over-writing existing file "'testtab.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'testtab.c'
X#include <curses.h>
X
Xmain()
X{
X    initscr();
X    clear();
X    move(9,0);
X    addstr("123456781234567812345678123456781234567812345678");
X
X    move(10,0);
X    addch('\t'); addch('8'); addch('\t'); addch('8'); addch('\t'); addch('8');
X    addch('\t'); addch('8');
X
X    move(15,0);
X    addstr("\t8\t8\t8\t8");
X
X    move(17,0); addstr("hit return to finish -->");
X    refresh();
X    getch();
X    endwin();
X}
X
X    
SHAR_EOF
echo shar: a missing newline was added to "'testtab.c'"
if test 409 -ne "`cat 'testtab.c' | wc -c`"
then
	echo shar: error transmitting "'testtab.c'" '(should have been 409 characters)'
fi
#	End of shell archive
exit 0
--
bang:   uunet!cadence!bammi			jwahar r. bammi
domain: bammi@cadence.com
GEnie:	J.Bammi
CIS:    71515,155