*** tcl.h.orig	Fri Jun 12 15:52:49 1998
--- tcl.h	Wed Jun 17 21:28:59 1998
***************
*** 1432,1437 ****
--- 1432,1444 ----
  	        	    char *chanName, int *modePtr));
  EXTERN int		Tcl_GetChannelBufferSize _ANSI_ARGS_((
      			    Tcl_Channel chan));
+ 
+ /* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+  * Support of Tcl-Trf (binio).
+  */
+ EXTERN int	Tcl_GetChannelByteorder _ANSI_ARGS_((
+     			    Tcl_Channel chan));
+ 
  EXTERN int		Tcl_GetChannelHandle _ANSI_ARGS_((Tcl_Channel chan,
  	        	    int direction, ClientData *handlePtr));
  EXTERN ClientData	Tcl_GetChannelInstanceData _ANSI_ARGS_((
*** tclIO.c.orig	Fri Jun 12 15:52:49 1998
--- tclIO.c	Wed Jun 17 21:28:59 1998
***************
*** 154,159 ****
--- 154,165 ----
  				 * data bytes.  May be TCL_ENCODING_START
  				 * before converting first byte and
  				 * TCL_ENCODING_END when EOF is seen. */
+ 
+   /* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+    * Support of Tcl-Trf (binio).
+    */
+   int byteOrder; /* byteorder associated to this channel */
+ 
      Tcl_EolTranslation inputTranslation;
  				/* What translation to apply for end of line
                                   * sequences on input? */    
***************
*** 465,470 ****
--- 471,484 ----
  static int		WriteChars _ANSI_ARGS_((Channel *chanPtr,
  			    CONST char *src, int srcLen));
  
+ /* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+  * Support of Tcl-Trf (binio).
+  */
+ static int Tcl_GetHostByteorder _ANSI_ARGS_ (());
+ 
+ #define TCL_BIGENDIAN   (0) /* Multibyte words are stored with MSB first */
+ #define TCL_SMALLENDIAN (1) /* Multibyte words are stored with MSB last  */
+ 
  
  /*
   *---------------------------------------------------------------------------
***************
*** 1273,1278 ****
--- 1287,1297 ----
       * indicator (e.g. ^Z) and does not append an EOF indicator to files.
       */
  
+     /* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+      * Support of Tcl-Trf (binio).
+      */
+     chanPtr->byteOrder = Tcl_GetHostByteorder ();
+ 
      chanPtr->inputTranslation = TCL_TRANSLATE_AUTO;
      chanPtr->outputTranslation = TCL_PLATFORM_TRANSLATION;
      chanPtr->inEofChar = 0;
***************
*** 4890,4896 ****
  {
      if (interp) {
  	CONST char *genericopt = 
! 	    	"blocking buffering buffersize eofchar translation";
  	char **argv;
  	int  argc, i;
  	Tcl_DString ds;
--- 4909,4915 ----
  {
      if (interp) {
  	CONST char *genericopt = 
! 	    	"blocking buffering buffersize byteorder eofchar translation";
  	char **argv;
  	int  argc, i;
  	Tcl_DString ds;
***************
*** 4920,4925 ****
--- 4939,5002 ----
      return TCL_ERROR;
  }
  
+ /* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+  * Support of Tcl-Trf (binio).
+  */
+ /*
+  *----------------------------------------------------------------------
+  *
+  * Tcl_GetChannelByteorder --
+  *
+  *	Retrieves the byteorder set for this channel.
+  *
+  * Results:
+  *	The size.
+  *
+  * Side effects:
+  *	None.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ int
+ Tcl_GetChannelByteorder(chan)
+     Tcl_Channel chan;		/* The channel for which to find the
+                                  * buffer size. */
+ {
+     Channel *chanPtr;
+ 
+     chanPtr = (Channel *) chan;
+     return chanPtr->byteOrder;
+ }
+ 
+ /*
+  *----------------------------------------------------------------------
+  *
+  * Tcl_GetHostByteorder --
+  *
+  *	Retrieves the byteorder of the machine we are running on.
+  *
+  * Results:
+  *	The size.
+  *
+  * Side effects:
+  *	None.
+  *
+  *----------------------------------------------------------------------
+  */
+ 
+ static int
+ Tcl_GetHostByteorder()
+ {
+   union {
+     char c[sizeof(short)];
+     short s;
+   } order;
+ 
+   order.s = 1;
+   return (order.c[0] == 1) ? TCL_SMALLENDIAN : TCL_BIGENDIAN;
+ }
+ 
  /*
   *----------------------------------------------------------------------
   *
***************
*** 5040,5045 ****
--- 5117,5139 ----
  	    return TCL_OK;
  	}
      }
+ 
+     /* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+      * Support of Tcl-Trf (binio).
+      */
+     if ((len == 0) || ((len > 2) && (optionName[1] == 'b') &&
+ 		       (strncmp(optionName, "-byteorder", len) == 0))) {
+       if (len == 0) {
+         Tcl_DStringAppendElement(dsPtr, "-byteorder");
+       }
+       Tcl_DStringAppendElement(dsPtr,
+ 			       (chanPtr->byteOrder == TCL_BIGENDIAN) ?
+ 			       "bigendian" : "smallendian");
+       if (len > 0) {
+         return TCL_OK;
+       }
+     }
+ 
      if ((len == 0) ||
              ((len > 2) && (optionName[1] == 'e') &&
                      (strncmp(optionName, "-eofchar", len) == 0))) {
***************
*** 5235,5240 ****
--- 5329,5367 ----
          if ((chanPtr->bufSize < 10) || (chanPtr->bufSize > (1024 * 1024))) {
              chanPtr->bufSize = CHANNELBUFFER_DEFAULT_SIZE;
          }
+ 
+ 	/* Andreas Kupries <a.kupries@westend.com>, 05/31/1997.
+ 	 * Support of Tcl-Trf (binio).
+ 	 */
+     } else if ((len > 2) && (optionName[1] == 'b') &&
+ 	       (strncmp(optionName, "-byteorder", len) == 0)) {
+       int nv_len = strlen (newValue);
+ 
+       if ((nv_len > 0) &&
+ 	  (strncmp (newValue, "smallendian", nv_len) == 0)) {
+ 	chanPtr->byteOrder = TCL_SMALLENDIAN;
+ 	return TCL_OK;
+       } else if ((nv_len > 0) &&
+ 		 (strncmp (newValue, "littleendian", nv_len) == 0)) {
+ 	chanPtr->byteOrder = TCL_SMALLENDIAN;
+ 	return TCL_OK;
+       } else if ((nv_len > 0) &&
+ 		 (strncmp (newValue, "network", nv_len) == 0)) {
+ 	chanPtr->byteOrder = TCL_BIGENDIAN;
+ 	return TCL_OK;
+       } else if ((nv_len > 0) &&
+ 		 (strncmp (newValue, "bigendian", nv_len) == 0)) {
+ 	chanPtr->byteOrder = TCL_BIGENDIAN;
+ 	return TCL_OK;
+       } 
+ 
+       if (interp != (Tcl_Interp *) NULL) {
+ 	Tcl_AppendResult(interp,
+ 			 "bad value for -byteorder: ",
+ 			 "must be one of smallendian, littleendian, bigendian or network",
+ 			 (char *) NULL);
+       }
+       return TCL_ERROR;
      } else if ((len > 2) && (optionName[1] == 'e') &&
  	    (strncmp(optionName, "-encoding", len) == 0)) {
  	Tcl_Encoding encoding;
