build: add Windows CE / CeGCC support, with CI jobs

Make it possible to build curl for Windows CE using the CeGCC toolchain.
With both CMake and autotools, including tests and examples, also in CI.
The build configuration is the default one with Schannel enabled. No
3rd-party dependencies have been tested.

Also revive old code to make Schannel build with Windows CE, including
certificate verification.

Builds have been throughougly tested. But, I've made no functional tests
for this PR. Some parts (esp. file operations, like truncate and seek)
are stubbed out and likely broken as a result. Test servers build, but
they do not work on Windows CE. This patch substitutes `fstat()` calls
with `stat()`, which operate on filenames, not file handles. This may or
may not work and/or may not be secure.

About CeGCC: I used the latest available macOS binary build v0.59.1
r1397 from 2009, in native `mingw32ce` build mode. CeGCC is in effect
MinGW + GCC 4.4.0 + old/classic-mingw Windows headers. It targets
Windows CE v3.0 according to its `_WIN32_WCE` value. It means this PR
restores portions of old/classic-mingw support. It makes the Windows CE
codepath compatible with GCC 4.4.0. It also adds workaround for CMake,
which cannot identify and configure this toolchain out of the box.

Notes:
- CMake doesn't recognize CeGCC/mingw32ce, necessitating tricks as seen
  with Amiga and MS-DOS.
- CMake doesn't set `MINGW` for mingw32ce. Set it and `MINGW32CE`
  manually as a helper variable, in addition to `WINCE` which CMake sets
  based on `CMAKE_SYSTEM_NAME`.
- CMake fails to create an implib for `libcurl.dll`, due to not
  recognizing the platform as a Windowsy one. This patch adds the
  necessary workaround to make it work.
- headers shipping with CeGCC miss some things curl needs for Schannel
  support. Fixed by restoring and renovating code previously deleted
  old-mingw code.
- it's sometime non-trivial to figure out if a fallout is WinCE,
  mingw32ce, old-mingw, or GCC version-specific.
- WinCE is always Unicode. With exceptions: no `wmain`,
  `GetProcAddress()`.
- `_fileno()` is said to convert from `FILE *` to `void *` which is
  a Win32 file `HANDLE`. (This patch doesn't use this, but with further
  effort it probably could be.)
  https://stackoverflow.com/questions/3989545/how-do-i-get-the-file-handle-from-the-fopen-file-structure
- WinCE has no signals, current directory, stdio/CRT file handles, no
  `_get_osfhandle()`, no `errno`, no `errno.h`. Some of this stuff is
  standard C89, yet missing from this platform. Microsoft expects
  Windows CE apps to use Win32 file API and `FILE *` exclusively.
- revived CeGCC here (not tested for this PR):
  https://building.enlyze.com/posts/a-new-windows-ce-x86-compiler-in-2024/

On `UNDER_CE` vs. `_WIN32_WCE`: (This patch settled on `UNDER_CE`)

- A custom VS2008 WinCE toolchain does not set any of these.
  The compiler binaries don't contain these strings, and has no compiler
  option for targeting WinCE, hinting that a vanilla toolchain isn't
  setting any of them either.
- `UNDER_CE` is automatically defined by the CeGCC compiler.
  https://cegcc.sourceforge.net/docs/details.html
- `UNDER_CE` is similar to `_WIN32`, except it's not set automatically
  by all compilers. It's not supposed to have any value, like a version.
  (Though e.g. OpenSSL sets it to a version)
- `_WIN32_WCE` is the CE counterpart of the non-CE `_WIN32_WINNT` macro.
  That does return the targeted Windows CE version.
- `_WIN32_WCE` is not defined by compilers, and relies on a header
  setting it to a default, or the build to set it to the desired target
  version. This is also how `_WIN32_WINNT` works.
- `_WIN32_WCE` default is set by `windef.h` in CeGCC.
- `_WIN32_WCE` isn't set to a default by MSVC Windows CE headers (the
  ones I checked at least).
- CMake sets `_WIN32_WCE=<ver>`, `UNDER_CE`, `WINCE` for MSVC WinCE.
- `_WIN32_WCE` seems more popular in other projects, including CeGCC
  itself. `zlib` is a notable exception amongst curl dependencies,
  which uses `UNDER_CE`.
