Use it from libtests' `first.c` and thus also from units, and tunits.
Also:
- cmake: drop stray `curltool` lib dependency for units.
- units: stop depending on `src` headers.
- tests/server: drop depending on `src` headers.
(the remaining one listed in the comments, `tool_xattr.h`, was not
actually used from servers.)
- tests/server: drop duplicate curlx headers.
(Except `warnless.h`, which is tricky on Windows.)
Closes #17672
curlx/winapi.c
LIB_CURLX_HFILES = \
+ curlx/binmode.h \
curlx/base64.h \
curlx/curlx.h \
curlx/dynbuf.h \
* SPDX-License-Identifier: curl
*
***************************************************************************/
-#include "tool_setup.h"
+#include "../curl_setup.h"
#if (defined(HAVE_SETMODE) || defined(HAVE__SETMODE)) && defined(O_BINARY)
/* Requires io.h and/or fcntl.h when available */
#ifdef HAVE__SETMODE
-# define CURL_SET_BINMODE(stream) (void)_setmode(fileno(stream), O_BINARY)
+# define CURLX_SET_BINMODE(stream) (void)_setmode(fileno(stream), O_BINARY)
#else
-# define CURL_SET_BINMODE(stream) (void)setmode(fileno(stream), O_BINARY)
+# define CURLX_SET_BINMODE(stream) (void)setmode(fileno(stream), O_BINARY)
#endif
#else
-# define CURL_SET_BINMODE(stream) (void)stream; tool_nop_stmt
+# define CURLX_SET_BINMODE(stream) (void)stream; Curl_nop_stmt
#endif
#endif /* HEADER_CURL_TOOL_BINMODE_H */
* be.
*/
+#include "binmode.h"
+/* "binmode.h" provides macro CURLX_SET_BINMODE() */
+
#include "nonblock.h"
/* "nonblock.h" provides curlx_nonblock() */
../lib/curlx/warnless.c
CURLX_HFILES = \
+ ../lib/curlx/binmode.h \
../lib/curlx/multibyte.h \
../lib/curl_setup.h \
../lib/curlx/dynbuf.h \
config2setopts.h \
slist_wc.h \
terminal.h \
- tool_binmode.h \
tool_bname.h \
tool_cb_dbg.h \
tool_cb_hdr.h \
#include "tool_cfgable.h"
#include "tool_msgs.h"
-#include "tool_binmode.h"
#include "tool_getparam.h"
#include "tool_paramhlp.h"
#include "tool_formparse.h"
curl_off_t origin;
struct_stat sbuf;
- CURL_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdin);
origin = ftell(stdin);
/* If stdin is a regular file, do not buffer data but read it
when needed. */
#include "tool_setup.h"
#include <curlx.h>
-#include "tool_binmode.h"
#include "tool_cfgable.h"
#include "tool_cb_prg.h"
#include "tool_filetime.h"
/* a '@' letter, it means that a filename or - (stdin) follows */
if(!strcmp("-", p)) {
file = stdin;
- CURL_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdin);
}
else {
file = fopen(p, "rb");
if(!strcmp("-", nextarg)) {
file = stdin;
if(cmd == C_DATA_BINARY) /* forced data-binary */
- CURL_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdin);
}
else {
file = fopen(nextarg, "rb");
#include <curlx.h>
-#include "tool_binmode.h"
#include "tool_cfgable.h"
#include "tool_cb_dbg.h"
#include "tool_cb_hdr.h"
}
else {
/* always use binary mode for protocol header output */
- CURL_SET_BINMODE(etag_save->stream);
+ CURLX_SET_BINMODE(etag_save->stream);
}
return CURLE_OK;
}
if(!strcmp(config->headerfile, "%")) {
heads->stream = stderr;
/* use binary mode for protocol header output */
- CURL_SET_BINMODE(heads->stream);
+ CURLX_SET_BINMODE(heads->stream);
}
else if(strcmp(config->headerfile, "-")) {
FILE *newfile;
}
else {
/* always use binary mode for protocol header output */
- CURL_SET_BINMODE(heads->stream);
+ CURLX_SET_BINMODE(heads->stream);
}
return CURLE_OK;
}
DEBUGASSERT(per->infdopen == FALSE);
DEBUGASSERT(per->infd == STDIN_FILENO);
- CURL_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdin);
if(!strcmp(per->uploadfile, ".")) {
if(curlx_nonblock((curl_socket_t)per->infd, TRUE) < 0)
warnf(global,
!config->use_ascii) {
/* We get the output to stdout and we have not got the ASCII/text
flag, then set stdout to be binary */
- CURL_SET_BINMODE(stdout);
+ CURLX_SET_BINMODE(stdout);
}
/* explicitly passed to stdout means okaying binary gunk */
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
"${PROJECT_SOURCE_DIR}/lib/curlx" # for curlx
- "${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h"
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
"${PROJECT_SOURCE_DIR}/tests/unit" # for "curlcheck.h"
)
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/curlx \
- -I$(top_srcdir)/src \
-I$(srcdir) \
-I$(top_srcdir)/tests/unit
#include "memdebug.h"
#include "curlx/timediff.h"
-#include "tool_binmode.h"
+#include "curlx/binmode.h"
int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv)
char *env;
size_t tmp;
- CURL_SET_BINMODE(stdout);
+ CURLX_SET_BINMODE(stdout);
memory_tracking_init();
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
"${PROJECT_SOURCE_DIR}/lib/curlx" # for curlx
- "${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h", "tool_xattr.h"
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
)
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "WITHOUT_LIBCURL")
# $(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
-# $(top_srcdir)/src for "tool_binmode.h", "tool_xattr.h"
# $(srcdir) for the generated bundle source to find included test sources
AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/curlx \
- -I$(top_srcdir)/src \
-I$(srcdir)
# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, UTILS, CURLX_SRCS, TESTFILES variables
#include <curlx.h> /* from the private lib dir */
#include "getpart.h"
-#include "tool_binmode.h"
-
/* include memdebug.h last */
#include <memdebug.h>
return 2;
#endif
- CURL_SET_BINMODE(stdin);
- CURL_SET_BINMODE(stdout);
- CURL_SET_BINMODE(stderr);
+ CURLX_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdout);
+ CURLX_SET_BINMODE(stderr);
install_signal_handlers(FALSE);
#endif
#include <curlx.h> /* from the private lib dir */
-#include "inet_pton.h"
-#include "timediff.h"
#include "warnless.h" /* for read() */
-#include "tool_binmode.h"
-
/* include memdebug.h last */
#include <memdebug.h>
return 2;
#endif
- CURL_SET_BINMODE(stdin);
- CURL_SET_BINMODE(stdout);
- CURL_SET_BINMODE(stderr);
+ CURLX_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdout);
+ CURLX_SET_BINMODE(stderr);
install_signal_handlers(false);
#endif
#include <curlx.h> /* from the private lib dir */
-#include "inet_pton.h"
-#include "tool_binmode.h"
/* include memdebug.h last */
#include <memdebug.h>
return 2;
#endif
- CURL_SET_BINMODE(stdin);
- CURL_SET_BINMODE(stdout);
- CURL_SET_BINMODE(stderr);
+ CURLX_SET_BINMODE(stdin);
+ CURLX_SET_BINMODE(stdout);
+ CURLX_SET_BINMODE(stderr);
install_signal_handlers(false);
#include <curlx.h> /* from the private lib dir */
#include "getpart.h"
-#include "inet_pton.h"
/* include memdebug.h last */
#include <memdebug.h>
add_executable(${BUNDLE} EXCLUDE_FROM_ALL ${UTILS} "${BUNDLE_SRC}")
add_dependencies(testdeps ${BUNDLE})
-target_link_libraries(${BUNDLE} curltool curlu)
+target_link_libraries(${BUNDLE} curlu)
target_include_directories(${BUNDLE} PRIVATE
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
"${PROJECT_SOURCE_DIR}/lib/curlx" # for curlx
- "${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h"
"${PROJECT_SOURCE_DIR}/tests/libtest" # for "first.h"
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
)
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/curlx \
- -I$(top_srcdir)/src \
-I$(top_srcdir)/tests/libtest \
-I$(srcdir)