Diff
Not logged in

Differences From Artifact [62e3866f41]:

To Artifact [acc8a7797d]:


1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19











-
+







/*
 * tclWinConsole.c --
 *
 *	This file implements the Windows-specific console functions, and the
 *	"console" channel driver.
 *
 * Copyright (c) 1999 by Scriptics Corp.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinConsole.c,v 1.11.4.11 2010/05/14 13:31:52 dgp Exp $
 * RCS: @(#) $Id: tclWinConsole.c,v 1.11.4.12 2010/09/13 16:57:03 dgp Exp $
 */

#include "tclWinInt.h"

#include <sys/stat.h>

/*
193
194
195
196
197
198
199
200

201
202

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

219
220

221
222
223
224
225
226
227
193
194
195
196
197
198
199

200


201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

217


218
219
220
221
222
223
224
225







-
+
-
-
+















-
+
-
-
+







    HANDLE hConsole,
    LPVOID lpBuffer,
    DWORD nbytes,
    LPDWORD nbytesread)
{
    DWORD ntchars;
    BOOL result;
    int tcharsize;
    int tcharsize = sizeof(TCHAR);
    tcharsize = tclWinProcs->useWide? 2 : 1;
    result = tclWinProcs->readConsoleProc(
    result = ReadConsole(
	    hConsole, lpBuffer, nbytes / tcharsize, &ntchars, NULL);
    if (nbytesread)
	*nbytesread = (ntchars*tcharsize);
    return result;
}

static BOOL
writeConsoleBytes(
    HANDLE hConsole,
    const void *lpBuffer,
    DWORD nbytes,
    LPDWORD nbyteswritten)
{
    DWORD ntchars;
    BOOL result;
    int tcharsize;
    int tcharsize = sizeof(TCHAR);
    tcharsize = tclWinProcs->useWide? 2 : 1;
    result = tclWinProcs->writeConsoleProc(
    result = WriteConsole(
	    hConsole, lpBuffer, nbytes / tcharsize, &ntchars, NULL);
    if (nbyteswritten)
	*nbyteswritten = (ntchars*tcharsize);
    return result;
}

/*
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412





1413
1414
1415
1416
1417
1418
1419
1399
1400
1401
1402
1403
1404
1405





1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417







-
-
-
-
-
+
+
+
+
+







    /*
     * Files have default translation of AUTO and ^Z eof char, which means
     * that a ^Z will be accepted as EOF when reading.
     */

    Tcl_SetChannelOption(NULL, infoPtr->channel, "-translation", "auto");
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-eofchar", "\032 {}");
    if (tclWinProcs->useWide)
	Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", "unicode");
    else
	Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", encoding);

#ifdef UNICODE
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", "unicode");
#else
    Tcl_SetChannelOption(NULL, infoPtr->channel, "-encoding", encoding);
#endif
    return infoPtr->channel;
}

/*
 *----------------------------------------------------------------------
 *
 * ConsoleThreadActionProc --