- Since `_WIN32_WCE` needs "certain" headers to have it defined, it's
  undefined depending on headers included beforehand.
- `curl/curl.h` re-uses `_WIN32_WCE`'s as a self-guard, relying on
  its not-(necessarily)-defined-by-default property:
  25b445e479/include/curl/curl.h (L77)

Toolchain downloads:
- Windows:
  https://downloads.sourceforge.net/cegcc/cegcc/0.59.1/cegcc_mingw32ce_cygwin1.7_r1399.tar.bz2
- macOS Intel:
  https://downloads.sourceforge.net/cegcc/cegcc/0.59.1/cegcc_mingw32ce_snowleopard_r1397.tar.bz2

Closes #15975
This commit is contained in:
Viktor Szakats 2025-01-10 11:04:02 +01:00
parent 93958499f2
commit 2a292c3984
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
89 changed files with 945 additions and 239 deletions

View File

@ -590,6 +590,111 @@ jobs:
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

View File

@ -29,7 +29,7 @@ if(WIN32 AND (ENABLE_DEBUG OR ENABLE_CURLDEBUG))
# 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()

View File

@ -44,6 +44,10 @@ if(MINGW)
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)
@ -191,3 +195,16 @@ set(STDC_HEADERS 1)
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()

View File

@ -91,6 +91,33 @@ if(WINDOWS_STORE AND MINGW) # mingw UWP build
# 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")
@ -119,6 +146,9 @@ endif()
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()
@ -195,12 +225,12 @@ if(WIN32)
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()
@ -476,7 +506,7 @@ if(HTTP_ONLY)
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()
@ -567,7 +597,19 @@ if(ENABLE_THREADED_RESOLVER)
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"
@ -588,7 +630,7 @@ elseif(AMIGA)
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})
@ -623,7 +665,7 @@ if(ENABLE_IPV6)
endif()
endif()
endif()
if(ENABLE_IPV6)
if(ENABLE_IPV6 AND NOT WINCE)
set(USE_IPV6 ON)
endif()
@ -954,8 +996,8 @@ macro(curl_openssl_check_exists)
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()
@ -967,7 +1009,7 @@ macro(curl_openssl_check_exists)
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()
@ -1174,7 +1216,7 @@ if(NOT CURL_DISABLE_SRP AND (HAVE_GNUTLS_SRP OR HAVE_OPENSSL_SRP))
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")
@ -1460,7 +1502,7 @@ if(USE_LIBRTMP)
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()
@ -1571,13 +1613,13 @@ if(WIN32)
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)
@ -1685,7 +1727,7 @@ endif()
# 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)
@ -1737,7 +1779,6 @@ check_symbol_exists("getpeername" "${CURL_INCLUDES}" HAVE_GETPEERNAME) # wi
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)
@ -1749,9 +1790,12 @@ if(NOT WIN32)
check_symbol_exists("strcmpi" "string.h" HAVE_STRCMPI)
endif()
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)
check_symbol_exists("CloseSocket" "${CURL_INCLUDES}" HAVE_CLOSESOCKET_CAMEL) # sys/socket.h proto/bsdsocket.h
@ -1930,9 +1974,14 @@ include(CMake/OtherTests.cmake)
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()
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")
@ -1944,7 +1993,10 @@ if(WIN32)
# 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()

View File

@ -1310,16 +1310,13 @@ AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
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*)
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'
;;
esac
fi
case "$curl_win32_has_largefile" in
yes)
if test x"$enable_largefile" = 'xno'; then
@ -1476,9 +1473,20 @@ AC_DEFUN([CURL_PREPARE_BUILDINFO], [
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

View File

@ -493,8 +493,12 @@ dnl **********************************************************************
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
@ -883,7 +887,7 @@ AS_HELP_STRING([--disable-telnet],[Disable TELNET support]),
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
@ -1161,11 +1165,42 @@ if test "$HAVE_GETHOSTBYNAME" != "1"; then
])
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
@ -1733,6 +1768,10 @@ AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),
)
)
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])
@ -2062,11 +2101,14 @@ CURL_WITH_RUSTLS
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
@ -2611,7 +2653,11 @@ dnl ----------------------------
dnl check Windows Unicode option
dnl ----------------------------
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"
@ -4068,7 +4114,6 @@ AC_CHECK_FUNCS([\
sendmsg \
sendmmsg \
setlocale \
setmode \
setrlimit \
snprintf \
utime \
@ -4086,9 +4131,12 @@ if test "$curl_cv_native_windows" != 'yes'; then
CURL_CHECK_FUNC_STRICMP
fi
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
AC_CHECK_FUNCS([arc4random])
@ -4467,7 +4515,7 @@ AS_HELP_STRING([--disable-unix-sockets],[Disable Unix domain sockets]),
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])

