mirror of https://github.com/aria2/aria2
Merge fff99323a3
into 999a5915b2
commit
d592322d93
|
@ -44,3 +44,6 @@ compile
|
||||||
main.log
|
main.log
|
||||||
main.trs
|
main.trs
|
||||||
test-suite.log
|
test-suite.log
|
||||||
|
compile_commands.json
|
||||||
|
/build
|
||||||
|
/.cache
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,66 @@
|
||||||
|
find_package(PackageHandleStandardArgs)
|
||||||
|
|
||||||
|
|
||||||
|
FIND_PATH(CPPUNIT_INCLUDE_DIR
|
||||||
|
cppunit/TestCase.h
|
||||||
|
PATHS
|
||||||
|
cppunit/include
|
||||||
|
/usr/local/include
|
||||||
|
/usr/include
|
||||||
|
${CMAKE_BINARY_DIR}/cppunit-src/include
|
||||||
|
${CMAKE_BINARY_DIR}/cppunit-build/include/cppunit
|
||||||
|
)
|
||||||
|
|
||||||
|
# With Win32, important to have both
|
||||||
|
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
|
||||||
|
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
|
||||||
|
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib
|
||||||
|
${CMAKE_BINARY_DIR}/cppunit-src/lib/Release
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd
|
||||||
|
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib
|
||||||
|
${CMAKE_BINARY_DIR}/cppunit-src/lib/Debug
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# On unix system, debug and release have the same name
|
||||||
|
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
|
||||||
|
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib
|
||||||
|
${CMAKE_BINARY_DIR}/cppunit-src/lib
|
||||||
|
)
|
||||||
|
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit
|
||||||
|
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib
|
||||||
|
${CMAKE_BINARY_DIR}/cppunit-src/lib
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CPPUNIT_INCLUDE_DIR)
|
||||||
|
if(CPPUNIT_LIBRARY)
|
||||||
|
set(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS})
|
||||||
|
set(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY} ${CMAKE_DL_LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_version_regex "^#define[ \t]+CPPUNIT_PACKAGE_VERSION[ \t]+\"([^\"]+)\".*")
|
||||||
|
file(STRINGS "${CPPUNIT_INCLUDE_DIR}/cppunit/config-auto.h" CPPUNIT_VERSION REGEX "${_version_regex}")
|
||||||
|
string(REGEX REPLACE "${_version_regex}" "\\1" CPPUNIT_VERSION ${CPPUNIT_VERSION})
|
||||||
|
unset(_version_regex)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_package_handle_standard_args(CPPUNIT
|
||||||
|
REQUIRED_VARS CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIR CPPUNIT_LIBRARY CPPUNIT_DEBUG_LIBRARY
|
||||||
|
VERSION_VAR CPPUNIT_VERSION
|
||||||
|
)
|
||||||
|
mark_as_advanced(CPPUNIT_INCLUDE_DIR CPPUNIT_LIBRARY CPPUNIT_DEBUG_LIBRARY CPPUNIT_LIBRARIES CPPUNIT_VERSION)
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Find the CUnit headers and libraries
|
||||||
|
#
|
||||||
|
# CUNIT_INCLUDE_DIRS - The CUnit include directory (directory where CUnit/CUnit.h was found)
|
||||||
|
# CUNIT_LIBRARIES - The libraries needed to use CUnit
|
||||||
|
# CUNIT_FOUND - True if CUnit found in system
|
||||||
|
|
||||||
|
|
||||||
|
FIND_PATH(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h)
|
||||||
|
MARK_AS_ADVANCED(CUNIT_INCLUDE_DIR)
|
||||||
|
|
||||||
|
FIND_LIBRARY(CUNIT_LIBRARY NAMES
|
||||||
|
cunit
|
||||||
|
libcunit
|
||||||
|
cunitlib
|
||||||
|
)
|
||||||
|
MARK_AS_ADVANCED(CUNIT_LIBRARY)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(CUnit_FOUND)
|
||||||
|
SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
|
||||||
|
SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
|
||||||
|
ENDIF()
|
|
@ -0,0 +1,34 @@
|
||||||
|
find_package(PackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_program( RST2HTML_EXECUTABLE NAMES rst2html.py rst2html DOC "Python Docutils reStructuredText to HTML converter")
|
||||||
|
|
||||||
|
if (RST2HTML_EXECUTABLE)
|
||||||
|
if (WIN32)
|
||||||
|
find_package(PythonInterp)
|
||||||
|
if (NOT PYTHON_EXECUTABLE)
|
||||||
|
message(FATAL_ERROR "Can't find Python interpreter, required by Docutils")
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${RST2HTML_EXECUTABLE} --version OUTPUT_VARIABLE DOCUTILS_VERSION_STR)
|
||||||
|
else()
|
||||||
|
execute_process(COMMAND ${RST2HTML_EXECUTABLE} --version OUTPUT_VARIABLE DOCUTILS_VERSION_STR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT "${DOCUTILS_VERSION_STR}" STREQUAL "")
|
||||||
|
string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" DOCUTILS_VERSION_PARTS "${DOCUTILS_VERSION_STR}")
|
||||||
|
list(GET DOCUTILS_VERSION_PARTS 2 DOCUTILS_VERSION_STR)
|
||||||
|
string(REGEX REPLACE "[ \t]+$" "" DOCUTILS_VERSION_STR ${DOCUTILS_VERSION_STR})
|
||||||
|
string(REGEX REPLACE "^[ \t]+" "" DOCUTILS_VERSION_STR ${DOCUTILS_VERSION_STR})
|
||||||
|
string(REGEX REPLACE ",$" "" DOCUTILS_VERSION_STR ${DOCUTILS_VERSION_STR})
|
||||||
|
|
||||||
|
set(DOCUTILS_VERSION ${DOCUTILS_VERSION_STR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_package_handle_standard_args(Docutils
|
||||||
|
REQUIRED_VARS RST2HTML_EXECUTABLE DOCUTILS_VERSION
|
||||||
|
VERSION_VAR DOCUTILS_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(RST2HTML_EXECUTABLE)
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Try to find the GNU Multiple Precision Arithmetic Library (GMP)
|
||||||
|
# See http://gmplib.org/
|
||||||
|
|
||||||
|
if (GMP_INCLUDES AND GMP_LIBRARIES)
|
||||||
|
set(GMP_FIND_QUIETLY TRUE)
|
||||||
|
endif (GMP_INCLUDES AND GMP_LIBRARIES)
|
||||||
|
|
||||||
|
find_path(GMP_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
gmp.h
|
||||||
|
PATHS
|
||||||
|
$ENV{GMPDIR}
|
||||||
|
${INCLUDE_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(GMP_LIBRARY gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR})
|
||||||
|
|
||||||
|
if(GMP_LIBRARY)
|
||||||
|
set(GMP_LIBRARIES ${GMP_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(
|
||||||
|
GMP
|
||||||
|
REQUIRED_VARS GMP_INCLUDE_DIR GMP_LIBRARIES
|
||||||
|
)
|
||||||
|
|
||||||
|
if(GMP_FOUND)
|
||||||
|
add_library(GMP::GMP UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(GMP::GMP PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${GMP_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${GMP_COMPILE_OPTIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES)
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
FIND_PATH( Jemalloc_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
jemalloc/jemalloc.h
|
||||||
|
PATHS
|
||||||
|
/usr/include
|
||||||
|
/usr/include/jemalloc
|
||||||
|
/usr/local/include
|
||||||
|
/usr/local/include/jemalloc
|
||||||
|
$ENV{JEMALLOC_ROOT}
|
||||||
|
$ENV{JEMALLOC_ROOT}/include
|
||||||
|
${CMAKE_SOURCE_DIR}/externals/jemalloc
|
||||||
|
)
|
||||||
|
FIND_LIBRARY(Jemalloc_LIBRARY
|
||||||
|
NAMES
|
||||||
|
jemalloc libjemalloc JEMALLOC
|
||||||
|
PATHS
|
||||||
|
/usr/lib
|
||||||
|
/usr/lib/jemalloc
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/local/lib/jemalloc
|
||||||
|
/usr/local/jemalloc/lib
|
||||||
|
$ENV{JEMALLOC_ROOT}/lib
|
||||||
|
$ENV{JEMALLOC_ROOT}
|
||||||
|
)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||||
|
Jemalloc
|
||||||
|
REQUIRED_VARS
|
||||||
|
Jemalloc_LIBRARY
|
||||||
|
Jemalloc_INCLUDE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced( Jemalloc_LIBRARY Jemalloc_INCLUDE_DIR )
|
|
@ -0,0 +1,146 @@
|
||||||
|
# Copyright 2014 Nicolás Alvarez <nicolas.alvarez@gmail.com>
|
||||||
|
# Copyright 2016, 2021 Igalia S.L
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# 3. The name of the author may not be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
FindGcrypt
|
||||||
|
----------
|
||||||
|
|
||||||
|
Find libgcrypt headers and libraries.
|
||||||
|
|
||||||
|
Imported Targets
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
``LibGcrypt::LibGcrypt``
|
||||||
|
The libgcrypt library, if found.
|
||||||
|
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
find_program(LIBGCRYPTCONFIG_SCRIPT NAMES libgcrypt-config)
|
||||||
|
if (PkgConfig_FOUND)
|
||||||
|
# XXX: The libgcrypt.pc file does not list gpg-error as a dependency,
|
||||||
|
# resulting in linking errors; search for the latter as well.
|
||||||
|
pkg_check_modules(PC_GCRYPT QUIET libgcrypt)
|
||||||
|
pkg_check_modules(PC_GPGERROR QUIET gpg-error)
|
||||||
|
set(LibGcrypt_COMPILE_OPTIONS ${PC_GCRYPT_CFLAGS_OTHER} ${PC_GPGERROR_CFLAGS_OTHER})
|
||||||
|
set(LibGcrypt_VERSION ${PC_GCRYPT_VERSION})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (LIBGCRYPTCONFIG_SCRIPT AND NOT PC_GCRYPT)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${LIBGCRYPTCONFIG_SCRIPT}" --prefix
|
||||||
|
RESULT_VARIABLE CONFIGSCRIPT_RESULT
|
||||||
|
OUTPUT_VARIABLE LIBGCRYPT_PREFIX
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if (CONFIGSCRIPT_RESULT EQUAL 0)
|
||||||
|
set(LIBGCRYPT_SCRIPT_LIB_HINT "${LIBGCRYPT_PREFIX}/lib")
|
||||||
|
set(LIBGCRYPT_SCRIPT_INCLUDE_HINT "${LIBGCRYPT_PREFIX}/include")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${LIBGCRYPTCONFIG_SCRIPT}" --cflags
|
||||||
|
RESULT_VARIABLE CONFIGSCRIPT_RESULT
|
||||||
|
OUTPUT_VARIABLE CONFIGSCRIPT_VALUE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if (CONFIGSCRIPT_RESULT EQUAL 0)
|
||||||
|
set(LibGcrypt_COMPILE_OPTIONS ${CONFIGSCRIPT_VALUE})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${LIBGCRYPTCONFIG_SCRIPT}" --version
|
||||||
|
RESULT_VARIABLE CONFIGSCRIPT_RESULT
|
||||||
|
OUTPUT_VARIABLE CONFIGSCRIPT_VALUE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if (CONFIGSCRIPT_RESULT EQUAL 0)
|
||||||
|
string(REGEX MATCH "^([0-9]+\.[0-9]+\.[0-9]+)" LibGcrypt_VERSION "${CONFIGSCRIPT_VALUE}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_path(LibGcrypt_GpgError_INCLUDE_DIR
|
||||||
|
NAMES gpg-error.h
|
||||||
|
HINTS ${PC_GPGERROR_INCLUDEDIR} ${PC_GPGERROR_INCLUDE_DIRS}
|
||||||
|
${PC_GCRYPT_INCLUDEDIR} ${PC_GCRYPT_INCLUDE_DIRS}
|
||||||
|
${LIBGCRYPT_SCRIPT_INCLUDE_HINT} ${LibGcrypt_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LibGcrypt_GpgError_LIBRARY
|
||||||
|
NAMES ${LibGcrypt_GpgError_NAMES} gpg-error libgpg-error
|
||||||
|
HINTS ${PC_GPGERROR_LIBDIR} ${PC_GPGERROR_LIBRARY_DIRS}
|
||||||
|
${PC_GCRYPT_LIBDIR} ${PC_GCRYPT_LIBRARY_DIRS} ${LIBGCRYPT_SCRIPT_LIB_HINT}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(LibGcrypt_INCLUDE_DIR
|
||||||
|
NAMES gcrypt.h
|
||||||
|
HINTS ${PC_GCRYPT_INCLUDEDIR} ${PC_GCRYPT_INCLUDE_DIRS}
|
||||||
|
${LIBGCRYPT_SCRIPT_INCLUDE_HINT} ${LibGcrypt_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LibGcrypt_LIBRARY
|
||||||
|
NAMES ${LibGcrypt_NAMES} gcrypt libgcrypt
|
||||||
|
HINTS ${PC_GCRYPT_LIBDIR} ${PC_GCRYPT_LIBRARY_DIRS} ${LIBGCRYPT_SCRIPT_LIB_HINT}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (LibGcrypt_INCLUDE_DIR AND NOT LibGcrypt_VERSION)
|
||||||
|
file(STRINGS ${LibGcrypt_INCLUDE_DIR}/gcrypt.h GCRYPT_H REGEX "^#define GCRYPT_VERSION ")
|
||||||
|
string(REGEX REPLACE "^#define GCRYPT_VERSION \"([0-9.]\+)[^\"]*\".*$" "\\1" LibGcrypt_VERSION "${GCRYPT_H}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(LibGcrypt
|
||||||
|
FOUND_VAR LibGcrypt_FOUND
|
||||||
|
REQUIRED_VARS LibGcrypt_LIBRARY LibGcrypt_INCLUDE_DIR
|
||||||
|
LibGcrypt_GpgError_LIBRARY LibGcrypt_GpgError_INCLUDE_DIR
|
||||||
|
VERSION_VAR LibGcrypt_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
if (LibGcrypt_GpgError_LIBRARY AND NOT TARGET LibGcrypt::GpgError)
|
||||||
|
add_library(LibGcrypt::GpgError UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(LibGcrypt::GpgError PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LibGcrypt_GpgError_LIBRARY}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LibGcrypt_GpgError_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (LibGcrypt_LIBRARY AND NOT TARGET LibGcrypt::LibGcrypt)
|
||||||
|
add_library(LibGcrypt::LibGcrypt UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(LibGcrypt::LibGcrypt PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LibGcrypt_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${LibGcrypt_COMPILE_OPTIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LibGcrypt_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
target_link_libraries(LibGcrypt::LibGcrypt INTERFACE LibGcrypt::GpgError)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
mark_as_advanced(LibGcrypt_INCLUDE_DIR LibGcrypt_LIBRARY
|
||||||
|
LibGcrypt_GpgError_INCLUDE_DIR LibGcrypt_GpgError_LIBRARY)
|
||||||
|
|
||||||
|
if (LibGcrypt_FOUND)
|
||||||
|
set(LibGcrypt_LIBRARIES ${LibGcrypt_LIBRARY} ${LibGcrypt_GpgError_LIBRARY})
|
||||||
|
set(LibGcrypt_INCLUDE_DIRS ${LibGcrypt_INCLUDE_DIR} ${LibGcrypt_GpgError_INCLUDE_DIR})
|
||||||
|
endif ()
|
|
@ -0,0 +1,31 @@
|
||||||
|
find_path(LIBSSH2_INCLUDE_DIR libssh2.h)
|
||||||
|
find_library(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
|
||||||
|
if(LIBSSH2_INCLUDE_DIR)
|
||||||
|
file(STRINGS "${LIBSSH2_INCLUDE_DIR}/libssh2.h" LIBSSH2_VERSION REGEX "^#define[\t ]+LIBSSH2_VERSION[\t ]+\"([^\"]+)\"")
|
||||||
|
string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" LIBSSH2_VERSION ${LIBSSH2_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBSSH2_LIBRARY)
|
||||||
|
set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(
|
||||||
|
LibSSH2
|
||||||
|
REQUIRED_VARS LIBSSH2_LIBRARIES LIBSSH2_INCLUDE_DIR
|
||||||
|
VERSION_VAR LIBSSH2_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARIES)
|
||||||
|
|
||||||
|
if(LibSSH2_FOUND)
|
||||||
|
add_library(LibSSH2::LibSSH2 UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(LibSSH2::LibSSH2 PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LIBSSH2_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${LIBSSH2_COMPILE_OPTIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LIBSSH2_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Standard FIND_PACKAGE module for libuv, sets the following variables:
|
||||||
|
# - LIBUV_FOUND
|
||||||
|
# - LIBUV_INCLUDE_DIRS (only if LIBUV_FOUND)
|
||||||
|
# - LIBUV_LIBRARIES (only if LIBUV_FOUND)
|
||||||
|
|
||||||
|
# Try to find the header
|
||||||
|
FIND_PATH(LIBUV_INCLUDE_DIR NAMES uv.h)
|
||||||
|
|
||||||
|
# Try to find the library
|
||||||
|
FIND_LIBRARY(LIBUV_LIBRARY NAMES uv libuv)
|
||||||
|
|
||||||
|
# Parse out version header
|
||||||
|
if(LIBUV_INCLUDE_DIR)
|
||||||
|
set(_version_major_regex "^#define[ \t]+UV_VERSION_MAJOR[ \t]+([0-9]+).*$")
|
||||||
|
set(_version_minor_regex "^#define[ \t]+UV_VERSION_MINOR[ \t]+([0-9]+).*$")
|
||||||
|
set(_version_patch_regex "^#define[ \t]+UV_VERSION_PATCH[ \t]+([0-9]+).*$")
|
||||||
|
file(STRINGS "${LIBUV_INCLUDE_DIR}/uv/version.h" LIBUV_VERSION_MAJOR REGEX ${_version_major_regex})
|
||||||
|
file(STRINGS "${LIBUV_INCLUDE_DIR}/uv/version.h" LIBUV_VERSION_MINOR REGEX ${_version_minor_regex})
|
||||||
|
file(STRINGS "${LIBUV_INCLUDE_DIR}/uv/version.h" LIBUV_VERSION_PATCH REGEX ${_version_patch_regex})
|
||||||
|
string(REGEX REPLACE ${_version_major_regex} "\\1" LIBUV_VERSION_MAJOR ${LIBUV_VERSION_MAJOR})
|
||||||
|
string(REGEX REPLACE ${_version_minor_regex} "\\1" LIBUV_VERSION_MINOR ${LIBUV_VERSION_MINOR})
|
||||||
|
string(REGEX REPLACE ${_version_patch_regex} "\\1" LIBUV_VERSION_PATCH ${LIBUV_VERSION_PATCH})
|
||||||
|
set(LIBUV_VERSION "${LIBUV_VERSION_MAJOR}.${LIBUV_VERSION_MINOR}.${LIBUV_VERSION_PATCH}")
|
||||||
|
unset(_version_major_regex)
|
||||||
|
unset(_version_minor_regex)
|
||||||
|
unset(_version_patch_regex)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Handle the QUIETLY/REQUIRED arguments, set LIBUV_FOUND if all variables are
|
||||||
|
# found
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||||
|
LIBUV
|
||||||
|
REQUIRED_VARS
|
||||||
|
LIBUV_LIBRARY
|
||||||
|
LIBUV_INCLUDE_DIR
|
||||||
|
VERSION_VAR LIBUV_VERSION
|
||||||
|
NAME_MISMATCHED
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Hide internal variables
|
||||||
|
MARK_AS_ADVANCED(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
|
||||||
|
|
||||||
|
# Set standard variables
|
||||||
|
IF(LIBUV_FOUND)
|
||||||
|
SET(LIBUV_INCLUDE_DIRS "${LIBUV_INCLUDE_DIR}")
|
||||||
|
SET(LIBUV_LIBRARIES "${LIBUV_LIBRARY}")
|
||||||
|
add_library(LIBUV::LIBUV UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(LIBUV::LIBUV PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LIBUV_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${LIBUV_COMPILE_OPTIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LIBUV_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
ENDIF()
|
|
@ -0,0 +1,49 @@
|
||||||
|
# - Try to find libcares
|
||||||
|
# Once done this will define
|
||||||
|
# LIBCARES_FOUND - System has libcares
|
||||||
|
# LIBCARES_INCLUDE_DIRS - The libcares include directories
|
||||||
|
# LIBCARES_LIBRARIES - The libraries needed to use libcares
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(PC_LIBCARES QUIET libcares)
|
||||||
|
|
||||||
|
find_path(LIBCARES_INCLUDE_DIR
|
||||||
|
NAMES ares.h
|
||||||
|
HINTS ${PC_LIBCARES_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
find_library(LIBCARES_LIBRARY
|
||||||
|
NAMES cares
|
||||||
|
HINTS ${PC_LIBCARES_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LIBCARES_INCLUDE_DIR)
|
||||||
|
set(_version_regex "^#define[ \t]+ARES_VERSION_STR[ \t]+\"([^\"]+)\".*")
|
||||||
|
file(STRINGS "${LIBCARES_INCLUDE_DIR}/ares_version.h"
|
||||||
|
LIBCARES_VERSION REGEX "${_version_regex}")
|
||||||
|
string(REGEX REPLACE "${_version_regex}" "\\1"
|
||||||
|
LIBCARES_VERSION "${LIBCARES_VERSION}")
|
||||||
|
unset(_version_regex)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LIBCARES_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE and the requested version matches.
|
||||||
|
find_package_handle_standard_args(Libcares REQUIRED_VARS
|
||||||
|
LIBCARES_LIBRARY LIBCARES_INCLUDE_DIR
|
||||||
|
VERSION_VAR LIBCARES_VERSION)
|
||||||
|
|
||||||
|
if(LIBCARES_FOUND)
|
||||||
|
set(LIBCARES_LIBRARIES ${LIBCARES_LIBRARY})
|
||||||
|
set(LIBCARES_INCLUDE_DIRS ${LIBCARES_INCLUDE_DIR})
|
||||||
|
|
||||||
|
add_library(Libcares::Libcares UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(Libcares::Libcares PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LIBCARES_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${LIBCARES_COMPILE_OPTIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LIBCARES_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
mark_as_advanced(LIBCARES_INCLUDE_DIR LIBCARES_LIBRARY)
|
|
@ -0,0 +1,50 @@
|
||||||
|
# - Find Nettle
|
||||||
|
# Find the Nettle include directory and library
|
||||||
|
#
|
||||||
|
# NETTLE_INCLUDE_DIR - where to find <nettle/sha.h>, etc.
|
||||||
|
# NETTLE_LIBRARIES - List of libraries when using libnettle.
|
||||||
|
# NETTLE_FOUND - True if libnettle found.
|
||||||
|
|
||||||
|
IF (NETTLE_INCLUDE_DIR)
|
||||||
|
# Already in cache, be silent
|
||||||
|
SET(NETTLE_FIND_QUIETLY TRUE)
|
||||||
|
ENDIF (NETTLE_INCLUDE_DIR)
|
||||||
|
|
||||||
|
FIND_PATH(NETTLE_INCLUDE_DIR nettle/md5.h nettle/ripemd160.h nettle/sha.h)
|
||||||
|
FIND_LIBRARY(NETTLE_LIBRARY NAMES nettle libnettle)
|
||||||
|
|
||||||
|
if(NETTLE_INCLUDE_DIR)
|
||||||
|
set(_version_regex_major "^#define[ \t]+NETTLE_VERSION_MAJOR[ \t]+([0-9])$")
|
||||||
|
set(_version_regex_minor "^#define[ \t]+NETTLE_VERSION_MINOR[ \t]+([0-9])$")
|
||||||
|
file(STRINGS "${NETTLE_INCLUDE_DIR}/nettle/version.h" NETTLE_VERSION_MAJOR REGEX ${_version_regex_major})
|
||||||
|
file(STRINGS "${NETTLE_INCLUDE_DIR}/nettle/version.h" NETTLE_VERSION_MINOR REGEX ${_version_regex_minor})
|
||||||
|
string(REGEX REPLACE "${_version_regex_major}" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION_MAJOR})
|
||||||
|
string(REGEX REPLACE "${_version_regex_minor}" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION_MINOR})
|
||||||
|
set(NETTLE_VERSION "${NETTLE_VERSION_MAJOR}.${NETTLE_VERSION_MINOR}")
|
||||||
|
unset(_version_regex_major)
|
||||||
|
unset(_version_regex_minor)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set NETTLE_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||||
|
NETTLE
|
||||||
|
REQUIRED_VARS NETTLE_LIBRARY NETTLE_INCLUDE_DIR
|
||||||
|
VERSION_VAR NETTLE_VERSION
|
||||||
|
NAME_MISMATCHED
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(NETTLE_FOUND)
|
||||||
|
SET(NETTLE_LIBRARIES ${NETTLE_LIBRARY})
|
||||||
|
|
||||||
|
add_library(Nettle::Nettle UNKNOWN IMPORTED GLOBAL)
|
||||||
|
set_target_properties(Nettle::Nettle PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${NETTLE_LIBRARY}"
|
||||||
|
INTERFACE_COMPILE_OPTIONS "${NETTLE_COMPILE_OPTIONS}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${NETTLE_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
ENDIF(NETTLE_FOUND)
|
||||||
|
mark_as_advanced(NETTLE_INCLUDE_DIR NETTLE_LIBRARY NETTLE_LIBRARIES NETTLE_VERSION NETTLE_VERSION_MINOR NETTLE_VERSION_MAJOR)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
# We are likely to find Sphinx near the Python interpreter
|
||||||
|
find_package(PythonInterp)
|
||||||
|
if(PYTHONINTERP_FOUND)
|
||||||
|
get_filename_component(_PYTHON_DIR "${PYTHON_EXECUTABLE}" DIRECTORY)
|
||||||
|
set(
|
||||||
|
_PYTHON_PATHS
|
||||||
|
"${_PYTHON_DIR}"
|
||||||
|
"${_PYTHON_DIR}/bin"
|
||||||
|
"${_PYTHON_DIR}/Scripts")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(
|
||||||
|
SPHINX_EXECUTABLE
|
||||||
|
NAMES sphinx-build sphinx-build.exe
|
||||||
|
HINTS ${_PYTHON_PATHS})
|
||||||
|
mark_as_advanced(SPHINX_EXECUTABLE)
|
||||||
|
|
||||||
|
if(SPHINX_EXECUTABLE)
|
||||||
|
|
||||||
|
if(WIN32 AND PYTHON_EXECUTABLE)
|
||||||
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SPHINX_EXECUTABLE} --version OUTPUT_VARIABLE SPHINX_VERSION_STR)
|
||||||
|
else()
|
||||||
|
execute_process(COMMAND ${SPHINX_EXECUTABLE} --version OUTPUT_VARIABLE SPHINX_VERSION_STR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT "${SPHINX_VERSION_STR}" STREQUAL "")
|
||||||
|
if (SPHINX_VERSION_STR MATCHES "sphinx-build ([0-9]+\\.[0-9]+(\\.|a?|b?)([0-9]*)(b?)([0-9]*))")
|
||||||
|
set (SPHINX_VERSION "${CMAKE_MATCH_1}")
|
||||||
|
elseif (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b?)([0-9]*)(b?)([0-9]*))")
|
||||||
|
set (SPHINX_VERSION "${CMAKE_MATCH_1}")
|
||||||
|
elseif (_Sphinx_VERSION MATCHES "Sphinx \\(sphinx-build\\) ([0-9]+\\.[0-9]+(\\.|a?|b?)([0-9]*)(b?)([0-9]*))")
|
||||||
|
set (SPHINX_VERSION "${CMAKE_MATCH_1}")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package_handle_standard_args(
|
||||||
|
Sphinx
|
||||||
|
REQUIRED_VARS SPHINX_EXECUTABLE SPHINX_VERSION
|
||||||
|
VERSION_VAR SPHINX_VERSION
|
||||||
|
)
|
|
@ -0,0 +1,42 @@
|
||||||
|
# - Find Tcmalloc
|
||||||
|
# Find the native Tcmalloc includes and library
|
||||||
|
#
|
||||||
|
# Tcmalloc_INCLUDE_DIR - where to find Tcmalloc.h, etc.
|
||||||
|
# Tcmalloc_LIBRARIES - List of libraries when using Tcmalloc.
|
||||||
|
# Tcmalloc_FOUND - True if Tcmalloc found.
|
||||||
|
|
||||||
|
find_path(Tcmalloc_INCLUDE_DIR gperftools/tcmalloc.h NO_DEFAULT_PATH PATHS
|
||||||
|
${HT_DEPENDENCY_INCLUDE_DIR}
|
||||||
|
/usr/include
|
||||||
|
/opt/local/include
|
||||||
|
/usr/local/include
|
||||||
|
)
|
||||||
|
|
||||||
|
if (USE_TCMALLOC)
|
||||||
|
set(Tcmalloc_NAMES libtcmalloc tcmalloc)
|
||||||
|
else ()
|
||||||
|
set(Tcmalloc_NAMES libtcmalloc libtcmalloc_minimal tcmalloc_minimal tcmalloc)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_library(Tcmalloc_LIBRARY NO_DEFAULT_PATH
|
||||||
|
NAMES ${Tcmalloc_NAMES}
|
||||||
|
PATHS ${HT_DEPENDENCY_LIB_DIR} /lib /usr/lib /usr/local/lib /opt/local/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if (Tcmalloc_INCLUDE_DIR AND Tcmalloc_LIBRARY)
|
||||||
|
set( Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY} )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||||
|
Tcmalloc
|
||||||
|
REQUIRED_VARS
|
||||||
|
Tcmalloc_LIBRARY
|
||||||
|
Tcmalloc_INCLUDE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
Tcmalloc_LIBRARY
|
||||||
|
Tcmalloc_INCLUDE_DIR
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
function(config_h_add_compile_definitions definitions)
|
||||||
|
set(${PROJECT_NAME}_CONFIG_H_definitions ${${PROJECT_NAME}_CONFIG_H_definitions} ${definitions} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(config_h_add_compile_macro definitions)
|
||||||
|
set(${PROJECT_NAME}_CONFIG_H_macros ${${PROJECT_NAME}_CONFIG_H_macros} ${definitions} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(config_h_generate_header name)
|
||||||
|
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "/* config.h.in. Generated from cmake*/\n")
|
||||||
|
foreach(def ${${PROJECT_NAME}_CONFIG_H_definitions})
|
||||||
|
set(def_var ${def})
|
||||||
|
string(REPLACE "=" ";" def_var ${def_var})
|
||||||
|
list(POP_FRONT def_var def_name)
|
||||||
|
if(def_var)
|
||||||
|
set(${def_name}_config_h_val ${def_var})
|
||||||
|
elseif(${${def_name}})
|
||||||
|
set(${def_name}_config_h_val "${${def_name}}")
|
||||||
|
string(REPLACE "yes" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||||
|
string(REPLACE "ON" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||||
|
string(REPLACE "on" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||||
|
string(REPLACE "TRUE" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||||
|
string(REPLACE "true" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
|
||||||
|
else()
|
||||||
|
set(${def_name}_config_h_val "1")
|
||||||
|
endif()
|
||||||
|
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "#define ${def_name} @${def_name}_config_h_val@\n" APPEND)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(macro ${${PROJECT_NAME}_CONFIG_H_macros})
|
||||||
|
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "#define ${macro} \n" APPEND)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in ${name}.h)
|
||||||
|
endfunction()
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
if (ENABLE_WEBSOCKET)
|
||||||
|
add_subdirectory(wslay)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
#if ENABLE_WEBSOCKET
|
||||||
|
#SUBDIRS = wslay
|
||||||
|
#endif # ENABLE_WEBSOCKET
|
|
@ -0,0 +1,225 @@
|
||||||
|
project(wslay LANGUAGES CXX C VERSION 1.1.1)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../cmake/")
|
||||||
|
|
||||||
|
# ####### Set compiler flags ########
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED true)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
include(GenerateConfigH)
|
||||||
|
|
||||||
|
config_h_add_compile_definitions(PACKAGE="${PROJECT_NAME}")
|
||||||
|
config_h_add_compile_definitions(PACKAGE_NAME="${PROJECT_NAME}")
|
||||||
|
config_h_add_compile_definitions(PACKAGE_STRING="${PROJECT_NAME} ${PROJECT_VERSION}")
|
||||||
|
config_h_add_compile_definitions(PACKAGE_TARNAME="${PROJECT_NAME}")
|
||||||
|
config_h_add_compile_definitions(PACKAGE_URL="${PROJECT_HOMEPAGE_URL}")
|
||||||
|
config_h_add_compile_definitions(PACKAGE_BUGREPORT="t-tujikawa@users.sourceforge.net")
|
||||||
|
config_h_add_compile_definitions(PACKAGE_VERSION="${PROJECT_VERSION}")
|
||||||
|
config_h_add_compile_definitions(VERSION="${PROJECT_VERSION}")
|
||||||
|
|
||||||
|
set(BUILD_ID "${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
set(HOST_ID "${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM_NAME}")
|
||||||
|
set(TARGET_ID "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
|
||||||
|
|
||||||
|
config_h_add_compile_definitions(HOST="${HOST_ID}")
|
||||||
|
config_h_add_compile_definitions(BUILD="${BUILD_ID}")
|
||||||
|
config_h_add_compile_definitions(TARGET="${TARGET_ID}")
|
||||||
|
|
||||||
|
set(PACKAGE_VERSION ${PROJECT_VERSION})
|
||||||
|
|
||||||
|
option(ENABLE_WERROR "Builld with werror" off)
|
||||||
|
|
||||||
|
# #### Check for Libraries #####
|
||||||
|
include(CheckLibraryExists)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
include(CheckCXXSymbolExists)
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
include(CheckTypeSize)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
# using Clang
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
# using GCC
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe" CACHE STRING "")
|
||||||
|
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
|
# using Intel C++
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
# using Visual Studio C++
|
||||||
|
# config_h_add_compile_definitions(__MSVC__=1) # USE _MSC_VER
|
||||||
|
add_compile_definitions(NOMINMAX)
|
||||||
|
config_h_add_compile_macro("__restrict__ __restrict")
|
||||||
|
config_h_add_compile_macro("__attribute__(unused) /*Empty*/")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32 AND NOT MINGW)
|
||||||
|
set(NO_UNIX)
|
||||||
|
config_h_add_compile_definitions(NO_UNIX=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(ENABLE_WERROR)
|
||||||
|
add_compile_options(-Wall -Werror -Wformat-security)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(Sphinx)
|
||||||
|
if(Sphinx_FOUND)
|
||||||
|
set(HAVE_SPHINX_BUILD true CACHE BOOL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT NETTLE_FOUND)
|
||||||
|
# may have already been found and imported by parent project
|
||||||
|
find_package(Nettle 2.4)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NETTLE_FOUND)
|
||||||
|
set(HAVE_NETTLE true CACHE BOOL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(CUnit)
|
||||||
|
if(CUnit_FOUND)
|
||||||
|
set(HAVE_CUNIT true CACHE BOOL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
# Required for ntoh*/hton* functions.
|
||||||
|
add_link_options(-lws2_32)
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} -lws2_32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(wslay_found_headers ${a2_found_headers}) #inherit from parent project if possible
|
||||||
|
|
||||||
|
set(_check_headers
|
||||||
|
arpa/inet.h
|
||||||
|
netinet/in.h
|
||||||
|
stddef.h
|
||||||
|
stdint.h
|
||||||
|
stdlib.h
|
||||||
|
string.h
|
||||||
|
unistd.h
|
||||||
|
memory.h
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(header ${_check_headers})
|
||||||
|
string(TOUPPER ${header} header_var)
|
||||||
|
string(REPLACE "." "_" header_var ${header_var})
|
||||||
|
string(REPLACE "/" "_" header_var ${header_var})
|
||||||
|
set(header_var "HAVE_${header_var}")
|
||||||
|
set(${header_var})
|
||||||
|
check_include_file(${header} ${header_var})
|
||||||
|
|
||||||
|
if(${header_var})
|
||||||
|
list(APPEND wslay_found_headers ${header})
|
||||||
|
config_h_add_compile_definitions(${header_var})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
unset(_check_headers)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
# Need winsock2.h for ntoh*/hton* functions.
|
||||||
|
check_include_file(winsock2.h HAVE_WINSOCK2_H)
|
||||||
|
|
||||||
|
if(HAVE_WINSOCK2_H)
|
||||||
|
config_h_add_compile_definitions(HAVE_WINSOCK2_H)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(save_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES})
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES ${wslay_found_headers})
|
||||||
|
check_type_size(ptrdiff_t PTRDIFF_T LANGUAGE CXX)
|
||||||
|
if(PTRDIFF_T)
|
||||||
|
set(HAVE_PTRDIFF_T yes CACHE BOOL "")
|
||||||
|
config_h_add_compile_definitions(HAVE_PTRDIFF_T)
|
||||||
|
endif()
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES save_CMAKE_EXTRA_INCLUDE_FILES)
|
||||||
|
|
||||||
|
set(_check_funcs
|
||||||
|
memmove
|
||||||
|
memset
|
||||||
|
ntohl
|
||||||
|
ntohs
|
||||||
|
htons
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(func ${_check_funcs})
|
||||||
|
string(TOUPPER ${func} func_var)
|
||||||
|
set(func_var "HAVE_${func_var}")
|
||||||
|
set(${func_var})
|
||||||
|
check_cxx_symbol_exists(${func} ${wslay_found_headers} ${func_var})
|
||||||
|
|
||||||
|
if(${func_var})
|
||||||
|
config_h_add_compile_definitions(${func_var})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lib/includes/wslay/wslayver.h.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/includes/wslay/wslayver.h)
|
||||||
|
|
||||||
|
unset(_check_funcs)
|
||||||
|
|
||||||
|
if(HAVE_NETTLE AND UNIX)
|
||||||
|
set(BUILD_EXAMPLES true)
|
||||||
|
set(ENABLE_EXAMPLES true)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
config_h_generate_header(config)
|
||||||
|
# pickup the generated config.h
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
add_compile_definitions(HAVE_CONFIG_H)
|
||||||
|
|
||||||
|
add_subdirectory(lib)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
|
|
||||||
|
message(STATUS "summary of build options:
|
||||||
|
|
||||||
|
version: ${PROJECT_VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE
|
||||||
|
Host type: ${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM}
|
||||||
|
Install prefix: ${CMAKE_INSTALL_PREFIX}
|
||||||
|
C compiler: ${CMAKE_CXX_COMPILER}
|
||||||
|
CFlags: ${CMAKE_C_FLAGS}
|
||||||
|
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||||
|
CUnit: ${HAVE_CUNIT}
|
||||||
|
Nettle: ${HAVE_NETTLE}
|
||||||
|
Build examples: ${BUILD_EXAMPLES}
|
||||||
|
")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Wslay - The WebSocket Library
|
||||||
|
#
|
||||||
|
## Copyright (c) 2011, 2012 Tatsuhiro Tsujikawa
|
||||||
|
#
|
||||||
|
## Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
## a copy of this software and associated documentation files (the
|
||||||
|
## "Software"), to deal in the Software without restriction, including
|
||||||
|
## without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
## distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
## permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
## the following conditions:
|
||||||
|
#
|
||||||
|
## The above copyright notice and this permission notice shall be
|
||||||
|
## included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
## OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#SUBDIRS = lib tests
|
||||||
|
#
|
||||||
|
#ACLOCAL_AMFLAGS = -I m4
|
|
@ -27,6 +27,7 @@
|
||||||
// g++ -Wall -O2 -g -o echoserv echoserv.cc -L../lib/.libs -I../lib/includes -lwslay -lnettle
|
// g++ -Wall -O2 -g -o echoserv echoserv.cc -L../lib/.libs -I../lib/includes -lwslay -lnettle
|
||||||
// $ export LD_LIBRARY_PATH=../lib/.libs
|
// $ export LD_LIBRARY_PATH=../lib/.libs
|
||||||
// $ ./a.out 9000
|
// $ ./a.out 9000
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
* $ export LD_LIBRARY_PATH=../lib/.libs
|
* $ export LD_LIBRARY_PATH=../lib/.libs
|
||||||
* $ ./a.out 9000
|
* $ ./a.out 9000
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
// $ g++ -Wall -O2 -g -o testclient testclient.cc -L../lib/.libs -I../lib/includes -lwslay -lnettle
|
// $ g++ -Wall -O2 -g -o testclient testclient.cc -L../lib/.libs -I../lib/includes -lwslay -lnettle
|
||||||
// $ export LD_LIBRARY_PATH=../lib/.libs
|
// $ export LD_LIBRARY_PATH=../lib/.libs
|
||||||
// $ ./a.out localhost 9001
|
// $ ./a.out localhost 9001
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_subdirectory(includes)
|
||||||
|
|
||||||
|
|
||||||
|
########### next target ###############
|
||||||
|
set(HFILES
|
||||||
|
wslay_frame.h
|
||||||
|
wslay_event.h
|
||||||
|
wslay_queue.h
|
||||||
|
wslay_net.h
|
||||||
|
wslay_macro.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(OBJECTS
|
||||||
|
wslay_frame.c
|
||||||
|
wslay_event.c
|
||||||
|
wslay_queue.c
|
||||||
|
wslay_net.c
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(wslay_STAT_SRCS ${HFILES} ${OBJECTS})
|
||||||
|
|
||||||
|
set(WSLAY_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(wslay STATIC ${wslay_STAT_SRCS})
|
||||||
|
|
||||||
|
target_include_directories(wslay PUBLIC ${WSLAY_INCLUDE_DIR})
|
||||||
|
target_include_directories(wslay INTERFACE ${WSLAY_INCLUDE_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Wslay - The WebSocket Library
|
||||||
|
#
|
||||||
|
## Copyright (c) 2011, 2012 Tatsuhiro Tsujikawa
|
||||||
|
#
|
||||||
|
## Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
## a copy of this software and associated documentation files (the
|
||||||
|
## "Software"), to deal in the Software without restriction, including
|
||||||
|
## without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
## distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
## permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
## the following conditions:
|
||||||
|
#
|
||||||
|
## The above copyright notice and this permission notice shall be
|
||||||
|
## included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
## OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#SUBDIRS = includes
|
||||||
|
#
|
||||||
|
#AM_CFLAGS = -Wall
|
||||||
|
#AM_CPPFLAGS = @DEFS@ -I$(srcdir)/includes -I$(builddir)/includes
|
||||||
|
#
|
||||||
|
#DISTCLEANFILES = $(pkgconfig_DATA)
|
||||||
|
#
|
||||||
|
#noinst_LTLIBRARIES = libwslay.la
|
||||||
|
#
|
||||||
|
#OBJECTS = wslay_frame.c wslay_event.c\
|
||||||
|
# wslay_queue.c wslay_net.c
|
||||||
|
#
|
||||||
|
#HFILES = wslay_frame.h wslay_event.h\
|
||||||
|
# wslay_queue.h wslay_net.h wslay_macro.h
|
||||||
|
#
|
||||||
|
#libwslay_la_SOURCES = $(HFILES) $(OBJECTS)
|
||||||
|
#libwslay_la_LDFLAGS = -no-undefined \
|
||||||
|
# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Wslay - The WebSocket Library
|
||||||
|
#
|
||||||
|
## Copyright (c) 2011, 2012 Tatsuhiro Tsujikawa
|
||||||
|
#
|
||||||
|
## Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
## a copy of this software and associated documentation files (the
|
||||||
|
## "Software"), to deal in the Software without restriction, including
|
||||||
|
## without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
## distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
## permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
## the following conditions:
|
||||||
|
#
|
||||||
|
## The above copyright notice and this permission notice shall be
|
||||||
|
## included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
## OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#noinst_HEADERS = wslay/wslay.h wslay/wslayver.h
|
|
@ -33,6 +33,11 @@ extern "C" {
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wslay/wslayver.h is generated from wslay/wslayver.h.in by
|
* wslay/wslayver.h is generated from wslay/wslayver.h.in by
|
||||||
* configure. The projects which do not use autotools can set
|
* configure. The projects which do not use autotools can set
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
########### next target ###############
|
||||||
|
set(HFILES
|
||||||
|
wslay_session_test.h
|
||||||
|
wslay_frame_test.h
|
||||||
|
wslay_event_test.h
|
||||||
|
wslay_queue_test.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(OBJECTS
|
||||||
|
main.c
|
||||||
|
wslay_frame_test.c
|
||||||
|
wslay_event_test.c
|
||||||
|
wslay_queue_test.c
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(main_SRCS ${HFILES} ${OBJECTS})
|
||||||
|
|
||||||
|
if(BUILD_TESTS)
|
||||||
|
|
||||||
|
add_executable(main ${main_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(main wslay cunit)
|
||||||
|
|
||||||
|
endif(BUILD_TESTS)
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Wslay - The WebSocket Library
|
||||||
|
#
|
||||||
|
## Copyright (c) 2011, 2012 Tatsuhiro Tsujikawa
|
||||||
|
#
|
||||||
|
## Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
## a copy of this software and associated documentation files (the
|
||||||
|
## "Software"), to deal in the Software without restriction, including
|
||||||
|
## without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
## distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
## permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
## the following conditions:
|
||||||
|
#
|
||||||
|
## The above copyright notice and this permission notice shall be
|
||||||
|
## included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
## OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
#if HAVE_CUNIT
|
||||||
|
#
|
||||||
|
#check_PROGRAMS = main
|
||||||
|
#
|
||||||
|
#OBJECTS = main.c wslay_frame_test.c\
|
||||||
|
# wslay_event_test.c\
|
||||||
|
# wslay_queue_test.c
|
||||||
|
#
|
||||||
|
#HFILES = wslay_session_test.h wslay_frame_test.h\
|
||||||
|
# wslay_event_test.h\
|
||||||
|
# wslay_queue_test.h
|
||||||
|
#
|
||||||
|
#main_SOURCES = $(HFILES) $(OBJECTS)
|
||||||
|
#
|
||||||
|
#main_LDADD = ${top_builddir}/lib/libwslay.la -lcunit
|
||||||
|
#main_LDFLAGS = -static
|
||||||
|
#AM_CFLAGS = -Wall -g -O2 -I${top_srcdir}/lib -I${top_srcdir}/lib/includes\
|
||||||
|
# @DEFS@
|
||||||
|
## DEFS += -D_ISOC99_SOURCE -D_GNU_SOURCE
|
||||||
|
#TESTS = main
|
||||||
|
#
|
||||||
|
#endif # HAVE_CUNIT
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
add_subdirectory(manual-src)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
install(FILES xmlrpc/aria2mon xmlrpc/aria2rpc xmlrpc/README.txt TYPE DOC)
|
||||||
|
install(FILES bash_completion/README.txt DESTINATION TYPE DOC)
|
||||||
|
install(FILES bash_completion/aria2c DESTINATION TYPE DOC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
#SUBDIRS = manual-src
|
||||||
|
#
|
||||||
|
#doc_xmlrpcdir = $(docdir)/xmlrpc
|
||||||
|
#dist_doc_xmlrpc_DATA = xmlrpc/aria2mon \
|
||||||
|
# xmlrpc/aria2rpc \
|
||||||
|
# xmlrpc/README.txt
|
||||||
|
#
|
||||||
|
#doc_bashcompletiondir = $(docdir)/bash_completion
|
||||||
|
#dist_doc_bashcompletion_DATA = bash_completion/README.txt
|
||||||
|
#
|
||||||
|
#doc_bashcompletionscriptdir = @bashcompletiondir@
|
||||||
|
#dist_doc_bashcompletionscript_DATA = bash_completion/aria2c
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
add_subdirectory(en)
|
||||||
|
add_subdirectory(ru)
|
||||||
|
add_subdirectory(pt)
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
#SUBDIRS = en ru pt
|
|
@ -0,0 +1,161 @@
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Makefile for Sphinx documentation
|
||||||
|
##
|
||||||
|
## You can set these variables from the command line.
|
||||||
|
#SPHINXOPTS =
|
||||||
|
#SPHINXBUILD = sphinx-build
|
||||||
|
#PAPER =
|
||||||
|
#BUILDDIR = _build
|
||||||
|
#
|
||||||
|
## Internal variables.
|
||||||
|
#PAPEROPT_a4 = -D latex_paper_size=a4
|
||||||
|
#PAPEROPT_letter = -D latex_paper_size=letter
|
||||||
|
#ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -c . @srcdir@
|
||||||
|
#
|
||||||
|
## Configurations for aria2.
|
||||||
|
#man_MANS = $(BUILDDIR)/man/aria2c.1
|
||||||
|
#EXTRA_DIST = $(man_MANS) aria2c.rst libaria2.rst index.rst README.rst\
|
||||||
|
# technical-notes.rst mkapiref.py
|
||||||
|
#
|
||||||
|
#if HAVE_SPHINXBUILD
|
||||||
|
#$(man_MANS): aria2c.rst
|
||||||
|
# $(MAKE) man
|
||||||
|
#else
|
||||||
|
#$(man_MANS):
|
||||||
|
# @echo "WARNING: Building only stub man pages. Please install sphinx-build: pip install sphinx"
|
||||||
|
# if [ ! -d "$(@D)" ]; then mkdir -p "$(@D)"; fi;
|
||||||
|
# if [ ! -e "$@" ]; then touch "$@"; fi;
|
||||||
|
#endif
|
||||||
|
#
|
||||||
|
## Autogenerated rules by sphinx-quickstart
|
||||||
|
#
|
||||||
|
#.PHONY: help docclean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
|
||||||
|
#
|
||||||
|
#help:
|
||||||
|
# @echo "Please use \`make <target>' where <target> is one of"
|
||||||
|
# @echo " html to make standalone HTML files"
|
||||||
|
# @echo " dirhtml to make HTML files named index.html in directories"
|
||||||
|
# @echo " singlehtml to make a single large HTML file"
|
||||||
|
# @echo " pickle to make pickle files"
|
||||||
|
# @echo " json to make JSON files"
|
||||||
|
# @echo " htmlhelp to make HTML files and a HTML help project"
|
||||||
|
# @echo " qthelp to make HTML files and a qthelp project"
|
||||||
|
# @echo " devhelp to make HTML files and a Devhelp project"
|
||||||
|
# @echo " epub to make an epub"
|
||||||
|
# @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||||
|
# @echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||||
|
# @echo " text to make text files"
|
||||||
|
# @echo " man to make manual pages"
|
||||||
|
# @echo " changes to make an overview of all changed/added/deprecated items"
|
||||||
|
# @echo " linkcheck to check all external links for integrity"
|
||||||
|
# @echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||||
|
#
|
||||||
|
#$(srcdir)/libaria2api: $(top_builddir)/src/includes/aria2/aria2.h
|
||||||
|
# $(srcdir)/mkapiref.py $^ > $@
|
||||||
|
#
|
||||||
|
#html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest: $(srcdir)/libaria2api
|
||||||
|
#
|
||||||
|
#docclean:
|
||||||
|
# -rm $(srcdir)/libaria2api
|
||||||
|
# -rm -rf $(BUILDDIR)/*
|
||||||
|
#
|
||||||
|
#html:
|
||||||
|
# $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||||
|
#
|
||||||
|
#dirhtml:
|
||||||
|
# $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||||
|
#
|
||||||
|
#singlehtml:
|
||||||
|
# $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||||
|
#
|
||||||
|
#pickle:
|
||||||
|
# $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can process the pickle files."
|
||||||
|
#
|
||||||
|
#json:
|
||||||
|
# $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can process the JSON files."
|
||||||
|
#
|
||||||
|
#htmlhelp:
|
||||||
|
# $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||||
|
# ".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||||
|
#
|
||||||
|
#qthelp:
|
||||||
|
# $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
|
# ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
|
# @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aria2.qhcp"
|
||||||
|
# @echo "To view the help file:"
|
||||||
|
# @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aria2.qhc"
|
||||||
|
#
|
||||||
|
#devhelp:
|
||||||
|
# $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished."
|
||||||
|
# @echo "To view the help file:"
|
||||||
|
# @echo "# mkdir -p $$HOME/.local/share/devhelp/aria2"
|
||||||
|
# @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aria2"
|
||||||
|
# @echo "# devhelp"
|
||||||
|
#
|
||||||
|
#epub:
|
||||||
|
# $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||||
|
#
|
||||||
|
#latex:
|
||||||
|
# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||||
|
# @echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||||
|
# "(use \`make latexpdf' here to do that automatically)."
|
||||||
|
#
|
||||||
|
#latexpdf:
|
||||||
|
# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
# @echo "Running LaTeX files through pdflatex..."
|
||||||
|
# $(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||||
|
# @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||||
|
#
|
||||||
|
#text:
|
||||||
|
# $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||||
|
#
|
||||||
|
#man:
|
||||||
|
# $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||||
|
#
|
||||||
|
#changes:
|
||||||
|
# $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||||
|
# @echo
|
||||||
|
# @echo "The overview file is in $(BUILDDIR)/changes."
|
||||||
|
#
|
||||||
|
#linkcheck:
|
||||||
|
# $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||||
|
# @echo
|
||||||
|
# @echo "Link check complete; look for any errors in the above output " \
|
||||||
|
# "or in $(BUILDDIR)/linkcheck/output.txt."
|
||||||
|
#
|
||||||
|
#doctest:
|
||||||
|
# $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||||
|
# @echo "Testing of doctests in the sources finished, look at the " \
|
||||||
|
# "results in $(BUILDDIR)/doctest/output.txt."
|
|
@ -0,0 +1,155 @@
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Makefile for Sphinx documentation
|
||||||
|
##
|
||||||
|
## You can set these variables from the command line.
|
||||||
|
#SPHINXOPTS =
|
||||||
|
#SPHINXBUILD = sphinx-build
|
||||||
|
#PAPER =
|
||||||
|
#BUILDDIR = _build
|
||||||
|
#
|
||||||
|
## Internal variables.
|
||||||
|
#PAPEROPT_a4 = -D latex_paper_size=a4
|
||||||
|
#PAPEROPT_letter = -D latex_paper_size=letter
|
||||||
|
#ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -c . @srcdir@
|
||||||
|
#
|
||||||
|
## Configurations for aria2.
|
||||||
|
#mandir = @mandir@/pt
|
||||||
|
#man_MANS = $(BUILDDIR)/man/aria2c.1
|
||||||
|
#EXTRA_DIST = $(man_MANS) aria2c.rst index.rst README.rst
|
||||||
|
#
|
||||||
|
#if HAVE_SPHINXBUILD
|
||||||
|
#$(man_MANS): aria2c.rst
|
||||||
|
# $(MAKE) man
|
||||||
|
#else
|
||||||
|
#$(man_MANS):
|
||||||
|
# @echo "WARNING: Building only stub man pages. Please install sphinx-build: pip install sphinx"
|
||||||
|
# if [ ! -d "$(@D)" ]; then mkdir -p "$(@D)"; fi;
|
||||||
|
# if [ ! -e "$@" ]; then touch "$@"; fi;
|
||||||
|
#endif
|
||||||
|
#
|
||||||
|
## Autogenerated rules by sphinx-quickstart
|
||||||
|
#
|
||||||
|
#.PHONY: help docclean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
|
||||||
|
#
|
||||||
|
#help:
|
||||||
|
# @echo "Please use \`make <target>' where <target> is one of"
|
||||||
|
# @echo " html to make standalone HTML files"
|
||||||
|
# @echo " dirhtml to make HTML files named index.html in directories"
|
||||||
|
# @echo " singlehtml to make a single large HTML file"
|
||||||
|
# @echo " pickle to make pickle files"
|
||||||
|
# @echo " json to make JSON files"
|
||||||
|
# @echo " htmlhelp to make HTML files and a HTML help project"
|
||||||
|
# @echo " qthelp to make HTML files and a qthelp project"
|
||||||
|
# @echo " devhelp to make HTML files and a Devhelp project"
|
||||||
|
# @echo " epub to make an epub"
|
||||||
|
# @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||||
|
# @echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||||
|
# @echo " text to make text files"
|
||||||
|
# @echo " man to make manual pages"
|
||||||
|
# @echo " changes to make an overview of all changed/added/deprecated items"
|
||||||
|
# @echo " linkcheck to check all external links for integrity"
|
||||||
|
# @echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||||
|
#
|
||||||
|
#docclean:
|
||||||
|
# -rm -rf $(BUILDDIR)/*
|
||||||
|
#
|
||||||
|
#html:
|
||||||
|
# $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||||
|
#
|
||||||
|
#dirhtml:
|
||||||
|
# $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||||
|
#
|
||||||
|
#singlehtml:
|
||||||
|
# $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||||
|
#
|
||||||
|
#pickle:
|
||||||
|
# $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can process the pickle files."
|
||||||
|
#
|
||||||
|
#json:
|
||||||
|
# $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can process the JSON files."
|
||||||
|
#
|
||||||
|
#htmlhelp:
|
||||||
|
# $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||||
|
# ".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||||
|
#
|
||||||
|
#qthelp:
|
||||||
|
# $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
|
# ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
|
# @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aria2.qhcp"
|
||||||
|
# @echo "To view the help file:"
|
||||||
|
# @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aria2.qhc"
|
||||||
|
#
|
||||||
|
#devhelp:
|
||||||
|
# $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished."
|
||||||
|
# @echo "To view the help file:"
|
||||||
|
# @echo "# mkdir -p $$HOME/.local/share/devhelp/aria2"
|
||||||
|
# @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aria2"
|
||||||
|
# @echo "# devhelp"
|
||||||
|
#
|
||||||
|
#epub:
|
||||||
|
# $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||||
|
#
|
||||||
|
#latex:
|
||||||
|
# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||||
|
# @echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||||
|
# "(use \`make latexpdf' here to do that automatically)."
|
||||||
|
#
|
||||||
|
#latexpdf:
|
||||||
|
# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
# @echo "Running LaTeX files through pdflatex..."
|
||||||
|
# $(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||||
|
# @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||||
|
#
|
||||||
|
#text:
|
||||||
|
# $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||||
|
#
|
||||||
|
#man:
|
||||||
|
# $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||||
|
#
|
||||||
|
#changes:
|
||||||
|
# $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||||
|
# @echo
|
||||||
|
# @echo "The overview file is in $(BUILDDIR)/changes."
|
||||||
|
#
|
||||||
|
#linkcheck:
|
||||||
|
# $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||||
|
# @echo
|
||||||
|
# @echo "Link check complete; look for any errors in the above output " \
|
||||||
|
# "or in $(BUILDDIR)/linkcheck/output.txt."
|
||||||
|
#
|
||||||
|
#doctest:
|
||||||
|
# $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||||
|
# @echo "Testing of doctests in the sources finished, look at the " \
|
||||||
|
# "results in $(BUILDDIR)/doctest/output.txt."
|
|
@ -0,0 +1,156 @@
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
## Makefile for Sphinx documentation
|
||||||
|
##
|
||||||
|
## You can set these variables from the command line.
|
||||||
|
#SPHINXOPTS =
|
||||||
|
#SPHINXBUILD = sphinx-build
|
||||||
|
#PAPER =
|
||||||
|
#BUILDDIR = _build
|
||||||
|
#
|
||||||
|
## Internal variables.
|
||||||
|
#PAPEROPT_a4 = -D latex_paper_size=a4
|
||||||
|
#PAPEROPT_letter = -D latex_paper_size=letter
|
||||||
|
#ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) -c . @srcdir@
|
||||||
|
#
|
||||||
|
## Configurations for aria2.
|
||||||
|
#mandir = @mandir@/ru
|
||||||
|
#man_MANS = $(BUILDDIR)/man/aria2c.1
|
||||||
|
#EXTRA_DIST = $(man_MANS) aria2c.rst index.rst
|
||||||
|
#
|
||||||
|
#if HAVE_SPHINXBUILD
|
||||||
|
#$(man_MANS): aria2c.rst
|
||||||
|
# $(MAKE) man
|
||||||
|
#else
|
||||||
|
#$(man_MANS):
|
||||||
|
# @echo "WARNING: Building only stub man pages. Please install sphinx-build: pip install sphinx"
|
||||||
|
# if [ ! -d "$(@D)" ]; then mkdir -p "$(@D)"; fi;
|
||||||
|
# if [ ! -e "$@" ]; then touch "$@"; fi;
|
||||||
|
#endif
|
||||||
|
#
|
||||||
|
## Autogenerated rules by sphinx-quickstart
|
||||||
|
#
|
||||||
|
#.PHONY: help docclean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
|
||||||
|
#
|
||||||
|
#help:
|
||||||
|
# @echo "Please use \`make <target>' where <target> is one of"
|
||||||
|
# @echo " html to make standalone HTML files"
|
||||||
|
# @echo " dirhtml to make HTML files named index.html in directories"
|
||||||
|
# @echo " singlehtml to make a single large HTML file"
|
||||||
|
# @echo " pickle to make pickle files"
|
||||||
|
# @echo " json to make JSON files"
|
||||||
|
# @echo " htmlhelp to make HTML files and a HTML help project"
|
||||||
|
# @echo " qthelp to make HTML files and a qthelp project"
|
||||||
|
# @echo " devhelp to make HTML files and a Devhelp project"
|
||||||
|
# @echo " epub to make an epub"
|
||||||
|
# @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||||
|
# @echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||||
|
# @echo " text to make text files"
|
||||||
|
# @echo " man to make manual pages"
|
||||||
|
# @echo " changes to make an overview of all changed/added/deprecated items"
|
||||||
|
# @echo " linkcheck to check all external links for integrity"
|
||||||
|
# @echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||||
|
#
|
||||||
|
#docclean:
|
||||||
|
# -rm -rf $(BUILDDIR)/*
|
||||||
|
#
|
||||||
|
#html:
|
||||||
|
# $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||||
|
#
|
||||||
|
#dirhtml:
|
||||||
|
# $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||||
|
#
|
||||||
|
#singlehtml:
|
||||||
|
# $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||||
|
#
|
||||||
|
#pickle:
|
||||||
|
# $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can process the pickle files."
|
||||||
|
#
|
||||||
|
#json:
|
||||||
|
# $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can process the JSON files."
|
||||||
|
#
|
||||||
|
#htmlhelp:
|
||||||
|
# $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||||
|
# ".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||||
|
#
|
||||||
|
#qthelp:
|
||||||
|
# $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
|
# ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
|
# @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aria2.qhcp"
|
||||||
|
# @echo "To view the help file:"
|
||||||
|
# @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aria2.qhc"
|
||||||
|
#
|
||||||
|
#devhelp:
|
||||||
|
# $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished."
|
||||||
|
# @echo "To view the help file:"
|
||||||
|
# @echo "# mkdir -p $$HOME/.local/share/devhelp/aria2"
|
||||||
|
# @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aria2"
|
||||||
|
# @echo "# devhelp"
|
||||||
|
#
|
||||||
|
#epub:
|
||||||
|
# $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||||
|
#
|
||||||
|
#latex:
|
||||||
|
# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||||
|
# @echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||||
|
# "(use \`make latexpdf' here to do that automatically)."
|
||||||
|
#
|
||||||
|
#latexpdf:
|
||||||
|
# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
# @echo "Running LaTeX files through pdflatex..."
|
||||||
|
# $(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||||
|
# @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||||
|
#
|
||||||
|
#text:
|
||||||
|
# $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||||
|
#
|
||||||
|
#man:
|
||||||
|
# $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||||
|
# sed -i -e '1i .\\" -*- mode: troff; coding: utf-8 -*-' $(BUILDDIR)/man/aria2c.1
|
||||||
|
# @echo
|
||||||
|
# @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||||
|
#
|
||||||
|
#changes:
|
||||||
|
# $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||||
|
# @echo
|
||||||
|
# @echo "The overview file is in $(BUILDDIR)/changes."
|
||||||
|
#
|
||||||
|
#linkcheck:
|
||||||
|
# $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||||
|
# @echo
|
||||||
|
# @echo "Link check complete; look for any errors in the above output " \
|
||||||
|
# "or in $(BUILDDIR)/linkcheck/output.txt."
|
||||||
|
#
|
||||||
|
#doctest:
|
||||||
|
# $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||||
|
# @echo "Testing of doctests in the sources finished, look at the " \
|
||||||
|
# "results in $(BUILDDIR)/doctest/output.txt."
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
#EXTRA_DIST = gettext.h
|
|
@ -34,7 +34,9 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "AbstractDiskWriter.h"
|
#include "AbstractDiskWriter.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h>
|
||||||
#endif // HAVE_MMAP
|
#endif // HAVE_MMAP
|
||||||
|
@ -54,12 +56,16 @@
|
||||||
#include "error_code.h"
|
#include "error_code.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# include <winioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
AbstractDiskWriter::AbstractDiskWriter(const std::string& filename)
|
AbstractDiskWriter::AbstractDiskWriter(const std::string& filename)
|
||||||
: filename_(filename),
|
: filename_(filename),
|
||||||
fd_(A2_BAD_FD),
|
fd_(A2_BAD_FD),
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
mapView_(0),
|
mapView_(0),
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
@ -78,7 +84,7 @@ namespace {
|
||||||
// the value of GetLastError(). Otherwise, return errno.
|
// the value of GetLastError(). Otherwise, return errno.
|
||||||
int fileError()
|
int fileError()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
return errno;
|
return errno;
|
||||||
|
@ -92,7 +98,7 @@ namespace {
|
||||||
// errno.
|
// errno.
|
||||||
std::string fileStrerror(int errNum)
|
std::string fileStrerror(int errNum)
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
auto msg = util::formatLastError(errNum);
|
auto msg = util::formatLastError(errNum);
|
||||||
if (msg.empty()) {
|
if (msg.empty()) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -113,7 +119,7 @@ void AbstractDiskWriter::openFile(int64_t totalLength)
|
||||||
}
|
}
|
||||||
catch (RecoverableException& e) {
|
catch (RecoverableException& e) {
|
||||||
if (
|
if (
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
e.getErrNum() == ERROR_FILE_NOT_FOUND ||
|
e.getErrNum() == ERROR_FILE_NOT_FOUND ||
|
||||||
e.getErrNum() == ERROR_PATH_NOT_FOUND
|
e.getErrNum() == ERROR_PATH_NOT_FOUND
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
|
@ -133,7 +139,7 @@ void AbstractDiskWriter::closeFile()
|
||||||
#if defined(HAVE_MMAP) || defined(__MINGW32__)
|
#if defined(HAVE_MMAP) || defined(__MINGW32__)
|
||||||
if (mapaddr_) {
|
if (mapaddr_) {
|
||||||
int errNum = 0;
|
int errNum = 0;
|
||||||
# ifdef __MINGW32__
|
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
if (!UnmapViewOfFile(mapaddr_)) {
|
if (!UnmapViewOfFile(mapaddr_)) {
|
||||||
errNum = GetLastError();
|
errNum = GetLastError();
|
||||||
}
|
}
|
||||||
|
@ -157,17 +163,17 @@ void AbstractDiskWriter::closeFile()
|
||||||
}
|
}
|
||||||
#endif // HAVE_MMAP || defined __MINGW32__
|
#endif // HAVE_MMAP || defined __MINGW32__
|
||||||
if (fd_ != A2_BAD_FD) {
|
if (fd_ != A2_BAD_FD) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
CloseHandle(fd_);
|
CloseHandle(fd_);
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
close(fd_);
|
a2_close(fd_);
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
fd_ = A2_BAD_FD;
|
fd_ = A2_BAD_FD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
HANDLE openFileWithFlags(const std::string& filename, int flags,
|
HANDLE openFileWithFlags(const std::string& filename, int flags,
|
||||||
error_code::Value errCode)
|
error_code::Value errCode)
|
||||||
{
|
{
|
||||||
|
@ -265,7 +271,7 @@ ssize_t AbstractDiskWriter::writeDataInternal(const unsigned char* data,
|
||||||
ssize_t writtenLength = 0;
|
ssize_t writtenLength = 0;
|
||||||
seek(offset);
|
seek(offset);
|
||||||
while ((size_t)writtenLength < len) {
|
while ((size_t)writtenLength < len) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
DWORD nwrite;
|
DWORD nwrite;
|
||||||
if (WriteFile(fd_, data + writtenLength, len - writtenLength, &nwrite,
|
if (WriteFile(fd_, data + writtenLength, len - writtenLength, &nwrite,
|
||||||
0)) {
|
0)) {
|
||||||
|
@ -303,7 +309,7 @@ ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
seek(offset);
|
seek(offset);
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
DWORD nread;
|
DWORD nread;
|
||||||
if (ReadFile(fd_, data, len, &nread, 0)) {
|
if (ReadFile(fd_, data, len, &nread, 0)) {
|
||||||
return nread;
|
return nread;
|
||||||
|
@ -313,7 +319,7 @@ ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len,
|
||||||
}
|
}
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
ssize_t ret = 0;
|
ssize_t ret = 0;
|
||||||
while ((ret = read(fd_, data, len)) == -1 && errno == EINTR)
|
while ((ret = a2_read(fd_, data, len)) == -1 && errno == EINTR)
|
||||||
;
|
;
|
||||||
return ret;
|
return ret;
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
@ -323,7 +329,7 @@ ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len,
|
||||||
void AbstractDiskWriter::seek(int64_t offset)
|
void AbstractDiskWriter::seek(int64_t offset)
|
||||||
{
|
{
|
||||||
assert(offset >= 0);
|
assert(offset >= 0);
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
LARGE_INTEGER fileLength;
|
LARGE_INTEGER fileLength;
|
||||||
fileLength.QuadPart = offset;
|
fileLength.QuadPart = offset;
|
||||||
if (SetFilePointerEx(fd_, fileLength, 0, FILE_BEGIN) == 0)
|
if (SetFilePointerEx(fd_, fileLength, 0, FILE_BEGIN) == 0)
|
||||||
|
@ -345,7 +351,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
|
||||||
if (mapaddr_) {
|
if (mapaddr_) {
|
||||||
if (static_cast<int64_t>(len + offset) > maplen_) {
|
if (static_cast<int64_t>(len + offset) > maplen_) {
|
||||||
int errNum = 0;
|
int errNum = 0;
|
||||||
# ifdef __MINGW32__
|
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
if (!UnmapViewOfFile(mapaddr_)) {
|
if (!UnmapViewOfFile(mapaddr_)) {
|
||||||
errNum = GetLastError();
|
errNum = GetLastError();
|
||||||
}
|
}
|
||||||
|
@ -385,7 +391,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
|
||||||
|
|
||||||
int errNum = 0;
|
int errNum = 0;
|
||||||
if (static_cast<int64_t>(len + offset) <= filesize) {
|
if (static_cast<int64_t>(len + offset) <= filesize) {
|
||||||
# ifdef __MINGW32__
|
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
mapView_ = CreateFileMapping(fd_, 0, PAGE_READWRITE, filesize >> 32,
|
mapView_ = CreateFileMapping(fd_, 0, PAGE_READWRITE, filesize >> 32,
|
||||||
filesize & 0xffffffffu, 0);
|
filesize & 0xffffffffu, 0);
|
||||||
if (mapView_) {
|
if (mapView_) {
|
||||||
|
@ -432,7 +438,7 @@ namespace {
|
||||||
bool isDiskFullError(int errNum)
|
bool isDiskFullError(int errNum)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
errNum == ERROR_DISK_FULL || errNum == ERROR_HANDLE_DISK_FULL
|
errNum == ERROR_DISK_FULL || errNum == ERROR_HANDLE_DISK_FULL
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
errNum == ENOSPC
|
errNum == ENOSPC
|
||||||
|
@ -483,7 +489,7 @@ void AbstractDiskWriter::truncate(int64_t length)
|
||||||
if (fd_ == A2_BAD_FD) {
|
if (fd_ == A2_BAD_FD) {
|
||||||
throw DL_ABORT_EX("File not yet opened.");
|
throw DL_ABORT_EX("File not yet opened.");
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// Since mingw32's ftruncate cannot handle over 2GB files, we use
|
// Since mingw32's ftruncate cannot handle over 2GB files, we use
|
||||||
// SetEndOfFile instead.
|
// SetEndOfFile instead.
|
||||||
seek(length);
|
seek(length);
|
||||||
|
@ -505,7 +511,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
||||||
throw DL_ABORT_EX("File not yet opened.");
|
throw DL_ABORT_EX("File not yet opened.");
|
||||||
}
|
}
|
||||||
if (sparse) {
|
if (sparse) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
DWORD bytesReturned;
|
DWORD bytesReturned;
|
||||||
if (!DeviceIoControl(fd_, FSCTL_SET_SPARSE, 0, 0, 0, 0, &bytesReturned,
|
if (!DeviceIoControl(fd_, FSCTL_SET_SPARSE, 0, 0, 0, 0, &bytesReturned,
|
||||||
0)) {
|
0)) {
|
||||||
|
@ -517,7 +523,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SOME_FALLOCATE
|
#ifdef HAVE_SOME_FALLOCATE
|
||||||
# ifdef __MINGW32__
|
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
truncate(offset + length);
|
truncate(offset + length);
|
||||||
if (!SetFileValidData(fd_, offset + length)) {
|
if (!SetFileValidData(fd_, offset + length)) {
|
||||||
auto errNum = fileError();
|
auto errNum = fileError();
|
||||||
|
@ -595,7 +601,7 @@ void AbstractDiskWriter::flushOSBuffers()
|
||||||
if (fd_ == A2_BAD_FD) {
|
if (fd_ == A2_BAD_FD) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
FlushFileBuffers(fd_);
|
FlushFileBuffers(fd_);
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
fsync(fd_);
|
fsync(fd_);
|
||||||
|
|
|
@ -44,7 +44,7 @@ class AbstractDiskWriter : public DiskWriter {
|
||||||
private:
|
private:
|
||||||
std::string filename_;
|
std::string filename_;
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
HANDLE fd_;
|
HANDLE fd_;
|
||||||
// The handle for memory mapped file. mmap equivalent in Windows.
|
// The handle for memory mapped file. mmap equivalent in Windows.
|
||||||
HANDLE mapView_;
|
HANDLE mapView_;
|
||||||
|
|
|
@ -694,7 +694,7 @@ OSStatus AppleTLSSession::sockRead(void* data, size_t* len)
|
||||||
uint8_t* buffer = static_cast<uint8_t*>(data);
|
uint8_t* buffer = static_cast<uint8_t*>(data);
|
||||||
*len = 0;
|
*len = 0;
|
||||||
while (remain) {
|
while (remain) {
|
||||||
ssize_t r = read(sockfd_, buffer, remain);
|
ssize_t r = a2_read(sockfd_, buffer, remain);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
return errSSLClosedGraceful;
|
return errSSLClosedGraceful;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ void BtFileAllocationEntry::prepareForNextAction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
if (!diskAdaptor->isReadOnlyEnabled()) {
|
if (!diskAdaptor->isReadOnlyEnabled()) {
|
||||||
// On Windows, if aria2 opens files with GENERIC_WRITE access
|
// On Windows, if aria2 opens files with GENERIC_WRITE access
|
||||||
// right, some programs cannot open them aria2 is seeding. To
|
// right, some programs cannot open them aria2 is seeding. To
|
||||||
|
|
|
@ -47,18 +47,18 @@ BufferedFile::BufferedFile(const char* filename, const char* mode)
|
||||||
: fp_(strcmp(DEV_STDIN, filename) == 0
|
: fp_(strcmp(DEV_STDIN, filename) == 0
|
||||||
? stdin
|
? stdin
|
||||||
:
|
:
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
|
a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
a2fopen(filename, mode)
|
a2fopen(filename, mode)
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
),
|
),
|
||||||
supportsColor_(fp_ ? isatty(fileno(fp_)) : false)
|
supportsColor_(fp_ ? a2_isatty(a2_fileno(fp_)) : false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedFile::BufferedFile(FILE* fp)
|
BufferedFile::BufferedFile(FILE* fp)
|
||||||
: fp_(fp), supportsColor_(fp_ ? isatty(fileno(fp_)) : false)
|
: fp_(fp), supportsColor_(fp_ ? a2_isatty(a2_fileno(fp_)) : false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ int BufferedFile::onClose()
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
if (fp_) {
|
if (fp_) {
|
||||||
fflush(fp_);
|
fflush(fp_);
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
fsync(fileno(fp_));
|
fsync(a2_fileno(fp_));
|
||||||
#else // __MINGW32__
|
#else // __MINGW32__
|
||||||
_commit(fileno(fp_));
|
_commit(a2_fileno(fp_));
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
if (fp_ != stdin && fp_ != stderr) {
|
if (fp_ != stdin && fp_ != stderr) {
|
||||||
rv = fclose(fp_);
|
rv = fclose(fp_);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,7 +40,9 @@
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
# include <sys/ioctl.h>
|
# include <sys/ioctl.h>
|
||||||
#endif // HAVE_SYS_IOCTL_H
|
#endif // HAVE_SYS_IOCTL_H
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
@ -272,10 +274,10 @@ ConsoleStatCalc::ConsoleStatCalc(std::chrono::seconds summaryInterval,
|
||||||
: summaryInterval_(std::move(summaryInterval)),
|
: summaryInterval_(std::move(summaryInterval)),
|
||||||
readoutVisibility_(true),
|
readoutVisibility_(true),
|
||||||
truncate_(true),
|
truncate_(true),
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
isTTY_(true),
|
isTTY_(true),
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
isTTY_(isatty(STDOUT_FILENO) == 1),
|
isTTY_(a2_isatty(STDOUT_FILENO) == 1),
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
colorOutput_(colorOutput)
|
colorOutput_(colorOutput)
|
||||||
{
|
{
|
||||||
|
@ -301,20 +303,20 @@ void ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
unsigned short int cols = 79;
|
unsigned short int cols = 79;
|
||||||
|
|
||||||
if (isTTY_) {
|
if (isTTY_) {
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
# ifdef HAVE_TERMIOS_H
|
# ifdef HAVE_TERMIOS_H
|
||||||
struct winsize size;
|
struct winsize size;
|
||||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
||||||
cols = std::max(0, (int)size.ws_col - 1);
|
cols = std::max(0, (int)size.ws_col - 1);
|
||||||
}
|
}
|
||||||
# endif // HAVE_TERMIOS_H
|
# endif // HAVE_TERMIOS_H
|
||||||
#else // __MINGW32__
|
#else // __MINGW32__ || _MSC_VER
|
||||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||||
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),
|
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
&info)) {
|
&info)) {
|
||||||
cols = std::max(0, info.dwSize.X - 2);
|
cols = std::max(0, info.dwSize.X - 2);
|
||||||
}
|
}
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__ && !_MSC_VER
|
||||||
std::string line(cols, ' ');
|
std::string line(cols, ' ');
|
||||||
global::cout()->printf("\r%s\r", line.c_str());
|
global::cout()->printf("\r%s\r", line.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,12 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "Context.h"
|
#include "Context.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
# include <sys/resource.h>
|
# include <sys/resource.h>
|
||||||
#endif // HAVE_SYS_RESOURCE_H
|
#endif // HAVE_SYS_RESOURCE_H
|
||||||
|
|
|
@ -485,7 +485,7 @@ void DefaultPieceStorage::completePiece(const std::shared_ptr<Piece>& piece)
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
if (downloadContext_->hasAttribute(CTX_ATTR_BT)) {
|
if (downloadContext_->hasAttribute(CTX_ATTR_BT)) {
|
||||||
if (!bittorrent::getTorrentAttrs(downloadContext_)->metadata.empty()) {
|
if (!bittorrent::getTorrentAttrs(downloadContext_)->metadata.empty()) {
|
||||||
# ifdef __MINGW32__
|
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// On Windows, if aria2 opens files with GENERIC_WRITE access
|
// On Windows, if aria2 opens files with GENERIC_WRITE access
|
||||||
// right, some programs cannot open them aria2 is seeding. To
|
// right, some programs cannot open them aria2 is seeding. To
|
||||||
// avoid this situation, re-open the files with read-only
|
// avoid this situation, re-open the files with read-only
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "AbstractCommand.h"
|
#include "AbstractCommand.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ EpollEventPoll::EpollEventPoll()
|
||||||
EpollEventPoll::~EpollEventPoll()
|
EpollEventPoll::~EpollEventPoll()
|
||||||
{
|
{
|
||||||
if (epfd_ != -1) {
|
if (epfd_ != -1) {
|
||||||
int r = close(epfd_);
|
int r = a2_close(epfd_);
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
A2_LOG_ERROR(fmt("Error occurred while closing epoll file descriptor"
|
A2_LOG_ERROR(fmt("Error occurred while closing epoll file descriptor"
|
||||||
|
|
|
@ -273,7 +273,7 @@ std::string usedCompilerAndPlatform()
|
||||||
|
|
||||||
#elif defined(__GNUG__)
|
#elif defined(__GNUG__)
|
||||||
|
|
||||||
# ifdef __MINGW32__
|
# if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
rv << "mingw ";
|
rv << "mingw ";
|
||||||
# ifdef __MINGW32_MAJOR_VERSION
|
# ifdef __MINGW32_MAJOR_VERSION
|
||||||
rv << (int)__MINGW32_MAJOR_VERSION;
|
rv << (int)__MINGW32_MAJOR_VERSION;
|
||||||
|
|
27
src/File.cc
27
src/File.cc
|
@ -39,7 +39,9 @@
|
||||||
#ifdef HAVE_UTIME_H
|
#ifdef HAVE_UTIME_H
|
||||||
# include <utime.h>
|
# include <utime.h>
|
||||||
#endif // HAVE_UTIME_H
|
#endif // HAVE_UTIME_H
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -52,6 +54,15 @@
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# if !defined(S_ISREG) && defined(_S_IFMT) && defined(_S_IFREG)
|
||||||
|
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||||
|
# endif
|
||||||
|
# if !defined(S_ISDIR) && defined(_S_IFMT) && defined(_S_IFDIR)
|
||||||
|
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
File::File(const std::string& name) : name_(name) {}
|
File::File(const std::string& name) : name_(name) {}
|
||||||
|
@ -120,7 +131,7 @@ bool File::remove()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
namespace {
|
namespace {
|
||||||
HANDLE openFile(const std::string& filename, bool readOnly = true)
|
HANDLE openFile(const std::string& filename, bool readOnly = true)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +147,7 @@ HANDLE openFile(const std::string& filename, bool readOnly = true)
|
||||||
|
|
||||||
int64_t File::size()
|
int64_t File::size()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// _wstat cannot be used for symlink. It always returns 0. Quoted
|
// _wstat cannot be used for symlink. It always returns 0. Quoted
|
||||||
// from https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx:
|
// from https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx:
|
||||||
//
|
//
|
||||||
|
@ -165,7 +176,7 @@ bool File::mkdirs()
|
||||||
if (isDir()) {
|
if (isDir()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
std::string path = name_;
|
std::string path = name_;
|
||||||
for (std::string::iterator i = path.begin(), eoi = path.end(); i != eoi;
|
for (std::string::iterator i = path.begin(), eoi = path.end(); i != eoi;
|
||||||
++i) {
|
++i) {
|
||||||
|
@ -224,7 +235,7 @@ bool File::mkdirs()
|
||||||
if (i != end) {
|
if (i != end) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
if (*(j - 1) == ':') {
|
if (*(j - 1) == ':') {
|
||||||
// This is a drive letter, e.g. C:, so skip it.
|
// This is a drive letter, e.g. C:, so skip it.
|
||||||
continue;
|
continue;
|
||||||
|
@ -289,7 +300,7 @@ bool File::isDir(const std::string& filename) { return File(filename).isDir(); }
|
||||||
|
|
||||||
bool File::renameTo(const std::string& dest)
|
bool File::renameTo(const std::string& dest)
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// MinGW's rename() doesn't delete an existing destination. Better
|
// MinGW's rename() doesn't delete an existing destination. Better
|
||||||
// to use MoveFileEx, which usually provides atomic move in aria2
|
// to use MoveFileEx, which usually provides atomic move in aria2
|
||||||
// usecase.
|
// usecase.
|
||||||
|
@ -374,7 +385,7 @@ Time File::getModifiedTime()
|
||||||
|
|
||||||
std::string File::getCurrentDir()
|
std::string File::getCurrentDir()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
const size_t buflen = 2048;
|
const size_t buflen = 2048;
|
||||||
wchar_t buf[buflen];
|
wchar_t buf[buflen];
|
||||||
if (_wgetcwd(buf, buflen)) {
|
if (_wgetcwd(buf, buflen)) {
|
||||||
|
@ -397,7 +408,7 @@ std::string File::getCurrentDir()
|
||||||
|
|
||||||
const char* File::getPathSeparators()
|
const char* File::getPathSeparators()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
return "/\\";
|
return "/\\";
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
return "/";
|
return "/";
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ int FtpConnection::receiveResponse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define LONGLONG_PRINTF "%I64d"
|
# define LONGLONG_PRINTF "%I64d"
|
||||||
# define ULONGLONG_PRINTF "%I64u"
|
# define ULONGLONG_PRINTF "%I64u"
|
||||||
# define LONGLONG_SCANF "%I64d"
|
# define LONGLONG_SCANF "%I64d"
|
||||||
|
|
|
@ -50,14 +50,14 @@ GZipFile::GZipFile(const char* filename, const char* mode)
|
||||||
strcmp(DEV_STDIN, filename) == 0
|
strcmp(DEV_STDIN, filename) == 0
|
||||||
? stdin
|
? stdin
|
||||||
:
|
:
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
|
a2fopen(utf8ToWChar(filename).c_str(), utf8ToWChar(mode).c_str())
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
a2fopen(filename, mode)
|
a2fopen(filename, mode)
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
;
|
;
|
||||||
if (fp) {
|
if (fp) {
|
||||||
int fd = dup(fileno(fp));
|
int fd = a2_dup(a2_fileno(fp));
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
fp_ = gzdopen(fd, mode);
|
fp_ = gzdopen(fd, mode);
|
||||||
if (fp_) {
|
if (fp_) {
|
||||||
|
@ -70,7 +70,7 @@ GZipFile::GZipFile(const char* filename, const char* mode)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
::close(fd);
|
::a2_close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
|
@ -101,11 +101,11 @@ typename Parser::ResultType parseFile(Parser& parser,
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return Parser::ParserStateMachineType::noResult();
|
return Parser::ParserStateMachineType::noResult();
|
||||||
}
|
}
|
||||||
auto fdclose = defer(fd, close);
|
auto fdclose = defer(fd, a2_close);
|
||||||
std::array<char, 4_k> buf;
|
std::array<char, 4_k> buf;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
ssize_t nproc;
|
ssize_t nproc;
|
||||||
while ((nread = read(fd, buf.data(), buf.size())) > 0) {
|
while ((nread = a2_read(fd, buf.data(), buf.size())) > 0) {
|
||||||
nproc = parser.parseUpdate(buf.data(), nread);
|
nproc = parser.parseUpdate(buf.data(), nread);
|
||||||
if (nproc < 0) {
|
if (nproc < 0) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -68,10 +68,18 @@ void DHKeyExchange::init(const unsigned char* prime, size_t primeBits,
|
||||||
generator_ = n(gen.c_str(), gen.length());
|
generator_ = n(gen.c_str(), gen.length());
|
||||||
|
|
||||||
size_t pbytes = (privateKeyBits + 7) / 8;
|
size_t pbytes = (privateKeyBits + 7) / 8;
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
// MSVC will not compile dynamic arrays
|
||||||
|
unsigned char* buf = new unsigned char[pbytes];
|
||||||
|
#else
|
||||||
unsigned char buf[pbytes];
|
unsigned char buf[pbytes];
|
||||||
|
#endif
|
||||||
util::generateRandomData(buf, pbytes);
|
util::generateRandomData(buf, pbytes);
|
||||||
privateKey_ = n(reinterpret_cast<char*>(buf), pbytes);
|
privateKey_ = n(reinterpret_cast<char*>(buf), pbytes);
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
// clean up memory
|
||||||
|
delete[] buf;
|
||||||
|
#endif
|
||||||
keyLength_ = (primeBits + 7) / 8;
|
keyLength_ = (primeBits + 7) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ KqueueEventPoll::KqueueEventPoll()
|
||||||
KqueueEventPoll::~KqueueEventPoll()
|
KqueueEventPoll::~KqueueEventPoll()
|
||||||
{
|
{
|
||||||
if (kqfd_ != -1) {
|
if (kqfd_ != -1) {
|
||||||
int r = close(kqfd_);
|
int r = a2_close(kqfd_);
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
A2_LOG_ERROR(fmt("Error occurred while closing kqueue file descriptor"
|
A2_LOG_ERROR(fmt("Error occurred while closing kqueue file descriptor"
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# ifdef _WIN32_WINNT
|
# ifdef _WIN32_WINNT
|
||||||
# undef _WIN32_WINNT
|
# undef _WIN32_WINNT
|
||||||
# endif // _WIN32_WINNT
|
# endif // _WIN32_WINNT
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
@ -59,7 +59,7 @@ bool LpdMessageReceiver::init(const std::string& localAddr)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
socket_ = std::make_shared<SocketCore>(SOCK_DGRAM);
|
socket_ = std::make_shared<SocketCore>(SOCK_DGRAM);
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// Binding multicast address fails under Windows.
|
// Binding multicast address fails under Windows.
|
||||||
socket_->bindWithFamily(multicastPort_, AF_INET);
|
socket_->bindWithFamily(multicastPort_, AF_INET);
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
|
|
|
@ -231,7 +231,7 @@ int MultiUrlRequestInfo::prepare()
|
||||||
auto authConfigFactory = make_unique<AuthConfigFactory>();
|
auto authConfigFactory = make_unique<AuthConfigFactory>();
|
||||||
File netrccf(option_->get(PREF_NETRC_PATH));
|
File netrccf(option_->get(PREF_NETRC_PATH));
|
||||||
if (!option_->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) {
|
if (!option_->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// Windows OS does not have permission, so set it to 0.
|
// Windows OS does not have permission, so set it to 0.
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "OptionParser.h"
|
#include "OptionParser.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -196,7 +198,7 @@ void OptionParser::parseArg(std::ostream& out,
|
||||||
// option is ambiguous.
|
// option is ambiguous.
|
||||||
int ambiguous = 0;
|
int ambiguous = 0;
|
||||||
for (int i = 1, len = option::countOption(); i < len; ++i) {
|
for (int i = 1, len = option::countOption(); i < len; ++i) {
|
||||||
PrefPtr pref = option::i2p(i);
|
PrefPtr pref = aria2::option::i2p(i);
|
||||||
const OptionHandler* h = find(pref);
|
const OptionHandler* h = find(pref);
|
||||||
if (h && !h->isHidden()) {
|
if (h && !h->isHidden()) {
|
||||||
if (strcmp(pref->k, optstr) == 0) {
|
if (strcmp(pref->k, optstr) == 0) {
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "SocketBuffer.h"
|
#include "SocketBuffer.h"
|
||||||
|
|
|
@ -182,7 +182,7 @@ bool Platform::setUp()
|
||||||
}
|
}
|
||||||
#endif // HAVE_WINSOCK2_H
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
(void)_setmode(_fileno(stdin), _O_BINARY);
|
(void)_setmode(_fileno(stdin), _O_BINARY);
|
||||||
(void)_setmode(_fileno(stdout), _O_BINARY);
|
(void)_setmode(_fileno(stdout), _O_BINARY);
|
||||||
(void)_setmode(_fileno(stderr), _O_BINARY);
|
(void)_setmode(_fileno(stderr), _O_BINARY);
|
||||||
|
|
|
@ -85,7 +85,7 @@ PortEventPoll::PortEventPoll()
|
||||||
PortEventPoll::~PortEventPoll()
|
PortEventPoll::~PortEventPoll()
|
||||||
{
|
{
|
||||||
if (port_ != -1) {
|
if (port_ != -1) {
|
||||||
int r = close(port_);
|
int r = a2_sclose(port_);
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
A2_LOG_ERROR(fmt("Error occurred while closing port %d: %s", port_,
|
A2_LOG_ERROR(fmt("Error occurred while closing port %d: %s", port_,
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) // for std::back_inserter
|
||||||
|
# include <iterator>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ReceiverMSEHandshakeCommand.h"
|
#include "ReceiverMSEHandshakeCommand.h"
|
||||||
#include "PeerReceiveHandshakeCommand.h"
|
#include "PeerReceiveHandshakeCommand.h"
|
||||||
#include "PeerConnection.h"
|
#include "PeerConnection.h"
|
||||||
|
|
|
@ -619,7 +619,7 @@ void RequestGroup::initPieceStorage()
|
||||||
std::make_shared<SegmentMan>(downloadContext_, tempPieceStorage);
|
std::make_shared<SegmentMan>(downloadContext_, tempPieceStorage);
|
||||||
pieceStorage_ = tempPieceStorage;
|
pieceStorage_ = tempPieceStorage;
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// Windows build: --file-allocation=falloc uses SetFileValidData
|
// Windows build: --file-allocation=falloc uses SetFileValidData
|
||||||
// which requires SE_MANAGE_VOLUME_NAME privilege. SetFileValidData
|
// which requires SE_MANAGE_VOLUME_NAME privilege. SetFileValidData
|
||||||
// has security implications (see
|
// has security implications (see
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -41,6 +41,10 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) // for std::back_inserter
|
||||||
|
# include <iterator>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "RpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
#include "ValueBase.h"
|
#include "ValueBase.h"
|
||||||
#include "TorrentAttribute.h"
|
#include "TorrentAttribute.h"
|
||||||
|
|
|
@ -145,6 +145,7 @@ ssize_t SSHSession::writeData(const void* data, size_t len)
|
||||||
{
|
{
|
||||||
// net implemented yet
|
// net implemented yet
|
||||||
assert(0);
|
assert(0);
|
||||||
|
return 0; // MSVC needs a return value even if it's unreached
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t SSHSession::readData(void* data, size_t len)
|
ssize_t SSHSession::readData(void* data, size_t len)
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "SelectEventPoll.h"
|
#include "SelectEventPoll.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -153,7 +153,7 @@ void SelectEventPoll::AsyncNameResolverEntry::process(fd_set* rfdsPtr,
|
||||||
|
|
||||||
SelectEventPoll::SelectEventPoll()
|
SelectEventPoll::SelectEventPoll()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
dummySocket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
dummySocket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
assert(dummySocket_ != (sock_t)-1);
|
assert(dummySocket_ != (sock_t)-1);
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
@ -162,7 +162,7 @@ SelectEventPoll::SelectEventPoll()
|
||||||
|
|
||||||
SelectEventPoll::~SelectEventPoll()
|
SelectEventPoll::~SelectEventPoll()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
::closesocket(dummySocket_);
|
::closesocket(dummySocket_);
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
memcpy(&rfds, &rfdset_, sizeof(fd_set));
|
memcpy(&rfds, &rfdset_, sizeof(fd_set));
|
||||||
memcpy(&wfds, &wfdset_, sizeof(fd_set));
|
memcpy(&wfds, &wfdset_, sizeof(fd_set));
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
fd_set efds;
|
fd_set efds;
|
||||||
memcpy(&efds, &wfdset_, sizeof(fd_set));
|
memcpy(&efds, &wfdset_, sizeof(fd_set));
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
@ -195,7 +195,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
int retval;
|
int retval;
|
||||||
do {
|
do {
|
||||||
struct timeval ttv = tv;
|
struct timeval ttv = tv;
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// winsock will report non-blocking connect() errors in efds,
|
// winsock will report non-blocking connect() errors in efds,
|
||||||
// unlike posix, which will mark such sockets as writable.
|
// unlike posix, which will mark such sockets as writable.
|
||||||
retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv);
|
retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv);
|
||||||
|
@ -213,7 +213,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
if (FD_ISSET(e.getSocket(), &wfds)) {
|
if (FD_ISSET(e.getSocket(), &wfds)) {
|
||||||
events |= EventPoll::EVENT_WRITE;
|
events |= EventPoll::EVENT_WRITE;
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
if (FD_ISSET(e.getSocket(), &efds)) {
|
if (FD_ISSET(e.getSocket(), &efds)) {
|
||||||
events |= EventPoll::EVENT_ERROR;
|
events |= EventPoll::EVENT_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
namespace {
|
namespace {
|
||||||
void checkFdCountMingw(const fd_set& fdset)
|
void checkFdCountMingw(const fd_set& fdset)
|
||||||
{
|
{
|
||||||
|
@ -251,7 +251,7 @@ void SelectEventPoll::updateFdSet()
|
||||||
{
|
{
|
||||||
FD_ZERO(&rfdset_);
|
FD_ZERO(&rfdset_);
|
||||||
FD_ZERO(&wfdset_);
|
FD_ZERO(&wfdset_);
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
FD_SET(dummySocket_, &rfdset_);
|
FD_SET(dummySocket_, &rfdset_);
|
||||||
FD_SET(dummySocket_, &wfdset_);
|
FD_SET(dummySocket_, &wfdset_);
|
||||||
fdmax_ = dummySocket_;
|
fdmax_ = dummySocket_;
|
||||||
|
@ -262,22 +262,22 @@ void SelectEventPoll::updateFdSet()
|
||||||
for (auto& i : socketEntries_) {
|
for (auto& i : socketEntries_) {
|
||||||
auto& e = i.second;
|
auto& e = i.second;
|
||||||
sock_t fd = e.getSocket();
|
sock_t fd = e.getSocket();
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
if (fd < 0 || FD_SETSIZE <= fd) {
|
if (fd < 0 || FD_SETSIZE <= fd) {
|
||||||
A2_LOG_WARN("Detected file descriptor >= FD_SETSIZE or < 0. "
|
A2_LOG_WARN("Detected file descriptor >= FD_SETSIZE or < 0. "
|
||||||
"Download may slow down or fail.");
|
"Download may slow down or fail.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__ && !_MSC_VER
|
||||||
int events = e.getEvents();
|
int events = e.getEvents();
|
||||||
if (events & EventPoll::EVENT_READ) {
|
if (events & EventPoll::EVENT_READ) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
checkFdCountMingw(rfdset_);
|
checkFdCountMingw(rfdset_);
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
FD_SET(fd, &rfdset_);
|
FD_SET(fd, &rfdset_);
|
||||||
}
|
}
|
||||||
if (events & EventPoll::EVENT_WRITE) {
|
if (events & EventPoll::EVENT_WRITE) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
checkFdCountMingw(wfdset_);
|
checkFdCountMingw(wfdset_);
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
FD_SET(fd, &wfdset_);
|
FD_SET(fd, &wfdset_);
|
||||||
|
|
|
@ -151,7 +151,7 @@ private:
|
||||||
fd_set rfdset_;
|
fd_set rfdset_;
|
||||||
fd_set wfdset_;
|
fd_set wfdset_;
|
||||||
sock_t fdmax_;
|
sock_t fdmax_;
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// Winsock select() doesn't work if no socket is in FD_SET. We add
|
// Winsock select() doesn't work if no socket is in FD_SET. We add
|
||||||
// this dummy socket to work around this problem
|
// this dummy socket to work around this problem
|
||||||
sock_t dummySocket_;
|
sock_t dummySocket_;
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -74,7 +76,7 @@ namespace {
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
SimpleRandomizer::SimpleRandomizer()
|
SimpleRandomizer::SimpleRandomizer()
|
||||||
{
|
{
|
||||||
BOOL r = ::CryptAcquireContext(&provider_, 0, 0, PROV_RSA_FULL,
|
BOOL r = ::CryptAcquireContext(&provider_, 0, 0, PROV_RSA_FULL,
|
||||||
|
@ -87,7 +89,7 @@ SimpleRandomizer::SimpleRandomizer() : gen_(rd()) {}
|
||||||
|
|
||||||
SimpleRandomizer::~SimpleRandomizer()
|
SimpleRandomizer::~SimpleRandomizer()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
CryptReleaseContext(provider_, 0);
|
CryptReleaseContext(provider_, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -100,7 +102,7 @@ long int SimpleRandomizer::getRandomNumber(long int to)
|
||||||
|
|
||||||
void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
|
void SimpleRandomizer::getRandomBytes(unsigned char* buf, size_t len)
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
BOOL r = CryptGenRandom(provider_, len, reinterpret_cast<BYTE*>(buf));
|
BOOL r = CryptGenRandom(provider_, len, reinterpret_cast<BYTE*>(buf));
|
||||||
if (!r) {
|
if (!r) {
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# include <wincrypt.h>
|
# include <wincrypt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
SimpleRandomizer();
|
SimpleRandomizer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
HCRYPTPROV provider_;
|
HCRYPTPROV provider_;
|
||||||
#else
|
#else
|
||||||
std::mt19937 gen_;
|
std::mt19937 gen_;
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
# include <iphlpapi.h>
|
# include <iphlpapi.h>
|
||||||
#endif // HAVE_IPHLPAPI_H
|
#endif // HAVE_IPHLPAPI_H
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_IFADDRS_H
|
#ifdef HAVE_IFADDRS_H
|
||||||
# include <ifaddrs.h>
|
# include <ifaddrs.h>
|
||||||
#endif // HAVE_IFADDRS_H
|
#endif // HAVE_IFADDRS_H
|
||||||
|
@ -68,13 +70,13 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
# define SOCKET_ERRNO (errno)
|
# define SOCKET_ERRNO (errno)
|
||||||
#else
|
#else
|
||||||
# define SOCKET_ERRNO (WSAGetLastError())
|
# define SOCKET_ERRNO (WSAGetLastError())
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define A2_EINPROGRESS WSAEWOULDBLOCK
|
# define A2_EINPROGRESS WSAEWOULDBLOCK
|
||||||
# define A2_EWOULDBLOCK WSAEWOULDBLOCK
|
# define A2_EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
# define A2_EINTR WSAEINTR
|
# define A2_EINTR WSAEINTR
|
||||||
|
@ -93,7 +95,7 @@ namespace aria2 {
|
||||||
# endif // EWOULDBLOCK != EAGAIN
|
# endif // EWOULDBLOCK != EAGAIN
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define CLOSE(X) ::closesocket(X)
|
# define CLOSE(X) ::closesocket(X)
|
||||||
#else
|
#else
|
||||||
# define CLOSE(X) close(X)
|
# define CLOSE(X) close(X)
|
||||||
|
@ -102,7 +104,7 @@ namespace aria2 {
|
||||||
namespace {
|
namespace {
|
||||||
std::string errorMsg(int errNum)
|
std::string errorMsg(int errNum)
|
||||||
{
|
{
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
return util::safeStrerror(errNum);
|
return util::safeStrerror(errNum);
|
||||||
#else
|
#else
|
||||||
auto msg = util::formatLastError(errNum);
|
auto msg = util::formatLastError(errNum);
|
||||||
|
@ -595,7 +597,7 @@ void SocketCore::applyIpDscp()
|
||||||
|
|
||||||
void SocketCore::setNonBlockingMode()
|
void SocketCore::setNonBlockingMode()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
static u_long flag = 1;
|
static u_long flag = 1;
|
||||||
if (::ioctlsocket(sockfd_, FIONBIO, &flag) == -1) {
|
if (::ioctlsocket(sockfd_, FIONBIO, &flag) == -1) {
|
||||||
int errNum = SOCKET_ERRNO;
|
int errNum = SOCKET_ERRNO;
|
||||||
|
@ -614,7 +616,7 @@ void SocketCore::setNonBlockingMode()
|
||||||
|
|
||||||
void SocketCore::setBlockingMode()
|
void SocketCore::setBlockingMode()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
static u_long flag = 0;
|
static u_long flag = 0;
|
||||||
if (::ioctlsocket(sockfd_, FIONBIO, &flag) == -1) {
|
if (::ioctlsocket(sockfd_, FIONBIO, &flag) == -1) {
|
||||||
int errNum = SOCKET_ERRNO;
|
int errNum = SOCKET_ERRNO;
|
||||||
|
@ -654,7 +656,7 @@ void SocketCore::closeConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
# define CHECK_FD(fd) \
|
# define CHECK_FD(fd) \
|
||||||
if (fd < 0 || FD_SETSIZE <= fd) { \
|
if (fd < 0 || FD_SETSIZE <= fd) { \
|
||||||
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
|
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
|
||||||
|
@ -681,7 +683,7 @@ bool SocketCore::isWritable(time_t timeout)
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
|
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
|
||||||
#else // !HAVE_POLL
|
#else // !HAVE_POLL
|
||||||
# ifndef __MINGW32__
|
# if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
CHECK_FD(sockfd_);
|
CHECK_FD(sockfd_);
|
||||||
# endif // !__MINGW32__
|
# endif // !__MINGW32__
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
@ -726,7 +728,7 @@ bool SocketCore::isReadable(time_t timeout)
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
|
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
|
||||||
#else // !HAVE_POLL
|
#else // !HAVE_POLL
|
||||||
# ifndef __MINGW32__
|
# if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
CHECK_FD(sockfd_);
|
CHECK_FD(sockfd_);
|
||||||
# endif // !__MINGW32__
|
# endif // !__MINGW32__
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
@ -759,7 +761,7 @@ ssize_t SocketCore::writeVector(a2iovec* iov, size_t iovcnt)
|
||||||
wantRead_ = false;
|
wantRead_ = false;
|
||||||
wantWrite_ = false;
|
wantWrite_ = false;
|
||||||
if (!secure_) {
|
if (!secure_) {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
DWORD nsent;
|
DWORD nsent;
|
||||||
int rv = WSASend(sockfd_, iov, iovcnt, &nsent, 0, 0, 0);
|
int rv = WSASend(sockfd_, iov, iovcnt, &nsent, 0, 0, 0);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
|
@ -1573,7 +1575,7 @@ bool ipv4AddrConfigured = true;
|
||||||
bool ipv6AddrConfigured = true;
|
bool ipv6AddrConfigured = true;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
namespace {
|
namespace {
|
||||||
const uint32_t APIPA_IPV4_BEGIN = 2851995649u; // 169.254.0.1
|
const uint32_t APIPA_IPV4_BEGIN = 2851995649u; // 169.254.0.1
|
||||||
const uint32_t APIPA_IPV4_END = 2852061183u; // 169.254.255.255
|
const uint32_t APIPA_IPV4_END = 2852061183u; // 169.254.255.255
|
||||||
|
|
|
@ -51,7 +51,7 @@ SocketRecvBuffer::~SocketRecvBuffer() = default;
|
||||||
|
|
||||||
ssize_t SocketRecvBuffer::recv()
|
ssize_t SocketRecvBuffer::recv()
|
||||||
{
|
{
|
||||||
size_t n = std::end(buf_) - last_;
|
size_t n = (buf_.data() + 16_k) - last_;
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
A2_LOG_DEBUG("Buffer full");
|
A2_LOG_DEBUG("Buffer full");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -58,12 +58,12 @@ bool parseFile(const std::string& filename, ParserStateMachine* psm)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto fdclose = defer(fd, close);
|
auto fdclose = defer(fd, a2_close);
|
||||||
XmlParser ps(psm);
|
XmlParser ps(psm);
|
||||||
std::array<char, 4_k> buf;
|
std::array<char, 4_k> buf;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
while ((nread = read(fd, buf.data(), buf.size())) > 0) {
|
while ((nread = a2_read(fd, buf.data(), buf.size())) > 0) {
|
||||||
if (ps.parseUpdate(buf.data(), nread) < 0) {
|
if (ps.parseUpdate(buf.data(), nread) < 0) {
|
||||||
retval = false;
|
retval = false;
|
||||||
break;
|
break;
|
||||||
|
|
41
src/a2io.h
41
src/a2io.h
|
@ -37,7 +37,9 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
|
@ -52,6 +54,9 @@
|
||||||
#ifdef HAVE_SHARE_H
|
#ifdef HAVE_SHARE_H
|
||||||
# include <share.h>
|
# include <share.h>
|
||||||
#endif // HAVE_SHARE_H
|
#endif // HAVE_SHARE_H
|
||||||
|
#ifdef HAVE_SYS_UTIME_H
|
||||||
|
# include <sys/utime.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// in some platforms following definitions are missing:
|
// in some platforms following definitions are missing:
|
||||||
#ifndef EINPROGRESS
|
#ifndef EINPROGRESS
|
||||||
|
@ -120,7 +125,7 @@
|
||||||
# define DEV_STDOUT "/dev/stdout"
|
# define DEV_STDOUT "/dev/stdout"
|
||||||
#endif // HAVE_WINSOCK2_H
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
|
# define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
|
||||||
# define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
|
# define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
|
||||||
# define a2fstat(fd, buf) _fstati64(fd, buf)
|
# define a2fstat(fd, buf) _fstati64(fd, buf)
|
||||||
|
@ -141,6 +146,9 @@
|
||||||
# define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode)
|
# define a2open(path, flags, mode) _wsopen(path, flags, _SH_DENYNO, mode)
|
||||||
# define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO)
|
# define a2fopen(path, mode) _wfsopen(path, mode, _SH_DENYNO)
|
||||||
// # define a2ftruncate(fd, length): We don't use ftruncate in Mingw build
|
// # define a2ftruncate(fd, length): We don't use ftruncate in Mingw build
|
||||||
|
# ifndef off_t
|
||||||
|
# define off_t _off_t
|
||||||
|
# endif
|
||||||
# define a2_off_t off_t
|
# define a2_off_t off_t
|
||||||
#elif defined(__ANDROID__) || defined(ANDROID)
|
#elif defined(__ANDROID__) || defined(ANDROID)
|
||||||
# define a2lseek(fd, offset, origin) lseek64(fd, offset, origin)
|
# define a2lseek(fd, offset, origin) lseek64(fd, offset, origin)
|
||||||
|
@ -190,10 +198,37 @@ extern int ftruncate64(int fd, off64_t length);
|
||||||
#define OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
|
#define OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
|
||||||
#define DIR_OPEN_MODE S_IRWXU | S_IRWXG | S_IRWXO
|
#define DIR_OPEN_MODE S_IRWXU | S_IRWXG | S_IRWXO
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define A2_BAD_FD INVALID_HANDLE_VALUE
|
# define A2_BAD_FD INVALID_HANDLE_VALUE
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
# define A2_BAD_FD -1
|
# define A2_BAD_FD -1
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
// Present with their _ prefixes on MSVC
|
||||||
|
# define O_RDONLY _O_RDONLY
|
||||||
|
# define O_WRONLY _O_WRONLY
|
||||||
|
# define O_RDWR _O_RDWR
|
||||||
|
# define O_APPEND _O_APPEND
|
||||||
|
# define O_CREAT _O_CREAT
|
||||||
|
# define O_EXCL _O_EXCL
|
||||||
|
# define O_TRUNC _O_TRUNC
|
||||||
|
|
||||||
|
# define STDIN_FILENO _fileno(stdin)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define a2_isatty _isatty
|
||||||
|
# define a2_fileno _fileno
|
||||||
|
# define a2_read _read
|
||||||
|
# define a2_close _close
|
||||||
|
# define a2_dup _dup
|
||||||
|
#else
|
||||||
|
# define a2_isatty isatty
|
||||||
|
# define a2_fileno fileno
|
||||||
|
# define a2_read read
|
||||||
|
# define a2_close close
|
||||||
|
# define a2_dup dup
|
||||||
|
#endif // !_MSC_VER
|
||||||
|
|
||||||
#endif // D_A2IO_H
|
#endif // D_A2IO_H
|
||||||
|
|
|
@ -37,13 +37,13 @@
|
||||||
|
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# ifdef HAVE_WS2TCPIP_H
|
# ifdef HAVE_WS2TCPIP_H
|
||||||
# include <ws2tcpip.h>
|
# include <ws2tcpip.h>
|
||||||
# endif // HAVE_WS2TCPIP_H
|
# endif // HAVE_WS2TCPIP_H
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define a2_sockopt_t char*
|
# define a2_sockopt_t char*
|
||||||
# ifndef HAVE_GETADDRINFO
|
# ifndef HAVE_GETADDRINFO
|
||||||
# define HAVE_GETADDRINFO
|
# define HAVE_GETADDRINFO
|
||||||
|
@ -84,7 +84,9 @@
|
||||||
|
|
||||||
#ifndef HAVE_GETADDRINFO
|
#ifndef HAVE_GETADDRINFO
|
||||||
# include "getaddrinfo.h"
|
# include "getaddrinfo.h"
|
||||||
# define HAVE_GAI_STRERROR
|
# ifndef HAVE_GAI_STRERROR
|
||||||
|
# define HAVE_GAI_STRERROR
|
||||||
|
# endif
|
||||||
#endif // HAVE_GETADDRINFO
|
#endif // HAVE_GETADDRINFO
|
||||||
|
|
||||||
#ifndef HAVE_GAI_STRERROR
|
#ifndef HAVE_GAI_STRERROR
|
||||||
|
@ -95,6 +97,7 @@
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# define sock_t SOCKET
|
# define sock_t SOCKET
|
||||||
|
# include <ws2def.h>
|
||||||
#else
|
#else
|
||||||
# define sock_t int
|
# define sock_t int
|
||||||
#endif
|
#endif
|
||||||
|
@ -105,7 +108,7 @@
|
||||||
|
|
||||||
#define DEFAULT_AI_FLAGS AI_ADDRCONFIG
|
#define DEFAULT_AI_FLAGS AI_ADDRCONFIG
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# ifndef SHUT_WR
|
# ifndef SHUT_WR
|
||||||
# define SHUT_WR SD_SEND
|
# define SHUT_WR SD_SEND
|
||||||
# endif // !SHUT_WR
|
# endif // !SHUT_WR
|
||||||
|
@ -141,7 +144,7 @@ struct Endpoint {
|
||||||
# define A2_IOV_MAX A2_DEFAULT_IOV_MAX
|
# define A2_IOV_MAX A2_DEFAULT_IOV_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
typedef WSABUF a2iovec;
|
typedef WSABUF a2iovec;
|
||||||
# define A2IOVEC_BASE buf
|
# define A2IOVEC_BASE buf
|
||||||
# define A2IOVEC_LEN len
|
# define A2IOVEC_LEN len
|
||||||
|
|
|
@ -36,7 +36,10 @@
|
||||||
#define D_A2TIME_H
|
#define D_A2TIME_H
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@
|
||||||
# include "asctime_r.h"
|
# include "asctime_r.h"
|
||||||
#endif // HAVE_ASCTIME_R
|
#endif // HAVE_ASCTIME_R
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define suseconds_t uint64_t
|
# define suseconds_t uint64_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,14 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#include "asctime_r.h"
|
#include "asctime_r.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
|
|
||||||
static CRITICAL_SECTION asctime_r_cs;
|
static CRITICAL_SECTION asctime_r_cs;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# ifdef malloc
|
# ifdef malloc
|
||||||
# undef malloc
|
# undef malloc
|
||||||
# endif
|
# endif
|
||||||
|
@ -48,7 +48,12 @@
|
||||||
# endif
|
# endif
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# ifndef WINVER
|
# ifndef WINVER
|
||||||
# define WINVER 0x501
|
# define WINVER 0x501
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "NullOutputFile.h"
|
#include "NullOutputFile.h"
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# include "WinConsoleFile.h"
|
# include "WinConsoleFile.h"
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
# include "BufferedFile.h"
|
# include "BufferedFile.h"
|
||||||
|
@ -56,7 +56,7 @@ void initConsole(bool suppress)
|
||||||
consoleCout = consoleCerr = std::make_shared<NullOutputFile>();
|
consoleCout = consoleCerr = std::make_shared<NullOutputFile>();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
consoleCout = std::make_shared<WinConsoleFile>(STD_OUTPUT_HANDLE);
|
consoleCout = std::make_shared<WinConsoleFile>(STD_OUTPUT_HANDLE);
|
||||||
consoleCerr = std::make_shared<WinConsoleFile>(STD_ERROR_HANDLE);
|
consoleCerr = std::make_shared<WinConsoleFile>(STD_ERROR_HANDLE);
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
std::string fmt(const char* fmt, ...)
|
std::string fmt(const char* fmt, ...)
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
__attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2)))
|
__attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2)))
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
__attribute__((format(printf, 1, 2)))
|
__attribute__((format(printf, 1, 2)))
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__)
|
||||||
# undef SIZE_MAX
|
# undef SIZE_MAX
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ extern "C" {
|
||||||
/*
|
/*
|
||||||
* Functions.
|
* Functions.
|
||||||
*/
|
*/
|
||||||
#ifdef __STDC__
|
#if defined(__STDC__) || defined(_MSC_VER)
|
||||||
const char* gai_strerror(int);
|
const char* gai_strerror(int);
|
||||||
#else
|
#else
|
||||||
const char* gai_strerror();
|
const char* gai_strerror();
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
# undef ERROR
|
# undef ERROR
|
||||||
# include <ws2tcpip.h>
|
# include <ws2tcpip.h>
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
|
|
||||||
#ifndef HAVE_MEMCPY
|
#ifndef HAVE_MEMCPY
|
||||||
# define memcpy(d, s, n) bcopy((s), (d), (n))
|
# define memcpy(d, s, n) bcopy((s), (d), (n))
|
||||||
# ifdef __STDC__
|
# if defined(__STDC__) || defined(_MSC_VER)
|
||||||
void* memchr(const void*, int, size_t);
|
void* memchr(const void*, int, size_t);
|
||||||
int memcmp(const void*, const void*, size_t);
|
int memcmp(const void*, const void*, size_t);
|
||||||
void* memmove(void*, const void*, size_t);
|
void* memmove(void*, const void*, size_t);
|
||||||
|
@ -137,6 +137,10 @@ char* memset();
|
||||||
# endif /* not __STDC__ */
|
# endif /* not __STDC__ */
|
||||||
#endif /* not HAVE_MEMCPY */
|
#endif /* not HAVE_MEMCPY */
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define H_ERRNO_DECLARED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef H_ERRNO_DECLARED
|
#ifndef H_ERRNO_DECLARED
|
||||||
extern int h_errno;
|
extern int h_errno;
|
||||||
#endif
|
#endif
|
||||||
|
@ -156,6 +160,11 @@ extern int h_errno;
|
||||||
# define N_(string) (string)
|
# define N_(string) (string)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# include <stdint.h>
|
||||||
|
# define in_port_t uint16_t
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Error messages for gai_strerror().
|
* Error messages for gai_strerror().
|
||||||
*/
|
*/
|
||||||
|
@ -211,7 +220,7 @@ static pthread_mutex_t gai_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
/*
|
/*
|
||||||
* Declaration of static functions.
|
* Declaration of static functions.
|
||||||
*/
|
*/
|
||||||
#ifdef __STDC__
|
#if defined(__STDC__) || defined(_MSC_VER)
|
||||||
static int is_integer(const char*);
|
static int is_integer(const char*);
|
||||||
static int is_address(const char*);
|
static int is_address(const char*);
|
||||||
static int itoa_length(int);
|
static int itoa_length(int);
|
||||||
|
@ -496,7 +505,9 @@ struct addrinfo** res;
|
||||||
*res = head_res;
|
*res = head_res;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
#if !defined(_MSC_VER) // h_errno >> WSAGetLastError() ; not editable
|
||||||
h_errno = saved_h_errno;
|
h_errno = saved_h_errno;
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_PTHREAD
|
#ifdef ENABLE_PTHREAD
|
||||||
pthread_mutex_unlock(&gai_mutex);
|
pthread_mutex_unlock(&gai_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
@ -590,7 +601,9 @@ int flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
#if !defined(_MSC_VER) // h_errno >> WSAGetLastError() ; not editable
|
||||||
h_errno = saved_h_errno;
|
h_errno = saved_h_errno;
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_PTHREAD
|
#ifdef ENABLE_PTHREAD
|
||||||
pthread_mutex_unlock(&gai_mutex);
|
pthread_mutex_unlock(&gai_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__)
|
||||||
# undef SIZE_MAX
|
# undef SIZE_MAX
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ extern "C" {
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# ifndef _WIN32_WINNT
|
# ifndef _WIN32_WINNT
|
||||||
# define _WIN32_WINNT 0x501
|
# define _WIN32_WINNT 0x501
|
||||||
# endif // _WIN32_WINNT
|
# endif // _WIN32_WINNT
|
||||||
|
@ -240,7 +240,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Nexenta OS(GNU/Solaris OS) defines `struct addrinfo' in netdb.h */
|
/* Nexenta OS(GNU/Solaris OS) defines `struct addrinfo' in netdb.h */
|
||||||
#if !defined(__MINGW32__) && !defined(__sun)
|
#if !defined(__MINGW32__) && !defined(__sun) // && !defined(_MSC_VER)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* struct addrinfo.
|
* struct addrinfo.
|
||||||
|
@ -256,12 +256,12 @@ struct addrinfo {
|
||||||
struct addrinfo* ai_next;
|
struct addrinfo* ai_next;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !__MINGW32__ && !__sun
|
#endif // !__MINGW32__ && !__sun && !defined(_MSC_VER)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions.
|
* Functions.
|
||||||
*/
|
*/
|
||||||
#ifdef __STDC__
|
#if defined(__STDC__) || defined(_MSC_VER)
|
||||||
const char* gai_strerror(int);
|
const char* gai_strerror(int);
|
||||||
void freeaddrinfo(struct addrinfo*);
|
void freeaddrinfo(struct addrinfo*);
|
||||||
int getaddrinfo(const char*, const char*, const struct addrinfo*,
|
int getaddrinfo(const char*, const char*, const struct addrinfo*,
|
||||||
|
|
|
@ -0,0 +1,562 @@
|
||||||
|
/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */
|
||||||
|
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* Sponsored in part by the Defense Advanced Research Projects
|
||||||
|
* Agency (DARPA) and Air Force Research Laboratory, Air Force
|
||||||
|
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||||
|
*/
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Dieter Baron and Thomas Klausner.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
|
||||||
|
|
||||||
|
#ifdef REPLACE_GETOPT
|
||||||
|
int opterr = 1; /* if error message should be printed */
|
||||||
|
int optind = 1; /* index into parent argv vector */
|
||||||
|
int optopt = '?'; /* character checked for validity */
|
||||||
|
#undef optreset /* see getopt.h */
|
||||||
|
#define optreset __mingw_optreset
|
||||||
|
int optreset; /* reset getopt */
|
||||||
|
char *optarg; /* argument associated with option */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PRINT_ERROR ((opterr) && (*options != ':'))
|
||||||
|
|
||||||
|
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
|
||||||
|
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
|
||||||
|
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
|
||||||
|
|
||||||
|
/* return values */
|
||||||
|
#define BADCH (int)'?'
|
||||||
|
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
|
||||||
|
#define INORDER (int)1
|
||||||
|
|
||||||
|
#ifndef __CYGWIN__
|
||||||
|
#define __progname __argv[0]
|
||||||
|
#else
|
||||||
|
extern char __declspec(dllimport) *__progname;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
static char EMSG[] = "";
|
||||||
|
#else
|
||||||
|
#define EMSG ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int getopt_internal(int, char * const *, const char *,
|
||||||
|
const struct option *, int *, int);
|
||||||
|
static int parse_long_options(char * const *, const char *,
|
||||||
|
const struct option *, int *, int);
|
||||||
|
static int gcd(int, int);
|
||||||
|
static void permute_args(int, int, int, char * const *);
|
||||||
|
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
|
||||||
|
/* XXX: set optreset to 1 rather than these two */
|
||||||
|
static int nonopt_start = -1; /* first non option argument (for permute) */
|
||||||
|
static int nonopt_end = -1; /* first option after non options (for permute) */
|
||||||
|
|
||||||
|
/* Error messages */
|
||||||
|
static const char recargchar[] = "option requires an argument -- %c";
|
||||||
|
static const char recargstring[] = "option requires an argument -- %s";
|
||||||
|
static const char ambig[] = "ambiguous option -- %.*s";
|
||||||
|
static const char noarg[] = "option doesn't take an argument -- %.*s";
|
||||||
|
static const char illoptchar[] = "unknown option -- %c";
|
||||||
|
static const char illoptstring[] = "unknown option -- %s";
|
||||||
|
|
||||||
|
static void
|
||||||
|
_vwarnx(const char *fmt,va_list ap)
|
||||||
|
{
|
||||||
|
(void)fprintf(stderr,"%s: ",__progname);
|
||||||
|
if (fmt != NULL)
|
||||||
|
(void)vfprintf(stderr,fmt,ap);
|
||||||
|
(void)fprintf(stderr,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
warnx(const char *fmt,...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap,fmt);
|
||||||
|
_vwarnx(fmt,ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute the greatest common divisor of a and b.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
gcd(int a, int b)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
c = a % b;
|
||||||
|
while (c != 0) {
|
||||||
|
a = b;
|
||||||
|
b = c;
|
||||||
|
c = a % b;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exchange the block from nonopt_start to nonopt_end with the block
|
||||||
|
* from nonopt_end to opt_end (keeping the same order of arguments
|
||||||
|
* in each block).
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
permute_args(int panonopt_start, int panonopt_end, int opt_end,
|
||||||
|
char * const *nargv)
|
||||||
|
{
|
||||||
|
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
|
||||||
|
char *swap;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* compute lengths of blocks and number and size of cycles
|
||||||
|
*/
|
||||||
|
nnonopts = panonopt_end - panonopt_start;
|
||||||
|
nopts = opt_end - panonopt_end;
|
||||||
|
ncycle = gcd(nnonopts, nopts);
|
||||||
|
cyclelen = (opt_end - panonopt_start) / ncycle;
|
||||||
|
|
||||||
|
for (i = 0; i < ncycle; i++) {
|
||||||
|
cstart = panonopt_end+i;
|
||||||
|
pos = cstart;
|
||||||
|
for (j = 0; j < cyclelen; j++) {
|
||||||
|
if (pos >= panonopt_end)
|
||||||
|
pos -= nnonopts;
|
||||||
|
else
|
||||||
|
pos += nopts;
|
||||||
|
swap = nargv[pos];
|
||||||
|
/* LINTED const cast */
|
||||||
|
((char **) nargv)[pos] = nargv[cstart];
|
||||||
|
/* LINTED const cast */
|
||||||
|
((char **)nargv)[cstart] = swap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse_long_options --
|
||||||
|
* Parse long options in argc/argv argument vector.
|
||||||
|
* Returns -1 if short_too is set and the option does not match long_options.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
parse_long_options(char * const *nargv, const char *options,
|
||||||
|
const struct option *long_options, int *idx, int short_too)
|
||||||
|
{
|
||||||
|
char *current_argv, *has_equal;
|
||||||
|
size_t current_argv_len;
|
||||||
|
int i, ambiguous, match;
|
||||||
|
|
||||||
|
#define IDENTICAL_INTERPRETATION(_x, _y) \
|
||||||
|
(long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
|
||||||
|
long_options[(_x)].flag == long_options[(_y)].flag && \
|
||||||
|
long_options[(_x)].val == long_options[(_y)].val)
|
||||||
|
|
||||||
|
current_argv = place;
|
||||||
|
match = -1;
|
||||||
|
ambiguous = 0;
|
||||||
|
|
||||||
|
optind++;
|
||||||
|
|
||||||
|
if ((has_equal = strchr(current_argv, '=')) != NULL) {
|
||||||
|
/* argument found (--option=arg) */
|
||||||
|
current_argv_len = has_equal - current_argv;
|
||||||
|
has_equal++;
|
||||||
|
} else
|
||||||
|
current_argv_len = strlen(current_argv);
|
||||||
|
|
||||||
|
for (i = 0; long_options[i].name; i++) {
|
||||||
|
/* find matching long option */
|
||||||
|
if (strncmp(current_argv, long_options[i].name,
|
||||||
|
current_argv_len))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strlen(long_options[i].name) == current_argv_len) {
|
||||||
|
/* exact match */
|
||||||
|
match = i;
|
||||||
|
ambiguous = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* If this is a known short option, don't allow
|
||||||
|
* a partial match of a single character.
|
||||||
|
*/
|
||||||
|
if (short_too && current_argv_len == 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (match == -1) /* partial match */
|
||||||
|
match = i;
|
||||||
|
else if (!IDENTICAL_INTERPRETATION(i, match))
|
||||||
|
ambiguous = 1;
|
||||||
|
}
|
||||||
|
if (ambiguous) {
|
||||||
|
/* ambiguous abbreviation */
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(ambig, (int)current_argv_len,
|
||||||
|
current_argv);
|
||||||
|
optopt = 0;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
if (match != -1) { /* option found */
|
||||||
|
if (long_options[match].has_arg == no_argument
|
||||||
|
&& has_equal) {
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(noarg, (int)current_argv_len,
|
||||||
|
current_argv);
|
||||||
|
/*
|
||||||
|
* XXX: GNU sets optopt to val regardless of flag
|
||||||
|
*/
|
||||||
|
if (long_options[match].flag == NULL)
|
||||||
|
optopt = long_options[match].val;
|
||||||
|
else
|
||||||
|
optopt = 0;
|
||||||
|
return (BADARG);
|
||||||
|
}
|
||||||
|
if (long_options[match].has_arg == required_argument ||
|
||||||
|
long_options[match].has_arg == optional_argument) {
|
||||||
|
if (has_equal)
|
||||||
|
optarg = has_equal;
|
||||||
|
else if (long_options[match].has_arg ==
|
||||||
|
required_argument) {
|
||||||
|
/*
|
||||||
|
* optional argument doesn't use next nargv
|
||||||
|
*/
|
||||||
|
optarg = nargv[optind++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((long_options[match].has_arg == required_argument)
|
||||||
|
&& (optarg == NULL)) {
|
||||||
|
/*
|
||||||
|
* Missing argument; leading ':' indicates no error
|
||||||
|
* should be generated.
|
||||||
|
*/
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(recargstring,
|
||||||
|
current_argv);
|
||||||
|
/*
|
||||||
|
* XXX: GNU sets optopt to val regardless of flag
|
||||||
|
*/
|
||||||
|
if (long_options[match].flag == NULL)
|
||||||
|
optopt = long_options[match].val;
|
||||||
|
else
|
||||||
|
optopt = 0;
|
||||||
|
--optind;
|
||||||
|
return (BADARG);
|
||||||
|
}
|
||||||
|
} else { /* unknown option */
|
||||||
|
if (short_too) {
|
||||||
|
--optind;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(illoptstring, current_argv);
|
||||||
|
optopt = 0;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
if (idx)
|
||||||
|
*idx = match;
|
||||||
|
if (long_options[match].flag) {
|
||||||
|
*long_options[match].flag = long_options[match].val;
|
||||||
|
return (0);
|
||||||
|
} else
|
||||||
|
return (long_options[match].val);
|
||||||
|
#undef IDENTICAL_INTERPRETATION
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt_internal --
|
||||||
|
* Parse argc/argv argument vector. Called by user level routines.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
getopt_internal(int nargc, char * const *nargv, const char *options,
|
||||||
|
const struct option *long_options, int *idx, int flags)
|
||||||
|
{
|
||||||
|
const char *oli; /* option letter list index */
|
||||||
|
int optchar, short_too;
|
||||||
|
static int posixly_correct = -1;
|
||||||
|
|
||||||
|
if (options == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX Some GNU programs (like cvs) set optind to 0 instead of
|
||||||
|
* XXX using optreset. Work around this braindamage.
|
||||||
|
*/
|
||||||
|
if (optind == 0)
|
||||||
|
optind = optreset = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disable GNU extensions if POSIXLY_CORRECT is set or options
|
||||||
|
* string begins with a '+'.
|
||||||
|
*
|
||||||
|
* CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or
|
||||||
|
* optreset != 0 for GNU compatibility.
|
||||||
|
*/
|
||||||
|
if (posixly_correct == -1 || optreset != 0)
|
||||||
|
posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
|
||||||
|
if (*options == '-')
|
||||||
|
flags |= FLAG_ALLARGS;
|
||||||
|
else if (posixly_correct || *options == '+')
|
||||||
|
flags &= ~FLAG_PERMUTE;
|
||||||
|
if (*options == '+' || *options == '-')
|
||||||
|
options++;
|
||||||
|
|
||||||
|
optarg = NULL;
|
||||||
|
if (optreset)
|
||||||
|
nonopt_start = nonopt_end = -1;
|
||||||
|
start:
|
||||||
|
if (optreset || !*place) { /* update scanning pointer */
|
||||||
|
optreset = 0;
|
||||||
|
if (optind >= nargc) { /* end of argument vector */
|
||||||
|
place = EMSG;
|
||||||
|
if (nonopt_end != -1) {
|
||||||
|
/* do permutation, if we have to */
|
||||||
|
permute_args(nonopt_start, nonopt_end,
|
||||||
|
optind, nargv);
|
||||||
|
optind -= nonopt_end - nonopt_start;
|
||||||
|
}
|
||||||
|
else if (nonopt_start != -1) {
|
||||||
|
/*
|
||||||
|
* If we skipped non-options, set optind
|
||||||
|
* to the first of them.
|
||||||
|
*/
|
||||||
|
optind = nonopt_start;
|
||||||
|
}
|
||||||
|
nonopt_start = nonopt_end = -1;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (*(place = nargv[optind]) != '-' ||
|
||||||
|
(place[1] == '\0' && strchr(options, '-') == NULL)) {
|
||||||
|
place = EMSG; /* found non-option */
|
||||||
|
if (flags & FLAG_ALLARGS) {
|
||||||
|
/*
|
||||||
|
* GNU extension:
|
||||||
|
* return non-option as argument to option 1
|
||||||
|
*/
|
||||||
|
optarg = nargv[optind++];
|
||||||
|
return (INORDER);
|
||||||
|
}
|
||||||
|
if (!(flags & FLAG_PERMUTE)) {
|
||||||
|
/*
|
||||||
|
* If no permutation wanted, stop parsing
|
||||||
|
* at first non-option.
|
||||||
|
*/
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
/* do permutation */
|
||||||
|
if (nonopt_start == -1)
|
||||||
|
nonopt_start = optind;
|
||||||
|
else if (nonopt_end != -1) {
|
||||||
|
permute_args(nonopt_start, nonopt_end,
|
||||||
|
optind, nargv);
|
||||||
|
nonopt_start = optind -
|
||||||
|
(nonopt_end - nonopt_start);
|
||||||
|
nonopt_end = -1;
|
||||||
|
}
|
||||||
|
optind++;
|
||||||
|
/* process next argument */
|
||||||
|
goto start;
|
||||||
|
}
|
||||||
|
if (nonopt_start != -1 && nonopt_end == -1)
|
||||||
|
nonopt_end = optind;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have "-" do nothing, if "--" we are done.
|
||||||
|
*/
|
||||||
|
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
|
||||||
|
optind++;
|
||||||
|
place = EMSG;
|
||||||
|
/*
|
||||||
|
* We found an option (--), so if we skipped
|
||||||
|
* non-options, we have to permute.
|
||||||
|
*/
|
||||||
|
if (nonopt_end != -1) {
|
||||||
|
permute_args(nonopt_start, nonopt_end,
|
||||||
|
optind, nargv);
|
||||||
|
optind -= nonopt_end - nonopt_start;
|
||||||
|
}
|
||||||
|
nonopt_start = nonopt_end = -1;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check long options if:
|
||||||
|
* 1) we were passed some
|
||||||
|
* 2) the arg is not just "-"
|
||||||
|
* 3) either the arg starts with -- we are getopt_long_only()
|
||||||
|
*/
|
||||||
|
if (long_options != NULL && place != nargv[optind] &&
|
||||||
|
(*place == '-' || (flags & FLAG_LONGONLY))) {
|
||||||
|
short_too = 0;
|
||||||
|
if (*place == '-')
|
||||||
|
place++; /* --foo long option */
|
||||||
|
else if (*place != ':' && strchr(options, *place) != NULL)
|
||||||
|
short_too = 1; /* could be short option too */
|
||||||
|
|
||||||
|
optchar = parse_long_options(nargv, options, long_options,
|
||||||
|
idx, short_too);
|
||||||
|
if (optchar != -1) {
|
||||||
|
place = EMSG;
|
||||||
|
return (optchar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((optchar = (int)*place++) == (int)':' ||
|
||||||
|
(optchar == (int)'-' && *place != '\0') ||
|
||||||
|
(oli = strchr(options, optchar)) == NULL) {
|
||||||
|
/*
|
||||||
|
* If the user specified "-" and '-' isn't listed in
|
||||||
|
* options, return -1 (non-option) as per POSIX.
|
||||||
|
* Otherwise, it is an unknown option character (or ':').
|
||||||
|
*/
|
||||||
|
if (optchar == (int)'-' && *place == '\0')
|
||||||
|
return (-1);
|
||||||
|
if (!*place)
|
||||||
|
++optind;
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(illoptchar, optchar);
|
||||||
|
optopt = optchar;
|
||||||
|
return (BADCH);
|
||||||
|
}
|
||||||
|
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
|
||||||
|
/* -W long-option */
|
||||||
|
if (*place) /* no space */
|
||||||
|
/* NOTHING */;
|
||||||
|
else if (++optind >= nargc) { /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(recargchar, optchar);
|
||||||
|
optopt = optchar;
|
||||||
|
return (BADARG);
|
||||||
|
} else /* white space */
|
||||||
|
place = nargv[optind];
|
||||||
|
optchar = parse_long_options(nargv, options, long_options,
|
||||||
|
idx, 0);
|
||||||
|
place = EMSG;
|
||||||
|
return (optchar);
|
||||||
|
}
|
||||||
|
if (*++oli != ':') { /* doesn't take argument */
|
||||||
|
if (!*place)
|
||||||
|
++optind;
|
||||||
|
} else { /* takes (optional) argument */
|
||||||
|
optarg = NULL;
|
||||||
|
if (*place) /* no white space */
|
||||||
|
optarg = place;
|
||||||
|
else if (oli[1] != ':') { /* arg not optional */
|
||||||
|
if (++optind >= nargc) { /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (PRINT_ERROR)
|
||||||
|
warnx(recargchar, optchar);
|
||||||
|
optopt = optchar;
|
||||||
|
return (BADARG);
|
||||||
|
} else
|
||||||
|
optarg = nargv[optind];
|
||||||
|
}
|
||||||
|
place = EMSG;
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
/* dump back option letter */
|
||||||
|
return (optchar);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef REPLACE_GETOPT
|
||||||
|
/*
|
||||||
|
* getopt --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*
|
||||||
|
* [eventually this will replace the BSD getopt]
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
getopt(int nargc, char * const *nargv, const char *options)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't pass FLAG_PERMUTE to getopt_internal() since
|
||||||
|
* the BSD getopt(3) (unlike GNU) has never done this.
|
||||||
|
*
|
||||||
|
* Furthermore, since many privileged programs call getopt()
|
||||||
|
* before dropping privileges it makes sense to keep things
|
||||||
|
* as simple (and bug-free) as possible.
|
||||||
|
*/
|
||||||
|
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
|
||||||
|
}
|
||||||
|
#endif /* REPLACE_GETOPT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt_long --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
getopt_long(int nargc, char * const *nargv, const char *options,
|
||||||
|
const struct option *long_options, int *idx)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (getopt_internal(nargc, nargv, options, long_options, idx,
|
||||||
|
FLAG_PERMUTE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt_long_only --
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
getopt_long_only(int nargc, char * const *nargv, const char *options,
|
||||||
|
const struct option *long_options, int *idx)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (getopt_internal(nargc, nargv, options, long_options, idx,
|
||||||
|
FLAG_PERMUTE|FLAG_LONGONLY));
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
#ifndef __GETOPT_H__
|
||||||
|
/**
|
||||||
|
* DISCLAIMER
|
||||||
|
* This file has no copyright assigned and is placed in the Public Domain.
|
||||||
|
* This file is a part of the w64 mingw-runtime package.
|
||||||
|
*
|
||||||
|
* The w64 mingw-runtime package and its code is distributed in the hope that it
|
||||||
|
* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
|
||||||
|
* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
|
||||||
|
* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __GETOPT_H__
|
||||||
|
|
||||||
|
/* All the headers include this file. */
|
||||||
|
#include <crtdefs.h>
|
||||||
|
|
||||||
|
#if defined( WINGETOPT_SHARED_LIB )
|
||||||
|
# if defined( BUILDING_WINGETOPT_DLL )
|
||||||
|
# define WINGETOPT_API __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define WINGETOPT_API __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define WINGETOPT_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
WINGETOPT_API extern int optind; /* index of first non-option in argv */
|
||||||
|
WINGETOPT_API extern int optopt; /* single option character, as parsed */
|
||||||
|
WINGETOPT_API extern int opterr; /* flag to enable built-in diagnostics... */
|
||||||
|
/* (user may set to zero, to suppress) */
|
||||||
|
|
||||||
|
WINGETOPT_API extern char *optarg; /* pointer to argument of current option */
|
||||||
|
|
||||||
|
extern int getopt(int nargc, char * const *nargv, const char *options);
|
||||||
|
|
||||||
|
#ifdef _BSD_SOURCE
|
||||||
|
/*
|
||||||
|
* BSD adds the non-standard `optreset' feature, for reinitialisation
|
||||||
|
* of `getopt' parsing. We support this feature, for applications which
|
||||||
|
* proclaim their BSD heritage, before including this header; however,
|
||||||
|
* to maintain portability, developers are advised to avoid it.
|
||||||
|
*/
|
||||||
|
# define optreset __mingw_optreset
|
||||||
|
extern int optreset;
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* POSIX requires the `getopt' API to be specified in `unistd.h';
|
||||||
|
* thus, `unistd.h' includes this header. However, we do not want
|
||||||
|
* to expose the `getopt_long' or `getopt_long_only' APIs, when
|
||||||
|
* included in this manner. Thus, close the standard __GETOPT_H__
|
||||||
|
* declarations block, and open an additional __GETOPT_LONG_H__
|
||||||
|
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
|
||||||
|
* to declare the extended API.
|
||||||
|
*/
|
||||||
|
#endif /* !defined(__GETOPT_H__) */
|
||||||
|
|
||||||
|
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
|
||||||
|
#define __GETOPT_LONG_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct option /* specification for a long form option... */
|
||||||
|
{
|
||||||
|
const char *name; /* option name, without leading hyphens */
|
||||||
|
int has_arg; /* does it take an argument? */
|
||||||
|
int *flag; /* where to save its status, or NULL */
|
||||||
|
int val; /* its associated status value */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum /* permitted values for its `has_arg' field... */
|
||||||
|
{
|
||||||
|
no_argument = 0, /* option never takes an argument */
|
||||||
|
required_argument, /* option always requires an argument */
|
||||||
|
optional_argument /* option may take an argument */
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int getopt_long(int nargc, char * const *nargv, const char *options,
|
||||||
|
const struct option *long_options, int *idx);
|
||||||
|
extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
|
||||||
|
const struct option *long_options, int *idx);
|
||||||
|
/*
|
||||||
|
* Previous MinGW implementation had...
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_DECL_GETOPT
|
||||||
|
/*
|
||||||
|
* ...for the long form API only; keep this for compatibility.
|
||||||
|
*/
|
||||||
|
# define HAVE_DECL_GETOPT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
|
|
@ -23,9 +23,17 @@
|
||||||
* Danny Smith <dannysmith@users.sourceforge.net>
|
* Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
#endif /* HAVE_WINSOCK2_H */
|
||||||
|
|
||||||
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#ifndef _D_GETTIMEOFDAY_H
|
#ifndef _D_GETTIMEOFDAY_H
|
||||||
#define _D_GETTIMEOFDAY_H 1
|
#define _D_GETTIMEOFDAY_H 1
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__)
|
||||||
# undef SIZE_MAX
|
# undef SIZE_MAX
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
@ -44,7 +44,9 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include <sys/time.h>
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
install(FILES aria2/aria2.h DESTINATION include)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
#if ENABLE_LIBARIA2
|
||||||
|
#nobase_include_HEADERS = aria2/aria2.h
|
||||||
|
#endif # ENABLE_LIBARIA2
|
|
@ -40,7 +40,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
|
|
||||||
char* basename(char* path);
|
char* basename(char* path);
|
||||||
char* dirname(char* path);
|
char* dirname(char* path);
|
||||||
|
|
|
@ -36,14 +36,14 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#include "localtime_r.h"
|
#include "localtime_r.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
|
|
||||||
static CRITICAL_SECTION localtime_r_cs;
|
static CRITICAL_SECTION localtime_r_cs;
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,11 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#ifndef NO_UNIX
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# include <shellapi.h>
|
# include <shellapi.h>
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ namespace aria2 {
|
||||||
|
|
||||||
error_code::Value main(int argc, char** argv)
|
error_code::Value main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
int winArgc;
|
int winArgc;
|
||||||
auto winArgv = CommandLineToArgvW(GetCommandLineW(), &winArgc);
|
auto winArgv = CommandLineToArgvW(GetCommandLineW(), &winArgc);
|
||||||
if (winArgv == nullptr) {
|
if (winArgv == nullptr) {
|
||||||
|
|
|
@ -54,11 +54,21 @@
|
||||||
#endif // HAVE_ALLOCA_H
|
#endif // HAVE_ALLOCA_H
|
||||||
|
|
||||||
#ifdef HAVE_MALLOC_H
|
#ifdef HAVE_MALLOC_H
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
// pull in alloca _alloca def
|
||||||
|
# define _CRT_INTERNAL_NONSTDC_NAMES 1
|
||||||
|
# endif
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
#endif // HAVE_MALLOC_H
|
#endif // HAVE_MALLOC_H
|
||||||
|
|
||||||
#include "strptime.h"
|
#include "strptime.h"
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define tzname _tzname
|
||||||
|
# define strncasecmp _strnicmp
|
||||||
|
# define strcasecmp _stricmp
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char* abb_weekdays[] = {"Sun", "Mon", "Tue", "Wed",
|
static const char* abb_weekdays[] = {"Sun", "Mon", "Tue", "Wed",
|
||||||
"Thu", "Fri", "Sat", NULL};
|
"Thu", "Fri", "Sat", NULL};
|
||||||
|
|
||||||
|
|
20
src/util.cc
20
src/util.cc
|
@ -96,7 +96,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
namespace {
|
namespace {
|
||||||
int utf8ToWChar(wchar_t* out, size_t outLength, const char* src)
|
int utf8ToWChar(wchar_t* out, size_t outLength, const char* src)
|
||||||
{
|
{
|
||||||
|
@ -1742,7 +1742,7 @@ void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
std::string getHomeDir()
|
std::string getHomeDir()
|
||||||
{
|
{
|
||||||
const char* p = getenv("HOME");
|
const char* p = getenv("HOME");
|
||||||
|
@ -1789,7 +1789,7 @@ std::string getXDGDir(const std::string& environmentVariable,
|
||||||
std::string filename;
|
std::string filename;
|
||||||
const char* p = getenv(environmentVariable.c_str());
|
const char* p = getenv(environmentVariable.c_str());
|
||||||
if (p &&
|
if (p &&
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
p[0] == '/'
|
p[0] == '/'
|
||||||
#else // __MINGW32__
|
#else // __MINGW32__
|
||||||
p[0] && p[1] == ':'
|
p[0] && p[1] == ':'
|
||||||
|
@ -2112,7 +2112,7 @@ std::string applyDir(const std::string& dir, const std::string& relPath)
|
||||||
s += relPath;
|
s += relPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
for (std::string::iterator i = s.begin(), eoi = s.end(); i != eoi; ++i) {
|
for (std::string::iterator i = s.begin(), eoi = s.end(); i != eoi; ++i) {
|
||||||
if (*i == '\\') {
|
if (*i == '\\') {
|
||||||
*i = '/';
|
*i = '/';
|
||||||
|
@ -2179,7 +2179,7 @@ bool detectDirTraversal(const std::string& s)
|
||||||
std::string escapePath(const std::string& s)
|
std::string escapePath(const std::string& s)
|
||||||
{
|
{
|
||||||
// We don't escape '/' because we use it as a path separator.
|
// We don't escape '/' because we use it as a path separator.
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
static const char WIN_INVALID_PATH_CHARS[] = {'"', '*', ':', '<',
|
static const char WIN_INVALID_PATH_CHARS[] = {'"', '*', ':', '<',
|
||||||
'>', '?', '\\', '|'};
|
'>', '?', '\\', '|'};
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
@ -2187,7 +2187,7 @@ std::string escapePath(const std::string& s)
|
||||||
for (auto cc : s) {
|
for (auto cc : s) {
|
||||||
unsigned char c = cc;
|
unsigned char c = cc;
|
||||||
if (in(c, 0x00u, 0x1fu) || c == 0x7fu
|
if (in(c, 0x00u, 0x1fu) || c == 0x7fu
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
|| std::find(std::begin(WIN_INVALID_PATH_CHARS),
|
|| std::find(std::begin(WIN_INVALID_PATH_CHARS),
|
||||||
std::end(WIN_INVALID_PATH_CHARS),
|
std::end(WIN_INVALID_PATH_CHARS),
|
||||||
c) != std::end(WIN_INVALID_PATH_CHARS)
|
c) != std::end(WIN_INVALID_PATH_CHARS)
|
||||||
|
@ -2234,7 +2234,7 @@ void executeHook(const std::string& command, a2_gid_t gid, size_t numFiles,
|
||||||
{
|
{
|
||||||
const std::string gidStr = GroupId::toHex(gid);
|
const std::string gidStr = GroupId::toHex(gid);
|
||||||
const std::string numFilesStr = util::uitos(numFiles);
|
const std::string numFilesStr = util::uitos(numFiles);
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
A2_LOG_INFO(fmt("Executing user command: %s %s %s %s", command.c_str(),
|
A2_LOG_INFO(fmt("Executing user command: %s %s %s %s", command.c_str(),
|
||||||
gidStr.c_str(), numFilesStr.c_str(), firstFilename.c_str()));
|
gidStr.c_str(), numFilesStr.c_str(), firstFilename.c_str()));
|
||||||
pid_t cpid = fork();
|
pid_t cpid = fork();
|
||||||
|
@ -2483,7 +2483,7 @@ TLSVersion toTLSVersion(const std::string& ver)
|
||||||
}
|
}
|
||||||
#endif // ENABLE_SSL
|
#endif // ENABLE_SSL
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
std::string formatLastError(int errNum)
|
std::string formatLastError(int errNum)
|
||||||
{
|
{
|
||||||
std::array<char, 4_k> buf;
|
std::array<char, 4_k> buf;
|
||||||
|
@ -2502,7 +2502,7 @@ std::string formatLastError(int errNum)
|
||||||
|
|
||||||
void make_fd_cloexec(int fd)
|
void make_fd_cloexec(int fd)
|
||||||
{
|
{
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// TODO from linux man page, fcntl() with F_GETFD or F_SETFD does
|
// TODO from linux man page, fcntl() with F_GETFD or F_SETFD does
|
||||||
|
@ -2519,7 +2519,7 @@ void make_fd_cloexec(int fd)
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
bool gainPrivilege(LPCTSTR privName)
|
bool gainPrivilege(LPCTSTR privName)
|
||||||
{
|
{
|
||||||
LUID luid;
|
LUID luid;
|
||||||
|
|
21
src/util.h
21
src/util.h
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
@ -95,7 +97,7 @@ inline uint64_t ntoh64(uint64_t x) { return byteswap64(x); }
|
||||||
inline uint64_t hton64(uint64_t x) { return byteswap64(x); }
|
inline uint64_t hton64(uint64_t x) { return byteswap64(x); }
|
||||||
#endif // !WORDS_BIGENDIAN
|
#endif // !WORDS_BIGENDIAN
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
std::wstring utf8ToWChar(const std::string& src);
|
std::wstring utf8ToWChar(const std::string& src);
|
||||||
|
|
||||||
std::wstring utf8ToWChar(const char* str);
|
std::wstring utf8ToWChar(const char* str);
|
||||||
|
@ -109,6 +111,17 @@ std::string toForwardSlash(const std::string& src);
|
||||||
# define utf8ToNative(src) src
|
# define utf8ToNative(src) src
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define strdup _strdup
|
||||||
|
# define wdscup _wcsdup
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
|
|
||||||
extern const char DEFAULT_STRIP_CHARSET[];
|
extern const char DEFAULT_STRIP_CHARSET[];
|
||||||
|
@ -863,7 +876,7 @@ bool tlsHostnameMatch(const std::string& pattern, const std::string& hostname);
|
||||||
TLSVersion toTLSVersion(const std::string& ver);
|
TLSVersion toTLSVersion(const std::string& ver);
|
||||||
#endif // ENABLE_SSL
|
#endif // ENABLE_SSL
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
// Formats error message for error code errNum, which is the return
|
// Formats error message for error code errNum, which is the return
|
||||||
// value of GetLastError(). On error, this function returns empty
|
// value of GetLastError(). On error, this function returns empty
|
||||||
// string.
|
// string.
|
||||||
|
@ -875,7 +888,7 @@ std::string formatLastError(int errNum);
|
||||||
// CreateProcess call.
|
// CreateProcess call.
|
||||||
void make_fd_cloexec(int fd);
|
void make_fd_cloexec(int fd);
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
bool gainPrivilege(LPCTSTR privName);
|
bool gainPrivilege(LPCTSTR privName);
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,359 @@
|
||||||
|
|
||||||
|
include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
|
||||||
|
|
||||||
|
|
||||||
|
########### next target ###############
|
||||||
|
|
||||||
|
set($(TESTS)_SRCS ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
|
||||||
|
|
||||||
|
if(KDE4_BUILD_TESTS)
|
||||||
|
|
||||||
|
kde4_add_executable($(TESTS) ${$(TESTS)_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries($(TESTS) ${KDE4_KDECORE_LIBS})
|
||||||
|
|
||||||
|
endif(KDE4_BUILD_TESTS)
|
||||||
|
|
||||||
|
########### install files ###############
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#original Makefile.am contents follow:
|
||||||
|
|
||||||
|
#a2_test_outdir = test_outdir
|
||||||
|
#TESTS = aria2c
|
||||||
|
#check_PROGRAMS = $(TESTS)
|
||||||
|
#aria2c_SOURCES = AllTest.cc\
|
||||||
|
# TestUtil.cc TestUtil.h\
|
||||||
|
# SocketCoreTest.cc\
|
||||||
|
# array_funTest.cc\
|
||||||
|
# Base64Test.cc\
|
||||||
|
# Base32Test.cc\
|
||||||
|
# a2functionalTest.cc\
|
||||||
|
# FileEntryTest.cc\
|
||||||
|
# PieceTest.cc\
|
||||||
|
# SegmentTest.cc\
|
||||||
|
# GrowSegmentTest.cc\
|
||||||
|
# SingleFileAllocationIteratorTest.cc\
|
||||||
|
# DefaultBtProgressInfoFileTest.cc\
|
||||||
|
# RequestGroupTest.cc\
|
||||||
|
# UtilTest1.cc\
|
||||||
|
# UtilTest2.cc\
|
||||||
|
# UtilSecurityTest.cc\
|
||||||
|
# UriListParserTest.cc\
|
||||||
|
# HttpHeaderProcessorTest.cc\
|
||||||
|
# RequestTest.cc\
|
||||||
|
# HttpRequestTest.cc\
|
||||||
|
# RequestGroupManTest.cc\
|
||||||
|
# AuthConfigFactoryTest.cc\
|
||||||
|
# NetrcAuthResolverTest.cc\
|
||||||
|
# DefaultAuthResolverTest.cc\
|
||||||
|
# OptionHandlerTest.cc\
|
||||||
|
# SegmentManTest.cc\
|
||||||
|
# BitfieldManTest.cc\
|
||||||
|
# NetrcTest.cc\
|
||||||
|
# SingletonHolderTest.cc\
|
||||||
|
# HttpHeaderTest.cc\
|
||||||
|
# HttpResponseTest.cc\
|
||||||
|
# FileTest.cc\
|
||||||
|
# OptionTest.cc\
|
||||||
|
# DefaultDiskWriterTest.cc\
|
||||||
|
# FeatureConfigTest.cc\
|
||||||
|
# SpeedCalcTest.cc\
|
||||||
|
# MultiDiskAdaptorTest.cc\
|
||||||
|
# MultiFileAllocationIteratorTest.cc\
|
||||||
|
# FixedNumberRandomizer.h\
|
||||||
|
# ProtocolDetectorTest.cc\
|
||||||
|
# ExceptionTest.cc\
|
||||||
|
# FmtTest.cc\
|
||||||
|
# DownloadHandlersTest.cc\
|
||||||
|
# SignatureTest.cc\
|
||||||
|
# ServerStatManTest.cc\
|
||||||
|
# FeedbackURISelectorTest.cc\
|
||||||
|
# InorderURISelectorTest.cc\
|
||||||
|
# ServerStatTest.cc\
|
||||||
|
# NsCookieParserTest.cc\
|
||||||
|
# DirectDiskAdaptorTest.cc\
|
||||||
|
# CookieTest.cc\
|
||||||
|
# CookieStorageTest.cc\
|
||||||
|
# TimeTest.cc\
|
||||||
|
# FtpConnectionTest.cc\
|
||||||
|
# OptionParserTest.cc\
|
||||||
|
# DNSCacheTest.cc\
|
||||||
|
# DownloadHelperTest.cc\
|
||||||
|
# SequentialPickerTest.cc\
|
||||||
|
# RarestPieceSelectorTest.cc\
|
||||||
|
# PieceStatManTest.cc\
|
||||||
|
# InorderPieceSelector.h\
|
||||||
|
# LongestSequencePieceSelectorTest.cc\
|
||||||
|
# a2algoTest.cc\
|
||||||
|
# bitfieldTest.cc\
|
||||||
|
# DownloadContextTest.cc\
|
||||||
|
# SessionSerializerTest.cc\
|
||||||
|
# ValueBaseTest.cc\
|
||||||
|
# ChunkedDecodingStreamFilterTest.cc\
|
||||||
|
# UriTest.cc\
|
||||||
|
# UriSplitTest.cc\
|
||||||
|
# MockSegment.h\
|
||||||
|
# CookieHelperTest.cc\
|
||||||
|
# JsonTest.cc\
|
||||||
|
# ValueBaseJsonParserTest.cc\
|
||||||
|
# RpcResponseTest.cc\
|
||||||
|
# RpcMethodTest.cc\
|
||||||
|
# HttpServerTest.cc\
|
||||||
|
# BufferedFileTest.cc\
|
||||||
|
# GeomStreamPieceSelectorTest.cc\
|
||||||
|
# SegListTest.cc\
|
||||||
|
# ParamedStringTest.cc\
|
||||||
|
# RpcHelperTest.cc\
|
||||||
|
# AbstractCommandTest.cc\
|
||||||
|
# SinkStreamFilterTest.cc\
|
||||||
|
# WrDiskCacheTest.cc\
|
||||||
|
# WrDiskCacheEntryTest.cc\
|
||||||
|
# GroupIdTest.cc\
|
||||||
|
# IndexedListTest.cc \
|
||||||
|
# SimpleRandomizerTest.cc
|
||||||
|
#
|
||||||
|
#if ENABLE_XML_RPC
|
||||||
|
#aria2c_SOURCES += XmlRpcRequestParserControllerTest.cc
|
||||||
|
#endif # ENABLE_XML_RPC
|
||||||
|
#
|
||||||
|
#if HAVE_SOME_FALLOCATE
|
||||||
|
#aria2c_SOURCES += FallocFileAllocationIteratorTest.cc
|
||||||
|
#endif # HAVE_SOME_FALLOCATE
|
||||||
|
#
|
||||||
|
#if HAVE_ZLIB
|
||||||
|
#aria2c_SOURCES += \
|
||||||
|
# GZipDecoder.cc GZipDecoder.h\
|
||||||
|
# GZipDecoderTest.cc GZipEncoderTest.cc\
|
||||||
|
# GZipDecodingStreamFilterTest.cc\
|
||||||
|
# GZipFileTest.cc
|
||||||
|
#endif # HAVE_ZLIB
|
||||||
|
#
|
||||||
|
#if HAVE_SQLITE3
|
||||||
|
#aria2c_SOURCES += Sqlite3CookieParserTest.cc
|
||||||
|
#endif # HAVE_SQLITE3
|
||||||
|
#
|
||||||
|
#aria2c_SOURCES += MessageDigestHelperTest.cc\
|
||||||
|
# IteratableChunkChecksumValidatorTest.cc\
|
||||||
|
# IteratableChecksumValidatorTest.cc\
|
||||||
|
# MessageDigestTest.cc
|
||||||
|
#
|
||||||
|
#if ENABLE_BITTORRENT
|
||||||
|
#aria2c_SOURCES += BtAllowedFastMessageTest.cc\
|
||||||
|
# BtBitfieldMessageTest.cc\
|
||||||
|
# BtCancelMessageTest.cc\
|
||||||
|
# BtChokeMessageTest.cc\
|
||||||
|
# BtHandshakeMessageTest.cc\
|
||||||
|
# BtHaveAllMessageTest.cc\
|
||||||
|
# BtHaveMessageTest.cc\
|
||||||
|
# BtHaveNoneMessageTest.cc\
|
||||||
|
# BtInterestedMessageTest.cc\
|
||||||
|
# BtKeepAliveMessageTest.cc\
|
||||||
|
# BtNotInterestedMessageTest.cc\
|
||||||
|
# BtPieceMessageTest.cc\
|
||||||
|
# BtPortMessageTest.cc\
|
||||||
|
# BtRejectMessageTest.cc\
|
||||||
|
# BtRequestMessageTest.cc\
|
||||||
|
# BtSuggestPieceMessageTest.cc\
|
||||||
|
# BtUnchokeMessageTest.cc\
|
||||||
|
# DefaultPieceStorageTest.cc\
|
||||||
|
# DefaultBtAnnounceTest.cc\
|
||||||
|
# DefaultBtMessageDispatcherTest.cc\
|
||||||
|
# DefaultBtRequestFactoryTest.cc\
|
||||||
|
# MockBtMessage.h\
|
||||||
|
# MockBtMessageDispatcher.h\
|
||||||
|
# MockBtMessageFactory.h\
|
||||||
|
# AnnounceListTest.cc\
|
||||||
|
# DefaultPeerStorageTest.cc\
|
||||||
|
# MockPeerStorage.h\
|
||||||
|
# ByteArrayDiskWriterTest.cc\
|
||||||
|
# PeerTest.cc\
|
||||||
|
# PeerSessionResourceTest.cc\
|
||||||
|
# ShareRatioSeedCriteriaTest.cc\
|
||||||
|
# BtRegistryTest.cc\
|
||||||
|
# BtDependencyTest.cc\
|
||||||
|
# BtPostDownloadHandlerTest.cc\
|
||||||
|
# TimeSeedCriteriaTest.cc\
|
||||||
|
# BtExtendedMessageTest.cc\
|
||||||
|
# HandshakeExtensionMessageTest.cc\
|
||||||
|
# UTPexExtensionMessageTest.cc\
|
||||||
|
# UTMetadataRequestExtensionMessageTest.cc\
|
||||||
|
# UTMetadataDataExtensionMessageTest.cc\
|
||||||
|
# UTMetadataRejectExtensionMessageTest.cc\
|
||||||
|
# UTMetadataRequestTrackerTest.cc\
|
||||||
|
# UTMetadataRequestFactoryTest.cc\
|
||||||
|
# UTMetadataPostDownloadHandlerTest.cc\
|
||||||
|
# MagnetTest.cc\
|
||||||
|
# DefaultBtMessageFactoryTest.cc\
|
||||||
|
# DefaultExtensionMessageFactoryTest.cc\
|
||||||
|
# DHTNodeTest.cc\
|
||||||
|
# DHTBucketTest.cc\
|
||||||
|
# DHTRoutingTableTest.cc\
|
||||||
|
# DHTMessageTrackerEntryTest.cc\
|
||||||
|
# DHTMessageTrackerTest.cc\
|
||||||
|
# DHTConnectionImplTest.cc\
|
||||||
|
# DHTPingMessageTest.cc\
|
||||||
|
# DHTPingReplyMessageTest.cc\
|
||||||
|
# DHTFindNodeMessageTest.cc\
|
||||||
|
# DHTFindNodeReplyMessageTest.cc\
|
||||||
|
# DHTGetPeersMessageTest.cc\
|
||||||
|
# DHTGetPeersReplyMessageTest.cc\
|
||||||
|
# DHTAnnouncePeerMessageTest.cc\
|
||||||
|
# DHTAnnouncePeerReplyMessageTest.cc\
|
||||||
|
# DHTUnknownMessageTest.cc\
|
||||||
|
# DHTMessageFactoryImplTest.cc\
|
||||||
|
# DHTBucketTreeTest.cc\
|
||||||
|
# DHTPeerAnnounceEntryTest.cc\
|
||||||
|
# DHTPeerAnnounceStorageTest.cc\
|
||||||
|
# DHTTokenTrackerTest.cc\
|
||||||
|
# XORCloserTest.cc\
|
||||||
|
# DHTIDCloserTest.cc\
|
||||||
|
# DHTRoutingTableSerializerTest.cc\
|
||||||
|
# DHTRoutingTableDeserializerTest.cc\
|
||||||
|
# DHTTaskExecutorTest.cc\
|
||||||
|
# DHKeyExchangeTest.cc\
|
||||||
|
# ARC4Test.cc\
|
||||||
|
# MSEHandshakeTest.cc\
|
||||||
|
# MockBtAnnounce.h\
|
||||||
|
# MockBtProgressInfoFile.h\
|
||||||
|
# MockBtRequestFactory.h\
|
||||||
|
# MockDHTMessage.h\
|
||||||
|
# MockDHTMessageCallback.h\
|
||||||
|
# MockDHTMessageDispatcher.h\
|
||||||
|
# MockDHTMessageFactory.h\
|
||||||
|
# MockDHTTask.h\
|
||||||
|
# MockDHTTaskFactory.h\
|
||||||
|
# MockDHTTaskQueue.h\
|
||||||
|
# MockExtensionMessage.h\
|
||||||
|
# MockExtensionMessageFactory.h\
|
||||||
|
# MockPieceStorage.h\
|
||||||
|
# BittorrentHelperTest.cc\
|
||||||
|
# PriorityPieceSelectorTest.cc\
|
||||||
|
# MockPieceSelector.h\
|
||||||
|
# extension_message_test_helper.h\
|
||||||
|
# LpdMessageDispatcherTest.cc\
|
||||||
|
# LpdMessageReceiverTest.cc\
|
||||||
|
# Bencode2Test.cc\
|
||||||
|
# PeerConnectionTest.cc\
|
||||||
|
# ValueBaseBencodeParserTest.cc\
|
||||||
|
# ExtensionMessageRegistryTest.cc\
|
||||||
|
# UDPTrackerClientTest.cc
|
||||||
|
#endif # ENABLE_BITTORRENT
|
||||||
|
#
|
||||||
|
#if ENABLE_METALINK
|
||||||
|
#aria2c_SOURCES += MetalinkerTest.cc\
|
||||||
|
# MetalinkEntryTest.cc\
|
||||||
|
# Metalink2RequestGroupTest.cc\
|
||||||
|
# MetalinkPostDownloadHandlerTest.cc\
|
||||||
|
# MetalinkHelperTest.cc\
|
||||||
|
# MetalinkParserControllerTest.cc\
|
||||||
|
# MetalinkProcessorTest.cc
|
||||||
|
#endif # ENABLE_METALINK
|
||||||
|
#
|
||||||
|
#if ENABLE_ASYNC_DNS
|
||||||
|
#aria2c_SOURCES += AsyncNameResolverTest.cc
|
||||||
|
#endif # ENABLE_ASYNC_DNS
|
||||||
|
#
|
||||||
|
#if !HAVE_TIMEGM
|
||||||
|
#aria2c_SOURCES += TimegmTest.cc
|
||||||
|
#endif # !HAVE_TIMEGM
|
||||||
|
#
|
||||||
|
#if ENABLE_LIBARIA2
|
||||||
|
#aria2c_SOURCES += Aria2ApiTest.cc
|
||||||
|
#endif # ENABLE_LIBARIA2
|
||||||
|
#
|
||||||
|
#aria2c_LDADD = \
|
||||||
|
# ../src/libaria2.la \
|
||||||
|
# @LIBINTL@ \
|
||||||
|
# @EXTRALIBS@ \
|
||||||
|
# @ZLIB_LIBS@ \
|
||||||
|
# @LIBUV_LIBS@ \
|
||||||
|
# @LIBXML2_LIBS@ \
|
||||||
|
# @EXPAT_LIBS@ \
|
||||||
|
# @SQLITE3_LIBS@ \
|
||||||
|
# @WINTLS_LIBS@ \
|
||||||
|
# @LIBGNUTLS_LIBS@ \
|
||||||
|
# @OPENSSL_LIBS@ \
|
||||||
|
# @LIBNETTLE_LIBS@ \
|
||||||
|
# @LIBGMP_LIBS@ \
|
||||||
|
# @LIBGCRYPT_LIBS@ \
|
||||||
|
# @LIBSSH2_LIBS@ \
|
||||||
|
# @LIBCARES_LIBS@ \
|
||||||
|
# @WSLAY_LIBS@ \
|
||||||
|
# @CPPUNIT_LIBS@ \
|
||||||
|
# @TCMALLOC_LIBS@ \
|
||||||
|
# @JEMALLOC_LIBS@
|
||||||
|
#
|
||||||
|
#AM_CPPFLAGS = \
|
||||||
|
# -I$(top_srcdir)/src \
|
||||||
|
# -I$(top_srcdir)/src/includes -I$(top_builddir)/src/includes \
|
||||||
|
# -I$(top_srcdir)/lib -I$(top_srcdir)/intl \
|
||||||
|
# -DLOCALEDIR=\"$(localedir)\" \
|
||||||
|
# -DA2_TEST_DIR=\"$(top_srcdir)/test\" \
|
||||||
|
# -DA2_TEST_OUT_DIR=\"${a2_test_outdir}\" \
|
||||||
|
# @CPPUNIT_CFLAGS@ \
|
||||||
|
# @DEFS@ \
|
||||||
|
# @EXTRACPPFLAGS@ \
|
||||||
|
# @ZLIB_CFLAGS@ \
|
||||||
|
# @LIBUV_CFLAGS@ \
|
||||||
|
# @LIBXML2_CFLAGS@ \
|
||||||
|
# @EXPAT_CFLAGS@ \
|
||||||
|
# @SQLITE3_CFLAGS@ \
|
||||||
|
# @LIBGNUTLS_CFLAGS@ \
|
||||||
|
# @OPENSSL_CFLAGS@ \
|
||||||
|
# @LIBNETTLE_CFLAGS@ \
|
||||||
|
# @LIBGMP_CFLAGS@ \
|
||||||
|
# @LIBGCRYPT_CFLAGS@ \
|
||||||
|
# @LIBSSH2_CFLAGS@ \
|
||||||
|
# @LIBCARES_CFLAGS@ \
|
||||||
|
# @WSLAY_CFLAGS@ \
|
||||||
|
# @TCMALLOC_CFLAGS@ \
|
||||||
|
# @JEMALLOC_CFLAGS@
|
||||||
|
#
|
||||||
|
#AM_LDFLAGS = \
|
||||||
|
# @EXTRALDFLAGS@ \
|
||||||
|
# @APPLETLS_LDFLAGS@
|
||||||
|
#
|
||||||
|
#AM_CFLAGS = @EXTRACFLAGS@
|
||||||
|
#
|
||||||
|
#AM_CXXFLAGS = @WARNCXXFLAGS@ @CXX1XCXXFLAGS@ @EXTRACXXFLAGS@
|
||||||
|
#
|
||||||
|
#EXTRA_DIST = 4096chunk.txt\
|
||||||
|
# chunkChecksumTestFile250.txt\
|
||||||
|
# cookies.sqlite\
|
||||||
|
# chromium_cookies.sqlite\
|
||||||
|
# emptyfile\
|
||||||
|
# file1r.txt\
|
||||||
|
# file2r.txt\
|
||||||
|
# file3r.txt\
|
||||||
|
# filelist1.txt\
|
||||||
|
# filelist2.txt\
|
||||||
|
# gzip_decode_test.gz\
|
||||||
|
# load-nonBt.aria2\
|
||||||
|
# load-nonBt-v0001.aria2\
|
||||||
|
# load.aria2\
|
||||||
|
# load-v0001.aria2\
|
||||||
|
# malformed.netrc\
|
||||||
|
# nscookietest.txt\
|
||||||
|
# sample.netrc\
|
||||||
|
# single.torrent\
|
||||||
|
# test.torrent\
|
||||||
|
# test.xml\
|
||||||
|
# url-list-multiFile.torrent\
|
||||||
|
# url-list-singleFile.torrent\
|
||||||
|
# url-list-singleFileEndsWithSlash.torrent\
|
||||||
|
# input_uris.txt\
|
||||||
|
# 2files.metalink\
|
||||||
|
# utf8.torrent\
|
||||||
|
# metalink4.xml\
|
||||||
|
# metalink3-dirtraversal.xml\
|
||||||
|
# metalink4-groupbymetaurl.xml\
|
||||||
|
# serialize_session.meta4\
|
||||||
|
# metalink4-dosdirtraversal.xml\
|
||||||
|
# base_uri.xml\
|
||||||
|
# local-metaurl.meta4
|
||||||
|
#
|
||||||
|
#clean-local:
|
||||||
|
# -rm -rf ${a2_test_outdir}
|
|
@ -88,7 +88,7 @@ void FileTest::testRemove()
|
||||||
if ((fd = creat(name.c_str(), S_IRUSR | S_IWUSR)) < 0) {
|
if ((fd = creat(name.c_str(), S_IRUSR | S_IWUSR)) < 0) {
|
||||||
CPPUNIT_FAIL("cannot create test file");
|
CPPUNIT_FAIL("cannot create test file");
|
||||||
}
|
}
|
||||||
close(fd);
|
a2_close(fd);
|
||||||
File f(name);
|
File f(name);
|
||||||
CPPUNIT_ASSERT(f.isFile());
|
CPPUNIT_ASSERT(f.isFile());
|
||||||
CPPUNIT_ASSERT(f.remove());
|
CPPUNIT_ASSERT(f.remove());
|
||||||
|
@ -97,7 +97,7 @@ void FileTest::testRemove()
|
||||||
CPPUNIT_ASSERT(!f.remove());
|
CPPUNIT_ASSERT(!f.remove());
|
||||||
|
|
||||||
std::string dir = A2_TEST_OUT_DIR "/aria2_FileTest_testRemove_testdir";
|
std::string dir = A2_TEST_OUT_DIR "/aria2_FileTest_testRemove_testdir";
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
mkdir(dir.c_str());
|
mkdir(dir.c_str());
|
||||||
#else
|
#else
|
||||||
mkdir(dir.c_str(), 0777);
|
mkdir(dir.c_str(), 0777);
|
||||||
|
@ -183,7 +183,7 @@ void FileTest::testGetDirname()
|
||||||
File f("");
|
File f("");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), f.getDirname());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), f.getDirname());
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
{
|
{
|
||||||
File f("c:\\foo\\bar");
|
File f("c:\\foo\\bar");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("c:\\foo"), f.getDirname());
|
CPPUNIT_ASSERT_EQUAL(std::string("c:\\foo"), f.getDirname());
|
||||||
|
@ -221,7 +221,7 @@ void FileTest::testGetBasename()
|
||||||
File f("");
|
File f("");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), f.getBasename());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), f.getBasename());
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
{
|
{
|
||||||
File f("c:\\foo\\bar");
|
File f("c:\\foo\\bar");
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("bar"), f.getBasename());
|
CPPUNIT_ASSERT_EQUAL(std::string("bar"), f.getBasename());
|
||||||
|
|
|
@ -44,7 +44,7 @@ void LpdMessageDispatcherTest::testCreateLpdRequest()
|
||||||
void LpdMessageDispatcherTest::testSendMessage()
|
void LpdMessageDispatcherTest::testSendMessage()
|
||||||
{
|
{
|
||||||
std::shared_ptr<SocketCore> recvsock(new SocketCore(SOCK_DGRAM));
|
std::shared_ptr<SocketCore> recvsock(new SocketCore(SOCK_DGRAM));
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
recvsock->bindWithFamily(LPD_MULTICAST_PORT, AF_INET);
|
recvsock->bindWithFamily(LPD_MULTICAST_PORT, AF_INET);
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
recvsock->bind(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, AF_INET);
|
recvsock->bind(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, AF_INET);
|
||||||
|
|
|
@ -208,7 +208,7 @@ void Metalink2RequestGroupTest::testGenerate_groupByMetaurl()
|
||||||
|
|
||||||
void Metalink2RequestGroupTest::testGenerate_dosDirTraversal()
|
void Metalink2RequestGroupTest::testGenerate_dosDirTraversal()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||||
# ifdef ENABLE_BITTORRENT
|
# ifdef ENABLE_BITTORRENT
|
||||||
std::vector<std::shared_ptr<RequestGroup>> groups;
|
std::vector<std::shared_ptr<RequestGroup>> groups;
|
||||||
option_->put(PREF_DIR, "/tmp");
|
option_->put(PREF_DIR, "/tmp");
|
||||||
|
|
|
@ -96,7 +96,7 @@ void TimeTest::testToHTTPDate()
|
||||||
{
|
{
|
||||||
// This test disabled for MinGW32, because the garbage will be
|
// This test disabled for MinGW32, because the garbage will be
|
||||||
// displayed and it hides real errors.
|
// displayed and it hides real errors.
|
||||||
#ifndef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||||
Time t(1220714793);
|
Time t(1220714793);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("Sat, 06 Sep 2008 15:26:33 GMT"),
|
CPPUNIT_ASSERT_EQUAL(std::string("Sat, 06 Sep 2008 15:26:33 GMT"),
|
||||||
t.toHTTPDate());
|
t.toHTTPDate());
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue