Skip to content

Commit

Permalink
Merge pull request #3 from dinhvh/master
Browse files Browse the repository at this point in the history
merge remote etpan
  • Loading branch information
loomy authored Jun 12, 2023
2 parents 80ee427 + 5c9eb6b commit 9a2a72d
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 115 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ xcuserdata/
/build-mac/build
/build-mac/include
/build-mac/dependencies/build/
/build-mac/dependencies/packages/
/build-mac/libsasl-ios/
/build-mac/update.log
/config.guess
Expand Down
14 changes: 0 additions & 14 deletions build-mac/dependencies/cyrus-2.1.25-libetpan.patch

This file was deleted.

144 changes: 92 additions & 52 deletions build-mac/dependencies/prepare-cyrus-sasl.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#! /bin/bash -

set -e

export PATH=/usr/bin:/bin:/usr/sbin:/sbin

version=2.1.26
version=2.1.28
ARCHIVE=cyrus-sasl-$version
ARCHIVE_NAME=$ARCHIVE.tar.gz
ARCHIVE_PATCH=$ARCHIVE.patch
#url=ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/$ARCHIVE_NAME
#url=ftp://ftp.cyrusimap.org/cyrus-sasl/$ARCHIVE_NAME
#url=https://www.cyrusimap.org/releases/$ARCHIVE_NAME
url=https://github.com/cyrusimap/cyrus-sasl/releases/download/$ARCHIVE/$ARCHIVE_NAME
patchfile=cyrus-2.1.25-libetpan.patch
parallel_mode=0

scriptdir="`pwd`"

Expand All @@ -24,6 +23,8 @@ logdir="$tempbuilddir/log"
resultdir="$builddir/builds"
tmpdir="$tempbuilddir/tmp"

BUILD="$(uname -m)"

mkdir -p "$resultdir"
mkdir -p "$logdir"
mkdir -p "$tmpdir"
Expand Down Expand Up @@ -71,12 +72,13 @@ logfile="$srcdir/$ARCHIVE/build.log"
echo "*** patching sources ***" > "$logfile" 2>&1

cd "$srcdir/$ARCHIVE"
patch -p1 < $current_dir/$patchfile

# patch source files

cd "$srcdir/$ARCHIVE/include"
sed -E 's/\.\/\$< /.\/\$<i386 /' < Makefile.am > Makefile.am.new
sed -E 's/\.\/\$< /.\/\$<'$BUILD' /' < Makefile.am > Makefile.am.new
mv Makefile.am.new Makefile.am
sed -E 's/\.\/\$< /.\/\$<i386 /' < Makefile.in > Makefile.in.new
sed -E 's/\.\/\$< /.\/\$<'$BUILD' /' < Makefile.in > Makefile.in.new
mv Makefile.in.new Makefile.in
cd "$srcdir/$ARCHIVE/lib"
sed -E 's/\$\(AR\) cru \.libs\/\$@ \$\(SASL_STATIC_OBJS\)/&; \$\(RANLIB\) .libs\/\$@/' < Makefile.in > Makefile.in.new
Expand All @@ -100,8 +102,8 @@ if [[ "$?" != "0" ]]; then
exit 1
fi
cd ..
echo generated makemd5i386 properly
mv "$srcdir/$ARCHIVE/include/makemd5" "$srcdir/$ARCHIVE/include/makemd5i386"
echo generated makemd5$BUILD properly
mv "$srcdir/$ARCHIVE/include/makemd5" "$srcdir/$ARCHIVE/include/makemd5$BUILD"
make clean >>"$logfile" 2>&1
make distclean >>"$logfile" 2>&1
find . -name config.cache -print0 | xargs -0 rm
Expand All @@ -122,6 +124,57 @@ if test "x$NOBITCODE" != x ; then
BITCODE_FLAGS=""
fi

xcode_developer="$(xcode-select -p)"