View File

@ -103,7 +103,11 @@ int main(int argc, char **argv)
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);

View File

@ -29,9 +29,9 @@
* 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

View File

@ -46,7 +46,11 @@
#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"

View File

@ -51,7 +51,11 @@ int main(void)
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 */
}

View File

@ -28,7 +28,11 @@
#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

View File

@ -77,7 +77,9 @@ static int upload(CURL *curlhandle, const char *remotepath,
f = fopen(localpath, "rb");
if(!f) {
#ifndef UNDER_CE
perror(NULL);
#endif
return 0;
}

View File

@ -28,7 +28,11 @@
#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>

View File

@ -30,7 +30,11 @@
#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

View File

@ -90,7 +90,9 @@ static int sftpResumeUpload(CURL *curlhandle, const char *remotepath,
f = fopen(localpath, "rb");
if(!f) {
#ifndef UNDER_CE
perror(NULL);
#endif
return 0;
}
@ -99,7 +101,7 @@ static int sftpResumeUpload(CURL *curlhandle, const char *remotepath,
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);

View File

@ -97,11 +97,8 @@
#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

View File

@ -137,13 +137,22 @@
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
# endif
#elif defined(_WIN32_WCE)
#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>

View File

@ -259,7 +259,7 @@ static CURLcode getaddrinfo_complete(struct Curl_easy *data)
* 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
@ -318,7 +318,7 @@ CURL_STDCALL getaddrinfo_thread(void *arg)
* 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
@ -477,7 +477,7 @@ err_exit:
destroy_async_data(data);
errno_exit:
errno = err;
CURL_SETERRNO(err);
return FALSE;
}

View File

@ -843,7 +843,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
* Someone got to verify this on Win-NT 4.0, 2000."
*/
#ifdef _WIN32_WCE
#ifdef UNDER_CE
Sleep(0);
#else
SleepEx(0, FALSE);
@ -853,7 +853,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
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);

View File

@ -35,15 +35,17 @@
/* 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. */
@ -53,8 +55,10 @@
/* #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. */
@ -109,8 +113,10 @@
#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
/* ---------------------------------------------------------------- */
@ -499,11 +505,9 @@ Vista
#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 */

View File

@ -301,7 +301,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
addr[0] = '\0';
*port = 0;
errno = EAFNOSUPPORT;
CURL_SETERRNO(EAFNOSUPPORT);
return FALSE;
}

View File

@ -84,6 +84,8 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w)
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)
@ -267,7 +269,7 @@ int curlx_win32_open(const char *filename, int oflag, ...)
curlx_unicodefree(filename_w);
}
else
errno = EINVAL;
CURL_SETERRNO(EINVAL);
#else
if(fix_excessive_path(filename, &fixed))
target = fixed;
@ -297,7 +299,7 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode)
result = _wfopen(target, mode_w);
}
else
errno = EINVAL;
CURL_SETERRNO(EINVAL);
curlx_unicodefree(filename_w);
curlx_unicodefree(mode_w);
#else
@ -333,7 +335,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
curlx_unicodefree(path_w);
}
else
errno = EINVAL;
CURL_SETERRNO(EINVAL);
#else
if(fix_excessive_path(path, &fixed))
target = fixed;
@ -350,4 +352,6 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
return result;
}
#endif /* UNDER_CE */
#endif /* _WIN32 */

View File

