1
2
3
4
5
6
7
8
9
10
11
|
/*
* Copyright (C) 1997-2000 Matt Newman <[email protected]>
*
* $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tlsBIO.c,v 1.2 2000/01/20 01:51:39 aborr Exp $
*
* Provides BIO layer to interface openssl to Tcl.
*/
#include "tlsInt.h"
/*
|
|
|
1
2
3
4
5
6
7
8
9
10
11
|
/*
* Copyright (C) 1997-2000 Matt Newman <[email protected]>
*
* $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tlsBIO.c,v 1.2.2.2 2000/07/12 01:54:26 hobbs Exp $
*
* Provides BIO layer to interface openssl to Tcl.
*/
#include "tlsInt.h"
/*
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
int bufLen;
{
Tcl_Channel chan = Tls_GetParent((State*)bio->ptr);
int ret;
dprintf(stderr,"\nBioWrite(0x%x, <buf>, %d) [0x%x]", bio, bufLen, chan);
ret = Tcl_Write( chan, buf, bufLen);
dprintf(stderr,"\n[0x%x] BioWrite(%d) -> %d [%d.%d]", chan, bufLen, ret,
Tcl_Eof( chan), Tcl_GetErrno());
BIO_clear_flags(bio, BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY);
if (ret == 0) {
|
>
>
>
>
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
int bufLen;
{
Tcl_Channel chan = Tls_GetParent((State*)bio->ptr);
int ret;
dprintf(stderr,"\nBioWrite(0x%x, <buf>, %d) [0x%x]", bio, bufLen, chan);
#ifdef TCL_CHANNEL_VERSION_2
ret = Tcl_WriteRaw( chan, buf, bufLen);
#else
ret = Tcl_Write( chan, buf, bufLen);
#endif
dprintf(stderr,"\n[0x%x] BioWrite(%d) -> %d [%d.%d]", chan, bufLen, ret,
Tcl_Eof( chan), Tcl_GetErrno());
BIO_clear_flags(bio, BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY);
if (ret == 0) {
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
Tcl_Channel chan = Tls_GetParent((State*)bio->ptr);
int ret = 0;
dprintf(stderr,"\nBioRead(0x%x, <buf>, %d) [0x%x]", bio, bufLen, chan);
if (buf == NULL) return 0;
ret = Tcl_Read( chan, buf, bufLen);
dprintf(stderr,"\n[0x%x] BioRead(%d) -> %d [%d.%d]", chan, bufLen, ret,
Tcl_Eof(chan), Tcl_GetErrno());
BIO_clear_flags(bio, BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY);
if (ret == 0) {
|
>
>
>
>
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
Tcl_Channel chan = Tls_GetParent((State*)bio->ptr);
int ret = 0;
dprintf(stderr,"\nBioRead(0x%x, <buf>, %d) [0x%x]", bio, bufLen, chan);
if (buf == NULL) return 0;
#ifdef TCL_CHANNEL_VERSION_2
ret = Tcl_ReadRaw( chan, buf, bufLen);
#else
ret = Tcl_Read( chan, buf, bufLen);
#endif
dprintf(stderr,"\n[0x%x] BioRead(%d) -> %d [%d.%d]", chan, bufLen, ret,
Tcl_Eof(chan), Tcl_GetErrno());
BIO_clear_flags(bio, BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY);
if (ret == 0) {
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
case BIO_CTRL_WPENDING:
ret=0;
break;
case BIO_CTRL_DUP:
break;
case BIO_CTRL_FLUSH:
dprintf(stderr, "BIO_CTRL_FLUSH\n");
if (Tcl_Flush( chan) == TCL_OK)
ret=1;
else
ret=-1;
break;
default:
ret=0;
break;
}
return(ret);
}
static int
BioNew (bio)
|
>
>
>
>
|
>
>
|
|
|
>
|
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
case BIO_CTRL_WPENDING:
ret=0;
break;
case BIO_CTRL_DUP:
break;
case BIO_CTRL_FLUSH:
dprintf(stderr, "BIO_CTRL_FLUSH\n");
if (
#ifdef TCL_CHANNEL_VERSION_2
Tcl_WriteRaw(chan, "", 0) >= 0
#else
Tcl_Flush( chan) == TCL_OK
#endif
) {
ret = 1;
} else {
ret = -1;
}
break;
default:
ret = 0;
break;
}
return(ret);
}
static int
BioNew (bio)
|