function build_target {
local current_logfile="$srcdir/$ARCHIVE-$TARGET-$MARCH/build.log"
echo "log to $current_logfile"
cp -R "$srcdir/$ARCHIVE" "$srcdir/$ARCHIVE-$TARGET-$MARCH"

cd "$srcdir/$ARCHIVE-$TARGET-$MARCH"

echo "*** building for $TARGET - $MARCH ***" >> "$current_logfile" 2>&1

local PREFIX=${BUILD_DIR}/${LIB_NAME}/${TARGET}${SDK_IOS_VERSION}${MARCH}
rm -rf $PREFIX

local CURRENT_TARGET="$MARCH-apple-ios${SDK_IOS_MIN_VERSION}${TARGET_SUFFIX}"
export CPPFLAGS="-isysroot ${SYSROOT} -target ${CURRENT_TARGET} -Os"
export CFLAGS="${CPPFLAGS} ${EXTRA_FLAGS}"
export CC="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
export CXX="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
export LD="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
export AR="$xcode_developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"

OPENSSL="--with-openssl=$BUILD_DIR/openssl-1.0.0d/universal"
PLUGINS="--enable-otp=no --enable-digest=no --with-des=no --enable-login"
./configure --host=${ARCH} --prefix=$PREFIX --enable-shared=no --enable-static=yes --with-pam=$BUILD_DIR/openpam-20071221/universal $PLUGINS >> "$current_logfile" 2>&1
make -j 8 >> "$current_logfile" 2>&1
if [[ "$?" != "0" ]]; then
echo "CONFIGURE FAILED"
cat "$current_logfile"
exit 1
fi
cd lib
make install >> "$current_logfile" 2>&1
cd ..
cd include
make install >> "$current_logfile" 2>&1
cd ..
cd plugins
make install >> "$current_logfile" 2>&1
cd ..
if [[ "$?" != "0" ]]; then
echo "BUILD FAILED"
cat "$current_logfile"
exit 1
fi
make clean >> "$current_logfile" 2>&1
make distclean >> "$current_logfile" 2>&1
find . -name config.cache -print0 | xargs -0 rm
}

pids=""
for TARGET in $TARGETS; do

DEVELOPER="$(xcode-select --print-path)"
Expand All @@ -133,53 +186,36 @@ for TARGET in $TARGETS; do
ARCH=arm
MARCHS="armv7 armv7s arm64"
EXTRA_FLAGS="$BITCODE_FLAGS -miphoneos-version-min=$SDK_IOS_MIN_VERSION"
TARGET_SUFFIX=""
;;
(iPhoneSimulator)
ARCH=i386
MARCHS="i386 x86_64"
EXTRA_FLAGS="-miphoneos-version-min=$SDK_IOS_MIN_VERSION"
MARCHS="i386 x86_64 arm64"
EXTRA_FLAGS="$BITCODE_FLAGS -miphoneos-version-min=$SDK_IOS_MIN_VERSION"
TARGET_SUFFIX="-simulator"
;;
esac

for MARCH in $MARCHS; do
echo "building for $TARGET - $MARCH"
echo "*** building for $TARGET - $MARCH ***" >> "$logfile" 2>&1

PREFIX=${BUILD_DIR}/${LIB_NAME}/${TARGET}${SDK_IOS_VERSION}${MARCH}
rm -rf $PREFIX

export CPPFLAGS="-arch ${MARCH} -isysroot ${SYSROOT}"
export CFLAGS="${CPPFLAGS} -Os ${EXTRA_FLAGS}"

OPENSSL="--with-openssl=$BUILD_DIR/openssl-1.0.0d/universal"
PLUGINS="--enable-otp=no --enable-digest=no --with-des=no --enable-login"
./configure --host=${ARCH} --prefix=$PREFIX --enable-shared=no --enable-static=yes --with-pam=$BUILD_DIR/openpam-20071221/universal $PLUGINS >> "$logfile" 2>&1
make -j 8 >> "$logfile" 2>&1
if [[ "$?" != "0" ]]; then
echo "CONFIGURE FAILED"
cat "$logfile"
exit 1
fi
cd lib
make install >> "$logfile" 2>&1
cd ..
cd include
make install >> "$logfile" 2>&1
cd ..
cd plugins
make install >> "$logfile" 2>&1
cd ..
if [[ "$?" != "0" ]]; then
echo "BUILD FAILED"
cat "$logfile"
exit 1