@ -465,7 +465,9 @@
*/
#ifdef USE_WIN32_LARGE_FILES
# ifdef HAVE_IO_H
# include <io.h>
# endif
# include <sys/types.h>
# include <sys/stat.h>
# undef lseek
@ -496,10 +498,12 @@
*/
#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)
@ -829,6 +833,24 @@
#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
*/

View File

@ -33,7 +33,9 @@
#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>
@ -390,7 +392,7 @@ typedef unsigned int bit;
#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 *

View File

@ -42,7 +42,7 @@ typedef PSecurityFunctionTable (APIENTRY *INITSECURITYINTERFACE_FN)(VOID);
/* See definition of SECURITY_ENTRYPOINT in sspi.h */
#ifdef UNICODE
# ifdef _WIN32_WCE
# ifdef UNDER_CE
# define SECURITYENTRYPOINT L"InitSecurityInterfaceW"
# else
# define SECURITYENTRYPOINT "InitSecurityInterfaceW"

View File

@ -70,6 +70,225 @@ extern PSecurityFunctionTable Curl_pSecFn;
#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
@ -80,6 +299,32 @@ extern PSecurityFunctionTable Curl_pSecFn;
# 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

View File

@ -103,7 +103,7 @@ int Curl_thread_join(curl_thread_t *hnd)
#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
@ -111,25 +111,26 @@ curl_thread_t Curl_thread_create(
(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 ||
int err = (gle == ERROR_ACCESS_DENIED ||
gle == ERROR_NOT_ENOUGH_MEMORY) ?
EACCES : EINVAL);
EACCES : EINVAL;
CURL_SETERRNO(err);
#endif
return curl_thread_t_null;
}

View File

@ -53,7 +53,7 @@
#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

View File

@ -105,7 +105,7 @@ static curl_simple_lock s_lock = CURL_SIMPLE_LOCK_INIT;
* 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

View File

@ -547,7 +547,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
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

View File

@ -105,7 +105,13 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
*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);

View File

@ -3290,7 +3290,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
/* 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

View File

@ -31,7 +31,7 @@
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;

View File

@ -42,7 +42,9 @@
#endif
#include <setjmp.h>
#ifndef UNDER_CE
#include <signal.h>
#endif
#include "urldata.h"
#include "sendf.h"

View File

@ -74,7 +74,7 @@ static char *inet_ntop4(const unsigned char *src, char *dst, size_t size)
len = strlen(tmp);
if(len == 0 || len >= size) {
errno = ENOSPC;
CURL_SETERRNO(ENOSPC);
return NULL;
}
strcpy(dst, tmp);
@ -153,7 +153,7 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
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);
@ -171,7 +171,7 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
/* Check for overflow, copy, and we are done.
*/
if((size_t)(tp - tmp) > size) {
errno = ENOSPC;
CURL_SETERRNO(ENOSPC);
return NULL;
}
strcpy(dst, tmp);
@ -197,7 +197,7 @@ char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size)
case AF_INET6:
return inet_ntop6((const unsigned char *)src, buf, size);
default:
errno = EAFNOSUPPORT;
CURL_SETERRNO(EAFNOSUPPORT);
return NULL;
}
}

View File

@ -80,7 +80,7 @@ Curl_inet_pton(int af, const char *src, void *dst)
case AF_INET6:
return inet_pton6(src, (unsigned char *)dst);
default:
errno = EAFNOSUPPORT;
CURL_SETERRNO(EAFNOSUPPORT);
return -1;
}
/* NOTREACHED */

View File

@ -117,7 +117,7 @@ static bool countcheck(const char *func, int line, const char *source)
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

View File

