# SPDX-License-Identifier: curl
#
###########################################################################
-# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, TESTFILES variables
+
+# Get BUNDLE, BUNDLE_SRC, CURLX_SRCS, FIRSTFILES, TESTFILES variables
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
+set(_bundle_extra "")
+if(LIB_SELECTED STREQUAL LIB_SHARED)
+ list(APPEND _bundle_extra ${CURLX_SRCS}) # Not exported from the libcurl shared build. Build a copy.
+endif()
+
add_custom_command(
OUTPUT "${BUNDLE_SRC}"
- COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" --test ${TESTFILES}
+ COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl"
+ --include ${_bundle_extra} --test ${TESTFILES}
${CURL_MK_UNITY_OPTION} --srcdir "${CMAKE_CURRENT_SOURCE_DIR}" > "${BUNDLE_SRC}"
DEPENDS
- "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" ${FIRSTFILES} ${TESTFILES}
+ "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
+ ${FIRSTFILES} ${_bundle_extra} ${TESTFILES}
VERBATIM)
add_executable(http-clients EXCLUDE_FROM_ALL "${BUNDLE_SRC}")
add_dependencies(testdeps http-clients)
target_include_directories(http-clients PRIVATE
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
+ "${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
+ "${PROJECT_SOURCE_DIR}/lib/curlx" # for curlx
"${CMAKE_CURRENT_SOURCE_DIR}" # for "first.h"
)
target_link_libraries(http-clients ${LIB_SELECTED} ${CURL_LIBS})
#
# $(top_srcdir)/include is for libcurl's external include files
# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
+# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_builddir)/lib \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/lib/curlx \
-I$(srcdir)
-# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, TESTFILES variables
+# Get BUNDLE, BUNDLE_SRC, CURLX_SRCS, FIRSTFILES, TESTFILES variables
include Makefile.inc
EXTRA_DIST = CMakeLists.txt $(FIRSTFILES) $(TESTFILES)
AM_CPPFLAGS += -DCURL_NO_OLDIES
-$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(TESTFILES)
- @PERL@ $(top_srcdir)/scripts/mk-unity.pl --test $(TESTFILES) > $(BUNDLE_SRC)
+bundle_extra =
+if USE_CPPFLAG_CURL_STATICLIB
+else
+# These are part of the libcurl static lib. Add them here when linking shared.
+bundle_extra += $(CURLX_SRCS)
+endif
+$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(bundle_extra) $(TESTFILES)
+ @PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(bundle_extra) --test $(TESTFILES) > $(BUNDLE_SRC)
noinst_PROGRAMS = $(BUNDLE)
nodist_clients_SOURCES = $(BUNDLE_SRC)
# Files referenced from the bundle source
FIRSTFILES = first.c first.h
+CURLX_SRCS = \
+ ../../../lib/curlx/multibyte.c
+
# All test clients
TESTFILES = \
h2_pausing.c \
* SPDX-License-Identifier: curl
*
***************************************************************************/
-#ifdef HAVE_CONFIG_H
-#include "curl_config.h" /* for CURL_DISABLE_WEBSOCKETS */
-#endif
+#include "curl_setup.h"
typedef int (*entry_func_t)(int, char **);
#include <stdlib.h> /* for calloc(), free(), strtol() */
#include <string.h> /* for strchr(), strcmp() */
-#ifdef _WIN32
-#include <windows.h> /* for Sleep() */
-#define strdup _strdup
-#else
+#ifndef _WIN32
#include <sys/time.h> /* for usleep() */
#include <unistd.h> /* for usleep() */
#endif
#include <cextdecs.h(PROCESS_DELAY_)> /* for usleep() logic */
#endif
-#if defined(_MSC_VER) && (_MSC_VER <= 1700)
-#pragma warning(disable:4127) /* "conditional expression is constant" */
-#endif
-
-#define CURL_ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
-
#define ERR() \
do { \
fprintf(stderr, "something unexpected went wrong - bailing out!\n"); \
(void)data;
if(curl_easy_getinfo(handle->h, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
&totalsize) == CURLE_OK)
- fprintf(stderr, "INFO: [%d] write, Content-Length %"CURL_FORMAT_CURL_OFF_T
- "\n", (int)handle->idx, totalsize);
+ curl_mfprintf(stderr, "INFO: [%d] write, "
+ "Content-Length %" CURL_FORMAT_CURL_OFF_T "\n",
+ (int)handle->idx, totalsize);
if(!handle->resumed) {
++handle->paused;
* re-using a connection */
}
else if(msg->data.result) {
- fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
- ": failed with %d\n", xfer_id, msg->data.result);
+ curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+ ": failed with %d\n", xfer_id, msg->data.result);
goto cleanup;
}
else if(status != 206) {
- fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
- ": wrong http status %ld (expected 206)\n", xfer_id, status);
+ curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+ ": wrong http status %ld (expected 206)\n", xfer_id,
+ status);
goto cleanup;
}
curl_multi_remove_handle(multi, msg->easy_handle);
curl_easy_cleanup(msg->easy_handle);
- fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
- "(%d now running)\n", xfer_id, running_handles);
+ curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
+ "(%d now running)\n", xfer_id, running_handles);
}
}
* re-using a connection */
}
else if(msg->data.result) {
- fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
- ": failed with %d\n", xfer_id, msg->data.result);
+ curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+ ": failed with %d\n", xfer_id, msg->data.result);
goto cleanup;
}
else if(status != 200) {
- fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
- ": wrong http status %ld (expected 200)\n", xfer_id, status);
+ curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+ ": wrong http status %ld (expected 200)\n", xfer_id,
+ status);
goto cleanup;
}
curl_multi_remove_handle(multi, msg->easy_handle);
curl_easy_cleanup(msg->easy_handle);
--ongoing;
- fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
- "(%d now running)\n", xfer_id, running_handles);
+ curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
+ "(%d now running)\n", xfer_id, running_handles);
}
}