echo "building for $TARGET - $MARCH"
build_target &
pid="$!"
pids="$pids $pid"
if test "x$parallel_mode" != x1 ; then
wait "$pid"
fi
make clean >> "$logfile" 2>&1
make distclean >> "$logfile" 2>&1
find . -name config.cache -print0 | xargs -0 rm
done
done

if test "x$parallel_mode" = x1 ; then
for pid in $pids; do
wait $pid || exit 1
done
fi

cd "$srcdir/$ARCHIVE"

echo "*** creating universal libs ***" >> "$logfile" 2>&1

rm -rf "$INSTALL_PATH"
Expand All @@ -193,11 +229,16 @@ for lib in $ALL_LIBS; do
if [[ "$dir" != "." ]]; then
mkdir -p ${INSTALL_PATH}/lib/$dir
fi
LIBS=
for TARGET in $TARGETS; do
LIBS="$LIBS ${BUILD_DIR}/${LIB_NAME}/${TARGET}${SDK_IOS_VERSION}*/lib/${lib}"
done
lipo -create ${LIBS} -output "${INSTALL_PATH}/lib/${lib}"

LIBS="${BUILD_DIR}/${LIB_NAME}/iPhoneOS${SDK_IOS_VERSION}*/lib/${lib}"
output="${INSTALL_PATH}/lib/iphoneos/${lib}"
mkdir -p "$(dirname "$output")"
lipo -create ${LIBS} -output "$output"

LIBS="${BUILD_DIR}/${LIB_NAME}/iPhoneSimulator${SDK_IOS_VERSION}*/lib/${lib}"
output="${INSTALL_PATH}/lib/iphonesimulator/${lib}"
mkdir -p "$(dirname "$output")"
lipo -create ${LIBS} -output "$output"
done

echo "*** creating built package ***" >> "$logfile" 2>&1
Expand All @@ -210,7 +251,6 @@ mkdir -p "$resultdir"
mv "libsasl-$version-ios.tar.gz" "$resultdir"
cd "$resultdir"
ln -s "libsasl-$version-ios.tar.gz" "libsasl-prebuilt-ios.tar.gz"
rm -rf "$tempbuilddir"

cd "$scriptdir/.."
tar xzf "$resultdir/libsasl-$version-ios.tar.gz"
Expand Down
2 changes: 1 addition & 1 deletion build-mac/libetpan.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cp \"$SRCROOT/libsasl-ios/lib/libsasl2.a\" \"$BUILT_PRODUCTS_DIR\"\n";
shellScript = "cp \"$SRCROOT/libsasl-ios/lib/$PLATFORM_NAME/libsasl2.a\" \"$BUILT_PRODUCTS_DIR\"\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
15 changes: 1 addition & 14 deletions build-windows/libetpan_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,13 @@
#endif

#ifndef LIBETPAN_VERSION_MINOR
#define LIBETPAN_VERSION_MINOR 8
#define LIBETPAN_VERSION_MINOR 6
#endif

#ifndef LIBETPAN_REENTRANT
#if 1
#define LIBETPAN_REENTRANT 1
#endif

#ifndef LIBETPAN_API_CURRENT
#define LIBETPAN_API_CURRENT 21
#endif

#ifndef LIBETPAN_API_REVISION
#define LIBETPAN_API_REVISION 0
#endif

#ifndef LIBETPAN_API_COMPATIBILITY
#define LIBETPAN_API_COMPATIBILITY 20
#endif

#endif

int libetpan_get_version_major(void);
Expand Down
4 changes: 2 additions & 2 deletions libetpan-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#define CONFIG_H
#include "config.h"
#endif
@ifdef WIN32
@if WIN32
@ define MMAP_UNAVAILABLE
@endif
@if defined(_MSC_VER) && !defined(__cplusplus)
@ifdef _MSC_VER
@ define inline __inline
@endif
#ifdef HAVE_LIMITS_H
Expand Down
3 changes: 3 additions & 0 deletions src/data-types/mailstream_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ mailstream_low * mailstream_low_compress_open(mailstream_low * ms)
if (compress_data == NULL)
goto err;

compress_data->compress_stream = NULL;
compress_data->decompress_stream = NULL;

