diff options
author | Steve Bennett <steveb@workware.net.au> | 2025-02-05 08:53:24 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2025-02-07 16:01:44 +1000 |
commit | caf9aae0155540357e2c68e31685772cdad26786 (patch) | |
tree | 5a5e214ee5101544e9214e770b183d9cd17201d4 /jim-aio.c | |
parent | b1b65e5cd9831b20ac9f27a58de861531be65a96 (diff) | |
download | jimtcl-caf9aae0155540357e2c68e31685772cdad26786.zip jimtcl-caf9aae0155540357e2c68e31685772cdad26786.tar.gz jimtcl-caf9aae0155540357e2c68e31685772cdad26786.tar.bz2 |
aio: add support for translation binary|text
Mainly to support changing stdout,stderr to binary mode
on Windows.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r-- | jim-aio.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -1666,6 +1666,28 @@ static int aio_cmd_buffering(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } +static int aio_cmd_translation(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +{ + enum {OPT_BINARY, OPT_TEXT}; + static const char * const options[] = { + "binary", + "text", + NULL + }; + int opt; + + if (Jim_GetEnum(interp, argv[0], options, &opt, NULL, JIM_ERRMSG) != JIM_OK) { + return JIM_ERR; + } +#if defined(Jim_SetMode) + else { + AioFile *af = Jim_CmdPrivData(interp); + Jim_SetMode(af->fd, opt == OPT_BINARY ? O_BINARY : O_TEXT); + } +#endif + return JIM_OK; +} + static int aio_cmd_readsize(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { AioFile *af = Jim_CmdPrivData(interp); @@ -2182,6 +2204,13 @@ static const jim_subcmd_type aio_command_table[] = { 2, /* Description: Sets or returns write buffering */ }, + { "translation", + "binary|text", + aio_cmd_translation, + 1, + 1, + /* Description: Sets output translation mode */ + }, { "readsize", "?size?", aio_cmd_readsize, |