From: Sebastian B. <sb...@us...> - 2014-02-22 19:53:42
|
Update of /cvsroot/simplemail/simplemail In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16716 Modified Files: http.c imap.c pop3.c smtp.c tcp.c tcp.h Log Message: Introduced error_code parameter in tcp_connect(). This can be used instead of querying the error code via tcp_error_code() on failure. Also fixed wrong calls to tcp_connect() that were missed to be changed in a previous commit. Index: smtp.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/smtp.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- smtp.c 14 Dec 2012 20:45:39 -0000 1.76 +++ smtp.c 22 Feb 2014 19:53:39 -0000 1.77 @@ -891,6 +891,8 @@ if (open_socket_lib()) { struct account *account; + struct connect_options connect_opts = {0}; + int error_code; for (account = (struct account*)list_first(account_list);account;account = (struct account*)node_next(&account->node)) { @@ -922,7 +924,7 @@ // thread_call_parent_function_async(status_set_status,1,N_("Connecting...")); - if ((conn.conn = tcp_connect(account->smtp->name, account->smtp->port,0))) + if ((conn.conn = tcp_connect(account->smtp->name, account->smtp->port,&connect_opts,&error_code))) { if (smtp_login(&conn,account)) { Index: imap.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/imap.c,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- imap.c 22 Feb 2014 19:53:11 -0000 1.95 +++ imap.c 22 Feb 2014 19:53:39 -0000 1.96 @@ -1106,6 +1106,7 @@ struct connection *conn; struct connect_options conn_opts = {0}; char head_buf[100]; + int error_code; SM_DEBUGF(10,("Synchronizing with server \"%s\"\n",server->name)); @@ -1144,7 +1145,7 @@ conn_opts.use_ssl = server->ssl; SM_DEBUGF(10,("Connecting\n")); - if ((conn = tcp_connect(server->name, server->port, &conn_opts))) + if ((conn = tcp_connect(server->name, server->port, &conn_opts, &error_code))) { thread_call_parent_function_async(status_set_status,1,_("Waiting for login...")); SM_DEBUGF(10,("Waiting for login\n")); @@ -1223,6 +1224,7 @@ struct connection *conn; struct connect_options conn_opts = {0}; char head_buf[100]; + int error_code; sm_snprintf(head_buf, sizeof(head_buf), ("Reading folders of %s"),server->name); thread_call_parent_function_async_string(status_set_head, 1, head_buf); @@ -1234,7 +1236,7 @@ conn_opts.use_ssl = server->ssl; - if ((conn = tcp_connect(server->name, server->port, &conn_opts))) + if ((conn = tcp_connect(server->name, server->port, &conn_opts, &error_code))) { thread_call_parent_function_async(status_set_status,1,N_("Waiting for login...")); if (imap_wait_login(conn,server)) @@ -1304,6 +1306,7 @@ struct connection *conn; struct connect_options conn_opts = {0}; char head_buf[100]; + int error_code; sm_snprintf(head_buf,sizeof(head_buf),_("Submitting subscribed folders to %s"),server->name); thread_call_parent_function_async_string(status_set_head, 1, head_buf); @@ -1315,7 +1318,7 @@ conn_opts.use_ssl = server->ssl; - if ((conn = tcp_connect(server->name, server->port, &conn_opts))) + if ((conn = tcp_connect(server->name, server->port, &conn_opts, &error_code))) { thread_call_parent_function_async(status_set_status,1,_("Waiting for login...")); if (imap_wait_login(conn,server)) @@ -1865,6 +1868,7 @@ { char status_buf[160]; struct connect_options conn_opts = {0}; + int error_code; if (!imap_socket_lib_open) imap_socket_lib_open = open_socket_lib(); @@ -1908,7 +1912,7 @@ conn_opts.use_ssl = imap_server->ssl; - if ((imap_connection = tcp_connect(imap_server->name, imap_server->port, &conn_opts))) + if ((imap_connection = tcp_connect(imap_server->name, imap_server->port, &conn_opts, &error_code))) { SM_DEBUGF(20,("Connected to %s\n",imap_server->name)); Index: http.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/http.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- http.c 21 Feb 2010 16:46:47 -0000 1.12 +++ http.c 22 Feb 2014 19:53:39 -0000 1.13 @@ -48,13 +48,15 @@ int http_download_photo(char *path, char *email) { struct connection *conn; + struct connect_options conn_opts = {0}; + int error_code; int rc; if (!open_socket_lib()) return 0; rc = 0; - if ((conn = tcp_connect("simplemail.sourceforge.net",80,0))) + if ((conn = tcp_connect("simplemail.sourceforge.net", 80, &conn_opts, &error_code))) { char *line; int download = 0; @@ -101,6 +103,8 @@ char *path_buf; char *port_buf; struct connection *conn; + struct connect_options connect_opts = {0}; + int error_code; char *server; uri += 7; @@ -126,7 +130,7 @@ if (open_socket_lib()) { - if ((conn = tcp_connect(server,port,0))) + if ((conn = tcp_connect(server,port,&connect_opts,&error_code))) { FILE *fh; Index: pop3.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/pop3.c,v retrieving revision 1.108 retrieving revision 1.109 diff -u -d -r1.108 -r1.109 --- pop3.c 22 Feb 2014 09:40:57 -0000 1.108 +++ pop3.c 22 Feb 2014 19:53:39 -0000 1.109 @@ -943,6 +943,7 @@ struct connection *conn; struct connect_options connect_options = {0}; char head_buf[100]; + int error_code; rc = 0; @@ -980,7 +981,7 @@ connect_options.use_ssl = server->ssl && !server->stls; - if ((conn = tcp_connect(server->name, server->port, &connect_options))) + if ((conn = tcp_connect(server->name, server->port, &connect_options, &error_code))) { char *timestamp; thread_call_parent_function_async(status_set_status,1,_("Waiting for login...")); @@ -1000,7 +1001,7 @@ pop3_quit(conn,server); tcp_disconnect(conn); SM_DEBUGF(15,("Trying to connect again to the server\n")); - if ((conn = tcp_connect(server->name, server->port, &connect_options))) + if ((conn = tcp_connect(server->name, server->port, &connect_options, &error_code))) { if (pop3_wait_login(conn,server,NULL)) { @@ -1174,10 +1175,11 @@ { struct connection *conn; struct connect_options conn_opts = {0}; + int error_code; conn_opts.use_ssl = server->ssl && (!server->stls); - if ((conn = tcp_connect(server->name, server->port, &conn_opts))) + if ((conn = tcp_connect(server->name, server->port, &conn_opts, &error_code))) { char *timestamp; @@ -1194,7 +1196,7 @@ In such cases a reconnect should help. */ pop3_quit(conn,server); tcp_disconnect(conn); - if ((conn = tcp_connect(server->name, server->port, &conn_opts))) + if ((conn = tcp_connect(server->name, server->port, &conn_opts, &error_code))) { if (pop3_wait_login(conn,server,NULL)) { Index: tcp.h =================================================================== RCS file: /cvsroot/simplemail/simplemail/tcp.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- tcp.h 22 Feb 2014 19:52:45 -0000 1.19 +++ tcp.h 22 Feb 2014 19:53:40 -0000 1.20 @@ -65,7 +65,7 @@ int tcp_error_code(void); const char *tcp_strerror(int code); -struct connection *tcp_connect(char *server, unsigned int port, struct connect_options *options, int *error_code); +struct connection *tcp_connect(char *server, unsigned int port, struct connect_options *options, int *error_code_ptr); void tcp_disconnect(struct connection *conn); int tcp_make_secure(struct connection *conn); int tcp_secure(struct connection *conn); Index: tcp.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/tcp.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- tcp.c 22 Feb 2014 19:52:25 -0000 1.54 +++ tcp.c 22 Feb 2014 19:53:40 -0000 1.55 @@ -108,11 +108,12 @@ * should be created. * @param port defines to which server port the connection should be established. * @param options defines additional options, such as if the connection should be made secure. + * @param error_code_ptr specifies a location in which an additional error code is stored if the call returns NULL. * @return the connection or NULL on failure. Use tcp_error_code() for more information. * * @note TODO: Rework the error code handling. */ -struct connection *tcp_connect(char *server, unsigned int port, struct connect_options *options) +struct connection *tcp_connect(char *server, unsigned int port, struct connect_options *options, int *error_code_ptr) { int i,sd; struct sockaddr_in sockaddr; |