From 24a2d4baa8137fa990fff01b8e751538311d4de2 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sun, 14 Jan 2001 22:48:09 +0000 Subject: Implemented. (stream_setsockopt): Implemented. 2001-01-14 Jeffrey Stedfast * camel-tcp-stream-ssl.c (stream_getsockopt): Implemented. (stream_setsockopt): Implemented. * camel-tcp-stream-raw.c (stream_getsockopt): Implemented. (stream_setsockopt): Implemented. * camel-tcp-stream.c (camel_tcp_stream_getsockopt): New method. (camel_tcp_stream_setsockopt): Another new method. I think you get the idea of what these are for so I won't explain them. svn path=/trunk/; revision=7491 --- camel/camel-tcp-stream-ssl.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'camel/camel-tcp-stream-ssl.c') diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c index e12d32251d..93b2e9da25 100644 --- a/camel/camel-tcp-stream-ssl.c +++ b/camel/camel-tcp-stream-ssl.c @@ -40,8 +40,10 @@ static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n); static int stream_flush (CamelStream *stream); static int stream_close (CamelStream *stream); -static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port); +static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port); static int stream_disconnect (CamelTcpStream *stream); +static int stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data); +static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data); static void camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *camel_tcp_stream_ssl_class) @@ -61,6 +63,8 @@ camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *camel_tcp_stream_ssl_cl camel_tcp_stream_class->connect = stream_connect; camel_tcp_stream_class->disconnect = stream_disconnect; + camel_tcp_stream_class->getsockopt = stream_getsockopt; + camel_tcp_stream_class->setsockopt = stream_setsockopt; } static void @@ -203,3 +207,33 @@ stream_disconnect (CamelTcpStream *stream) return PR_Close (((CamelTcpStreamSSL *)stream)->sockfd); } + +static int +stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data) +{ + PRSocketOptionData sodata; + + memset ((void *) &sodata, 0, sizeof (sodata)); + memcpy ((void *) &sodata, (void *) data, sizeof (CamelSockOptData)); + + if (PR_GetSocketOption (((CamelTcpStreamSSL *)stream)->sockfd, &sodata) == PR_FAILURE) + return -1; + + memcpy ((void *) data, (void *) &sodata, sizeof (CamelSockOptData)); + + return 0; +} + +static int +stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data) +{ + PRSocketOptionData sodata; + + memset ((void *) &sodata, 0, sizeof (sodata)); + memcpy ((void *) &sodata, (void *) data, sizeof (CamelSockOptData)); + + if (PR_SetSocketOption (((CamelTcpStreamRaw *)stream)->sockfd, &sodata) == PR_FAILURE) + return -1; + + return 0; +} -- cgit