1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
*** tcl.h.orig Fri Dec 4 04:02:25 1998
--- tcl.h Tue Dec 15 00:32:08 1998
***************
*** 1495,1500 ****
--- 1495,1507 ----
char *chanName, int *modePtr));
EXTERN int Tcl_GetChannelBufferSize _ANSI_ARGS_((
Tcl_Channel chan));
+
+ /* Andreas Kupries <andreas_kupries@users.sourceforge.net>, 05/31/1997.
+ * "Trf-Patch for channels with a switchable byteorder"
+ */
+ 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 Dec 4 04:02:25 1998
--- tclIO.c Tue Dec 15 00:52:07 1998
***************
*** 261,266 ****
--- 261,270 ----
* When set, file events will not be
* delivered for buffered data until
* the state of the channel changes. */
+ /* Andreas Kupries <andreas_kupries@users.sourceforge.net>, 05/31/1997.
+ * "Trf-Patch for channels with a switchable byteorder"
+ */
+ #define CHANNEL_IS_SMALLENDIAN (1<<16) /* Multibyte words are stored with MSB last */
/*
* For each channel handler registered in a call to Tcl_CreateChannelHandler,
***************
*** 1241,1246 ****
--- 1245,1264 ----
CONST char *name;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+ /* Andreas Kupries <andreas_kupries@users.sourceforge.net>, 05/31/1997.
+ * "Trf-Patch for channels with a switchable byteorder"
+ * Location: Tcl_CreateChannel.
+ */
+ union {
+ char c[sizeof(short)];
+ short s;
+ } order;
+
+ order.s = 1;
+ if (order.c[0] == 1) {
+ mask |= CHANNEL_IS_SMALLENDIAN;
+ }
+
chanPtr = (Channel *) ckalloc((unsigned) sizeof(Channel));
if (chanName != (char *) NULL) {
***************
*** 4924,4930 ****
{
if (interp) {
CONST char *genericopt =
! "blocking buffering buffersize eofchar translation";
char **argv;
int argc, i;
Tcl_DString ds;
--- 4942,4948 ----
{
if (interp) {
CONST char *genericopt =
! "blocking buffering buffersize byteorder eofchar translation";
char **argv;
int argc, i;
Tcl_DString ds;
***************
*** 4954,4959 ****
--- 4972,5009 ----
return TCL_ERROR;
}
+ /* Andreas Kupries <andreas_kupries@users.sourceforge.net>, 05/31/1997.
+ * "Trf-Patch for channels with a switchable byteorder"
+ * Exported functionality.
+ */
+
+ /*
+ *----------------------------------------------------------------------
+ *
+ * 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->flags & CHANNEL_IS_SMALLENDIAN) != 0);
+ }
+
/*
*----------------------------------------------------------------------
*
***************
*** 5074,5079 ****
--- 5124,5148 ----
return TCL_OK;
}
}
+
+ /* Andreas Kupries <andreas_kupries@users.sourceforge.net>, 05/31/1997.
+ * "Trf-Patch for channels with a switchable byteorder"
+ * Location: Tcl_GetChannelOption
+ */
+
+ if ((len == 0) || ((len > 2) && (optionName[1] == 'b') &&
+ (strncmp(optionName, "-byteorder", len) == 0))) {
+ if (len == 0) {
+ Tcl_DStringAppendElement(dsPtr, "-byteorder");
+ }
+ Tcl_DStringAppendElement(dsPtr,
+ (chanPtr->flags & CHANNEL_IS_SMALLENDIAN) ?
+ "smallendian" : "bigendian");
+ if (len > 0) {
+ return TCL_OK;
+ }
+ }
+
if ((len == 0) ||
((len > 2) && (optionName[1] == 'e') &&
(strncmp(optionName, "-eofchar", len) == 0))) {
***************
*** 5269,5274 ****
--- 5338,5378 ----
if ((chanPtr->bufSize < 10) || (chanPtr->bufSize > (1024 * 1024))) {
chanPtr->bufSize = CHANNELBUFFER_DEFAULT_SIZE;
}
+
+ /* Andreas Kupries <andreas_kupries@users.sourceforge.net>, 05/31/1997.
+ * "Trf-Patch for channels with a switchable byteorder"
+ * Location: Tcl_SetChannelOption.
+ */
+
+ } 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->flags |= CHANNEL_IS_SMALLENDIAN;
+ return TCL_OK;
+ } else if ((nv_len > 0) &&
+ (strncmp (newValue, "littleendian", nv_len) == 0)) {
+ chanPtr->flags |= CHANNEL_IS_SMALLENDIAN;
+ return TCL_OK;
+ } else if ((nv_len > 0) &&
+ (strncmp (newValue, "network", nv_len) == 0)) {
+ chanPtr->flags &= ~CHANNEL_IS_SMALLENDIAN;
+ return TCL_OK;
+ } else if ((nv_len > 0) &&
+ (strncmp (newValue, "bigendian", nv_len) == 0)) {
+ chanPtr->flags &= ~CHANNEL_IS_SMALLENDIAN;
+ 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;
|