@ -337,7 +337,7 @@ static int parsefmt(const char *format,
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')) {
@ -356,7 +356,7 @@ static int parsefmt(const char *format,
#endif
}
break;
#endif /* _WIN32 || _WIN32_WCE */
#endif /* _WIN32 */
case 'l':
if(flags & FLAGS_LONG)
flags |= FLAGS_LONGLONG;

View File

@ -40,7 +40,7 @@
/* 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. */

View File

@ -103,7 +103,9 @@ int Curl_socketpair(int domain, int type, int protocol,
* 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>

View File

@ -48,7 +48,7 @@
#include "curl_memory.h"
#include "memdebug.h"
#if defined(_WIN32) || defined(_WIN32_WCE)
#ifdef _WIN32
#define PRESERVE_WINDOWS_ERROR_CODE
#endif
@ -768,7 +768,7 @@ get_winsock_error(int err, char *buf, size_t len)
}
#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.
@ -810,7 +810,7 @@ get_winapi_error(int err, char *buf, size_t buflen)
return *buf ? buf : NULL;
}
#endif /* _WIN32 || _WIN32_WCE */
#endif /* _WIN32 */
/*
* Our thread-safe and smart strerror() replacement.
@ -848,8 +848,8 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
*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]);
@ -911,7 +911,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
*p = '\0';
if(errno != old_errno)
errno = old_errno;
CURL_SETERRNO(old_errno);
#ifdef PRESERVE_WINDOWS_ERROR_CODE
if(old_win_err != GetLastError())
@ -925,7 +925,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
* 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
@ -951,7 +951,7 @@ const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
#endif
if(errno != old_errno)
errno = old_errno;
CURL_SETERRNO(old_errno);
#ifdef PRESERVE_WINDOWS_ERROR_CODE
if(old_win_err != GetLastError())
@ -960,7 +960,7 @@ const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
return buf;
}
#endif /* _WIN32 || _WIN32_WCE */
#endif /* _WIN32 */
#ifdef USE_WINDOWS_SSPI
/*
@ -1100,7 +1100,7 @@ const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
#endif
if(errno != old_errno)
errno = old_errno;
CURL_SETERRNO(old_errno);
#ifdef PRESERVE_WINDOWS_ERROR_CODE
if(old_win_err != GetLastError())

View File

@ -29,7 +29,7 @@
#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

View File

@ -96,9 +96,15 @@ CURLcode Curl_win32_init(long flags)
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;
@ -150,7 +156,7 @@ typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD);
/* See function definitions in winbase.h */
#ifdef UNICODE
# ifdef _WIN32_WCE
# ifdef UNDER_CE
# define LOADLIBARYEX L"LoadLibraryExW"
# else
# define LOADLIBARYEX "LoadLibraryExW"
@ -175,7 +181,7 @@ typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD);
*/
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;

View File

@ -39,7 +39,9 @@
#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>

View File

@ -602,7 +602,6 @@ static int ipv4_normalize(struct dynbuf *host)
if(*c == '[')
return HOST_IPV6;
errno = 0; /* for strtoul */
while(!done) {
int rc;
curl_off_t l;

View File

@ -29,7 +29,6 @@
#include "curl_printf.h"
#include <errno.h>
#include <rustls.h>
#include "inet_pton.h"

View File

@ -141,6 +141,12 @@
#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
@ -150,7 +156,7 @@
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;
@ -880,7 +886,9 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
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;
@ -912,9 +920,9 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
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
@ -2373,7 +2381,7 @@ static void schannel_close(struct Curl_cfilter *cf, struct Curl_easy *data)
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;
@ -2383,7 +2391,7 @@ static int schannel_init(void)
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) {
@ -2399,7 +2407,7 @@ static int schannel_init(void)
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;
}
@ -2524,7 +2532,12 @@ static void schannel_checksum(const unsigned char *input,
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 */

View File

@ -57,6 +57,22 @@
#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-----"
@ -76,6 +92,7 @@ struct cert_chain_engine_config_win7 {
HCERTSTORE hExclusiveTrustedPeople;
};
#ifndef UNDER_CE
static int is_cr_or_lf(char c)
{
return c == '\r' || c == '\n';
@ -330,9 +347,11 @@ cleanup:
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
@ -511,15 +530,68 @@ static bool get_alt_name_info(struct Curl_easy *data,
#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;
@ -664,6 +736,7 @@ cleanup:
if(pCertContextServer)
CertFreeCertificateContext(pCertContextServer);
#endif /* !UNDER_CE */
return result;
}
@ -681,8 +754,10 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf,
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);
@ -698,6 +773,7 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf,
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) {
@ -782,6 +858,7 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf,
}
}
}
#endif /* !UNDER_CE */
if(result == CURLE_OK) {
CERT_CHAIN_PARA ChainPara;
@ -848,6 +925,7 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf,
}
}
#ifndef UNDER_CE
if(cert_chain_engine) {
CertFreeCertificateChainEngine(cert_chain_engine);
}
@ -855,6 +933,7 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf,
if(own_trust_store) {
CertCloseStore(own_trust_store, 0);
}
#endif /* !UNDER_CE */
if(pChainContext)
CertFreeCertificateChain(pChainContext);

