/*
 * hztty -- version 2.0
 *
 * This program turns a tty session from one encoding to another.
 * For example, running hztty on cxterm can allow you to read/write
 * Chinese in HZ format, which was not supported by cxterm.
 * If you have many applications in different encodings but your
 * favor terminal program only supports one, hztty can make life easy.
 * For example, hztty can your GB cxterm into a HZ terminal, a
 * Unicode (16bit, or UTF8, or UTF7) terminal, or a Big5 terminal.
 * 
 * The idea is to open a new shell session on top of the current one
 * and to translate the encoding between the new tty and the orignal.
 * For example, if your application uses encoding A and your terminal
 * supports encoding B.  Hztty catches the output of the application
 * and converts them from A to B before sending to the terminal.
 * Similarly, hztty converts all the terminal input from B to A before
 * sending to the application.
 *
 * The conversion is implemented in a configurable I/O stream style.
 * Conversion modules are specified in command line options "-O" (for
 * output) and "-I" (for input).  In each direction, conversion modules
 * can be piped one to one using connection character ':'.  For example,
 * specifying "hz2gb:gb2big" in output stream translate the cxterm screen
 * output from zW/HZ to GB, then from GB to Big5.  
 *
 * One interesting application is to emulate a 16bit Unicode terminal
 * on a GB or Big5 terminal.  Although some information is lost (since
 * Unicode is a superset), you get a reasonable environment to try
 * running your Unicode program.
 * 
 *	Yongguang ZHANG 		(ygz@cs.purdue.edu)
 *	Purdue University		August 4, 1992
 * 
 *	Yongguang ZHANG 		(ygz@isl.hrl.hac.com)
 *	Hughes Research	Labs		January 28, 1995
 */


HOW TO MAKE
-----------
	Type "make".  Follow what it tells you.

HOW TO RUN
----------
	In the cxterm, type "hztty".  If sucessful, you will see
	"[hztty start]" and then the new shell prompt.
	To exit hztty, exit the second shell.

	Typically, "hztty" can be used for these purposes:

	 -- To use HZ or a GB cxterm or other GB terminal (e.g., via
	    modem communication on Chinese DOS, TwinBridge, etc.):

		hztty -I gb2hz -O hz2gb

	 -- To use GB on a Big5 cxterm or other Big5 terminal
	    (e.g. on ETen DOS):

		hztty -I big2gb -O gb2big

	 -- To use Big5 on GB cxterm or terminal:

		hztty -I gb2big -O big2gb

	 -- To use HZ or GB on a Big5 cxterm:

		hztty -I big2gb:gb2hz -O hz2gb:gb2big

	 -- To use Unicode UTF8 on a GB cxterm:

		hztty -I gb2uni:uni-utf -O utf-uni:uni2gb

	 -- To use Unicode UTF7 on a Big5 cxterm:

		hztty -I big2uni:uni-utf7 -O utf7-uni:uni2big

	 -- To emulate a real unicode terminal on GB cxterm:

		hztty -I gb2uni -O uni2gb

	All combination are possible, type "hztty -h" for the list
	of supported modules.

NOTICES
-------
	For zW/HZ session, this is _NOT_ a coding-to-coding decoder
	or encoder.  It is your responsibility to conform the HZ
	specification.  This program does not enforce any standard.
	Put all Chinese characters and only Chinese characters
	inside ~{  ~} pairs.  Read the doc/HZ.spec carefully.
	The ~{  ~} pairs are not removed to preserve the one-to-one
	mapping.

	In zW/HZ session, since all the code in zW/HZ encoding are 7-bit,
	"celvis" or "cless" are no long meaningful.  You can simply use
	"vi" or "more".

	Since it's basically a screen viewer, it is impossible to check
	the HZ code for you.  If you put the wrong thing inside ~{  ~}
	pair, you will mess up the line when other people reads it. Go
	double-check it (by redrawing the screen) before posting or mailing.
	Also, don't make your cxterm narrower than 80 columns.

	This is a preliminary release and it is far from satisfaction.
	There are a few notable problems:

	1.  Sometimes it fails to show a HZ even it is in the HZ mode,
	    especially when you are doing editing (e.g. in "vi").
	    In this case you need to redraw the screen (e.g. by 'Ctrl-L')
	    from time to time.  This's a big bug.

	2.  If your cxterm is not 80x24 at the time your run hztty,
	    you may have to type "resize".

PORTABILITY
-----------
	I have strived to make it work for you.  However I simply
	don't have many types of computers to test it.  I expect to
	see some problems in other kind of machines.  If any of these
	comes out, please let me know.  Or, if you have fixed it,
	I appreciate that you can tell me.

	If you see problems like "unable to open /dev/tty..", it is
	likely a portability problem.  However it may also caused by
	someone who didn't logout cleanly.  Try rlogin to yourself
	several time and logout, then try hztty again.

CONTRIBUTORS & TERMS
--------------------
	For an incomplete list of the contributors, see the man page (hztty.1).

	Permission to use, copy, modify, and redistribute is hereby granted.
	The author(s) disclaims all warranties with regarding to this software.

TODO
----
	Lots of them.  Just don't have time.

	To fix all the problems listed above.  They requires the program
	to keep a copy of the screen and parse for every output characters.
	(That is, to implement vt102, what a pain!)

	To add escape keys -- 1) to turn the conversion on/off, 2) to stop
	and escape back to the parent shell.

	Dynamically drop and add conversion modules.

	The following BIG jobs can be done after implementing
	a vt102 in hztty:

	1)  Add conversion modules to facilitate Chinese input.
	    For example, we can write an input module that captures each
	    hanzi you just typed and prompts a list of associated words.
	    Phrase input or associative input can be implemented this way.
	    Hope someone can try this.  Good for a term project.

	2)  With the input/output stream structure, you can easily add
	    real crazy stuffs.  For example, rot13 is added in hack.c.

HISTORY
-------
2.0	jan/95	added Unicode, add code for OSF/Linux/IRIX5, remove et2hku
1.1	aug/93	supports more platforms including Solaris 2
1.0	sep/92	no major bugs have been reported since 0.99
0.99	jul/92	prepare to be version 1.0
0.9b	jul/92	fix for sequent
0.9	jul/92	new io stream structure
0.5	jun/92	major bug-fix for SYSV
0.4	jun/92	minor bug-fix
0.3	jun/92	minor bug-fix, first announced
0.1	jun/92	first working version
0.2	jun/92	minor bug-fix

