make -C bld -j5 examples
fi
+ wince:
+ name: "mingw32ce, ${{ matrix.build == 'cmake' && 'CM' || 'AM' }} 4.4.0-arm schannel"
+ runs-on: 'macos-latest'
+ timeout-minutes: 10
+ env:
+ toolchain-version: '0.59.1'
+ strategy:
+ matrix:
+ build: [autotools, cmake]
+ fail-fast: false
+ steps:
+ - name: 'install packages'
+ if: ${{ matrix.build == 'autotools' }}
+ run: |
+ echo automake libtool | xargs -Ix -n1 echo brew '"x"' > /tmp/Brewfile
+ while [[ $? == 0 ]]; do for i in 1 2 3; do brew update && brew bundle install --no-lock --file /tmp/Brewfile && break 2 || { echo Error: wait to try again; sleep 10; } done; false Too many retries; done
+
+ - name: 'cache compiler (mingw32ce)'
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
+ id: cache-compiler
+ with:
+ path: ~/opt/mingw32ce
+ key: ${{ runner.os }}-mingw32ce-${{ env.toolchain-version }}-amd64
+
+ - name: 'install compiler (mingw32ce)'
+ if: ${{ steps.cache-compiler.outputs.cache-hit != 'true' }}
+ run: |
+ cd "${HOME}" || exit 1
+ curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 120 --retry 3 --retry-connrefused --proto-redir =https \
+ --location 'https://downloads.sourceforge.net/cegcc/cegcc/${{ env.toolchain-version }}/cegcc_mingw32ce_snowleopard_r1397.tar.bz2' | tar -x
+ ls -l
+
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
+
+ - name: 'configure'
+ run: |
+ MINGW32CE_ROOT="${HOME}/opt/mingw32ce"
+ if [ '${{ matrix.build }}' = 'cmake' ]; then
+ cmake -B bld \
+ -DCMAKE_SYSTEM_NAME=WindowsCE \
+ -DCMAKE_SYSTEM_VERSION=8.0 \
+ -DCMAKE_SYSTEM_PROCESSOR=arm \
+ -DCMAKE_C_COMPILER_TARGET=arm-wince-mingw32ce \
+ -DCMAKE_C_COMPILER="${MINGW32CE_ROOT}/bin/arm-mingw32ce-gcc" \
+ -DCMAKE_RC_COMPILER="${MINGW32CE_ROOT}/bin/arm-mingw32ce-windres" \
+ -DMINGW32CE_LIBRARY_DIR="${MINGW32CE_ROOT}/arm-mingw32ce/lib" \
+ -DCMAKE_IGNORE_PREFIX_PATH="$(brew --prefix)" \
+ -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
+ -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_STATIC_CURL=OFF \
+ -DCURL_WERROR=ON \
+ -DCURL_USE_SCHANNEL=ON \
+ -DCURL_USE_LIBPSL=OFF
+ else
+ autoreconf -fi
+ mkdir bld && cd bld && ../configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
+ ac_cv_prog_cc_c99=no \
+ CC="${MINGW32CE_ROOT}/bin/arm-mingw32ce-gcc" \
+ AR="${MINGW32CE_ROOT}/bin/arm-mingw32ce-ar" \
+ RANLIB="${MINGW32CE_ROOT}/bin/arm-mingw32ce-ranlib" \
+ RC="${MINGW32CE_ROOT}/bin/arm-mingw32ce-windres" \
+ --host=arm-wince-mingw32ce \
+ --with-schannel \
+ --without-libpsl \
+ --disable-shared
+ fi
+
+ - name: 'configure log'
+ if: ${{ !cancelled() }}
+ run: cat bld/config.log bld/CMakeFiles/CMake*.yaml 2>/dev/null || true
+
+ - name: 'curl_config.h'
+ run: |
+ echo '::group::raw'; cat bld/lib/curl_config.h || true; echo '::endgroup::'
+ grep -F '#define' bld/lib/curl_config.h | sort || true
+
+ - name: 'build'
+ run: |
+ if [ '${{ matrix.build }}' = 'cmake' ]; then
+ cmake --build bld
+ else
+ make -j5 -C bld
+ fi
+
+ - name: 'curl info'
+ run: |
+ find . \( -name '*.exe' -o -name '*.dll' -o -name '*.a' \) -exec file '{}' \;
+
+ - name: 'build tests'
+ if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time
+ run: |
+ if [ '${{ matrix.build }}' = 'cmake' ]; then
+ cmake --build bld --target testdeps
+ else
+ make -j5 -C bld -C tests
+ fi
+
+ - name: 'build examples'
+ if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time
+ run: |
+ if [ '${{ matrix.build }}' = 'cmake' ]; then
+ cmake --build bld --target curl-examples
+ else
+ make -j5 -C bld examples
+ fi
+
msvc:
name: 'msvc, CM ${{ matrix.arch }}-${{ matrix.plat }} ${{ matrix.name }}'
runs-on: windows-latest
# e.g. curl_easy_perform_ev() or curl_dbg_*(),
# so disable symbol hiding for debug builds and for memory tracking.
set(CURL_HIDDEN_SYMBOLS OFF)
-elseif(DOS OR AMIGA)
+elseif(DOS OR AMIGA OR MINGW32CE)
set(CURL_HIDDEN_SYMBOLS OFF)
endif()
set(HAVE_UTIME_H 1) # wrapper to sys/utime.h
set(HAVE_DIRENT_H 1)
set(HAVE_OPENDIR 1)
+ if(MINGW32CE)
+ set(HAVE_STRTOK_R 0)
+ set(HAVE_FILE_OFFSET_BITS 0)
+ endif()
else()
set(HAVE_LIBGEN_H 0)
set(HAVE_FTRUNCATE 0)
set(HAVE_SIZEOF_SUSECONDS_T 0)
set(HAVE_SIZEOF_SA_FAMILY_T 0)
+
+if(WINCE) # Windows CE exceptions
+ set(HAVE_LOCALE_H 0)
+ set(HAVE_GETADDRINFO 0)
+ set(HAVE_FREEADDRINFO 0)
+ set(HAVE_SETLOCALE 0)
+ set(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 0)
+ set(HAVE_SIGNAL 0)
+ set(HAVE_SETMODE 0)
+ if(MINGW32CE)
+ set(HAVE__SETMODE 0)
+ endif()
+endif()
# CMake (as of v3.31.2) gets confused and applies the MSVC rc.exe command-line
# template to windres. Reset it to the windres template via 'Modules/Platform/Windows-windres.cmake':
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> <INCLUDES> <FLAGS> <SOURCE> <OBJECT>")
+elseif(WIN32 AND WINCE AND CMAKE_COMPILER_IS_GNUCC) # mingw32ce build
+ if(NOT MINGW32CE_LIBRARY_DIR)
+ message(FATAL_ERROR "Set MINGW32CE_LIBRARY_DIR variable to the mingw32ce platform library directory.")
+ endif()
+
+ set(MINGW 1)
+ set(MINGW32CE 1)
+
+ # Build implib with libcurl DLL. Copied from CMake's 'Modules/Platform/Windows-GNU.cmake'.
+ set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS>")
+ string(APPEND CMAKE_C_CREATE_SHARED_LIBRARY " <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB>")
+ string(APPEND CMAKE_C_CREATE_SHARED_LIBRARY " ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+
+ # Build resources. Copied from CMake's 'Modules/Platform/Windows-windres.cmake'.
+ set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> <INCLUDES> <FLAGS> <SOURCE> <OBJECT>")
+ enable_language(RC)
+
+ set(CMAKE_C_COMPILE_OPTIONS_PIC "") # CMake sets it to '-fPIC', confusing the toolchain and breaking builds. Zap it.
+
+ set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
+ set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
+ set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+ set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
+ set(CMAKE_IMPORT_LIBRARY_PREFIX "lib")
+ set(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a")
+ set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib")
elseif(DOS AND CMAKE_COMPILER_IS_GNUCC) # DJGPP
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
if(WIN32)
string(APPEND _target_flags " WIN32")
endif()
+if(WINCE)
+ string(APPEND _target_flags " WINCE")
+endif()
if(WINDOWS_STORE)
string(APPEND _target_flags " UWP")
endif()
endif()
option(ENABLE_UNICODE "Use the Unicode version of the Windows API functions" OFF)
- if(WINDOWS_STORE)
+ if(WINDOWS_STORE OR WINCE)
set(ENABLE_UNICODE ON)
endif()
if(ENABLE_UNICODE)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "UNICODE" "_UNICODE")
- if(MINGW)
+ if(MINGW AND NOT MINGW32CE)
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-municode")
endif()
endif()
set(CURL_DISABLE_TFTP ON)
endif()
-if(WINDOWS_STORE)
+if(WINDOWS_STORE OR WINCE)
set(CURL_DISABLE_TELNET ON) # telnet code needs fixing to compile for UWP.
endif()
endif()
# Check for all needed libraries
-if(DOS)
+if(WIN32)
+ if(WINCE)
+ set(_win32_winsock "ws2")
+ else()
+ set(_win32_winsock "ws2_32")
+ endif()
+ set(_win32_crypt32 "crypt32")
+
+ if(MINGW32CE) # FIXME upstream: must specify the full path to avoid CMake converting "ws2" to "ws2.lib"
+ set(_win32_winsock "${MINGW32CE_LIBRARY_DIR}/lib${_win32_winsock}.a")
+ set(_win32_crypt32 "${MINGW32CE_LIBRARY_DIR}/lib${_win32_crypt32}.a")
+ endif()
+elseif(DOS)
if(WATT_ROOT)
set(USE_WATT32 ON)
# FIXME upstream: must specify the full path to avoid CMake converting "watt" to "watt.lib"
set(CURL_USE_OPENSSL ON)
set(CURL_CA_FALLBACK ON CACHE BOOL "")
endif()
-elseif(NOT WIN32 AND NOT APPLE)
+elseif(NOT APPLE)
check_library_exists("socket" "connect" "" HAVE_LIBSOCKET)
if(HAVE_LIBSOCKET)
set(CURL_LIBS "socket" ${CURL_LIBS})
endif()
endif()
endif()
-if(ENABLE_IPV6)
+if(ENABLE_IPV6 AND NOT WINCE)
set(USE_IPV6 ON)
endif()
if(HAVE_LIBZ)
list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
endif()
- if(WIN32)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32")
+ if(WIN32 AND NOT WINCE)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${_win32_winsock}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "bcrypt") # for OpenSSL/LibreSSL
endif()
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB) # Public wolfSSL headers also require zlib headers
endif()
if(WIN32)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32" "crypt32")
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${_win32_winsock}" "${_win32_crypt32}")
endif()
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DHAVE_UINTPTR_T") # to pull in stdint.h (as of wolfSSL v5.5.4)
endif()
endif()
if(NOT CURL_DISABLE_LDAP)
- if(WIN32 AND NOT WINDOWS_STORE)
+ if(WIN32 AND NOT WINDOWS_STORE AND NOT WINCE)
option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON)
if(USE_WIN32_LDAP)
list(APPEND CURL_LIBS "wldap32")
endif()
option(ENABLE_UNIX_SOCKETS "Enable Unix domain sockets support" ON)
-if(ENABLE_UNIX_SOCKETS)
+if(ENABLE_UNIX_SOCKETS AND NOT WINCE)
if(WIN32 OR DOS)
set(USE_UNIX_SOCKETS ON)
else()
list(APPEND CURL_INCLUDES "ws2tcpip.h")
if(HAVE_WIN32_WINNT)
- if(HAVE_WIN32_WINNT LESS 0x0501)
+ if(HAVE_WIN32_WINNT LESS 0x0501 AND NOT WINCE)
# Windows XP is required for freeaddrinfo, getaddrinfo
message(FATAL_ERROR "Building for Windows XP or newer is required.")
endif()
# Pre-fill detection results based on target OS version
- if(MINGW OR MSVC)
+ if(MINGW OR MSVC OR WINCE)
if(HAVE_WIN32_WINNT LESS 0x0600)
set(HAVE_INET_NTOP 0)
set(HAVE_INET_PTON 0)
# Apply to all feature checks
if(WIN32)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32")
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${_win32_winsock}")
elseif(HAVE_LIBSOCKET)
list(APPEND CMAKE_REQUIRED_LIBRARIES "socket")
elseif(DOS)
check_symbol_exists("getsockname" "${CURL_INCLUDES}" HAVE_GETSOCKNAME) # winsock2.h unistd.h proto/bsdsocket.h
check_function_exists("getrlimit" HAVE_GETRLIMIT)
check_function_exists("setlocale" HAVE_SETLOCALE)
-check_function_exists("setmode" HAVE_SETMODE)
check_function_exists("setrlimit" HAVE_SETRLIMIT)
if(NOT WIN32)
check_symbol_exists("strcmpi" "string.h" HAVE_STRCMPI)
endif()
-if(WIN32 OR CYGWIN)
- check_function_exists("_setmode" HAVE__SETMODE)
+if(NOT MINGW32CE) # Avoid false detections
+ check_function_exists("setmode" HAVE_SETMODE)
+ if(WIN32 OR CYGWIN)
+ check_function_exists("_setmode" HAVE__SETMODE)
+ endif()
endif()
if(AMIGA)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "HAVE_CONFIG_H")
if(WIN32)
- list(APPEND CURL_LIBS "ws2_32" "bcrypt")
+ list(APPEND CURL_LIBS "${_win32_winsock}")
+ if(NOT WINCE)
+ list(APPEND CURL_LIBS "bcrypt")
+ endif()
- set(USE_WIN32_LARGE_FILES ON)
+ if(NOT WINCE)
+ set(USE_WIN32_LARGE_FILES ON)
+ endif()
# Use the manifest embedded in the Windows Resource
string(APPEND CMAKE_RC_FLAGS " -DCURL_EMBED_MANIFEST")
# Link required libraries for USE_WIN32_CRYPTO or USE_SCHANNEL
if(USE_WIN32_CRYPTO OR USE_SCHANNEL)
- list(APPEND CURL_LIBS "advapi32" "crypt32")
+ if(NOT WINCE)
+ list(APPEND CURL_LIBS "advapi32")
+ endif()
+ list(APPEND CURL_LIBS "${_win32_crypt32}")
endif()
endif()
AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
if test "$curl_cv_native_windows" = 'yes'; then
AC_MSG_CHECKING([whether build target supports Win32 large files])
- case $host_os in
- mingw32ce*|cegcc*)
- dnl Windows CE does not support large files
- curl_win32_has_largefile='no'
- ;;
- *)
- dnl All mingw-w64 versions support large files
- curl_win32_has_largefile='yes'
- ;;
- esac
+ if test "$curl_cv_wince" = 'yes'; then
+ dnl Windows CE does not support large files
+ curl_win32_has_largefile='no'
+ else
+ dnl All mingw-w64 versions support large files
+ curl_win32_has_largefile='yes'
+ fi
case "$curl_win32_has_largefile" in
yes)
if test x"$enable_largefile" = 'xno'; then
if test "$curl_cv_native_windows" = 'yes'; then
curl_pflags="${curl_pflags} WIN32"
fi
+ if test "$curl_cv_wince" = 'yes'; then
+ curl_pflags="${curl_pflags} WINCE"
+ fi
if test "$curl_cv_winuwp" = 'yes'; then
curl_pflags="${curl_pflags} UWP"
fi
+ case $host in
+ *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
+ curl_pflags="${curl_pflags} UNIX";;
+ esac
+ case $host in
+ *-*-*bsd*)
+ curl_pflags="${curl_pflags} BSD";;
+ esac
if test "$curl_cv_cygwin" = 'yes'; then
curl_pflags="${curl_pflags} CYGWIN"
fi
CURL_CHECK_COMPILER
CURL_CHECK_NATIVE_WINDOWS
+curl_cv_wince='no'
curl_cv_winuwp='no'
if test "$curl_cv_native_windows" = "yes"; then
+ case $host_os in
+ mingw32ce*) curl_cv_wince='yes';;
+ esac
case "$CPPFLAGS" in
*-DWINSTORECOMPAT*) curl_cv_winuwp='yes';;
esac
AC_MSG_RESULT(yes)
)
-if test "$curl_cv_winuwp" = 'yes'; then
+if test "$curl_cv_winuwp" = 'yes' -o "$curl_cv_wince" = 'yes'; then
AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
CURL_DISABLE_TELNET=1
fi
])
fi
+if test "$HAVE_GETHOSTBYNAME" != "1"; then
+ if test "$curl_cv_wince" = 'yes'; then
+ dnl This is for Windows CE systems
+ winsock_LIB="-lws2"
+ if test ! -z "$winsock_LIB"; then
+ my_ac_save_LIBS=$LIBS
+ LIBS="$winsock_LIB $LIBS"
+ AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[
+ #ifdef _WIN32
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
+ #include <winsock2.h>
+ #endif
+ ]],[[
+ gethostbyname("localhost");
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ HAVE_GETHOSTBYNAME="1"
+ ],[
+ AC_MSG_RESULT([no])
+ winsock_LIB=""
+ LIBS=$my_ac_save_LIBS
+ ])
+ fi
+ fi
+fi
+
# In UWP mode gethostbyname gets detected via the core libs, but some
# code (in6addr_any) still need ws2_32, so let us detect and add it.
if test "$HAVE_GETHOSTBYNAME" != "1" -o "$curl_cv_winuwp" = "yes"; then
- dnl This is for Winsock systems
if test "$curl_cv_native_windows" = "yes"; then
+ dnl This is for Winsock systems
winsock_LIB="-lws2_32"
if test ! -z "$winsock_LIB"; then
my_ac_save_LIBS=$LIBS
)
)
+if test "$curl_cv_wince" = 'yes'; then
+ ipv6=no
+fi
+
if test "$ipv6" = yes; then
curl_ipv6_msg="enabled"
AC_DEFINE(USE_IPV6, 1, [Define if you want to enable IPv6 support])
dnl link required libraries for USE_WIN32_CRYPTO or SCHANNEL_ENABLED
if test "x$USE_WIN32_CRYPTO" = "x1" -o "x$SCHANNEL_ENABLED" = "x1"; then
- LIBS="-ladvapi32 -lcrypt32 $LIBS"
+ LIBS="-lcrypt32 $LIBS"
+ if test "$curl_cv_wince" = 'no'; then
+ LIBS="-ladvapi32 $LIBS"
+ fi
fi
dnl link bcrypt for BCryptGenRandom() (used when building for Vista or newer)
-if test "x$curl_cv_native_windows" = "xyes"; then
+if test "x$curl_cv_native_windows" = "xyes" -a "$curl_cv_wince" = 'no'; then
LIBS="-lbcrypt $LIBS"
fi
dnl check Windows Unicode option
dnl ----------------------------
-want_winuni="no"
+if test "$curl_cv_wince" = 'yes'; then
+ want_winuni="yes"
+else
+ want_winuni="no"
+fi
if test "$curl_cv_native_windows" = "yes"; then
if test "$curl_cv_winuwp" = 'yes'; then
want_winuni="yes"
sendmsg \
sendmmsg \
setlocale \
- setmode \
setrlimit \
snprintf \
utime \
CURL_CHECK_FUNC_STRICMP
fi
-if test "$curl_cv_native_windows" = 'yes' -o "$curl_cv_cygwin" = 'yes'; then
- AC_CHECK_FUNCS([_setmode])
+if test "$curl_cv_wince" = 'no'; then
+ AC_CHECK_FUNCS([setmode])
+ if test "$curl_cv_native_windows" = 'yes' -o "$curl_cv_cygwin" = 'yes'; then
+ AC_CHECK_FUNCS([_setmode])
+ fi
fi
if test -z "$ssl_backends"; then
want_unix_sockets=auto
]
)
-if test "x$want_unix_sockets" != "xno"; then
+if test "x$want_unix_sockets" != "xno" -a "$curl_cv_wince" = 'no'; then
if test "x$curl_cv_native_windows" = "xyes"; then
USE_UNIX_SOCKETS=1
AC_DEFINE(USE_UNIX_SOCKETS, 1, [Use Unix domain sockets])
if(!fp)
return 2;
+#ifdef UNDER_CE
+ stat(file, &file_info);
+#else
fstat(fileno(fp), &file_info);
+#endif
/* In Windows, this inits the Winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
* filter IP addresses.
*/
-#ifdef __AMIGA__
+#if defined(__AMIGA__) || defined(UNDER_CE)
#include <stdio.h>
-int main(void) { printf("AmigaOS is not supported.\n"); return 1; }
+int main(void) { printf("Platform not supported.\n"); return 1; }
#else
#ifdef _WIN32
#include <unistd.h> /* misc. Unix functions */
#endif
+#ifdef UNDER_CE
+#define strerror(e) "?"
+#else
#include <errno.h>
+#endif
/* The IP address and port number to connect to */
#define IPADDR "127.0.0.1"
return 1; /* cannot continue */
/* to get the file size */
+#ifdef UNDER_CE
+ if(stat("debugit", &file_info) != 0) {
+#else
if(fstat(fileno(fd), &file_info) != 0) {
+#endif
fclose(fd);
return 1; /* cannot continue */
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#ifdef UNDER_CE
+#define strerror(e) "?"
+#else
#include <errno.h>
+#endif
#ifdef _WIN32
#include <io.h>
#undef stat
f = fopen(localpath, "rb");
if(!f) {
+#ifndef UNDER_CE
perror(NULL);
+#endif
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef UNDER_CE
+#define strerror(e) "?"
+#else
#include <errno.h>
+#endif
/* curl stuff */
#include <curl/curl.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
+#ifdef UNDER_CE
+#define strerror(e) "?"
+#else
#include <errno.h>
+#endif
/* somewhat Unix-specific */
#ifndef _MSC_VER
f = fopen(localpath, "rb");
if(!f) {
+#ifndef UNDER_CE
perror(NULL);
+#endif
return 0;
}
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc);
curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
_fseeki64(f, remoteFileSizeByte, SEEK_SET);
#else
fseek(f, (long)remoteFileSizeByte, SEEK_SET);
#include <sys/select.h>
#endif
-#if !defined(_WIN32) && !defined(_WIN32_WCE)
-#include <sys/socket.h>
-#endif
-
#if !defined(_WIN32)
+#include <sys/socket.h>
#include <sys/time.h>
#endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
# endif
-#elif defined(_WIN32_WCE)
-# define CURL_TYPEOF_CURL_OFF_T __int64
-# define CURL_FORMAT_CURL_OFF_T "I64d"
-# define CURL_FORMAT_CURL_OFF_TU "I64u"
-# define CURL_SUFFIX_CURL_OFF_T i64
-# define CURL_SUFFIX_CURL_OFF_TU ui64
-# define CURL_TYPEOF_CURL_SOCKLEN_T int
+#elif defined(UNDER_CE)
+# if defined(__MINGW32CE__)
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
+# else
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T i64
+# define CURL_SUFFIX_CURL_OFF_TU ui64
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
+# endif
#elif defined(__MINGW32__)
# include <inttypes.h>
* and wait on it.
*/
static
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
DWORD
#else
unsigned int
* gethostbyname_thread() resolves a name and then exits.
*/
static
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
DWORD
#else
unsigned int
destroy_async_data(data);
errno_exit:
- errno = err;
+ CURL_SETERRNO(err);
return FALSE;
}
* Someone got to verify this on Win-NT 4.0, 2000."
*/
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
Sleep(0);
#else
SleepEx(0, FALSE);
if(0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
err = SOCKERRNO;
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
/* Old Windows CE versions do not support SO_ERROR */
if(WSAENOPROTOOPT == err) {
SET_SOCKERRNO(0);
/* Define if you have the <arpa/inet.h> header file. */
/* #define HAVE_ARPA_INET_H 1 */
+#ifndef UNDER_CE
+
/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
+#define HAVE_FCNTL_H 1 /* exists on __MINGW32CE__ */
/* Define if you have the <io.h> header file. */
-#define HAVE_IO_H 1
+#define HAVE_IO_H 1 /* exists on __MINGW32CE__ */
/* Define if you have the <locale.h> header file. */
-#ifndef UNDER_CE
#define HAVE_LOCALE_H 1
+
#endif
/* Define if you have the <netdb.h> header file. */
/* #define HAVE_NETINET_IN_H 1 */
/* Define to 1 if you have the <stdbool.h> header file. */
+#ifndef UNDER_CE
#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || defined(__MINGW32__)
-#define HAVE_STDBOOL_H 1
+#define HAVE_STDBOOL_H 1 /* exists on __MINGW32CE__ */
+#endif
#endif
/* Define if you have the <sys/param.h> header file. */
#define STDC_HEADERS 1
/* Define to 1 if bool is an available type. */
+#ifndef UNDER_CE
#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || defined(__MINGW32__)
-#define HAVE_BOOL_T 1
+#define HAVE_BOOL_T 1 /* exists on __MINGW32CE__ */
+#endif
#endif
/* ---------------------------------------------------------------- */
#define CURL_DISABLE_TELNET 1
#define CURL_DISABLE_LDAP 1
-#define ENOSPC 1
-#define ENOMEM 2
-#define EAGAIN 3
-
+#ifndef _MSC_VER
extern int stat(const char *path, struct stat *buffer);
+#endif
#endif /* UNDER_CE */
addr[0] = '\0';
*port = 0;
- errno = EAFNOSUPPORT;
+ CURL_SETERRNO(EAFNOSUPPORT);
return FALSE;
}
return str_utf8;
}
+#ifndef UNDER_CE
+
/* declare GetFullPathNameW for mingw-w64 UWP builds targeting old windows */
#if defined(CURL_WINDOWS_UWP) && defined(__MINGW32__) && \
(_WIN32_WINNT < _WIN32_WINNT_WIN10)
curlx_unicodefree(filename_w);
}
else
- errno = EINVAL;
+ CURL_SETERRNO(EINVAL);
#else
if(fix_excessive_path(filename, &fixed))
target = fixed;
result = _wfopen(target, mode_w);
}
else
- errno = EINVAL;
+ CURL_SETERRNO(EINVAL);
curlx_unicodefree(filename_w);
curlx_unicodefree(mode_w);
#else
curlx_unicodefree(path_w);
}
else
- errno = EINVAL;
+ CURL_SETERRNO(EINVAL);
#else
if(fix_excessive_path(path, &fixed))
target = fixed;
return result;
}
+#endif /* UNDER_CE */
+
#endif /* _WIN32 */
*/
#ifdef USE_WIN32_LARGE_FILES
+# ifdef HAVE_IO_H
# include <io.h>
+# endif
# include <sys/types.h>
# include <sys/stat.h>
# undef lseek
*/
#if defined(_WIN32) && !defined(USE_WIN32_LARGE_FILES)
+# ifdef HAVE_IO_H
# include <io.h>
+# endif
# include <sys/types.h>
# include <sys/stat.h>
-# ifndef _WIN32_WCE
+# ifndef UNDER_CE
# undef lseek
# define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
# define fstat(fdes,stp) _fstat(fdes, stp)
#include "curl_setup_once.h"
#endif
+#ifdef UNDER_CE
+#define getenv curl_getenv /* Windows CE does not support getenv() */
+#define raise(s) ((void)(s))
+/* Terrible workarounds to make Windows CE compile */
+#define errno 0
+#define CURL_SETERRNO(x) ((void)(x))
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EEXIST 17
+#define EISDIR 21
+#define ENOSPC 28
+#define ERANGE 34
+#define strerror(x) "?"
+#else
+#define CURL_SETERRNO(x) (errno = (x))
+#endif
+
/*
* Definition of our NOP statement Object-like macro
*/
#include <string.h>
#include <stdarg.h>
#include <time.h>
+#ifndef UNDER_CE
#include <errno.h>
+#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#ifdef __VMS
#define argv_item_t __char_ptr32
-#elif defined(_UNICODE)
+#elif defined(_UNICODE) && !defined(UNDER_CE)
#define argv_item_t wchar_t *
#else
#define argv_item_t char *
/* See definition of SECURITY_ENTRYPOINT in sspi.h */
#ifdef UNICODE
-# ifdef _WIN32_WCE
+# ifdef UNDER_CE
# define SECURITYENTRYPOINT L"InitSecurityInterfaceW"
# else
# define SECURITYENTRYPOINT "InitSecurityInterfaceW"
#define ISC_REQ_USE_HTTP_STYLE 0x01000000
#endif
+#ifdef __MINGW32CE__
+#ifndef ISC_RET_REPLAY_DETECT
+#define ISC_RET_REPLAY_DETECT 0x00000004
+#endif
+#ifndef ISC_RET_SEQUENCE_DETECT
+#define ISC_RET_SEQUENCE_DETECT 0x00000008
+#endif
+#ifndef ISC_RET_CONFIDENTIALITY
+#define ISC_RET_CONFIDENTIALITY 0x00000010
+#endif
+#ifndef ISC_RET_ALLOCATED_MEMORY
+#define ISC_RET_ALLOCATED_MEMORY 0x00000100
+#endif
+#ifndef ISC_RET_STREAM
+#define ISC_RET_STREAM 0x00008000
+#endif
+
+#ifndef SEC_E_INSUFFICIENT_MEMORY
+#define SEC_E_INSUFFICIENT_MEMORY ((HRESULT)0x80090300L)
+#endif
+#ifndef SEC_E_INVALID_HANDLE
+#define SEC_E_INVALID_HANDLE ((HRESULT)0x80090301L)
+#endif
+#ifndef SEC_E_UNSUPPORTED_FUNCTION
+#define SEC_E_UNSUPPORTED_FUNCTION ((HRESULT)0x80090302L)
+#endif
+#ifndef SEC_E_TARGET_UNKNOWN
+#define SEC_E_TARGET_UNKNOWN ((HRESULT)0x80090303L)
+#endif
+#ifndef SEC_E_INTERNAL_ERROR
+#define SEC_E_INTERNAL_ERROR ((HRESULT)0x80090304L)
+#endif
+#ifndef SEC_E_SECPKG_NOT_FOUND
+#define SEC_E_SECPKG_NOT_FOUND ((HRESULT)0x80090305L)
+#endif
+#ifndef SEC_E_NOT_OWNER
+#define SEC_E_NOT_OWNER ((HRESULT)0x80090306L)
+#endif
+#ifndef SEC_E_CANNOT_INSTALL
+#define SEC_E_CANNOT_INSTALL ((HRESULT)0x80090307L)
+#endif
+#ifndef SEC_E_INVALID_TOKEN
+#define SEC_E_INVALID_TOKEN ((HRESULT)0x80090308L)
+#endif
+#ifndef SEC_E_CANNOT_PACK
+#define SEC_E_CANNOT_PACK ((HRESULT)0x80090309L)
+#endif
+#ifndef SEC_E_QOP_NOT_SUPPORTED
+#define SEC_E_QOP_NOT_SUPPORTED ((HRESULT)0x8009030AL)
+#endif
+#ifndef SEC_E_NO_IMPERSONATION
+#define SEC_E_NO_IMPERSONATION ((HRESULT)0x8009030BL)
+#endif
+#ifndef SEC_E_LOGON_DENIED
+#define SEC_E_LOGON_DENIED ((HRESULT)0x8009030CL)
+#endif
+#ifndef SEC_E_UNKNOWN_CREDENTIALS
+#define SEC_E_UNKNOWN_CREDENTIALS ((HRESULT)0x8009030DL)
+#endif
+#ifndef SEC_E_NO_CREDENTIALS
+#define SEC_E_NO_CREDENTIALS ((HRESULT)0x8009030EL)
+#endif
+#ifndef SEC_E_MESSAGE_ALTERED
+#define SEC_E_MESSAGE_ALTERED ((HRESULT)0x8009030FL)
+#endif
+#ifndef SEC_E_OUT_OF_SEQUENCE
+#define SEC_E_OUT_OF_SEQUENCE ((HRESULT)0x80090310L)
+#endif
+#ifndef SEC_E_NO_AUTHENTICATING_AUTHORITY
+#define SEC_E_NO_AUTHENTICATING_AUTHORITY ((HRESULT)0x80090311L)
+#endif
+#ifndef SEC_E_BAD_PKGID
+#define SEC_E_BAD_PKGID ((HRESULT)0x80090316L)
+#endif
+#ifndef SEC_E_CONTEXT_EXPIRED
+#define SEC_E_CONTEXT_EXPIRED ((HRESULT)0x80090317L)
+#endif
+#ifndef SEC_E_INCOMPLETE_MESSAGE
+#define SEC_E_INCOMPLETE_MESSAGE ((HRESULT)0x80090318L)
+#endif
+#ifndef SEC_E_INCOMPLETE_CREDENTIALS
+#define SEC_E_INCOMPLETE_CREDENTIALS ((HRESULT)0x80090320L)
+#endif
+#ifndef SEC_E_BUFFER_TOO_SMALL
+#define SEC_E_BUFFER_TOO_SMALL ((HRESULT)0x80090321L)
+#endif
+#ifndef SEC_E_WRONG_PRINCIPAL
+#define SEC_E_WRONG_PRINCIPAL ((HRESULT)0x80090322L)
+#endif
+#ifndef SEC_E_TIME_SKEW
+#define SEC_E_TIME_SKEW ((HRESULT)0x80090324L)
+#endif
+#ifndef SEC_E_UNTRUSTED_ROOT
+#define SEC_E_UNTRUSTED_ROOT ((HRESULT)0x80090325L)
+#endif
+#ifndef SEC_E_ILLEGAL_MESSAGE
+#define SEC_E_ILLEGAL_MESSAGE ((HRESULT)0x80090326L)
+#endif
+#ifndef SEC_E_CERT_UNKNOWN
+#define SEC_E_CERT_UNKNOWN ((HRESULT)0x80090327L)
+#endif
+#ifndef SEC_E_CERT_EXPIRED
+#define SEC_E_CERT_EXPIRED ((HRESULT)0x80090328L)
+#endif
+#ifndef SEC_E_ENCRYPT_FAILURE
+#define SEC_E_ENCRYPT_FAILURE ((HRESULT)0x80090329L)
+#endif
+#ifndef SEC_E_DECRYPT_FAILURE
+#define SEC_E_DECRYPT_FAILURE ((HRESULT)0x80090330L)
+#endif
+#ifndef SEC_E_ALGORITHM_MISMATCH
+#define SEC_E_ALGORITHM_MISMATCH ((HRESULT)0x80090331L)
+#endif
+#ifndef SEC_E_SECURITY_QOS_FAILED
+#define SEC_E_SECURITY_QOS_FAILED ((HRESULT)0x80090332L)
+#endif
+#ifndef SEC_E_UNFINISHED_CONTEXT_DELETED
+#define SEC_E_UNFINISHED_CONTEXT_DELETED ((HRESULT)0x80090333L)
+#endif
+#ifndef SEC_E_NO_TGT_REPLY
+#define SEC_E_NO_TGT_REPLY ((HRESULT)0x80090334L)
+#endif
+#ifndef SEC_E_NO_IP_ADDRESSES
+#define SEC_E_NO_IP_ADDRESSES ((HRESULT)0x80090335L)
+#endif
+#ifndef SEC_E_WRONG_CREDENTIAL_HANDLE
+#define SEC_E_WRONG_CREDENTIAL_HANDLE ((HRESULT)0x80090336L)
+#endif
+#ifndef SEC_E_CRYPTO_SYSTEM_INVALID
+#define SEC_E_CRYPTO_SYSTEM_INVALID ((HRESULT)0x80090337L)
+#endif
+#ifndef SEC_E_MAX_REFERRALS_EXCEEDED
+#define SEC_E_MAX_REFERRALS_EXCEEDED ((HRESULT)0x80090338L)
+#endif
+#ifndef SEC_E_MUST_BE_KDC
+#define SEC_E_MUST_BE_KDC ((HRESULT)0x80090339L)
+#endif
+#ifndef SEC_E_STRONG_CRYPTO_NOT_SUPPORTED
+#define SEC_E_STRONG_CRYPTO_NOT_SUPPORTED ((HRESULT)0x8009033AL)
+#endif
+#ifndef SEC_E_TOO_MANY_PRINCIPALS
+#define SEC_E_TOO_MANY_PRINCIPALS ((HRESULT)0x8009033BL)
+#endif
+#ifndef SEC_E_NO_PA_DATA
+#define SEC_E_NO_PA_DATA ((HRESULT)0x8009033CL)
+#endif
+#ifndef SEC_E_PKINIT_NAME_MISMATCH
+#define SEC_E_PKINIT_NAME_MISMATCH ((HRESULT)0x8009033DL)
+#endif
+#ifndef SEC_E_SMARTCARD_LOGON_REQUIRED
+#define SEC_E_SMARTCARD_LOGON_REQUIRED ((HRESULT)0x8009033EL)
+#endif
+#ifndef SEC_E_SHUTDOWN_IN_PROGRESS
+#define SEC_E_SHUTDOWN_IN_PROGRESS ((HRESULT)0x8009033FL)
+#endif
+#ifndef SEC_E_KDC_INVALID_REQUEST
+#define SEC_E_KDC_INVALID_REQUEST ((HRESULT)0x80090340L)
+#endif
+#ifndef SEC_E_KDC_UNABLE_TO_REFER
+#define SEC_E_KDC_UNABLE_TO_REFER ((HRESULT)0x80090341L)
+#endif
+#ifndef SEC_E_KDC_UNKNOWN_ETYPE
+#define SEC_E_KDC_UNKNOWN_ETYPE ((HRESULT)0x80090342L)
+#endif
+#ifndef SEC_E_UNSUPPORTED_PREAUTH
+#define SEC_E_UNSUPPORTED_PREAUTH ((HRESULT)0x80090343L)
+#endif
+#ifndef SEC_E_DELEGATION_REQUIRED
+#define SEC_E_DELEGATION_REQUIRED ((HRESULT)0x80090345L)
+#endif
+#ifndef SEC_E_BAD_BINDINGS
+#define SEC_E_BAD_BINDINGS ((HRESULT)0x80090346L)
+#endif
+#ifndef SEC_E_MULTIPLE_ACCOUNTS
+#define SEC_E_MULTIPLE_ACCOUNTS ((HRESULT)0x80090347L)
+#endif
+#ifndef SEC_E_NO_KERB_KEY
+#define SEC_E_NO_KERB_KEY ((HRESULT)0x80090348L)
+#endif
+#ifndef SEC_E_CERT_WRONG_USAGE
+#define SEC_E_CERT_WRONG_USAGE ((HRESULT)0x80090349L)
+#endif
+#ifndef SEC_E_DOWNGRADE_DETECTED
+#define SEC_E_DOWNGRADE_DETECTED ((HRESULT)0x80090350L)
+#endif
+#ifndef SEC_E_SMARTCARD_CERT_REVOKED
+#define SEC_E_SMARTCARD_CERT_REVOKED ((HRESULT)0x80090351L)
+#endif
+#ifndef SEC_E_ISSUING_CA_UNTRUSTED
+#define SEC_E_ISSUING_CA_UNTRUSTED ((HRESULT)0x80090352L)
+#endif
+#ifndef SEC_E_REVOCATION_OFFLINE_C
+#define SEC_E_REVOCATION_OFFLINE_C ((HRESULT)0x80090353L)
+#endif
+#ifndef SEC_E_PKINIT_CLIENT_FAILURE
+#define SEC_E_PKINIT_CLIENT_FAILURE ((HRESULT)0x80090354L)
+#endif
+#ifndef SEC_E_SMARTCARD_CERT_EXPIRED
+#define SEC_E_SMARTCARD_CERT_EXPIRED ((HRESULT)0x80090355L)
+#endif
+#ifndef SEC_E_NO_S4U_PROT_SUPPORT
+#define SEC_E_NO_S4U_PROT_SUPPORT ((HRESULT)0x80090356L)
+#endif
+#ifndef SEC_E_CROSSREALM_DELEGATION_FAILURE
+#define SEC_E_CROSSREALM_DELEGATION_FAILURE ((HRESULT)0x80090357L)
+#endif
+#ifndef SEC_E_REVOCATION_OFFLINE_KDC
+#define SEC_E_REVOCATION_OFFLINE_KDC ((HRESULT)0x80090358L)
+#endif
+#ifndef SEC_E_ISSUING_CA_UNTRUSTED_KDC
+#define SEC_E_ISSUING_CA_UNTRUSTED_KDC ((HRESULT)0x80090359L)
+#endif
+#ifndef SEC_E_KDC_CERT_EXPIRED
+#define SEC_E_KDC_CERT_EXPIRED ((HRESULT)0x8009035AL)
+#endif
+#ifndef SEC_E_KDC_CERT_REVOKED
+#define SEC_E_KDC_CERT_REVOKED ((HRESULT)0x8009035BL)
+#endif
+#endif /* __MINGW32CE__ */
#ifndef SEC_E_INVALID_PARAMETER
# define SEC_E_INVALID_PARAMETER ((HRESULT)0x8009035DL)
#endif
# define SEC_E_POLICY_NLTM_ONLY ((HRESULT)0x8009035FL)
#endif
+#ifdef __MINGW32CE__
+#ifndef SEC_I_CONTINUE_NEEDED
+#define SEC_I_CONTINUE_NEEDED ((HRESULT)0x00090312L)
+#endif
+#ifndef SEC_I_COMPLETE_NEEDED
+#define SEC_I_COMPLETE_NEEDED ((HRESULT)0x00090313L)
+#endif
+#ifndef SEC_I_COMPLETE_AND_CONTINUE
+#define SEC_I_COMPLETE_AND_CONTINUE ((HRESULT)0x00090314L)
+#endif
+#ifndef SEC_I_LOCAL_LOGON
+#define SEC_I_LOCAL_LOGON ((HRESULT)0x00090315L)
+#endif
+#ifndef SEC_I_CONTEXT_EXPIRED
+#define SEC_I_CONTEXT_EXPIRED ((HRESULT)0x00090317L)
+#endif
+#ifndef SEC_I_INCOMPLETE_CREDENTIALS
+#define SEC_I_INCOMPLETE_CREDENTIALS ((HRESULT)0x00090320L)
+#endif
+#ifndef SEC_I_RENEGOTIATE
+#define SEC_I_RENEGOTIATE ((HRESULT)0x00090321L)
+#endif
+#ifndef SEC_I_NO_LSA_CONTEXT
+#define SEC_I_NO_LSA_CONTEXT ((HRESULT)0x00090323L)
+#endif
+#endif /* __MINGW32CE__ */
#ifndef SEC_I_SIGNATURE_NEEDED
#define SEC_I_SIGNATURE_NEEDED ((HRESULT)0x0009035CL)
#endif
#elif defined(USE_THREADS_WIN32)
curl_thread_t Curl_thread_create(
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
DWORD
#else
unsigned int
(CURL_STDCALL *func) (void *),
void *arg)
{
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
typedef HANDLE curl_win_thread_handle_t;
#else
typedef uintptr_t curl_win_thread_handle_t;
#endif
curl_thread_t t;
curl_win_thread_handle_t thread_handle;
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
thread_handle = CreateThread(NULL, 0, func, arg, 0, NULL);
#else
thread_handle = _beginthreadex(NULL, 0, func, arg, 0, NULL);
#endif
t = (curl_thread_t)thread_handle;
if((t == 0) || (t == LongToHandle(-1L))) {
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
DWORD gle = GetLastError();
- errno = ((gle == ERROR_ACCESS_DENIED ||
- gle == ERROR_NOT_ENOUGH_MEMORY) ?
- EACCES : EINVAL);
+ int err = (gle == ERROR_ACCESS_DENIED ||
+ gle == ERROR_NOT_ENOUGH_MEMORY) ?
+ EACCES : EINVAL;
+ CURL_SETERRNO(err);
#endif
return curl_thread_t_null;
}
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
curl_thread_t Curl_thread_create(
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
DWORD
#else
unsigned int
* ways, but at this point it must be defined as the system-supplied strdup
* so the callback pointer is initialized correctly.
*/
-#if defined(_WIN32_WCE)
+#if defined(UNDER_CE)
#define system_strdup _strdup
#elif !defined(HAVE_STRDUP)
#define system_strdup Curl_strdup
if(data->state.resume_from) {
if(!S_ISDIR(statbuf.st_mode)) {
-#ifdef __AMIGA__
+#if defined(__AMIGA__) || defined(__MINGW32CE__)
if(data->state.resume_from !=
lseek(fd, (off_t)data->state.resume_from, SEEK_SET))
#else
*fh = fopen(filename, FOPEN_WRITETEXT);
if(!*fh)
goto fail;
- if(fstat(fileno(*fh), &sb) == -1 || !S_ISREG(sb.st_mode)) {
+ if(
+#ifdef UNDER_CE
+ stat(filename, &sb) == -1
+#else
+ fstat(fileno(*fh), &sb) == -1
+#endif
+ || !S_ISREG(sb.st_mode)) {
return CURLE_OK;
}
fclose(*fh);
/* shut down the socket to inform the server we are done */
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
shutdown(conn->sock[SECONDARYSOCKET], 2); /* SD_BOTH */
#endif
static char *GetEnv(const char *variable)
{
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP) || \
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE) || \
defined(__ORBIS__) || defined(__PROSPERO__) /* PlayStation 4 and 5 */
(void)variable;
return NULL;
#endif
#include <setjmp.h>
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#include "urldata.h"
#include "sendf.h"
len = strlen(tmp);
if(len == 0 || len >= size) {
- errno = ENOSPC;
+ CURL_SETERRNO(ENOSPC);
return NULL;
}
strcpy(dst, tmp);
if(i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if(!inet_ntop4(src + 12, tp, sizeof(tmp) - (tp - tmp))) {
- errno = ENOSPC;
+ CURL_SETERRNO(ENOSPC);
return NULL;
}
tp += strlen(tp);
/* Check for overflow, copy, and we are done.
*/
if((size_t)(tp - tmp) > size) {
- errno = ENOSPC;
+ CURL_SETERRNO(ENOSPC);
return NULL;
}
strcpy(dst, tmp);
case AF_INET6:
return inet_ntop6((const unsigned char *)src, buf, size);
default:
- errno = EAFNOSUPPORT;
+ CURL_SETERRNO(EAFNOSUPPORT);
return NULL;
}
}
case AF_INET6:
return inet_pton6(src, (unsigned char *)dst);
default:
- errno = EAFNOSUPPORT;
+ CURL_SETERRNO(EAFNOSUPPORT);
return -1;
}
/* NOTREACHED */
fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
source, line, func);
fflush(curl_dbg_logfile); /* because it might crash now */
- errno = ENOMEM;
+ CURL_SETERRNO(ENOMEM);
return TRUE; /* RETURN ERROR! */
}
else
case 'h':
flags |= FLAGS_SHORT;
break;
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#ifdef _WIN32
case 'I':
/* Non-ANSI integer extensions I32 I64 */
if((fmt[0] == '3') && (fmt[1] == '2')) {
#endif
}
break;
-#endif /* _WIN32 || _WIN32_WCE */
+#endif /* _WIN32 */
case 'l':
if(flags & FLAGS_LONG)
flags |= FLAGS_LONGLONG;
/* return 0 on success, 1 on error */
int Curl_rename(const char *oldpath, const char *newpath)
{
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
/* rename() on Windows does not overwrite, so we cannot use it here.
MoveFileEx() will overwrite and is usually atomic, however it fails
when there are open handles to the file. */
* This is a socketpair() implementation for Windows.
*/
#include <string.h>
+#ifdef HAVE_IO_H
#include <io.h>
+#endif
#else
#ifdef HAVE_NETDB_H
#include <netdb.h>
#include "curl_memory.h"
#include "memdebug.h"
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#ifdef _WIN32
#define PRESERVE_WINDOWS_ERROR_CODE
#endif
}
#endif /* USE_WINSOCK */
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#ifdef _WIN32
/* This is a helper function for Curl_strerror that converts Windows API error
* codes (GetLastError) to error messages.
* Returns NULL if no error message was found for error code.
return *buf ? buf : NULL;
}
-#endif /* _WIN32 || _WIN32_WCE */
+#endif /* _WIN32 */
/*
* Our thread-safe and smart strerror() replacement.
*buf = '\0';
-#if defined(_WIN32) || defined(_WIN32_WCE)
-#if defined(_WIN32)
+#ifdef _WIN32
+#ifndef UNDER_CE
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
if(err >= 0 && err < sys_nerr)
msnprintf(buf, buflen, "%s", sys_errlist[err]);
*p = '\0';
if(errno != old_errno)
- errno = old_errno;
+ CURL_SETERRNO(old_errno);
#ifdef PRESERVE_WINDOWS_ERROR_CODE
if(old_win_err != GetLastError())
* Curl_winapi_strerror:
* Variant of Curl_strerror if the error code is definitely Windows API.
*/
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#ifdef _WIN32
const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
{
#ifdef PRESERVE_WINDOWS_ERROR_CODE
#endif
if(errno != old_errno)
- errno = old_errno;
+ CURL_SETERRNO(old_errno);
#ifdef PRESERVE_WINDOWS_ERROR_CODE
if(old_win_err != GetLastError())
return buf;
}
-#endif /* _WIN32 || _WIN32_WCE */
+#endif /* _WIN32 */
#ifdef USE_WINDOWS_SSPI
/*
#endif
if(errno != old_errno)
- errno = old_errno;
+ CURL_SETERRNO(old_errno);
#ifdef PRESERVE_WINDOWS_ERROR_CODE
if(old_win_err != GetLastError())
#define STRERROR_LEN 256 /* a suitable length */
const char *Curl_strerror(int err, char *buf, size_t buflen);
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#ifdef _WIN32
const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen);
#endif
#ifdef USE_WINDOWS_SSPI
s_hIpHlpApiDll = Curl_load_library(TEXT("iphlpapi.dll"));
if(s_hIpHlpApiDll) {
/* Get the address of the if_nametoindex function */
+#ifdef UNDER_CE
+ #define CURL_TEXT(n) TEXT(n)
+#else
+ #define CURL_TEXT(n) (n)
+#endif
IF_NAMETOINDEX_FN pIfNameToIndex =
CURLX_FUNCTION_CAST(IF_NAMETOINDEX_FN,
- (GetProcAddress(s_hIpHlpApiDll, "if_nametoindex")));
+ (GetProcAddress(s_hIpHlpApiDll,
+ CURL_TEXT("if_nametoindex"))));
if(pIfNameToIndex)
Curl_if_nametoindex = pIfNameToIndex;
/* See function definitions in winbase.h */
#ifdef UNICODE
-# ifdef _WIN32_WCE
+# ifdef UNDER_CE
# define LOADLIBARYEX L"LoadLibraryExW"
# else
# define LOADLIBARYEX "LoadLibraryExW"
*/
HMODULE Curl_load_library(LPCTSTR filename)
{
-#ifndef CURL_WINDOWS_UWP
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
HMODULE hModule = NULL;
LOADLIBRARYEX_FN pLoadLibraryEx = NULL;
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
if(*c == '[')
return HOST_IPV6;
- errno = 0; /* for strtoul */
while(!done) {
int rc;
curl_off_t l;
#include "curl_printf.h"
-#include <errno.h>
#include <rustls.h>
#include "inet_pton.h"
#define CALG_SHA_256 0x0000800c
#endif
+/* Work around typo in CeGCC (as of 0.59.1) w32api headers */
+#if defined(__MINGW32CE__) && \
+ !defined(ALG_CLASS_DHASH) && defined(ALG_CLASS_HASH)
+#define ALG_CLASS_DHASH ALG_CLASS_HASH
+#endif
+
#ifndef PKCS12_NO_PERSIST_KEY
#define PKCS12_NO_PERSIST_KEY 0x00008000
#endif
https://technet.microsoft.com/en-us/library/hh831771%28v=ws.11%29.aspx
Or mingw-w64 9.0 or upper.
*/
-#if (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 9) || \
+#if (defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 9) || \
(defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(_USING_V110_SDK71_))
#define HAS_ALPN_SCHANNEL
static bool s_win_has_alpn;
struct ssl_connect_data *connssl = cf->ctx;
struct schannel_ssl_backend_data *backend =
(struct schannel_ssl_backend_data *)connssl->backend;
+#ifndef UNDER_CE
struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
+#endif
struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
SecBuffer outbuf;
SecBufferDesc outbuf_desc;
backend->use_alpn = FALSE;
#endif
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
#ifdef HAS_MANUAL_VERIFY_API
- /* certificate validation on CE does not seem to work right; we will
+ /* certificate validation on Windows CE does not seem to work right; we will
* do it following a more manual process. */
backend->use_manual_cred_validation = TRUE;
#else
static int schannel_init(void)
{
-#ifdef HAS_ALPN_SCHANNEL
+#if defined(HAS_ALPN_SCHANNEL) && !defined(UNDER_CE)
bool wine = FALSE;
bool wine_has_alpn = FALSE;
Assume no WINE because WINE has no UWP support. */
WINE_GET_VERSION_FN p_wine_get_version =
CURLX_FUNCTION_CAST(WINE_GET_VERSION_FN,
- (GetProcAddress(GetModuleHandle(TEXT("ntdll")),
+ (GetProcAddress(GetModuleHandleA("ntdll"),
"wine_get_version")));
wine = !!p_wine_get_version;
if(wine) {
s_win_has_alpn = curlx_verify_windows_version(6, 3, 0, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL);
}
-#endif /* HAS_ALPN_SCHANNEL */
+#endif /* HAS_ALPN_SCHANNEL && !UNDER_CE */
return Curl_sspi_global_init() == CURLE_OK ? 1 : 0;
}
if(!CryptCreateHash(hProv, algId, 0, 0, &hHash))
break; /* failed */
+#ifdef __MINGW32CE__
+ /* workaround for CeGCC, should be (const BYTE*) */
+ if(!CryptHashData(hHash, (BYTE*)input, (DWORD)inputlen, 0))
+#else
if(!CryptHashData(hHash, input, (DWORD)inputlen, 0))
+#endif
break; /* failed */
/* get hash size */
#ifdef HAS_MANUAL_VERIFY_API
+#ifdef __MINGW32CE__
+#define CERT_QUERY_OBJECT_BLOB 0x00000002
+#define CERT_QUERY_CONTENT_CERT 1
+#define CERT_QUERY_CONTENT_FLAG_CERT (1 << CERT_QUERY_CONTENT_CERT)
+#define CERT_QUERY_FORMAT_BINARY 1
+#define CERT_QUERY_FORMAT_BASE64_ENCODED 2
+#define CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED 3
+#define CERT_QUERY_FORMAT_FLAG_ALL \
+ (1 << CERT_QUERY_FORMAT_BINARY) | \
+ (1 << CERT_QUERY_FORMAT_BASE64_ENCODED) | \
+ (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
+#define CERT_CHAIN_REVOCATION_CHECK_CHAIN 0x20000000
+#define CERT_NAME_DISABLE_IE4_UTF8_FLAG 0x00010000
+#define CERT_TRUST_IS_OFFLINE_REVOCATION 0x01000000
+#endif /* __MINGW32CE__ */
+
#define MAX_CAFILE_SIZE 1048576 /* 1 MiB */
#define BEGIN_CERT "-----BEGIN CERTIFICATE-----"
#define END_CERT "\n-----END CERTIFICATE-----"
HCERTSTORE hExclusiveTrustedPeople;
};
+#ifndef UNDER_CE
static int is_cr_or_lf(char c)
{
return c == '\r' || c == '\n';
return result;
}
+#endif
#endif /* HAS_MANUAL_VERIFY_API */
+#ifndef UNDER_CE
/*
* Returns the number of characters necessary to populate all the host_names.
* If host_names is not NULL, populate it with all the hostnames. Each string
#endif
return result;
}
+#endif /* !UNDER_CE */
/* Verify the server's hostname */
CURLcode Curl_verify_host(struct Curl_cfilter *cf,
struct Curl_easy *data)
{
- struct ssl_connect_data *connssl = cf->ctx;
- SECURITY_STATUS sspi_status;
CURLcode result = CURLE_PEER_FAILED_VERIFICATION;
+ struct ssl_connect_data *connssl = cf->ctx;
CERT_CONTEXT *pCertContextServer = NULL;
+#ifdef UNDER_CE
+ TCHAR cert_hostname_buff[256];
+ DWORD len;
+
+ /* This code does not support certificates with multiple alternative names.
+ * Right now we are only asking for the first preferred alternative name.
+ * Instead we would need to do all via CERT_NAME_SEARCH_ALL_NAMES_FLAG
+ * (If Windows CE supports that?) and run this section in a loop for each.
+ * https://msdn.microsoft.com/en-us/library/windows/desktop/aa376086.aspx
+ * curl: (51) schannel: CertGetNameString() certificate hostname
+ * (.google.com) did not match connection (google.com)
+ */
+ len = CertGetNameString(pCertContextServer,
+ CERT_NAME_DNS_TYPE,
+ CERT_NAME_DISABLE_IE4_UTF8_FLAG,
+ NULL,
+ cert_hostname_buff,
+ 256);
+ if(len > 0) {
+ /* Comparing the cert name and the connection hostname encoded as UTF-8
+ * is acceptable since both values are assumed to use ASCII
+ * (or some equivalent) encoding
+ */
+ char *cert_hostname = curlx_convert_tchar_to_UTF8(cert_hostname_buff);
+ if(!cert_hostname) {
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ else{
+ const char *conn_hostname = connssl->peer.hostname;
+ if(Curl_cert_hostcheck(cert_hostname, strlen(cert_hostname),
+ conn_hostname, strlen(conn_hostname))) {
+ infof(data,
+ "schannel: connection hostname (%s) validated "
+ "against certificate name (%s)\n",
+ conn_hostname, cert_hostname);
+ result = CURLE_OK;
+ }
+ else{
+ failf(data,
+ "schannel: connection hostname (%s) "
+ "does not match certificate name (%s)",
+ conn_hostname, cert_hostname);
+ }
+ Curl_safefree(cert_hostname);
+ }
+ }
+ else {
+ failf(data,
+ "schannel: CertGetNameString did not provide any "
+ "certificate name information");
+ }
+#else
+ SECURITY_STATUS sspi_status;
TCHAR *cert_hostname_buff = NULL;
size_t cert_hostname_buff_index = 0;
const char *conn_hostname = connssl->peer.hostname;
if(pCertContextServer)
CertFreeCertificateContext(pCertContextServer);
+#endif /* !UNDER_CE */
return result;
}
CERT_CONTEXT *pCertContextServer = NULL;
const CERT_CHAIN_CONTEXT *pChainContext = NULL;
HCERTCHAINENGINE cert_chain_engine = NULL;
+#ifndef UNDER_CE
HCERTSTORE trust_store = NULL;
HCERTSTORE own_trust_store = NULL;
+#endif /* !UNDER_CE */
DEBUGASSERT(BACKEND);
sspi_status =
Curl_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
- SECPKG_ATTR_REMOTE_CERT_CONTEXT,
- &pCertContextServer);
+ SECPKG_ATTR_REMOTE_CERT_CONTEXT,
+ &pCertContextServer);
if((sspi_status != SEC_E_OK) || !pCertContextServer) {
char buffer[STRERROR_LEN];
result = CURLE_PEER_FAILED_VERIFICATION;
}
+#ifndef UNDER_CE
if(result == CURLE_OK &&
(conn_config->CAfile || conn_config->ca_info_blob) &&
BACKEND->use_manual_cred_validation) {
}
}
}
+#endif /* !UNDER_CE */
if(result == CURLE_OK) {
CERT_CHAIN_PARA ChainPara;
}
}
+#ifndef UNDER_CE
if(cert_chain_engine) {
CertFreeCertificateChainEngine(cert_chain_engine);
}
if(own_trust_store) {
CertCloseStore(own_trust_store, 0);
}
+#endif /* !UNDER_CE */
if(pChainContext)
CertFreeCertificateChain(pChainContext);
* valid when used in another process with different CWD. However,
* when a path does not exist, this does not work. Then, we add
* the path as is. */
-#ifdef _WIN32
+#ifdef UNDER_CE
+ (void)is_local;
+ return Curl_dyn_addf(buf, ":%s-%s", name, path);
+#elif defined(_WIN32)
char abspath[_MAX_PATH];
if(_fullpath(abspath, path, _MAX_PATH))
return Curl_dyn_addf(buf, ":%s-%s", name, abspath);
set_target_properties(${EXE_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
-if(ENABLE_UNICODE AND MINGW)
+if(ENABLE_UNICODE AND MINGW AND NOT MINGW32CE)
target_link_libraries(${EXE_NAME} "-municode")
endif()
struct winsize ts;
if(!ioctl(STDIN_FILENO, TIOCGWINSZ, &ts))
cols = (int)ts.ws_col;
-#elif defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
+#elif defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
{
HANDLE stderr_hnd = GetStdHandle(STD_ERROR_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO console_info;
/*
* Truncate the etag save stream, it can have an existing etag value.
*/
-#ifdef HAVE_FTRUNCATE
+#if defined(HAVE_FTRUNCATE) && !defined(__MINGW32CE__)
if(ftruncate(fileno(etag_save->stream), 0)) {
return CURL_WRITEFUNC_ERROR;
}
rc = read(per->infd, buffer, sz*nmemb);
if(rc < 0) {
if(errno == EAGAIN) {
- errno = 0;
+ CURL_SETERRNO(0);
config->readbusy = TRUE;
return CURL_READFUNC_PAUSE;
}
}
#endif
-#ifdef __AMIGA__
+#if defined(__AMIGA__) || defined(__MINGW32CE__)
if(LSEEK_ERROR == lseek(per->infd, (off_t)offset, whence))
#else
if(LSEEK_ERROR == lseek(per->infd, offset, whence))
struct OperationConfig *config = per->config;
size_t bytes = sz * nmemb;
bool is_tty = config->global->isatty;
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
CONSOLE_SCREEN_BUFFER_INFO console_info;
intptr_t fhnd;
#endif
}
}
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
fhnd = _get_osfhandle(fileno(outs->stream));
/* if Windows console then UTF-8 must be converted to UTF-16 */
if(isatty(fileno(outs->stream)) &&
#include <sys/stat.h>
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
# include <direct.h>
#endif
#ifdef _WIN32
-#if !defined(CURL_WINDOWS_UWP) && \
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE) && \
!defined(CURL_DISABLE_CA_SEARCH) && !defined(CURL_CA_SEARCH_SAFE)
/* Search and set the CA cert file for Windows.
*
struct curl_slist *GetLoadedModulePaths(void)
{
struct curl_slist *slist = NULL;
-#if !defined(CURL_WINDOWS_UWP)
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
HANDLE hnd = INVALID_HANDLE_VALUE;
MODULEENTRY32 mod = {0};
bool tool_term_has_bold;
-#ifndef CURL_WINDOWS_UWP
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
/* The terminal settings to restore on exit */
static struct TerminalSettings {
HANDLE hStdOut;
QueryPerformanceFrequency(&tool_freq);
-#ifndef CURL_WINDOWS_UWP
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
init_terminal();
#endif
#ifdef _WIN32
-#if !defined(CURL_WINDOWS_UWP) && \
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE) && \
!defined(CURL_DISABLE_CA_SEARCH) && !defined(CURL_CA_SEARCH_SAFE)
CURLcode FindWin32CACert(struct OperationConfig *config,
const TCHAR *bundle_file);
}
}
else { /* Standard input. */
+#ifdef UNDER_CE
+ int fd = STDIN_FILENO;
+#else
int fd = fileno(stdin);
+#endif
char *data = NULL;
curl_off_t size;
curl_off_t origin;
case C_BUFFER: /* --buffer */
/* disable the output I/O buffering. note that the option is called
--buffer but is mostly used in the negative form: --no-buffer */
- config->nobuffer = longopt ? !toggle : TRUE;
+ config->nobuffer = (bool)(longopt ? !toggle : TRUE);
break;
case C_REMOTE_NAME_ALL: /* --remote-name-all */
config->default_node_flags = toggle ? GETOUT_USEREMOTE : 0;
struct OperationConfig *config = global->first;
for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
+#ifdef UNDER_CE
+ orig_opt = strdup(argv[i]);
+#else
orig_opt = curlx_convert_tchar_to_UTF8(argv[i]);
+#endif
if(!orig_opt)
return PARAM_NO_MEM;
else {
char *nextarg = NULL;
if(i < (argc - 1)) {
+#ifdef UNDER_CE
+ nextarg = strdup(argv[i + 1]);
+#else
nextarg = curlx_convert_tchar_to_UTF8(argv[i + 1]);
+#endif
if(!nextarg) {
curlx_unicodefree(orig_opt);
return PARAM_NO_MEM;
# include iodef
#endif
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
# include <conio.h>
#endif
#define DONE
#endif /* __VMS */
-#if defined(_WIN32)
+#ifdef _WIN32
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
{
return buffer; /* we always return success */
}
#define DONE
-#endif /* _WIN32 */
+#endif /* _WIN32 && !UNDER_CE */
#ifndef DONE /* not previously provided */
#include <tchar.h>
#endif
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
/*
** curl tool main function.
*/
-#ifdef _UNICODE
+#if defined(_UNICODE) && !defined(UNDER_CE)
#if defined(__GNUC__) || defined(__clang__)
/* GCC does not know about wmain() */
#pragma GCC diagnostic push
tool_init_stderr();
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
/* Undocumented diagnostic option to list the full paths of all loaded
modules. This is purposely pre-init. */
if(argc == 2 && !_tcscmp(argv[1], _T("--dump-module-paths"))) {
curl_slist_free_all(head);
return head ? 0 : 1;
}
+#endif
+#ifdef _WIN32
/* win32_init must be called before other init routines. */
result = win32_init();
if(result) {
#endif
}
-#ifdef _UNICODE
+#if defined(_UNICODE) && !defined(UNDER_CE)
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
outs->bytes);
fflush(outs->stream);
/* truncate file at the position where we started appending */
-#if defined(HAVE_FTRUNCATE) && !defined(__DJGPP__) && !defined(__AMIGA__)
+#if defined(HAVE_FTRUNCATE) && !defined(__DJGPP__) && !defined(__AMIGA__) && \
+ !defined(__MINGW32CE__)
if(ftruncate(fileno(outs->stream), outs->init)) {
/* when truncate fails, we cannot just append as then we will
create something strange, bail out */
fclose(cafile);
config->cacert = strdup(cacert);
}
-#elif !defined(CURL_WINDOWS_UWP) && !defined(CURL_DISABLE_CA_SEARCH)
+#elif !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE) && \
+ !defined(CURL_DISABLE_CA_SEARCH)
result = FindWin32CACert(config, TEXT("curl-ca-bundle.crt"));
if(result)
goto fail;
CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
{
CURLcode result = CURLE_OK;
- char *first_arg = argc > 1 ? curlx_convert_tchar_to_UTF8(argv[1]) : NULL;
+ char *first_arg;
+#ifdef UNDER_CE
+ first_arg = argc > 1 ? strdup(argv[1]) : NULL;
+#else
+ first_arg = argc > 1 ? curlx_convert_tchar_to_UTF8(argv[1]) : NULL;
+#endif
#ifdef HAVE_SETLOCALE
/* Override locale for number parsing (only) */
long num;
if(!str[0])
return PARAM_BLANK_STRING;
- errno = 0;
+ CURL_SETERRNO(0);
num = strtol(str, &endptr, base);
if(errno == ERANGE)
return PARAM_NUMBER_TOO_LARGE;
if(str) {
char *endptr;
double num;
- errno = 0;
+ CURL_SETERRNO(0);
num = strtod(str, &endptr);
if(errno == ERANGE)
return PARAM_NUMBER_TOO_LARGE;
return PARAM_BAD_NUMERIC;
}
#else
- errno = 0;
+ CURL_SETERRNO(0);
*val = strtol(str, &endptr, 0);
if((*val == LONG_MIN || *val == LONG_MAX) && errno == ERANGE)
return PARAM_NUMBER_TOO_LARGE;
}
filename = pathalloc = curlrc;
}
-#ifdef _WIN32 /* Windows */
+#if defined(_WIN32) && !defined(UNDER_CE)
else {
char *fullp;
/* check for .curlrc then _curlrc in the dir of the executable */
# define CURL_STRICMP(p1, p2) strcmp(p1, p2)
#endif
-#if defined(_WIN32)
+#ifdef _WIN32
/* set in win32_init() */
extern LARGE_INTEGER tool_freq;
extern bool tool_isVistaOrGreater;
/* set in init_terminal() */
extern bool tool_term_has_bold;
+
+#ifdef UNDER_CE
+# undef isatty
+# define isatty(fd) 0 /* fd is void*, expects int */
+# undef _get_osfhandle
+# define _get_osfhandle(fd) (fd)
+# undef _getch
+# define _getch() 0
+# undef STDIN_FILENO
+# define STDIN_FILENO 0
#endif
-#if defined(_WIN32) && !defined(HAVE_FTRUNCATE)
+#ifndef HAVE_FTRUNCATE
int tool_ftruncate64(int fd, curl_off_t where);
#define HAVE_FTRUNCATE 1
#define USE_TOOL_FTRUNCATE 1
-#endif /* _WIN32 && ! HAVE_FTRUNCATE */
+#endif /* ! HAVE_FTRUNCATE */
+#endif /* _WIN32 */
#endif /* HEADER_CURL_TOOL_SETUP_H */
if(end_c == ':') {
char *endp;
- errno = 0;
+ CURL_SETERRNO(0);
step = strtoul(&pattern[4], &endp, 10);
if(errno || &pattern[4] == endp || *endp != ']')
step = 0;
}
}
- errno = 0;
+ CURL_SETERRNO(0);
min_n = strtoul(pattern, &endp, 10);
if(errno || (endp == pattern))
endp = NULL;
endp = NULL;
goto fail;
}
- errno = 0;
+ CURL_SETERRNO(0);
max_n = strtoul(pattern, &endp, 10);
if(errno)
/* overflow */
endp = NULL;
else if(*endp == ':') {
pattern = endp + 1;
- errno = 0;
+ CURL_SETERRNO(0);
step_n = strtoul(pattern, &endp, 10);
if(errno)
/* over/underflow situation */
#ifdef USE_TOOL_FTRUNCATE
-#ifdef _WIN32_WCE
+#ifdef UNDER_CE
/* 64-bit lseek-like function unavailable */
# undef _lseeki64
# define _lseeki64(hnd,ofs,whence) lseek(hnd,ofs,whence)
-# undef _get_osfhandle
-# define _get_osfhandle(fd) (fd)
#endif
/*
#endif /* USE_TOOL_FTRUNCATE */
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
FILE *Curl_execpath(const char *filename, char **pathp)
{
static char filebuffer[512];
int struplocompare(const char *p1, const char *p2);
int struplocompare4sort(const void *p1, const void *p2);
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
FILE *Curl_execpath(const char *filename, char **pathp);
#endif
#include <stdio.h>
#include <stdlib.h>
-/* #include <error.h> */
-#include <errno.h>
static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type)
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-/* #include <error.h> */
-#include <errno.h>
static void log_line_start(FILE *log, const char *idsbuf, curl_infotype type)
{
#define NUM_THREADS 100
#ifdef _WIN32
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
static DWORD WINAPI run_thread(LPVOID ptr)
#else
#include <process.h>
CURLcode test(char *URL)
{
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
typedef HANDLE curl_win_thread_handle_t;
#else
typedef uintptr_t curl_win_thread_handle_t;
for(i = 0; i < tid_count; i++) {
curl_win_thread_handle_t th;
results[i] = CURL_LAST; /* initialize with invalid value */
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
th = CreateThread(NULL, 0, run_thread, &results[i], 0, NULL);
#else
th = _beginthreadex(NULL, 0, run_thread, &results[i], 0, NULL);
static
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP)
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
DWORD
#else
unsigned int
}
/* get the file size of the local file */
+#ifdef UNDER_CE
+ hd = stat(libtest_arg2, &file_info);
+#else
hd = fstat(fileno(hd_src), &file_info);
+#endif
if(hd == -1) {
/* can't open file, bail out */
fprintf(stderr, "fstat() failed with error: %d %s\n",
}
/* get the file size of the local file */
+#ifdef UNDER_CE
+ hd = stat(libtest_arg2, &file_info);
+#else
hd = fstat(fileno(hd_src), &file_info);
+#endif
if(hd == -1) {
/* can't open file, bail out */
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
}
/* get the file size of the local file */
+#ifdef UNDER_CE
+ hd = stat(libtest_arg2, &file_info);
+#else
hd = fstat(fileno(hd_src), &file_info);
+#endif
if(hd == -1) {
/* can't open file, bail out */
fprintf(stderr, "fstat() failed with error: %d %s\n",
if(nread) {
/* send received stuff to stdout */
+#ifdef UNDER_CE
+ if((size_t)fwrite(buf, sizeof(buf[0]), nread, stdout) != nread) {
+#else
if((size_t)write(STDOUT_FILENO, buf, nread) != nread) {
+#endif
fprintf(stderr, "write() failed: errno %d (%s)\n",
errno, strerror(errno));
res = TEST_ERR_FAILURE;
}
/* get the file size of the local file */
+#ifdef UNDER_CE
+ hd = stat(libtest_arg2, &file_info);
+#else
hd = fstat(fileno(hd_src), &file_info);
+#endif
if(hd == -1) {
/* can't open file, bail out */
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
#ifdef _WIN32
HMODULE win32_load_system_library(const TCHAR *filename)
{
-#ifdef CURL_WINDOWS_UWP
+#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
(void)filename;
return NULL;
#else
UTIL = \
util.c \
- util.h
+ util.h \
+ ../../lib/strerror.c \
+ ../../lib/strerror.h
getpart_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) \
testpart.c
/* based on sockfilt.c */
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
*
*/
-#include <signal.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
* This source file was started based on curl's HTTP test suite server.
*/
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
while(*ptr && ISSPACE(*ptr))
ptr++;
endptr = ptr;
- errno = 0;
+ CURL_SETERRNO(0);
clen = strtoul(ptr, &endptr, 10);
if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == errno)) {
/* this assumes that a zero Content-Length is valid */
* it!
*/
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
ACTIVE_DISCONNECT /* as a client, disconnected from server */
};
-#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
+#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
/*
* read-wrapper to support reading from stdin on Windows.
*/
return rcount;
}
- errno = (int)GetLastError();
+ CURL_SETERRNO((int)GetLastError());
return -1;
}
#undef read
return wcount;
}
- errno = (int)GetLastError();
+ CURL_SETERRNO((int)GetLastError());
return -1;
}
#undef write
#define write(a,b,c) write_wincon(a,b,c)
#endif
+#ifndef UNDER_CE
+
/* On Windows, we sometimes get this for a broken pipe, seemingly
* when the client just closed stdin? */
#define CURL_WIN32_EPIPE 109
}
return TRUE;
}
+#endif
/*
* write_stdout tries to write to stdio nbytes from the given buffer. This is a
static bool write_stdout(const void *buffer, size_t nbytes)
{
- ssize_t nwrite = fullwrite(fileno(stdout), buffer, nbytes);
+ ssize_t nwrite;
+#ifdef UNDER_CE
+ puts(buffer);
+ nwrite = nbytes;
+#else
+ nwrite = fullwrite(fileno(stdout), buffer, nbytes);
+#endif
if(nwrite != (ssize_t)nbytes) {
logmsg("exiting...");
return FALSE;
return TRUE;
}
+#ifndef UNDER_CE
static void lograw(unsigned char *buffer, ssize_t len)
{
char data[120];
return TRUE;
}
+#endif
-#if defined(USE_WINSOCK) && !defined(CURL_WINDOWS_UWP)
+#if defined(USE_WINSOCK) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
/*
* Winsock select() does not support standard file descriptors,
* it can only check SOCKETs. The following function is an attempt
HANDLE signal; /* internal event to signal handle trigger */
HANDLE abort; /* internal event to abort waiting threads */
};
-#ifdef _WIN32_WCE
-static DWORD WINAPI select_ws_wait_thread(LPVOID lpParameter)
-#else
#include <process.h>
static unsigned int WINAPI select_ws_wait_thread(void *lpParameter)
-#endif
{
struct select_ws_wait_data *data;
HANDLE signal, handle, handles[2];
}
static HANDLE select_ws_wait(HANDLE handle, HANDLE signal, HANDLE abort)
{
-#ifdef _WIN32_WCE
- typedef HANDLE curl_win_thread_handle_t;
-#else
typedef uintptr_t curl_win_thread_handle_t;
-#endif
struct select_ws_wait_data *data;
curl_win_thread_handle_t thread;
data->abort = abort;
/* launch waiting thread */
-#ifdef _WIN32_WCE
- thread = CreateThread(NULL, 0, &select_ws_wait_thread, data, 0, NULL);
-#else
thread = _beginthreadex(NULL, 0, &select_ws_wait_thread, data, 0, NULL);
-#endif
/* free data if thread failed to launch */
if(!thread) {
/* check if the input value is valid */
if(nfds < 0) {
- errno = EINVAL;
+ CURL_SETERRNO(EINVAL);
return -1;
}
/* create internal event to abort waiting threads */
abort = CreateEvent(NULL, TRUE, FALSE, NULL);
if(!abort) {
- errno = ENOMEM;
+ CURL_SETERRNO(ENOMEM);
return -1;
}
data = calloc(nfds, sizeof(struct select_ws_data));
if(!data) {
CloseHandle(abort);
- errno = ENOMEM;
+ CURL_SETERRNO(ENOMEM);
return -1;
}
if(!handles) {
CloseHandle(abort);
free(data);
- errno = ENOMEM;
+ CURL_SETERRNO(ENOMEM);
return -1;
}
#endif /* USE_WINSOCK */
+#ifndef UNDER_CE
/* Perform the disconnect handshake with sockfilt
* This involves waiting for the disconnect acknowledgment after the DISC
* command, while throwing away anything else that might come in before
} while(TRUE);
return TRUE;
}
+#endif
/*
sockfdp is a pointer to an established stream or CURL_SOCKET_BAD
curl_socket_t listenfd,
enum sockmode *mode)
{
+#ifdef UNDER_CE
+ (void)sockfdp;
+ (void)listenfd;
+ (void)mode;
+ return FALSE;
+#else
struct timeval timeout;
fd_set fds_read;
fd_set fds_write;
}
return TRUE;
+#endif
}
static curl_socket_t sockdaemon(curl_socket_t sock,
/* based on sockfilt.c */
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
*/
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
while(*ptr && ISSPACE(*ptr))
ptr++;
endptr = ptr;
- errno = 0;
+ CURL_SETERRNO(0);
clen = strtoul(ptr, &endptr, 10);
if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == errno)) {
/* this assumes that a zero Content-Length is valid */
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
***************************************************************************/
#include "server_setup.h"
+#ifndef UNDER_CE
#include <signal.h>
+#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <dos.h> /* delay() */
#endif
+#ifdef _WIN32
+#include "strerror.h"
+#endif
+
#include "curlx.h" /* from the private lib dir */
#include "getpart.h"
#include "util.h"
}
#ifdef _WIN32
-/* use instead of strerror() on generic Windows */
-static const char *win32_strerror(int err, char *buf, size_t buflen)
-{
- if(!FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS), NULL, (DWORD)err,
- LANG_NEUTRAL, buf, (DWORD)buflen, NULL))
- msnprintf(buf, buflen, "Unknown error %d (%#x)", err, err);
- return buf;
-}
-
/* use instead of perror() on generic Windows */
void win32_perror(const char *msg)
{
char buf[512];
int err = SOCKERRNO;
- win32_strerror(err, buf, sizeof(buf));
+ Curl_winapi_strerror(err, buf, sizeof(buf));
if(msg)
fprintf(stderr, "%s: ", msg);
fprintf(stderr, "%s\n", buf);
_flushall();
}
-/* socket-safe strerror (works on Winsock errors, too */
+/* socket-safe strerror (works on Winsock errors, too) */
const char *sstrerror(int err)
{
static char buf[512];
- return win32_strerror(err, buf, sizeof(buf));
+ return Curl_winapi_strerror(err, buf, sizeof(buf));
}
#endif /* _WIN32 */
if(!timeout_ms)
return 0;
if(timeout_ms < 0) {
- errno = EINVAL;
+ CURL_SETERRNO(EINVAL);
return -1;
}
#if defined(MSDOS)
static SIGHANDLER_T old_sigbreak_handler = SIG_ERR;
#endif
-#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
-#ifdef _WIN32_WCE
-static DWORD thread_main_id = 0;
-#else
+#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
static unsigned int thread_main_id = 0;
-#endif
static HANDLE thread_main_window = NULL;
static HWND hidden_main_window = NULL;
#endif
* The first time this is called it will set got_exit_signal to one and
* store in exit_signal the signal that triggered its execution.
*/
+#ifndef UNDER_CE
static void exit_signal_handler(int signum)
{
int old_errno = errno;
#endif
}
(void)signal(signum, exit_signal_handler);
- errno = old_errno;
+ CURL_SETERRNO(old_errno);
}
+#endif
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(UNDER_CE)
/* CTRL event handler for Windows Console applications to simulate
* SIGINT, SIGTERM and SIGBREAK on CTRL events and trigger signal handler.
*
}
#endif
-#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
+#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
/* Window message handler for Windows applications to add support
* for graceful process termination via taskkill (without /f) which
* sends WM_CLOSE to all Windows of a process (even hidden ones).
}
/* Window message queue loop for hidden main window, details see above.
*/
-#ifdef _WIN32_WCE
-static DWORD WINAPI main_window_loop(LPVOID lpParameter)
-#else
#include <process.h>
static unsigned int WINAPI main_window_loop(void *lpParameter)
-#endif
{
WNDCLASS wc;
BOOL ret;
}
#endif
+#ifndef UNDER_CE
static SIGHANDLER_T set_signal(int signum, SIGHANDLER_T handler,
bool restartable)
{
return oldhdlr;
#endif
}
+#endif
void install_signal_handlers(bool keep_sigalrm)
{
logmsg("cannot install SIGBREAK handler: %s", strerror(errno));
#endif
#ifdef _WIN32
+#ifndef UNDER_CE
if(!SetConsoleCtrlHandler(ctrl_event_handler, TRUE))
logmsg("cannot install CTRL event handler");
+#endif
-#ifndef CURL_WINDOWS_UWP
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
{
-#ifdef _WIN32_WCE
- typedef HANDLE curl_win_thread_handle_t;
-#else
typedef uintptr_t curl_win_thread_handle_t;
-#endif
curl_win_thread_handle_t thread;
-#ifdef _WIN32_WCE
- thread = CreateThread(NULL, 0, &main_window_loop,
- (LPVOID)GetModuleHandle(NULL), 0, &thread_main_id);
-#else
thread = _beginthreadex(NULL, 0, &main_window_loop,
(void *)GetModuleHandle(NULL), 0, &thread_main_id);
-#endif
thread_main_window = (HANDLE)thread;
if(!thread_main_window || !thread_main_id)
logmsg("cannot start main window loop");
(void) set_signal(SIGBREAK, old_sigbreak_handler, FALSE);
#endif
#ifdef _WIN32
+#ifndef UNDER_CE
(void)SetConsoleCtrlHandler(ctrl_event_handler, FALSE);
-#ifndef CURL_WINDOWS_UWP
+#endif
+#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
if(thread_main_window && thread_main_id) {
if(PostThreadMessage(thread_main_id, WM_APP, 0, 0)) {
if(WaitForSingleObjectEx(thread_main_window, INFINITE, TRUE)) {
#include <inet.h>
#endif
-#include <setjmp.h>
-#include <signal.h>
-
#include "urldata.h"
#include "connect.h"
#include "cfilters.h"