View File

@ -385,7 +385,10 @@ static CURLcode cf_ssl_peer_key_add_path(struct dynbuf *buf,
* 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);

View File

@ -107,7 +107,7 @@ if(CURL_HAS_LTO)
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()

View File

@ -66,7 +66,7 @@ unsigned int get_terminal_columns(void)
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;

View File

@ -158,7 +158,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
/*
* 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;
}

View File

@ -91,7 +91,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
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;
}

View File

@ -80,7 +80,7 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence)
}
#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))

View File

@ -138,7 +138,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
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
@ -210,7 +210,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
}
}
#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)) &&

View File

@ -25,7 +25,7 @@
#include <sys/stat.h>
#ifdef _WIN32
#if defined(_WIN32) && !defined(UNDER_CE)
# include <direct.h>
#endif

View File

@ -561,7 +561,7 @@ char **__crt0_glob_function(char *arg)
#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.
*
@ -613,7 +613,7 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
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};
@ -664,7 +664,7 @@ cleanup:
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;
@ -747,7 +747,7 @@ CURLcode win32_init(void)
QueryPerformanceFrequency(&tool_freq);
#ifndef CURL_WINDOWS_UWP
#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
init_terminal();
#endif

View File

@ -47,7 +47,7 @@ char **__crt0_glob_function(char *arg);
#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);

View File

@ -125,7 +125,11 @@ static struct tool_mime *tool_mime_new_filedata(struct tool_mime *parent,
}
}
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;

View File

@ -2714,7 +2714,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
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;
@ -2873,7 +2873,11 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
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;
@ -2887,7 +2891,11 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
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;

View File

@ -46,7 +46,7 @@
# include iodef
#endif
#ifdef _WIN32
#if defined(_WIN32) && !defined(UNDER_CE)
# include <conio.h>
#endif
@ -94,7 +94,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
#define DONE
#endif /* __VMS */
#if defined(_WIN32)
#ifdef _WIN32
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
{
@ -122,7 +122,7 @@ 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 */

View File

@ -29,7 +29,9 @@
#include <tchar.h>
#endif
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
@ -224,7 +226,7 @@ static void main_free(struct GlobalConfig *config)
/*
** 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
@ -242,7 +244,7 @@ int main(int argc, char *argv[])
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"))) {
@ -252,6 +254,8 @@ int main(int argc, char *argv[])
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) {
@ -295,7 +299,7 @@ int main(int argc, char *argv[])
#endif
}
#ifdef _UNICODE
#if defined(_UNICODE) && !defined(UNDER_CE)
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif

View File

@ -664,7 +664,8 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
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 */
@ -3003,7 +3004,8 @@ static CURLcode cacertpaths(struct OperationConfig *config)
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;
@ -3130,7 +3132,12 @@ static CURLcode run_all_transfers(struct GlobalConfig *global,
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) */

View File

@ -230,7 +230,7 @@ static ParameterError getnum(long *val, const char *str, int base)
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;
@ -319,7 +319,7 @@ static ParameterError str2double(double *val, const char *str, double max)
if(str) {
char *endptr;
double num;
errno = 0;
CURL_SETERRNO(0);
num = strtod(str, &endptr);
if(errno == ERANGE)
return PARAM_NUMBER_TOO_LARGE;
@ -577,7 +577,7 @@ ParameterError str2offset(curl_off_t *val, const char *str)
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;

View File

@ -64,7 +64,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
}
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 */

View File

@ -81,15 +81,25 @@ extern FILE *tool_stderr;
# 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);
@ -99,7 +109,8 @@ 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 */

View File

@ -215,7 +215,7 @@ static CURLcode glob_range(struct URLGlob *glob, char **patternp,
if(end_c == ':') {
char *endp;
errno = 0;
CURL_SETERRNO(0);
step = strtoul(&pattern[4], &endp, 10);
if(errno || &pattern[4] == endp || *endp != ']')
step = 0;
@ -269,7 +269,7 @@ static CURLcode glob_range(struct URLGlob *glob, char **patternp,
}
}
errno = 0;
CURL_SETERRNO(0);
min_n = strtoul(pattern, &endp, 10);
if(errno || (endp == pattern))
endp = NULL;
@ -284,14 +284,14 @@ static CURLcode glob_range(struct URLGlob *glob, char **patternp,
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 */

View File

@ -188,12 +188,10 @@ int struplocompare4sort(const void *p1, const void *p2)
#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
/*
@ -215,7 +213,7 @@ int tool_ftruncate64(int fd, curl_off_t where)
#endif /* USE_TOOL_FTRUNCATE */
#ifdef _WIN32
#if defined(_WIN32) && !defined(UNDER_CE)
FILE *Curl_execpath(const char *filename, char **pathp)
{
static char filebuffer[512];

View File

@ -48,7 +48,7 @@ long tvdiff(struct timeval t1, struct timeval t2);
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

View File

@ -29,8 +29,6 @@
#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)
{

View File

@ -30,8 +30,6 @@
#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)
{

View File

@ -29,7 +29,7 @@
#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>
@ -47,7 +47,7 @@ static unsigned int WINAPI run_thread(void *ptr)
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;
@ -78,7 +78,7 @@ CURLcode test(char *URL)
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);

View File

@ -74,7 +74,7 @@ static size_t write_memory_callback(char *contents, size_t size,
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

View File

@ -63,7 +63,11 @@ CURLcode test(char *URL)
}
/* 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",

View File

@ -63,7 +63,11 @@ CURLcode test(char *URL)
}
/* 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",

View File

@ -55,7 +55,11 @@ CURLcode test(char *URL)
}
/* 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",

View File

@ -94,7 +94,11 @@ again:
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;

View File

@ -256,7 +256,11 @@ CURLcode test(char *URL)
}
/* 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",

View File

@ -133,7 +133,7 @@ double tutil_tvdiff_secs(struct timeval newer, struct timeval older)
#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

View File

@ -64,7 +64,9 @@ USEFUL = \
UTIL = \
util.c \
util.h
util.h \
../../lib/strerror.c \
../../lib/strerror.h
getpart_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) \
testpart.c

View File

@ -37,7 +37,9 @@
/* based on sockfilt.c */
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

View File

@ -33,7 +33,6 @@
*
*/
#include <signal.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

View File

@ -29,7 +29,9 @@
* 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
@ -474,7 +476,7 @@ static int ProcessRequest(struct httprequest *req)
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 */

View File

@ -85,7 +85,9 @@
* it!
*/
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@ -151,7 +153,7 @@ enum sockmode {
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.
*/
@ -178,7 +180,7 @@ static ssize_t read_wincon(int fd, void *buf, size_t count)
return rcount;
}
errno = (int)GetLastError();
CURL_SETERRNO((int)GetLastError());
return -1;
}
#undef read
@ -213,13 +215,15 @@ static ssize_t write_wincon(int fd, const void *buf, size_t count)
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
@ -337,6 +341,7 @@ static bool read_stdin(void *buffer, size_t nbytes)
}
return TRUE;
}
#endif
/*
* write_stdout tries to write to stdio nbytes from the given buffer. This is a
@ -347,7 +352,13 @@ static bool read_stdin(void *buffer, size_t nbytes)
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;
@ -355,6 +366,7 @@ static bool write_stdout(const void *buffer, size_t nbytes)
return TRUE;
}
#ifndef UNDER_CE
static void lograw(unsigned char *buffer, ssize_t len)
{
char data[120];
@ -426,9 +438,10 @@ static bool read_data_block(unsigned char *buffer, ssize_t maxlen,
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
@ -446,12 +459,8 @@ struct select_ws_wait_data {
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];
@ -594,11 +603,7 @@ static unsigned int WINAPI select_ws_wait_thread(void *lpParameter)
}
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;
@ -610,11 +615,7 @@ static HANDLE select_ws_wait(HANDLE handle, HANDLE signal, HANDLE abort)
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) {
@ -646,7 +647,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* check if the input value is valid */
if(nfds < 0) {
errno = EINVAL;
CURL_SETERRNO(EINVAL);
return -1;
}
@ -667,7 +668,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
/* create internal event to abort waiting threads */
abort = CreateEvent(NULL, TRUE, FALSE, NULL);
if(!abort) {
errno = ENOMEM;
CURL_SETERRNO(ENOMEM);
return -1;
}
@ -675,7 +676,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
data = calloc(nfds, sizeof(struct select_ws_data));
if(!data) {
CloseHandle(abort);
errno = ENOMEM;
CURL_SETERRNO(ENOMEM);
return -1;
}
@ -684,7 +685,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
if(!handles) {
CloseHandle(abort);
free(data);
errno = ENOMEM;
CURL_SETERRNO(ENOMEM);
return -1;
}
@ -900,6 +901,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
#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
@ -954,6 +956,7 @@ static bool disc_handshake(void)
} while(TRUE);
return TRUE;
}
#endif
/*
sockfdp is a pointer to an established stream or CURL_SOCKET_BAD
@ -965,6 +968,12 @@ static bool juggle(curl_socket_t *sockfdp,
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;
@ -1236,6 +1245,7 @@ static bool juggle(curl_socket_t *sockfdp,
}
return TRUE;
#endif
}
static curl_socket_t sockdaemon(curl_socket_t sock,

View File

@ -57,7 +57,9 @@
/* based on sockfilt.c */
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

