From d071e7266483b0110ad94157a55780005150bab4 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 16 Mar 2015 14:32:48 -0700 Subject: [PATCH 01/46] Added dependency in README for windows --- build-windows/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/build-windows/README.md b/build-windows/README.md index 235534d..5a514f0 100644 --- a/build-windows/README.md +++ b/build-windows/README.md @@ -10,6 +10,7 @@ In case you just need a binary build of libEtPan: Also, you'll need all the dependencies, download the most recent binary builds in: +- [Cyrus SASL](http://d.etpan.org/mailcore2-deps/cyrus-sasl-win32/) - [zlib](http://d.etpan.org/mailcore2-deps/zlib-win32/) - [OpenSSL](http://d.etpan.org/mailcore2-deps/misc-win32/) From 27948015af1517e591cd2e4cd9ed467f093f7285 Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Tue, 17 Mar 2015 10:42:18 -0300 Subject: [PATCH 02/46] Adding link to the lib sasl in the README so that the user know where to download it from. --- build-windows/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-windows/README.md b/build-windows/README.md index 235534d..037b6f3 100644 --- a/build-windows/README.md +++ b/build-windows/README.md @@ -12,6 +12,7 @@ Also, you'll need all the dependencies, download the most recent binary builds i - [zlib](http://d.etpan.org/mailcore2-deps/zlib-win32/) - [OpenSSL](http://d.etpan.org/mailcore2-deps/misc-win32/) +- [SASL](http://d.etpan.org/mailcore2-deps/cyrus-sasl-win32/) ### Build using Visual Studio 2013 ### @@ -19,6 +20,7 @@ You'll need all the dependencies, download the most recent binary builds in: - [zlib](http://d.etpan.org/mailcore2-deps/zlib-win32/) - [OpenSSL](http://d.etpan.org/mailcore2-deps/misc-win32/) +- [SASL](http://d.etpan.org/mailcore2-deps/cyrus-sasl-win32/) #### Instructions for zlib #### From 0d2e1b28f3859877ae48860c7f444f06111fe26d Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Fri, 20 Mar 2015 16:50:51 +0800 Subject: [PATCH 03/46] Update mailimap.c 163 mail server will reject the command which with a number tag. --- src/low-level/imap/mailimap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index bfb4409..9923ece 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2309,7 +2309,7 @@ int mailimap_send_current_tag(mailimap * session) int r; session->imap_tag ++; - snprintf(tag_str, 15, "%i", session->imap_tag); + snprintf(tag_str, 15, "X%i", session->imap_tag); r = mailimap_tag_send(session->imap_stream, tag_str); if (r != MAILIMAP_NO_ERROR) From f0f5b4a64db5d0610a85f4316a1b0de7dadeb342 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Fri, 20 Mar 2015 16:59:43 +0800 Subject: [PATCH 04/46] Update mailimap.c --- src/low-level/imap/mailimap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index 9923ece..c4642e3 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2309,7 +2309,7 @@ int mailimap_send_current_tag(mailimap * session) int r; session->imap_tag ++; - snprintf(tag_str, 15, "X%i", session->imap_tag); + snprintf(tag_str, 15, "C%i", session->imap_tag); r = mailimap_tag_send(session->imap_stream, tag_str); if (r != MAILIMAP_NO_ERROR) From a12e1dd612481fc83862b0d0451a435e13b24082 Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Tue, 17 Mar 2015 10:42:47 -0300 Subject: [PATCH 05/46] removing the public head "libetpan_version.h" from the public header installation list since it no longer exists. --- build-windows/build_headers.list | 1 - 1 file changed, 1 deletion(-) diff --git a/build-windows/build_headers.list b/build-windows/build_headers.list index b4a9f7e..7f12816 100644 --- a/build-windows/build_headers.list +++ b/build-windows/build_headers.list @@ -151,7 +151,6 @@ src\low-level\smtp\mailsmtp_socket.h src\low-level\smtp\mailsmtp_ssl.h src\low-level\smtp\mailsmtp_types.h src\main\libetpan.h -src\main\libetpan_version.h src\windows\win_etpan.h build-windows\libetpan-config.h build-windows\libetpan_version.h From b87bfd18e029c598a4104b9cdf559bcbe3f1af53 Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Tue, 17 Mar 2015 10:43:12 -0300 Subject: [PATCH 06/46] The readme has been renamed to a .md instead of a .txt. This change fixes the reference from within the .sln. --- build-windows/libetpan.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-windows/libetpan.sln b/build-windows/libetpan.sln index faa0839..37f58ab 100644 --- a/build-windows/libetpan.sln +++ b/build-windows/libetpan.sln @@ -4,7 +4,7 @@ VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B2C11050-3E46-4E10-B734-F9203A75AA46}" ProjectSection(SolutionItems) = preProject - README.txt = README.txt + README.md = README.md EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libetpan", "libetpan\libetpan.vcxproj", "{BA4DED3C-E56F-4484-BFC3-9C13E461A1BE}" From 707b0f31f3fa986cc9a329170465542777b595eb Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Tue, 17 Mar 2015 10:43:36 -0300 Subject: [PATCH 07/46] The vcproj was accidentally trying to link in a .dll instead of a .lib. This change fixes that. --- build-windows/libetpan/libetpan.vcxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-windows/libetpan/libetpan.vcxproj b/build-windows/libetpan/libetpan.vcxproj index b6dce70..14ce292 100644 --- a/build-windows/libetpan/libetpan.vcxproj +++ b/build-windows/libetpan/libetpan.vcxproj @@ -98,7 +98,7 @@ /DLL %(AdditionalOptions) - libsasl2.dll;zlib.lib;Ws2_32.lib;ssleay32MDd.lib;libeay32MDd.lib;%(AdditionalDependencies) + libsasl2.lib;zlib.lib;Ws2_32.lib;ssleay32MDd.lib;libeay32MDd.lib;%(AdditionalDependencies) true ../../third-party/lib;%(AdditionalLibraryDirectories) C;%(IgnoreSpecificDefaultLibraries) @@ -130,7 +130,7 @@ /DLL %(AdditionalOptions) - libsasl2.dll;zlib.lib;Ws2_32.lib;ssleay32MDd.lib;libeay32MDd.lib;%(AdditionalDependencies) + libsasl2.lib;zlib.lib;Ws2_32.lib;ssleay32MDd.lib;libeay32MDd.lib;%(AdditionalDependencies) true ../../third-party/lib64;%(AdditionalLibraryDirectories) C;%(IgnoreSpecificDefaultLibraries) @@ -412,4 +412,4 @@ build_headers.bat - \ No newline at end of file + From 0ea3c97cdae47ec961d4c33cf077433428da8a8c Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Tue, 17 Mar 2015 16:20:37 -0300 Subject: [PATCH 08/46] The inline keyword is not part of C in visual studio but is part of C++ and it is illegal to re-define a C++ keyword. This change makes it so that we define the inline only when this header file is included in C. --- build-windows/libetpan-config.h | 2 ++ libetpan-config.h.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build-windows/libetpan-config.h b/build-windows/libetpan-config.h index 5dc7a02..04be4c0 100644 --- a/build-windows/libetpan-config.h +++ b/build-windows/libetpan-config.h @@ -80,7 +80,9 @@ #include #ifdef _MSC_VER # define MMAP_UNAVAILABLE +# ifndef __cplusplus # define inline __inline +# endif #else # include #endif diff --git a/libetpan-config.h.in b/libetpan-config.h.in index eca3def..3583340 100644 --- a/libetpan-config.h.in +++ b/libetpan-config.h.in @@ -9,7 +9,7 @@ @if WIN32 @ define MMAP_UNAVAILABLE @endif -@ifdef _MSC_VER +@if defined(_MSC_VER) && !defined(__cplusplus) @ define inline __inline @endif #ifdef HAVE_LIMITS_H From 0fdf95e3b392f73a34ba1d741786311f5a72e185 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Fri, 20 Mar 2015 12:29:12 -0700 Subject: [PATCH 09/46] Fixed generation of build_headers.list (#185) --- build-windows/gen-public-headers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-windows/gen-public-headers.sh b/build-windows/gen-public-headers.sh index f779369..f1fdb02 100755 --- a/build-windows/gen-public-headers.sh +++ b/build-windows/gen-public-headers.sh @@ -23,7 +23,7 @@ list_headers() } cd ../src -list_headers libetpan.h | sort +list_headers libetpan.h | grep -v libetpan_version.h | sort echo src\\windows\\win_etpan.h echo build-windows\\libetpan-config.h echo build-windows\\libetpan_version.h From 713323b782fb0e10a207d9f4bf60251d39e5a6ec Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Fri, 20 Mar 2015 15:11:06 -0300 Subject: [PATCH 10/46] Add some of the headers in the vcproj to help finding code in visual studio. --- build-windows/libetpan/libetpan.vcxproj | 199 +++++- .../libetpan/libetpan.vcxproj.filters | 591 ++++++++++++++++++ 2 files changed, 789 insertions(+), 1 deletion(-) diff --git a/build-windows/libetpan/libetpan.vcxproj b/build-windows/libetpan/libetpan.vcxproj index 14ce292..beec889 100644 --- a/build-windows/libetpan/libetpan.vcxproj +++ b/build-windows/libetpan/libetpan.vcxproj @@ -402,8 +402,205 @@ build_headers.bat + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -412,4 +609,4 @@ build_headers.bat - + \ No newline at end of file diff --git a/build-windows/libetpan/libetpan.vcxproj.filters b/build-windows/libetpan/libetpan.vcxproj.filters index 858e9b0..74dd953 100644 --- a/build-windows/libetpan/libetpan.vcxproj.filters +++ b/build-windows/libetpan/libetpan.vcxproj.filters @@ -638,6 +638,597 @@ Source Files\low-level\smtp + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\datatypes + + + Source Files\driver\implementation\data-message + + + Source Files\driver\implementation\feed + + + Source Files\driver\implementation\feed + + + Source Files\driver\implementation\feed + + + Source Files\driver\implementation\feed + + + Source Files\driver\implementation\hotmail + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\imap + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\maildir + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mbox + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mh + + + Source Files\driver\implementation\mime-message + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\nntp + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\implementation\pop3 + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\interface + + + Source Files\driver\tools + + + Source Files\driver\tools + + + Source Files\driver\tools + + + Source Files\driver\tools + + + Source Files\driver\tools + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\feed + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imap + + + Source Files\low-level\imf + + + Source Files\low-level\imf + + + Source Files\low-level\imf + + + Source Files\low-level\imf + + + Source Files\low-level\imf + + + Source Files\low-level\imf + + + Source Files\low-level\imf + + + Source Files\low-level\maildir + + + Source Files\low-level\maildir + + + Source Files\low-level\mbox + + + Source Files\low-level\mbox + + + Source Files\low-level\mbox + + + Source Files\low-level\mh + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\mime + + + Source Files\low-level\nntp + + + Source Files\low-level\nntp + + + Source Files\low-level\nntp + + + Source Files\low-level\nntp + + + Source Files\low-level\pop3 + + + Source Files\low-level\pop3 + + + Source Files\low-level\pop3 + + + Source Files\low-level\pop3 + + + Source Files\low-level\pop3 + + + Source Files\low-level\smtp + + + Source Files\low-level\smtp + + + Source Files\low-level\smtp + + + Source Files\low-level\smtp + + + Source Files\low-level\smtp + + + Source Files\low-level\smtp + From ce9989d7497b958055c2aaeb49c10b815a5e6a33 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Mon, 23 Mar 2015 15:01:02 +0800 Subject: [PATCH 11/46] Update mailimap_types.h --- src/low-level/imap/mailimap_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/low-level/imap/mailimap_types.h b/src/low-level/imap/mailimap_types.h index 17d539d..cfcfc35 100644 --- a/src/low-level/imap/mailimap_types.h +++ b/src/low-level/imap/mailimap_types.h @@ -3385,6 +3385,8 @@ struct mailimap { void (* imap_logger)(mailimap * session, int log_type, const char * str, size_t size, void * context); void * imap_logger_context; + + int complex_command_tag_enabled; }; From 09c5ad3b3937751fc6e8e565bea711e84cc789f9 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Mon, 23 Mar 2015 15:02:30 +0800 Subject: [PATCH 12/46] Update mailimap.h --- src/low-level/imap/mailimap.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index 9326b02..1a2b1bb 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -802,7 +802,16 @@ time_t mailimap_get_timeout(mailimap * session); LIBETPAN_EXPORT void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, int log_type, const char * str, size_t size, void * context), void * logger_context); + +LIBETPAN_EXPORT +void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled); +LIBETPAN_EXPORT +int mailimap_is_complex_command_tag_enabled(mailimap * imap); + + #ifdef __cplusplus + } + #endif #ifdef __cplusplus } #endif From dc4410f9c71b5771f58b890f8798c6ef6fd0b389 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Mon, 23 Mar 2015 15:03:27 +0800 Subject: [PATCH 13/46] Update mailimap.h --- src/low-level/imap/mailimap.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index 1a2b1bb..cd42ad4 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -809,9 +809,6 @@ void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled); LIBETPAN_EXPORT int mailimap_is_complex_command_tag_enabled(mailimap * imap); - #ifdef __cplusplus - } - #endif #ifdef __cplusplus } #endif From 382bccb740f5df5fe0220ec574d5a23ea2d657a5 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Mon, 23 Mar 2015 15:04:49 +0800 Subject: [PATCH 14/46] Update mailimap.c --- src/low-level/imap/mailimap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index c4642e3..692050d 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2590,3 +2590,13 @@ void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, session->imap_logger = logger; session->imap_logger_context = logger_context; } + +LIBETPAN_EXPORT +void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled) { + imap->complex_command_tag_enabled = enabled; +} + +LIBETPAN_EXPORT +int mailimap_is_complex_command_tag_enabled(mailimap * imap) { + return imap->complex_command_tag_enabled; +} From 1ea3f883cd3d89009df25554aadded8c0fa19c55 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Mon, 23 Mar 2015 15:06:21 +0800 Subject: [PATCH 15/46] Update mailimap.c --- src/low-level/imap/mailimap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index 692050d..267de9f 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2502,7 +2502,7 @@ mailimap * mailimap_new(size_t imap_progr_rate, f->imap_logger = NULL; f->imap_logger_context = NULL; - + f->complex_command_tag_enabled = 0 return f; free_stream_buffer: From 293143a24629de1841fd73c57726d37e4722ce07 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Tue, 24 Mar 2015 15:58:43 +0800 Subject: [PATCH 16/46] Update mailimap.c changed ` int mailimap_is__complex_command_tag_enabled(mailimap * imap); ` ` void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled);` to `int mailimap_is_163_workaround_enabled(mailimap * imap);` `void mailimap_set_163_workaround_enabled(mailimap * imap, int enabled);` --- src/low-level/imap/mailimap.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index 267de9f..1073036 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2309,7 +2309,12 @@ int mailimap_send_current_tag(mailimap * session) int r; session->imap_tag ++; - snprintf(tag_str, 15, "C%i", session->imap_tag); + + if(mailimap_is_163_workaround_enabled(session)) + snprintf(tag_str, 15, "C%i", session->imap_tag); + else + snprintf(tag_str, 15, "%i", session->imap_tag); + r = mailimap_tag_send(session->imap_stream, tag_str); if (r != MAILIMAP_NO_ERROR) @@ -2502,7 +2507,7 @@ mailimap * mailimap_new(size_t imap_progr_rate, f->imap_logger = NULL; f->imap_logger_context = NULL; - f->complex_command_tag_enabled = 0 + f->is_163_workaround_enabled = 0; return f; free_stream_buffer: @@ -2592,11 +2597,11 @@ void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, } LIBETPAN_EXPORT -void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled) { - imap->complex_command_tag_enabled = enabled; +void mailimap_set_163_workaround_enabled(mailimap * imap, int enabled) { + imap->is_163_workaround_enabled = enabled; } LIBETPAN_EXPORT -int mailimap_is_complex_command_tag_enabled(mailimap * imap) { - return imap->complex_command_tag_enabled; +int mailimap_is_163_workaround_enabled(mailimap * imap) { + return imap->is_163_workaround_enabled; } From 00b201eb317ffecca58cef2ace61479356fb5847 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Tue, 24 Mar 2015 16:02:08 +0800 Subject: [PATCH 17/46] Update mailimap.h changed ` int mailimap_is__complex_command_tag_enabled(mailimap * imap); ` ` void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled);` to `int mailimap_is_163_workaround_enabled(mailimap * imap);` `void mailimap_set_163_workaround_enabled(mailimap * imap, int enabled);` --- src/low-level/imap/mailimap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index cd42ad4..c4e9500 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -802,12 +802,12 @@ time_t mailimap_get_timeout(mailimap * session); LIBETPAN_EXPORT void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, int log_type, const char * str, size_t size, void * context), void * logger_context); - -LIBETPAN_EXPORT -void mailimap_set_complex_command_tag_enabled(mailimap * imap, int enabled); LIBETPAN_EXPORT -int mailimap_is_complex_command_tag_enabled(mailimap * imap); +int mailimap_is_163_workaround_enabled(mailimap * imap); + +LIBETPAN_EXPORT +void mailimap_set_163_workaround_enabled(mailimap * imap, int enabled); #ifdef __cplusplus } From 12f9dd83c3971546e7f87b5471d1dd259430537b Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Tue, 24 Mar 2015 16:04:30 +0800 Subject: [PATCH 18/46] Update mailimap_types.h changed mailimap's member `complex_command_tag_enabled` to `is_163_workaround_enabled`. --- src/low-level/imap/mailimap_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/low-level/imap/mailimap_types.h b/src/low-level/imap/mailimap_types.h index cfcfc35..379c38c 100644 --- a/src/low-level/imap/mailimap_types.h +++ b/src/low-level/imap/mailimap_types.h @@ -3386,7 +3386,7 @@ struct mailimap { void (* imap_logger)(mailimap * session, int log_type, const char * str, size_t size, void * context); void * imap_logger_context; - int complex_command_tag_enabled; + int is_163_workaround_enabled; }; From 40518e0f5de24563c1e93d18c1a7e96643eac8e7 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Tue, 24 Mar 2015 17:44:55 +0800 Subject: [PATCH 19/46] Update mailimap.h --- src/low-level/imap/mailimap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index c4e9500..620a1e0 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -804,10 +804,10 @@ void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, const char * str, size_t size, void * context), void * logger_context); LIBETPAN_EXPORT -int mailimap_is_163_workaround_enabled(mailimap * imap); +int mailimap_is_163_workaround_enabled(mailimap * session); LIBETPAN_EXPORT -void mailimap_set_163_workaround_enabled(mailimap * imap, int enabled); +void mailimap_set_163_workaround_enabled(mailimap * session, int enabled); #ifdef __cplusplus } From 4175a4ebafd4d2791cf0f5ab07f0b646a661ff20 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Tue, 24 Mar 2015 17:45:36 +0800 Subject: [PATCH 20/46] Update mailimap.c --- src/low-level/imap/mailimap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index 1073036..bad12cc 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2597,11 +2597,11 @@ void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, } LIBETPAN_EXPORT -void mailimap_set_163_workaround_enabled(mailimap * imap, int enabled) { +void mailimap_set_163_workaround_enabled(mailimap * session, int enabled) { imap->is_163_workaround_enabled = enabled; } LIBETPAN_EXPORT -int mailimap_is_163_workaround_enabled(mailimap * imap) { +int mailimap_is_163_workaround_enabled(mailimap * session) { return imap->is_163_workaround_enabled; } From d3770a9835970618648fb2c7cf5667969a519fe5 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Tue, 24 Mar 2015 17:49:17 +0800 Subject: [PATCH 21/46] Update mailimap.c changed parameter name from `imap` to `session`. --- src/low-level/imap/mailimap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index bad12cc..4072c68 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2598,10 +2598,10 @@ void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, LIBETPAN_EXPORT void mailimap_set_163_workaround_enabled(mailimap * session, int enabled) { - imap->is_163_workaround_enabled = enabled; + session->is_163_workaround_enabled = enabled; } LIBETPAN_EXPORT int mailimap_is_163_workaround_enabled(mailimap * session) { - return imap->is_163_workaround_enabled; + return session->is_163_workaround_enabled; } From 19112615db8dd42b3b656dc443dfa4162be9f52e Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Tue, 24 Mar 2015 11:18:36 -0700 Subject: [PATCH 22/46] Use closesocket() on windows --- src/driver/interface/mailstorage_tools.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/driver/interface/mailstorage_tools.c b/src/driver/interface/mailstorage_tools.c index 204e5d2..e3726b6 100644 --- a/src/driver/interface/mailstorage_tools.c +++ b/src/driver/interface/mailstorage_tools.c @@ -301,7 +301,11 @@ int mailstorage_generic_connect_with_local_address(mailsession_driver * driver, if (stream == NULL) { res = MAIL_ERROR_STREAM; +#ifdef WIN32 + closesocket(fd); +#else close(fd); +#endif goto err; } From 36581edc908c825f65f46246d49c81f15e88d75c Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Tue, 24 Mar 2015 11:38:14 -0700 Subject: [PATCH 23/46] Send top-level multiple search without parenthesis --- src/low-level/imap/mailimap_sender.c | 55 +++++++++++++++++++++------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/src/low-level/imap/mailimap_sender.c b/src/low-level/imap/mailimap_sender.c index b8580c4..9f8042c 100644 --- a/src/low-level/imap/mailimap_sender.c +++ b/src/low-level/imap/mailimap_sender.c @@ -184,6 +184,11 @@ static int mailimap_astring_literalplus_send(mailstream * fd, const char * astri static int mailimap_literalplus_count_send(mailstream * fd, size_t count); +static int search_key_notoplevel_send(mailstream * fd, + struct mailimap_search_key * key); + +static int search_key_literalplus_notoplevel_send(mailstream * fd, + struct mailimap_search_key * key); @@ -2252,7 +2257,7 @@ int mailimap_uid_search_literalplus_send(mailstream * fd, const char * charset, static int search_key_send(mailstream * fd, struct mailimap_search_key * key, - int literalplus_enabled) + int literalplus_enabled, int toplevel) { int r; @@ -2479,7 +2484,7 @@ static int search_key_send(mailstream * fd, r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; - r = mailimap_search_key_send(fd, key->sk_data.sk_not); + r = search_key_send(fd, key->sk_data.sk_not, literalplus_enabled, 0); if (r != MAILIMAP_NO_ERROR) return r; return MAILIMAP_NO_ERROR; @@ -2491,13 +2496,13 @@ static int search_key_send(mailstream * fd, r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; - r = mailimap_search_key_send(fd, key->sk_data.sk_or.sk_or1); + r = search_key_send(fd, key->sk_data.sk_or.sk_or1, literalplus_enabled, 0); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; - r = mailimap_search_key_send(fd, key->sk_data.sk_or.sk_or2); + r = search_key_send(fd, key->sk_data.sk_or.sk_or2, literalplus_enabled, 0); if (r != MAILIMAP_NO_ERROR) return r; return MAILIMAP_NO_ERROR; @@ -2605,18 +2610,28 @@ static int search_key_send(mailstream * fd, return MAILIMAP_NO_ERROR; case MAILIMAP_SEARCH_KEY_MULTIPLE: - r = mailimap_oparenth_send(fd); - if (r != MAILIMAP_NO_ERROR) - return r; + if (!toplevel) { + r = mailimap_oparenth_send(fd); + if (r != MAILIMAP_NO_ERROR) + return r; + } - r = mailimap_struct_spaced_list_send(fd, key->sk_data.sk_multiple, - (mailimap_struct_sender *) mailimap_search_key_send); + if (literalplus_enabled) { + r = mailimap_struct_spaced_list_send(fd, key->sk_data.sk_multiple, + (mailimap_struct_sender *) search_key_literalplus_notoplevel_send); + } + else { + r = mailimap_struct_spaced_list_send(fd, key->sk_data.sk_multiple, + (mailimap_struct_sender *) search_key_notoplevel_send); + } if (r != MAILIMAP_NO_ERROR) return r; - r = mailimap_cparenth_send(fd); - if (r != MAILIMAP_NO_ERROR) - return r; + if (!toplevel) { + r = mailimap_cparenth_send(fd); + if (r != MAILIMAP_NO_ERROR) + return r; + } return MAILIMAP_NO_ERROR; case MAILIMAP_SEARCH_KEY_MODSEQ: @@ -2682,16 +2697,28 @@ static int search_key_send(mailstream * fd, } } +static int search_key_notoplevel_send(mailstream * fd, + struct mailimap_search_key * key) +{ + return search_key_send(fd, key, 0, 0); +} + +static int search_key_literalplus_notoplevel_send(mailstream * fd, + struct mailimap_search_key * key) +{ + return search_key_send(fd, key, 1, 0); +} + int mailimap_search_key_send(mailstream * fd, struct mailimap_search_key * key) { - return search_key_send(fd, key, 0); + return search_key_send(fd, key, 0, 1); } int mailimap_search_key_literalplus_send(mailstream * fd, struct mailimap_search_key * key) { - return search_key_send(fd, key, 1); + return search_key_send(fd, key, 1, 1); } int mailimap_mod_sequence_value_send(mailstream * fd, uint64_t number) From b66b77bafb568dc3eaca9893d779ed4e4ab573fd Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Wed, 25 Mar 2015 15:15:06 +0800 Subject: [PATCH 24/46] Add macro ENABLE_163_WORKAROUND I have added this feature into the mailcore2, the compiler will ignore this feature if someone compile the new version of mailcore2 without this patch and this macro definition. --- src/low-level/imap/mailimap.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index 620a1e0..9864624 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -803,6 +803,10 @@ LIBETPAN_EXPORT void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, int log_type, const char * str, size_t size, void * context), void * logger_context); +#ifndef ENABLE_163_WORKAROUND + #define ENABLE_163_WORKAROUND +#endif + LIBETPAN_EXPORT int mailimap_is_163_workaround_enabled(mailimap * session); From 8aeca42f2a2209681c38708ef03faa3b67b03fae Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Wed, 25 Mar 2015 15:19:59 +0800 Subject: [PATCH 25/46] Update mailimap.h --- src/low-level/imap/mailimap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index 9864624..86f3280 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -804,7 +804,7 @@ void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, const char * str, size_t size, void * context), void * logger_context); #ifndef ENABLE_163_WORKAROUND - #define ENABLE_163_WORKAROUND + #define ENABLE_163_WORKAROUND 1 #endif LIBETPAN_EXPORT From 1f8408718ffdc9aac6d5e99914c6511ad0881718 Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Wed, 25 Mar 2015 15:22:34 +0800 Subject: [PATCH 26/46] Update mailimap.h Changed ENABLE_163_WORKAROUND to LIBETPAN_HAS_MAILIMAP_163_WORKAROUND --- src/low-level/imap/mailimap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/low-level/imap/mailimap.h b/src/low-level/imap/mailimap.h index 86f3280..883c902 100644 --- a/src/low-level/imap/mailimap.h +++ b/src/low-level/imap/mailimap.h @@ -803,8 +803,8 @@ LIBETPAN_EXPORT void mailimap_set_logger(mailimap * session, void (* logger)(mailimap * session, int log_type, const char * str, size_t size, void * context), void * logger_context); -#ifndef ENABLE_163_WORKAROUND - #define ENABLE_163_WORKAROUND 1 +#ifndef LIBETPAN_HAS_MAILIMAP_163_WORKAROUND + #define LIBETPAN_HAS_MAILIMAP_163_WORKAROUND 1 #endif LIBETPAN_EXPORT From a52aef48196eb01b47b392e99f89b5d2b282f24d Mon Sep 17 00:00:00 2001 From: Lin Zhan Date: Thu, 26 Mar 2015 13:59:49 +0800 Subject: [PATCH 27/46] Update mailimap.c #190 parse response --- src/low-level/imap/mailimap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/low-level/imap/mailimap.c b/src/low-level/imap/mailimap.c index 4072c68..8d4f02c 100644 --- a/src/low-level/imap/mailimap.c +++ b/src/low-level/imap/mailimap.c @@ -2389,7 +2389,11 @@ int mailimap_parse_response(mailimap * session, return MAILIMAP_ERROR_FATAL; } - snprintf(tag_str, 15, "%i", session->imap_tag); + if(mailimap_is_163_workaround_enabled(session)) + snprintf(tag_str, 15, "C%i", session->imap_tag); + else + snprintf(tag_str, 15, "%i", session->imap_tag); + if (strcmp(response->rsp_resp_done->rsp_data.rsp_tagged->rsp_tag, tag_str) != 0) { mailimap_response_free(response); return MAILIMAP_ERROR_PROTOCOL; From 959f87c709a3830206e938ccb8e5b2516af4b9ff Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 27 Apr 2015 10:56:30 -0700 Subject: [PATCH 28/46] Fixed #198, #173: parse missing closing quote if it's not parsed as part of a word with an opening quote in a phrase --- src/low-level/imf/mailimf.c | 28 ++++++++++++++++++++++------ src/low-level/imf/mailimf.h | 2 +- src/low-level/mime/mailmime_decode.c | 11 +++++++++-- src/low-level/mime/mailmime_decode.h | 2 +- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/low-level/imf/mailimf.c b/src/low-level/imf/mailimf.c index fb164cf..8d9ce4a 100644 --- a/src/low-level/imf/mailimf.c +++ b/src/low-level/imf/mailimf.c @@ -1170,8 +1170,8 @@ int mailimf_atom_parse(const char * message, size_t length, } LIBETPAN_EXPORT -int mailimf_fws_atom_for_word_parse(const char * message, size_t length, - size_t * indx, char ** result) +static int mailimf_fws_atom_for_word_parse(const char * message, size_t length, + size_t * indx, char ** result, int * p_missing_closing_quote) { size_t end; size_t cur_token; @@ -1179,9 +1179,11 @@ int mailimf_fws_atom_for_word_parse(const char * message, size_t length, int res; struct mailmime_encoded_word * word; int has_fwd; + int missing_closing_quote; char * atom; cur_token = * indx; + missing_closing_quote = 0; r = mailimf_fws_parse(message, length, &cur_token); if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { @@ -1191,7 +1193,7 @@ int mailimf_fws_atom_for_word_parse(const char * message, size_t length, end = cur_token; - r = mailmime_encoded_word_parse(message, length, &cur_token, &word, &has_fwd); + r = mailmime_encoded_word_parse(message, length, &cur_token, &word, &has_fwd, &missing_closing_quote); if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { res = r; goto err; @@ -1213,6 +1215,7 @@ int mailimf_fws_atom_for_word_parse(const char * message, size_t length, * result = atom; * indx = cur_token; + * p_missing_closing_quote = missing_closing_quote; return MAILIMF_NO_ERROR; @@ -1591,15 +1594,17 @@ int mailimf_word_parse(const char * message, size_t length, LIBETPAN_EXPORT int mailimf_fws_word_parse(const char * message, size_t length, - size_t * indx, char ** result) + size_t * indx, char ** result, int * p_missing_closing_quote) { size_t cur_token; char * word; int r; + int missing_closing_quote; cur_token = * indx; + missing_closing_quote = 0; - r = mailimf_fws_atom_for_word_parse(message, length, &cur_token, &word); + r = mailimf_fws_atom_for_word_parse(message, length, &cur_token, &word, &missing_closing_quote); if (r == MAILIMF_ERROR_PARSE) r = mailimf_fws_quoted_string_parse(message, length, &cur_token, &word); @@ -1609,6 +1614,7 @@ int mailimf_fws_word_parse(const char * message, size_t length, * result = word; * indx = cur_token; + * p_missing_closing_quote = missing_closing_quote; return MAILIMF_NO_ERROR; } @@ -1627,8 +1633,10 @@ static int mailimf_phrase_parse(const char * message, size_t length, int r; int res; char * str; + int has_missing_closing_quote; cur_token = * indx; + has_missing_closing_quote = 0; gphrase = mmap_string_new(""); if (gphrase == NULL) { @@ -1639,7 +1647,11 @@ static int mailimf_phrase_parse(const char * message, size_t length, first = TRUE; while (1) { - r = mailimf_fws_word_parse(message, length, &cur_token, &word); + int missing_quote = 0; + r = mailimf_fws_word_parse(message, length, &cur_token, &word, &missing_quote); + if (missing_quote) { + has_missing_closing_quote = 1; + } if (r == MAILIMF_NO_ERROR) { if (!first) { if (mmap_string_append_c(gphrase, ' ') == NULL) { @@ -1669,6 +1681,10 @@ static int mailimf_phrase_parse(const char * message, size_t length, goto free; } + if (has_missing_closing_quote) { + r = mailimf_char_parse(message, length, &cur_token, '\"'); + } + str = strdup(gphrase->str); if (str == NULL) { res = MAILIMF_ERROR_MEMORY; diff --git a/src/low-level/imf/mailimf.h b/src/low-level/imf/mailimf.h index 9dccac1..059ec67 100644 --- a/src/low-level/imf/mailimf.h +++ b/src/low-level/imf/mailimf.h @@ -348,7 +348,7 @@ int mailimf_fws_atom_parse(const char * message, size_t length, LIBETPAN_EXPORT int mailimf_fws_word_parse(const char * message, size_t length, - size_t * indx, char ** result); + size_t * indx, char ** result, int * p_missing_closing_quote); LIBETPAN_EXPORT int mailimf_fws_quoted_string_parse(const char * message, size_t length, diff --git a/src/low-level/mime/mailmime_decode.c b/src/low-level/mime/mailmime_decode.c index bea7b62..80605e2 100644 --- a/src/low-level/mime/mailmime_decode.c +++ b/src/low-level/mime/mailmime_decode.c @@ -110,6 +110,7 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, char * str; char * wordutf8; int type; + int missing_closing_quote; cur_token = * indx; @@ -127,7 +128,7 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, int has_fwd; word = NULL; - r = mailmime_encoded_word_parse(message, length, &cur_token, &word, &has_fwd); + r = mailmime_encoded_word_parse(message, length, &cur_token, &word, &has_fwd, &missing_closing_quote); if (r == MAILIMF_NO_ERROR) { if ((!first) && has_fwd) { if (type != TYPE_ENCODED_WORD) { @@ -366,7 +367,7 @@ mailmime_non_encoded_word_parse(const char * message, size_t length, int mailmime_encoded_word_parse(const char * message, size_t length, size_t * indx, struct mailmime_encoded_word ** result, - int * p_has_fwd) + int * p_has_fwd, int * p_missing_closing_quote) { size_t cur_token; char * charset; @@ -381,9 +382,11 @@ int mailmime_encoded_word_parse(const char * message, size_t length, int opening_quote; int end; int has_fwd; + int missing_closing_quote; cur_token = * indx; + missing_closing_quote = 0; has_fwd = 0; r = mailimf_fws_parse(message, length, &cur_token); if (r == MAILIMF_NO_ERROR) { @@ -509,6 +512,9 @@ int mailmime_encoded_word_parse(const char * message, size_t length, goto free_encoded_text; } #endif + if (r == MAILIMF_ERROR_PARSE) { + missing_closing_quote = 1; + } } /* fix charset */ @@ -525,6 +531,7 @@ int mailmime_encoded_word_parse(const char * message, size_t length, * result = ew; * indx = cur_token; * p_has_fwd = has_fwd; + * p_missing_closing_quote = missing_closing_quote; return MAILIMF_NO_ERROR; diff --git a/src/low-level/mime/mailmime_decode.h b/src/low-level/mime/mailmime_decode.h index f17b371..a5ea10b 100644 --- a/src/low-level/mime/mailmime_decode.h +++ b/src/low-level/mime/mailmime_decode.h @@ -53,7 +53,7 @@ int mailmime_encoded_word_parse(const char * message, size_t length, size_t * indx, struct mailmime_encoded_word ** result, - int * p_has_fwd); + int * p_has_fwd, int * p_missing_closing_quote); #ifdef __cplusplus } From 66b3650d871a151ec9822912530bc25e56cb84cb Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 27 Apr 2015 14:38:47 -0700 Subject: [PATCH 29/46] Implemented workaround for qq mail (#200) --- src/low-level/imap/mailimap_parser.c | 201 +++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/src/low-level/imap/mailimap_parser.c b/src/low-level/imap/mailimap_parser.c index 7febc7c..c02843d 100644 --- a/src/low-level/imap/mailimap_parser.c +++ b/src/low-level/imap/mailimap_parser.c @@ -768,6 +768,24 @@ mailimap_string_parse_progress(mailstream * fd, MMAPString * buffer, static int has_crlf(MMAPString * buffer, size_t index); +static int mailimap_address_list_parse(mailstream * fd, MMAPString * buffer, + size_t * indx, + clist ** result, + size_t progr_rate, + progress_function * progr_fun); + +static int mailimap_envelope_parse_full(mailstream * fd, MMAPString * buffer, + size_t * indx, + struct mailimap_envelope ** result, + size_t progr_rate, + progress_function * progr_fun); + +static int mailimap_envelope_parse_workaround_qq_mail(mailstream * fd, MMAPString * buffer, + size_t * indx, + struct mailimap_envelope ** result, + size_t progr_rate, + progress_function * progr_fun); + /* ************************************************************************* */ /* ************************************************************************* */ /* ************************************************************************* */ @@ -4613,6 +4631,25 @@ static int mailimap_envelope_parse(mailstream * fd, MMAPString * buffer, struct mailimap_envelope ** result, size_t progr_rate, progress_function * progr_fun) +{ + int r; + r = mailimap_envelope_parse_full(fd, buffer, indx, result, progr_rate, progr_fun); + if (r == MAILIMAP_NO_ERROR) { + return MAILIMAP_NO_ERROR; + } + else if (r != MAILIMAP_ERROR_PARSE) { + return r; + } + + r = mailimap_envelope_parse_workaround_qq_mail(fd, buffer, indx, result, progr_rate, progr_fun); + return r; +} + +static int mailimap_envelope_parse_full(mailstream * fd, MMAPString * buffer, + size_t * indx, + struct mailimap_envelope ** result, + size_t progr_rate, + progress_function * progr_fun) { size_t cur_token; char * date; @@ -4814,6 +4851,170 @@ static int mailimap_envelope_parse(mailstream * fd, MMAPString * buffer, return res; } +static int mailimap_envelope_parse_workaround_qq_mail(mailstream * fd, MMAPString * buffer, + size_t * indx, + struct mailimap_envelope ** result, + size_t progr_rate, + progress_function * progr_fun) +{ + size_t cur_token; + char * date; + char * subject; + struct mailimap_env_from * from; + char * in_reply_to; + char * message_id; + struct mailimap_envelope * envelope; + int r; + int res; + char * first_string; + char * second_string; + int has_first_string; + int has_second_string; + + date = NULL; + subject = NULL; + from = NULL; + in_reply_to = NULL; + message_id = NULL; + first_string = NULL; + second_string = NULL; + + cur_token = * indx; + + r = mailimap_oparenth_parse(fd, buffer, &cur_token); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto err; + } + + r = mailimap_env_date_parse(fd, buffer, &cur_token, &date, + progr_rate, progr_fun); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto err; + } + + r = mailimap_space_parse(fd, buffer, &cur_token); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto date; + } + + r = mailimap_env_subject_parse(fd, buffer, &cur_token, &subject, + progr_rate, progr_fun); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto date; + } + + r = mailimap_space_parse(fd, buffer, &cur_token); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto subject; + } + + r = mailimap_env_from_parse(fd, buffer, &cur_token, &from, + progr_rate, progr_fun); + if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { + res = r; + goto subject; + } + + while (1) { + clist * list; + + r = mailimap_space_parse(fd, buffer, &cur_token); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto from; + } + + r = mailimap_address_list_parse(fd, buffer, &cur_token, &list, + progr_rate, progr_fun); + if (r == MAILIMAP_ERROR_PARSE) { + break; + } + else if (r != MAILIMAP_NO_ERROR) { + res = r; + goto from; + } + if (list != NULL) { + clist_foreach(list, (clist_func) mailimap_address_free, NULL); + clist_free(list); + } + } + + has_first_string = 0; + r = mailimap_nstring_parse(fd, buffer, indx, &first_string, NULL, + progr_rate, progr_fun); + if (r == MAILIMAP_NO_ERROR) { + has_first_string = 1; + } + else if (r == MAILIMAP_ERROR_PARSE) { + // Do nothing. + } + else { + res = r; + goto from; + } + + r = mailimap_space_parse(fd, buffer, &cur_token); + // ignore errors. + + has_second_string = 0; + r = mailimap_nstring_parse(fd, buffer, indx, &second_string, NULL, + progr_rate, progr_fun); + if (r == MAILIMAP_NO_ERROR) { + has_second_string = 1; + } + else if (r == MAILIMAP_ERROR_PARSE) { + // Do nothing. + } + else { + res = r; + goto first_string; + } + + if (has_first_string && has_second_string) { + in_reply_to = first_string; + message_id = second_string; + } + else if (has_first_string) { + message_id = second_string; + } + + r = mailimap_cparenth_parse(fd, buffer, &cur_token); + if (r != MAILIMAP_NO_ERROR) { + res = r; + goto second_string; + } + + envelope = mailimap_envelope_new(date, subject, from, NULL, NULL, NULL, + NULL, NULL, in_reply_to, message_id); + if (envelope == NULL) { + res = MAILIMAP_ERROR_MEMORY; + goto second_string; + } + + * result = envelope; + * indx = cur_token; + + return MAILIMAP_NO_ERROR; + +second_string: + free(second_string); +first_string: + free(first_string); +from: + mailimap_env_from_free(from); +subject: + mailimap_env_subject_free(date); +date: + mailimap_env_date_free(date); +err: + return res; +} + /* "(" 1*address ")" / nil */ From 9d88f56dde0eb709161814d7483af7a500ab8fac Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 27 Apr 2015 15:34:01 -0700 Subject: [PATCH 30/46] Fixes of the workaround for qq.com IMAP server --- src/low-level/imap/mailimap_parser.c | 50 +++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/low-level/imap/mailimap_parser.c b/src/low-level/imap/mailimap_parser.c index c02843d..88e19b5 100644 --- a/src/low-level/imap/mailimap_parser.c +++ b/src/low-level/imap/mailimap_parser.c @@ -1532,6 +1532,14 @@ static int mailimap_addr_host_parse(mailstream * fd, MMAPString * buffer, size_t progr_rate, progress_function * progr_fun) { + int r; + + /* workaround for qq.com IMAP Server. */ + r = mailimap_token_case_insensitive_parse(fd, buffer, indx, "\"qq.com\\\""); + if (r == MAILIMAP_NO_ERROR) { + return r; + } + return mailimap_nstring_parse(fd, buffer, indx, result, NULL, progr_rate, progr_fun); } @@ -4641,6 +4649,7 @@ static int mailimap_envelope_parse(mailstream * fd, MMAPString * buffer, return r; } + /* workaround for qq.com IMAP Server. */ r = mailimap_envelope_parse_workaround_qq_mail(fd, buffer, indx, result, progr_rate, progr_fun); return r; } @@ -4920,11 +4929,44 @@ static int mailimap_envelope_parse_workaround_qq_mail(mailstream * fd, MMAPStrin goto subject; } + if (from == NULL) { + clist * list; + struct mailimap_address * addr; + + addr = mailimap_address_new("", NULL, "", ""); + if (addr == NULL) { + goto subject; + } + + list = clist_new(); + if (list == NULL) { + mailimap_address_free(addr); + goto subject; + } + + r = clist_append(list, addr); + if (r < 0) { + clist_free(list); + mailimap_address_free(addr); + goto subject; + } + + from = mailimap_env_from_new(list); + if (from == NULL) { + clist_free(list); + mailimap_address_free(addr); + goto subject; + } + } + while (1) { clist * list; r = mailimap_space_parse(fd, buffer, &cur_token); - if (r != MAILIMAP_NO_ERROR) { + if (r == MAILIMAP_ERROR_PARSE) { + break; + } + else if (r != MAILIMAP_NO_ERROR) { res = r; goto from; } @@ -4945,7 +4987,7 @@ static int mailimap_envelope_parse_workaround_qq_mail(mailstream * fd, MMAPStrin } has_first_string = 0; - r = mailimap_nstring_parse(fd, buffer, indx, &first_string, NULL, + r = mailimap_nstring_parse(fd, buffer, &cur_token, &first_string, NULL, progr_rate, progr_fun); if (r == MAILIMAP_NO_ERROR) { has_first_string = 1; @@ -4962,7 +5004,7 @@ static int mailimap_envelope_parse_workaround_qq_mail(mailstream * fd, MMAPStrin // ignore errors. has_second_string = 0; - r = mailimap_nstring_parse(fd, buffer, indx, &second_string, NULL, + r = mailimap_nstring_parse(fd, buffer, &cur_token, &second_string, NULL, progr_rate, progr_fun); if (r == MAILIMAP_NO_ERROR) { has_second_string = 1; @@ -4980,7 +5022,7 @@ static int mailimap_envelope_parse_workaround_qq_mail(mailstream * fd, MMAPStrin message_id = second_string; } else if (has_first_string) { - message_id = second_string; + message_id = first_string; } r = mailimap_cparenth_parse(fd, buffer, &cur_token); From 1f970d7a3eab5a1c03d8d5ebd305f43ae56e7192 Mon Sep 17 00:00:00 2001 From: Yuk Lai Suen Date: Wed, 17 Jun 2015 23:16:33 -0700 Subject: [PATCH 31/46] Update parameter for mailimap_has_extension and mailimap_has_authentication to use const char * --- src/low-level/imap/mailimap_extension.c | 4 ++-- src/low-level/imap/mailimap_extension.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/low-level/imap/mailimap_extension.c b/src/low-level/imap/mailimap_extension.c index 9df9714..19ae259 100644 --- a/src/low-level/imap/mailimap_extension.c +++ b/src/low-level/imap/mailimap_extension.c @@ -189,7 +189,7 @@ void mailimap_extension_data_store(mailimap * session, } LIBETPAN_EXPORT -int mailimap_has_extension(mailimap * session, char * extension_name) +int mailimap_has_extension(mailimap * session, const char * extension_name) { if (session->imap_connection_info != NULL) { if (session->imap_connection_info->imap_capability != NULL) { @@ -214,7 +214,7 @@ int mailimap_has_extension(mailimap * session, char * extension_name) } LIBETPAN_EXPORT -int mailimap_has_authentication(mailimap * session, char * authentication_name) +int mailimap_has_authentication(mailimap * session, const char * authentication_name) { if (session->imap_connection_info != NULL) { if (session->imap_connection_info->imap_capability != NULL) { diff --git a/src/low-level/imap/mailimap_extension.h b/src/low-level/imap/mailimap_extension.h index 42974e9..9d63d08 100644 --- a/src/low-level/imap/mailimap_extension.h +++ b/src/low-level/imap/mailimap_extension.h @@ -99,10 +99,10 @@ void mailimap_extension_data_store(mailimap * session, */ LIBETPAN_EXPORT -int mailimap_has_extension(mailimap * session, char * extension_name); +int mailimap_has_extension(mailimap * session, const char * extension_name); LIBETPAN_EXPORT -int mailimap_has_authentication(mailimap * session, char * authentication_name); +int mailimap_has_authentication(mailimap * session, const char * authentication_name); #ifdef __cplusplus } From 2bbd57231f3f349a9c22b7f3eac3cf9d31476744 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 1 Jul 2015 12:29:28 -0700 Subject: [PATCH 32/46] Fixed crash in email generation --- src/low-level/imf/mailimf_write_generic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/low-level/imf/mailimf_write_generic.c b/src/low-level/imf/mailimf_write_generic.c index 23af6ce..f7ee94e 100644 --- a/src/low-level/imf/mailimf_write_generic.c +++ b/src/low-level/imf/mailimf_write_generic.c @@ -1773,10 +1773,12 @@ static int mailimf_path_write_driver(int (* do_write)(void *, const char *, size if (r != MAILIMF_NO_ERROR) return r; - r = mailimf_string_write_driver(do_write, data, col, path->pt_addr_spec, - strlen(path->pt_addr_spec)); - if (r != MAILIMF_NO_ERROR) - return r; + if (path->pt_addr_spec != NULL) { + r = mailimf_string_write_driver(do_write, data, col, path->pt_addr_spec, + strlen(path->pt_addr_spec)); + if (r != MAILIMF_NO_ERROR) + return r; + } r = mailimf_string_write_driver(do_write, data, col, ">", 1); if (r != MAILIMF_NO_ERROR) From a04fadba222976be61b663feceb03cb24dc55e9d Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Thu, 9 Jul 2015 08:53:35 -0700 Subject: [PATCH 33/46] Fixed potential crasher --- src/data-types/mailstream_cfstream.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data-types/mailstream_cfstream.c b/src/data-types/mailstream_cfstream.c index 50b7705..43976a0 100755 --- a/src/data-types/mailstream_cfstream.c +++ b/src/data-types/mailstream_cfstream.c @@ -1192,6 +1192,11 @@ static carray * mailstream_low_cfstream_get_certificate_chain(mailstream_low * s for(i = 0 ; i < count ; i ++) { SecCertificateRef cert = (SecCertificateRef) SecTrustGetCertificateAtIndex(secTrust, i); CFDataRef data = SecCertificateCopyData(cert); + if (data == NULL) { + carray_free(result); + CFRelease(secTrust); + return NULL; + } CFIndex length = CFDataGetLength(data); const UInt8 * bytes = CFDataGetBytePtr(data); MMAPString * str = mmap_string_sized_new(length); @@ -1209,6 +1214,11 @@ static carray * mailstream_low_cfstream_get_certificate_chain(mailstream_low * s for(i = 0 ; i < count ; i ++) { SecCertificateRef cert = (SecCertificateRef) CFArrayGetValueAtIndex(certs, i); CFDataRef data = SecCertificateCopyData(cert); + if (data == NULL) { + carray_free(result); + CFRelease(certs); + return NULL; + } CFIndex length = CFDataGetLength(data); const UInt8 * bytes = CFDataGetBytePtr(data); MMAPString * str = mmap_string_sized_new(length); From 9406a001e717ca971a3c85ab529b58346ea6a374 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Mon, 20 Jul 2015 08:35:38 -0700 Subject: [PATCH 34/46] Xcode 6.4 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f440049..6211a09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,4 @@ os: language: c before_script: travis/before-script.sh script: travis/script.sh +osx_image: xcode6.4 From 754e815e98454f523da7d699e7720ed06802b069 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 20 Jul 2015 09:14:02 -0700 Subject: [PATCH 35/46] iOS 8.4 --- travis/script.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/travis/script.sh b/travis/script.sh index 211a870..1f0a67d 100755 --- a/travis/script.sh +++ b/travis/script.sh @@ -1,6 +1,9 @@ #!/bin/sh set -e +IOSSDK=8.4 +OSXSDK=10.10 + if test "x`uname`" = xLinux ; then distdir=libetpan-travis-build ./autogen.sh --with-curl=no --disable-db --with-expat=no @@ -13,12 +16,12 @@ if test "x`uname`" = xLinux ; then make imap-sample else echo Building library for iPhoneOS - xctool -project build-mac/libetpan.xcodeproj -sdk iphoneos8.1 -scheme "libetpan ios" build ARCHS="armv7 armv7s arm64" + xctool -project build-mac/libetpan.xcodeproj -sdk iphoneos$IOSSDK -scheme "libetpan ios" build ARCHS="armv7 armv7s arm64" echo Building library for iPhoneSimulator - xctool -project build-mac/libetpan.xcodeproj -sdk iphonesimulator8.1 -scheme "libetpan ios" build ARCHS="i386 x86_64" + xctool -project build-mac/libetpan.xcodeproj -sdk iphonesimulator$IOSSDK -scheme "libetpan ios" build ARCHS="i386 x86_64" echo Building library for Mac - xctool -project build-mac/libetpan.xcodeproj -sdk macosx10.10 -scheme "static libetpan" build + xctool -project build-mac/libetpan.xcodeproj -sdk macosx$OSXSDK -scheme "static libetpan" build echo Building framework for Mac - xctool -project build-mac/libetpan.xcodeproj -sdk macosx10.10 -scheme "libetpan" build + xctool -project build-mac/libetpan.xcodeproj -sdk macosx$OSXSDK -scheme "libetpan" build fi From 936bde4fcccb4e05c4b3ae6a684359bddde6d7a1 Mon Sep 17 00:00:00 2001 From: cuisinart Date: Sun, 26 Jul 2015 13:40:10 -0700 Subject: [PATCH 36/46] Fixed IMAP Idle for Windows Build select in windows cannot be used with non-sockets, use WaitForMultipleObjects instead. --- src/data-types/mailstream_low.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/data-types/mailstream_low.c b/src/data-types/mailstream_low.c index c85752b..32696e7 100644 --- a/src/data-types/mailstream_low.c +++ b/src/data-types/mailstream_low.c @@ -451,6 +451,30 @@ int mailstream_low_wait_idle(mailstream_low * low, struct mailstream_cancel * id cancel_fd = mailstream_cancel_get_fd(mailstream_low_get_cancel(low)); FD_ZERO(&readfds); +#ifdef WIN32 + HANDLE event = CreateEvent(NULL, TRUE, FALSE, NULL); + WSAEventSelect(fd, event, FD_READ | FD_CLOSE); + FD_SET(event, &readfds); + FD_SET(idle_fd, &readfds); + FD_SET(cancel_fd, &readfds); + r = WaitForMultipleObjects(readfds.fd_count, readfds.fd_array, FALSE, max_idle_delay * 1000); + WSAEventSelect(fd, event, 0); + CloseHandle(event); + if (r == WAIT_TIMEOUT) { + return MAILSTREAM_IDLE_TIMEOUT; + } + else if (r == WAIT_OBJECT_0){ + return MAILSTREAM_IDLE_HASDATA; + } + else if (r == WAIT_OBJECT_0 + 1){ + return MAILSTREAM_IDLE_INTERRUPTED; + } + else if (r == WAIT_OBJECT_0 + 2){ + return MAILSTREAM_IDLE_CANCELLED; + } + DWORD i = GetLastError(); + return MAILSTREAM_IDLE_ERROR; +#else FD_SET(fd, &readfds); FD_SET(idle_fd, &readfds); FD_SET(cancel_fd, &readfds); @@ -490,6 +514,7 @@ int mailstream_low_wait_idle(mailstream_low * low, struct mailstream_cancel * id } return MAILSTREAM_IDLE_ERROR; } +#endif } int mailstream_low_setup_idle(mailstream_low * low) From f58b1d7581c6f01f44c6337287358d5a95f521f7 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Wed, 29 Jul 2015 16:28:17 -0700 Subject: [PATCH 37/46] Fixed issue with space in names (#207) --- build-mac/update.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build-mac/update.sh b/build-mac/update.sh index 56cd794..0fdba81 100755 --- a/build-mac/update.sh +++ b/build-mac/update.sh @@ -7,12 +7,12 @@ logfile="`pwd`/update.log" cd .. -if test x$1 = xprepare ; then +if test "x$1" = xprepare ; then echo preparing ./autogen.sh > "$logfile" 2>&1 tar czf build-mac/autogen-result.tar.gz `find . -name '*.in'` configure install-sh config.sub missing config.guess exit 0 -elif test x$1 = xprepare-clean ; then +elif test "x$1" = xprepare-clean ; then if test -f Makefile ; then make maintainer-clean >/dev/null cd build-mac @@ -22,16 +22,16 @@ elif test x$1 = xprepare-clean ; then exit 0 fi -if test x$SRCROOT = x ; then +if test "x$SRCROOT" = x ; then echo Should be run from Xcode exit 1 fi -if test x$ACTION = x ; then +if test "x$ACTION" = x ; then ACTION=build fi -if test x$ACTION = xbuild ; then +if test "x$ACTION" = xbuild ; then md5 build-mac/autogen-result.tar.gz > build-mac/autogen-result.md5.new if ! cmp -s build-mac/autogen-result.md5 build-mac/autogen-result.md5.new ; then @@ -53,14 +53,14 @@ if test x$ACTION = xbuild ; then make libetpan-config.h >> "$logfile" 2>&1 md5 build-mac/autogen-result.tar.gz > build-mac/autogen-result.md5 fi - if test x$PLATFORM_NAME = xiphoneos -o x$PLATFORM_NAME = xiphonesimulator ; then + if test "x$PLATFORM_NAME" = xiphoneos -o "x$PLATFORM_NAME" = xiphonesimulator ; then if test ! -d build-mac/libsasl-ios ; then # build dependencies for iOS cd build-mac sh ./prepare-ios.sh fi fi -elif test x$ACTION = xclean ; then +elif test "x$ACTION" = xclean ; then if test -f Makefile ; then make distclean >/dev/null cd build-mac From 9dc45796c970d5d49618405fad4f5d098a78ae08 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Thu, 13 Aug 2015 19:17:02 -0700 Subject: [PATCH 38/46] Fix build for Xcode 7.0 beta 5. This beta has added (or at least rearranged) the SDKs to include WatchOS. This results in SDK_IOS_VERSION finding the WatchOS version number (2.0) instead of the iOS SDK version number. Fix this by rewriting the lines that handle xcodebuild to use different logic that is more robust. Tested on Xcode 6.4 and Xcode 7.0 beta 5. --- build-mac/dependencies/prepare-cyrus-sasl.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build-mac/dependencies/prepare-cyrus-sasl.sh b/build-mac/dependencies/prepare-cyrus-sasl.sh index 02af7e7..bbe12d8 100755 --- a/build-mac/dependencies/prepare-cyrus-sasl.sh +++ b/build-mac/dependencies/prepare-cyrus-sasl.sh @@ -111,14 +111,15 @@ LIB_NAME=$ARCHIVE TARGETS="iPhoneOS iPhoneSimulator" SDK_IOS_MIN_VERSION=7.0 -SDK_IOS_VERSION="`xcodebuild -version -sdk 2>/dev/null | egrep SDKVersion | tail -n 1 | sed -E -n -e 's|SDKVersion: *(.*) *$|\1|p'`" +SDK_IOS_VERSION="$(xcodebuild -version -sdk 'iphoneos' 2>/dev/null | egrep '^SDKVersion: ' | cut -d" " -f 2 | sort -n | tail -n1)" BUILD_DIR="$tmpdir/build" INSTALL_PATH="${BUILD_DIR}/${LIB_NAME}/universal" for TARGET in $TARGETS; do DEVELOPER="$(xcode-select --print-path)" - SYSROOT="`xcodebuild -version -sdk 2>/dev/null | egrep $TARGET -B 3 | egrep '^Path: '| egrep $SDK_IOS_VERSION | sort -u | tail -n 1| cut -d ' ' -f 2`" + SDK_ID="$(echo "$TARGET$SDK_IOS_VERSION" | tr A-Z a-z)" + SYSROOT="$(xcodebuild -version -sdk "$SDK_ID" 2>/dev/null | egrep '^Path: ' | cut -d ' ' -f 2)" case $TARGET in (iPhoneOS) From 787146dbcf0df5779bbcb77b3b171649119bd2f1 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Tue, 15 Sep 2015 14:51:35 -0700 Subject: [PATCH 39/46] Enable bitcode build --- build-mac/dependencies/prepare-cyrus-sasl.sh | 5 ++--- build-mac/libetpan.xcodeproj/project.pbxproj | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/build-mac/dependencies/prepare-cyrus-sasl.sh b/build-mac/dependencies/prepare-cyrus-sasl.sh index bbe12d8..aea72e2 100755 --- a/build-mac/dependencies/prepare-cyrus-sasl.sh +++ b/build-mac/dependencies/prepare-cyrus-sasl.sh @@ -111,7 +111,7 @@ LIB_NAME=$ARCHIVE TARGETS="iPhoneOS iPhoneSimulator" SDK_IOS_MIN_VERSION=7.0 -SDK_IOS_VERSION="$(xcodebuild -version -sdk 'iphoneos' 2>/dev/null | egrep '^SDKVersion: ' | cut -d" " -f 2 | sort -n | tail -n1)" +SDK_IOS_VERSION="`xcodebuild -showsdks 2>/dev/null | grep iphoneos | sed 's/.*iphoneos\(.*\)/\1/'`" BUILD_DIR="$tmpdir/build" INSTALL_PATH="${BUILD_DIR}/${LIB_NAME}/universal" @@ -125,14 +125,13 @@ for TARGET in $TARGETS; do (iPhoneOS) ARCH=arm MARCHS="armv7 armv7s arm64" - EXTRA_FLAGS="-miphoneos-version-min=$SDK_IOS_MIN_VERSION" ;; (iPhoneSimulator) ARCH=i386 MARCHS="i386 x86_64" - EXTRA_FLAGS="-miphoneos-version-min=$SDK_IOS_MIN_VERSION" ;; esac + EXTRA_FLAGS="-fembed-bitcode -miphoneos-version-min=$SDK_IOS_MIN_VERSION" for MARCH in $MARCHS; do echo "building for $TARGET - $MARCH" diff --git a/build-mac/libetpan.xcodeproj/project.pbxproj b/build-mac/libetpan.xcodeproj/project.pbxproj index b24566d..970069f 100644 --- a/build-mac/libetpan.xcodeproj/project.pbxproj +++ b/build-mac/libetpan.xcodeproj/project.pbxproj @@ -2481,6 +2481,7 @@ GCC_OPTIMIZATION_LEVEL = 0; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "@loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = libetpan; SDKROOT = macosx; WRAPPER_EXTENSION = framework; @@ -2499,6 +2500,7 @@ GCC_MODEL_TUNING = G5; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "@loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = libetpan; SDKROOT = macosx; STRIP_INSTALLED_PRODUCT = YES; @@ -2522,6 +2524,7 @@ OTHER_CFLAGS = ( "-DHAVE_CFNETWORK=1", "-DHAVE_CONFIG_H=1", + "-DLIBETPAN_IOS_DISABLE_SSL=1", ); }; name = Debug; @@ -2540,6 +2543,7 @@ OTHER_CFLAGS = ( "-DHAVE_CFNETWORK=1", "-DHAVE_CONFIG_H=1", + "-DLIBETPAN_IOS_DISABLE_SSL=1", ); }; name = Release; @@ -2579,6 +2583,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; + ENABLE_BITCODE = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; @@ -2587,11 +2592,8 @@ "$(SRCROOT)/libsasl-ios/include", ); INSTALL_PATH = /usr/local/lib; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LIBRARY_SEARCH_PATHS = "$(SRCROOT)/libsasl-ios/lib"; - OTHER_CFLAGS = ( - "$(inherited)", - "-DLIBETPAN_IOS_DISABLE_SSL=1", - ); PRODUCT_NAME = "etpan-ios"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -2604,17 +2606,15 @@ ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_BITCODE = YES; GCC_MODEL_TUNING = G5; HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/libsasl-ios/include", ); INSTALL_PATH = /usr/local/lib; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LIBRARY_SEARCH_PATHS = "$(SRCROOT)/libsasl-ios/lib"; - OTHER_CFLAGS = ( - "$(inherited)", - "-DLIBETPAN_IOS_DISABLE_SSL=1", - ); PRODUCT_NAME = "etpan-ios"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -2632,6 +2632,7 @@ GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; INSTALL_PATH = /usr/local/lib; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = etpan; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -2647,6 +2648,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_MODEL_TUNING = G5; INSTALL_PATH = /usr/local/lib; + MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = etpan; SDKROOT = macosx; SKIP_INSTALL = YES; From cfe913b5b0765c7ae664244d436c5c0ea9d4cf35 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Tue, 15 Sep 2015 15:15:45 -0700 Subject: [PATCH 40/46] Use Xcode7 on Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6211a09..245c56d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ os: language: c before_script: travis/before-script.sh script: travis/script.sh -osx_image: xcode6.4 +osx_image: xcode7 From 6d6e470679e995eb7bf1a75401c08847556a08fa Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Tue, 15 Sep 2015 15:27:48 -0700 Subject: [PATCH 41/46] Automatically choose SDK on Travis --- travis/script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/script.sh b/travis/script.sh index 1f0a67d..c84c809 100755 --- a/travis/script.sh +++ b/travis/script.sh @@ -1,8 +1,8 @@ #!/bin/sh set -e -IOSSDK=8.4 -OSXSDK=10.10 +IOSSDK="`xcodebuild -showsdks 2>/dev/null | grep iphoneos | sed 's/.*iphoneos\(.*\)/\1/'`" +OSXSDK="`xcodebuild -showsdks 2>/dev/null | grep macosx | sed 's/.*macosx\(.*\)/\1/'`" if test "x`uname`" = xLinux ; then distdir=libetpan-travis-build From 84b22f9aa6467c97c214dc67a952de5b7a3d3d76 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Wed, 16 Sep 2015 10:16:06 -0700 Subject: [PATCH 42/46] Fixed archive action --- build-mac/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-mac/update.sh b/build-mac/update.sh index 0fdba81..163eb6f 100755 --- a/build-mac/update.sh +++ b/build-mac/update.sh @@ -31,7 +31,7 @@ if test "x$ACTION" = x ; then ACTION=build fi -if test "x$ACTION" = xbuild ; then +if test "x$ACTION" = xbuild -o "x$ACTION" = xinstall ; then md5 build-mac/autogen-result.tar.gz > build-mac/autogen-result.md5.new if ! cmp -s build-mac/autogen-result.md5 build-mac/autogen-result.md5.new ; then From 8fdcbd41cba0173894373c8e60f8c7f484469d6c Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 16 Sep 2015 18:16:09 -0700 Subject: [PATCH 43/46] Fixed build issue --- src/data-types/connect.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/data-types/connect.h b/src/data-types/connect.h index 43f8f92..2eda3ea 100644 --- a/src/data-types/connect.h +++ b/src/data-types/connect.h @@ -37,9 +37,8 @@ #define CONNECT_H -#ifdef HAVE_INTTYPES_H -# include -#endif +#include + #include #ifdef __cplusplus From c2c2d0df4c3e33047a1f4b804510fc432c2ab101 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 16 Sep 2015 23:16:05 -0700 Subject: [PATCH 44/46] inherited CFLAGS --- build-mac/libetpan.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-mac/libetpan.xcodeproj/project.pbxproj b/build-mac/libetpan.xcodeproj/project.pbxproj index 970069f..a9b0be4 100644 --- a/build-mac/libetpan.xcodeproj/project.pbxproj +++ b/build-mac/libetpan.xcodeproj/project.pbxproj @@ -2522,6 +2522,7 @@ ); ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( + "$(inherited)", "-DHAVE_CFNETWORK=1", "-DHAVE_CONFIG_H=1", "-DLIBETPAN_IOS_DISABLE_SSL=1", @@ -2541,6 +2542,7 @@ "$(SRCROOT)/include", ); OTHER_CFLAGS = ( + "$(inherited)", "-DHAVE_CFNETWORK=1", "-DHAVE_CONFIG_H=1", "-DLIBETPAN_IOS_DISABLE_SSL=1", From 5d3f7023cb0555dbc0786d9341473d6b3509be59 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 16 Sep 2015 23:28:18 -0700 Subject: [PATCH 45/46] Revert "inherited CFLAGS" This reverts commit c2c2d0df4c3e33047a1f4b804510fc432c2ab101. --- build-mac/libetpan.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-mac/libetpan.xcodeproj/project.pbxproj b/build-mac/libetpan.xcodeproj/project.pbxproj index a9b0be4..970069f 100644 --- a/build-mac/libetpan.xcodeproj/project.pbxproj +++ b/build-mac/libetpan.xcodeproj/project.pbxproj @@ -2522,7 +2522,6 @@ ); ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( - "$(inherited)", "-DHAVE_CFNETWORK=1", "-DHAVE_CONFIG_H=1", "-DLIBETPAN_IOS_DISABLE_SSL=1", @@ -2542,7 +2541,6 @@ "$(SRCROOT)/include", ); OTHER_CFLAGS = ( - "$(inherited)", "-DHAVE_CFNETWORK=1", "-DHAVE_CONFIG_H=1", "-DLIBETPAN_IOS_DISABLE_SSL=1", From fd95586c4140c4a40fd4a6ccd68fc8ddc4deca75 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 16 Sep 2015 23:28:26 -0700 Subject: [PATCH 46/46] Revert "Fixed build issue" This reverts commit 8fdcbd41cba0173894373c8e60f8c7f484469d6c. --- src/data-types/connect.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/data-types/connect.h b/src/data-types/connect.h index 2eda3ea..43f8f92 100644 --- a/src/data-types/connect.h +++ b/src/data-types/connect.h @@ -37,8 +37,9 @@ #define CONNECT_H -#include - +#ifdef HAVE_INTTYPES_H +# include +#endif #include #ifdef __cplusplus