diff options
author | Steve Bennett <steveb@workware.net.au> | 2016-01-25 09:33:38 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2016-02-01 10:47:13 +1000 |
commit | 79f9dc56a7bfb369e2556659603f99bc34700793 (patch) | |
tree | 814ac5871628ef7f234ffeccaf8c7e72af1c05e1 | |
parent | b7dae50e44da0e637399d89fdedee25c41f28019 (diff) | |
download | jimtcl-79f9dc56a7bfb369e2556659603f99bc34700793.zip jimtcl-79f9dc56a7bfb369e2556659603f99bc34700793.tar.gz jimtcl-79f9dc56a7bfb369e2556659603f99bc34700793.tar.bz2 |
aio: don't set ssl in make channel
It is simpler if af->ssl is handled after creating the channel
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-aio.c | 31 |
1 files changed, 14 insertions, 17 deletions
@@ -274,7 +274,7 @@ static const JimAioFopsType ssl_fops = { static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv); static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename, - const char *hdlfmt, int family, const char *mode, void *ssl); + const char *hdlfmt, int family, const char *mode); #if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) static int JimParseIPv6Address(Jim_Interp *interp, const char *hostport, union sockaddr_any *sa, int *salen) @@ -803,7 +803,7 @@ static int aio_cmd_accept(Jim_Interp *interp, int argc, Jim_Obj *const *argv) /* Create the file command */ return JimMakeChannel(interp, NULL, sock, Jim_NewStringObj(interp, "accept", -1), - "aio.sockstream%ld", af->addr_family, "r+", NULL); + "aio.sockstream%ld", af->addr_family, "r+"); } static int aio_cmd_listen(Jim_Interp *interp, int argc, Jim_Obj *const *argv) @@ -1119,10 +1119,13 @@ static int aio_cmd_ssl(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } } - if (JimMakeChannel(interp, NULL, fd, NULL, "aio.sslstream%ld", af->addr_family, "r+", ssl) != JIM_OK) { + if (JimMakeChannel(interp, NULL, fd, NULL, "aio.sslstream%ld", af->addr_family, "r+") != JIM_OK) { goto out; } + af->ssl = ssl; + af->fops = &ssl_fops; + return JIM_OK; out: @@ -1356,7 +1359,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc, } } #endif - return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode, NULL); + return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode); } #if defined(JIM_SSL) @@ -1397,7 +1400,7 @@ static SSL_CTX *JimAioSslCtx(Jim_Interp *interp) * Creates the command and sets the name as the current result. */ static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename, - const char *hdlfmt, int family, const char *mode, void *ssl) + const char *hdlfmt, int family, const char *mode) { AioFile *af; char buf[AIO_CMD_LEN]; @@ -1451,12 +1454,6 @@ static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filenam af->openFlags = openFlags; af->addr_family = family; af->fops = &stdio_fops; - af->ssl = ssl; -#if defined(JIM_SSL) - if (ssl) { - af->fops = &ssl_fops; - } -#endif Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc); @@ -1475,11 +1472,11 @@ static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filenam static int JimMakeChannelPair(Jim_Interp *interp, int p[2], Jim_Obj *filename, const char *hdlfmt, int family, const char *mode[2]) { - if (JimMakeChannel(interp, NULL, p[0], filename, hdlfmt, family, mode[0], NULL) == JIM_OK) { + if (JimMakeChannel(interp, NULL, p[0], filename, hdlfmt, family, mode[0]) == JIM_OK) { Jim_Obj *objPtr = Jim_NewListObj(interp, NULL, 0); Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp)); - if (JimMakeChannel(interp, NULL, p[1], filename, hdlfmt, family, mode[1], NULL) == JIM_OK) { + if (JimMakeChannel(interp, NULL, p[1], filename, hdlfmt, family, mode[1]) == JIM_OK) { Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp)); Jim_SetResult(interp, objPtr); return JIM_OK; @@ -1759,7 +1756,7 @@ static int JimAioSockCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_ERR; } - return JimMakeChannel(interp, NULL, sock, argv[1], hdlfmt, family, mode, NULL); + return JimMakeChannel(interp, NULL, sock, argv[1], hdlfmt, family, mode); } #endif /* JIM_BOOTSTRAP */ @@ -1848,9 +1845,9 @@ int Jim_aioInit(Jim_Interp *interp) #endif /* Create filehandles for stdin, stdout and stderr */ - JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r", NULL); - JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w", NULL); - JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w", NULL); + JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r"); + JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w"); + JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w"); return JIM_OK; } |