View File

@ -30,7 +30,9 @@
*/
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@ -622,7 +624,7 @@ static int ProcessRequest(struct httprequest *req)
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 */

View File

@ -55,7 +55,9 @@
#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

View File

@ -23,7 +23,9 @@
***************************************************************************/
#include "server_setup.h"
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@ -44,6 +46,10 @@
#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"
@ -136,22 +142,12 @@ void logmsg(const char *msg, ...)
}
#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);
@ -193,11 +189,11 @@ void win32_cleanup(void)
_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 */
@ -244,7 +240,7 @@ int wait_ms(int timeout_ms)
if(!timeout_ms)
return 0;
if(timeout_ms < 0) {
errno = EINVAL;
CURL_SETERRNO(EINVAL);
return -1;
}
#if defined(MSDOS)
@ -503,12 +499,8 @@ static SIGHANDLER_T old_sigterm_handler = SIG_ERR;
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
@ -529,6 +521,7 @@ HANDLE exit_event = NULL;
* 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;
@ -542,10 +535,11 @@ static void exit_signal_handler(int signum)
#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.
*
@ -593,7 +587,7 @@ static BOOL WINAPI ctrl_event_handler(DWORD dwCtrlType)
}
#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).
@ -625,12 +619,8 @@ static LRESULT CALLBACK main_window_proc(HWND hwnd, UINT uMsg,
}
/* 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;
@ -678,6 +668,7 @@ static unsigned int WINAPI main_window_loop(void *lpParameter)
}
#endif
#ifndef UNDER_CE
static SIGHANDLER_T set_signal(int signum, SIGHANDLER_T handler,
bool restartable)
{
@ -707,6 +698,7 @@ static SIGHANDLER_T set_signal(int signum, SIGHANDLER_T handler,
return oldhdlr;
#endif
}
#endif
void install_signal_handlers(bool keep_sigalrm)
{
@ -757,24 +749,17 @@ 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");
#ifndef CURL_WINDOWS_UWP
{
#ifdef _WIN32_WCE
typedef HANDLE curl_win_thread_handle_t;
#else
typedef uintptr_t curl_win_thread_handle_t;
#endif
#if !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
{
typedef uintptr_t curl_win_thread_handle_t;
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");
@ -814,8 +799,10 @@ void restore_signal_handlers(bool keep_sigalrm)
(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)) {

View File

@ -40,9 +40,6 @@
#include <inet.h>
#endif
#include <setjmp.h>
#include <signal.h>
#include "urldata.h"
#include "connect.h"
#include "cfilters.h"