Reverting r513. I mistakenly committed my entire tree.

This commit is contained in:
Jack Moffitt
2008-08-26 04:46:41 +00:00
parent ade38ae188
commit 1c0bbb1f5d
5 changed files with 20 additions and 31 deletions

View File

@@ -48,7 +48,7 @@ Sources = Split("""
util.c util.c
thread.c thread.c
snprintf.c snprintf.c
tls_gnutls.c tls_dummy.c
oocontext.cpp oocontext.cpp
oostanza.cpp oostanza.cpp
""") """)
@@ -98,7 +98,7 @@ Default(strophe)
exenv = env.Clone() exenv = env.Clone()
exenv.Append(CPPPATH=['.']) exenv.Append(CPPPATH=['.'])
exenv.Append(LIBS=["strophe", "expat", "gnutls"]) exenv.Append(LIBS=["strophe", "expat"])
exenv.Append(LIBPATH=["."]) exenv.Append(LIBPATH=["."])
if exenv["PLATFORM"] == "win32": if exenv["PLATFORM"] == "win32":
exenv.Append(LIBS=["ws2_32", "winmm"]) exenv.Append(LIBS=["ws2_32", "winmm"])

View File

@@ -89,14 +89,12 @@ void handler_fire_stanza(xmpp_conn_t * const conn,
while (item) { while (item) {
/* skip newly added handlers */ /* skip newly added handlers */
if (!item->enabled) { if (!item->enabled) {
prev = item;
item = item->next; item = item->next;
continue; continue;
} }
/* don't call user handlers until authentication succeeds */ /* don't call user handlers until authentication succeeds */
if (item->user_handler && !conn->authenticated) { if (item->user_handler && !conn->authenticated) {
prev = item;
item = item->next; item = item->next;
continue; continue;
} }

View File

@@ -78,6 +78,11 @@ int tls_write(tls_t *tls, const void * const buff, const size_t len)
return -1; return -1;
} }
int tls_clear_pending_write(tls_t *tls)
{
return -1;
}
int tls_is_recoverable(int error) int tls_is_recoverable(int error)
{ {
return 0; return 0;

View File

@@ -24,7 +24,6 @@
struct _tls { struct _tls {
xmpp_ctx_t *ctx; /* do we need this? */ xmpp_ctx_t *ctx; /* do we need this? */
int error;
sock_t sock; sock_t sock;
gnutls_session_t session; gnutls_session_t session;
gnutls_certificate_credentials_t cred; gnutls_certificate_credentials_t cred;
@@ -54,7 +53,6 @@ tls_t *tls_new(xmpp_ctx_t *ctx, sock_t sock)
if (tls) { if (tls) {
tls->ctx = ctx; tls->ctx = ctx;
tls->error = 0;
tls->sock = sock; tls->sock = sock;
gnutls_init(&tls->session, GNUTLS_CLIENT); gnutls_init(&tls->session, GNUTLS_CLIENT);
@@ -65,7 +63,7 @@ tls_t *tls_new(xmpp_ctx_t *ctx, sock_t sock)
/* fixme: this may require setting a callback on win32? */ /* fixme: this may require setting a callback on win32? */
gnutls_transport_set_ptr(tls->session, gnutls_transport_set_ptr(tls->session,
(gnutls_transport_ptr_t)sock); (gnutls_transport_ptr_t)sock);
} }
return tls; return tls;
@@ -95,14 +93,7 @@ int tls_set_credentials(tls_t *tls, const char *cafilename)
int tls_start(tls_t *tls) int tls_start(tls_t *tls)
{ {
int ret; return gnutls_handshake(tls->session);
xmpp_debug(tls->ctx, "TLS", "tls starting");
ret = gnutls_handshake(tls->session);
if (ret < 0) {
tls->error = ret;
return 0;
}
return 1;
} }
int tls_stop(tls_t *tls) int tls_stop(tls_t *tls)
@@ -110,13 +101,17 @@ int tls_stop(tls_t *tls)
return gnutls_bye(tls->session, GNUTLS_SHUT_RDWR); return gnutls_bye(tls->session, GNUTLS_SHUT_RDWR);
} }
int tls_error(tls_t *tls)
{
/* todo: some kind of error polling/dump */
return 0;
}
int tls_read(tls_t *tls, void * const buff, const size_t len) int tls_read(tls_t *tls, void * const buff, const size_t len)
{ {
int ret; int ret;
xmpp_debug(tls->ctx, "TLS", "tls_read called");
ret = gnutls_record_recv(tls->session, buff, len); ret = gnutls_record_recv(tls->session, buff, len);
xmpp_debug(tls->ctx, "TLS", "tls_read returned %d", ret);
return ret; return ret;
} }
@@ -130,17 +125,3 @@ int tls_write(tls_t *tls, const void * const buff, const size_t len)
return ret; return ret;
} }
int tls_clear_pending_write(tls_t *tls)
{
return 0;
}
int tls_error(tls_t *tls)
{
return tls->error;
}
int tls_is_recoverable(int error)
{
return sock_is_recoverable(error);
}

View File

@@ -189,6 +189,11 @@ int tls_stop(tls_t *tls)
return 1; return 1;
} }
int tls_error(tls_t *tls)
{
return tls->lasterror;
}
int tls_is_recoverable(int error) int tls_is_recoverable(int error)
{ {
return (error == SSL_ERROR_NONE || error == SSL_ERROR_WANT_READ return (error == SSL_ERROR_NONE || error == SSL_ERROR_WANT_READ