/* allocate deflate state */
compress_data->compress_stream = malloc(sizeof(z_stream));
if (compress_data->compress_stream == NULL) {
Expand Down
6 changes: 3 additions & 3 deletions src/driver/implementation/mbox/mboxdriver_cached.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,6 @@ static int mboxdriver_cached_logout(mailsession * session)
int r;

r = write_max_uid_value(session);
if (r != MAIL_NO_ERROR)
return r;

cached_data = get_cached_data(session);

Expand Down Expand Up @@ -763,7 +761,9 @@ static int mboxdriver_cached_expunge_folder(mailsession * session)
mmap_string_free(mmapstr);
mail_cache_db_close_unlock(filename_flags, cache_db_flags);

return mailmbox_expunge(folder);
r = mailmbox_expunge(folder);

return MAIL_NO_ERROR;

close_db_flags:
mail_cache_db_close_unlock(filename_flags, cache_db_flags);
Expand Down
7 changes: 2 additions & 5 deletions src/driver/implementation/mh/mhdriver_cached.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,12 @@ static int mhdriver_cached_select_folder(mailsession * session, const char * mb)
}

r = write_max_uid_value(session);
if (r != MAIL_NO_ERROR) {
res = r;
goto err;
}

free_state(cached_data);
cached_data->mh_quoted_mb = quoted_mb;

return read_max_uid_value(session);
r = read_max_uid_value(session);
return MAIL_NO_ERROR;

free:
free(quoted_mb);
Expand Down
8 changes: 7 additions & 1 deletion src/driver/tools/imfcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,15 @@ static int mailimf_cache_field_write(MMAPString * mmapstr, size_t * indx,
r = mailimf_cache_subject_write(mmapstr, indx,
field->fld_data.fld_subject);
break;
default:
r = MAIL_NO_ERROR;
break;
}

return r;
if (r != MAIL_NO_ERROR)
return r;

return MAIL_NO_ERROR;
}


Expand Down
2 changes: 1 addition & 1 deletion src/driver/tools/mailthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ mail_build_thread_references(char * default_from,
if (env_tree->node_msg == NULL)
replace = TRUE;
else {
if (!env_tree->node_is_reply)
if (msg_in_table->node_is_reply && !env_tree->node_is_reply)
replace = TRUE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/low-level/imap/mailimap_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -6024,7 +6024,7 @@ static int mailimap_literal_parse_progress(mailstream * fd, MMAPString * buffer,
mailimap_space_parse(fd, buffer, &cur_token);
mailimap_space_parse(fd, buffer, &cur_token);
}
if (r != MAILIMAP_NO_ERROR) {
else if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
Expand Down
8 changes: 5 additions & 3 deletions src/low-level/imap/mailimap_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,11 @@ void
mailimap_mailbox_data_status_free(struct mailimap_mailbox_data_status * info)
{
mailimap_mailbox_free(info->st_mailbox);
clist_foreach(info->st_info_list, (clist_func) mailimap_status_info_free,
NULL);
clist_free(info->st_info_list);
if (info->st_info_list != NULL) {
clist_foreach(info->st_info_list, (clist_func) mailimap_status_info_free,
NULL);
clist_free(info->st_info_list);
}
free(info);
}

Expand Down
2 changes: 1 addition & 1 deletion src/low-level/imap/uidplus_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ static int mailimap_uidplus_resp_code_parse(mailstream * fd, MMAPString * buffer
r = mailimap_uidplus_uidnotsticky_parse(fd, buffer, parser_ctx, &cur_token);
if (r == MAILIMAP_NO_ERROR) {
ext = mailimap_extension_data_new(&mailimap_extension_uidplus,
MAILIMAP_UIDPLUS_RESP_CODE_UIDNOTSTICKY, resp_code_copy);
MAILIMAP_UIDPLUS_RESP_CODE_UIDNOTSTICKY, NULL);
if (ext == NULL) {
mailimap_uidplus_resp_code_copy_free(resp_code_copy);
return MAILIMAP_ERROR_MEMORY;
Expand Down
Loading

0 comments on commit 9a2a72d

Please sign in to comment.