Update networking layer w/ CURL and emscripten impl

This commit is contained in:
2025-11-08 01:50:36 +11:00
parent a17925904d
commit f6874dc55a
4105 changed files with 694617 additions and 179 deletions
+5
View File
@@ -0,0 +1,5 @@
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# SPDX-License-Identifier: curl
allowfunc printf
+78
View File
@@ -0,0 +1,78 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Viktor Szakats, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
option(CURL_COMPLETION_FISH "Install fish completions" OFF)
option(CURL_COMPLETION_ZSH "Install zsh completions" OFF)
if(CURL_COMPLETION_FISH OR
CURL_COMPLETION_ZSH)
if(PERL_FOUND)
if(CURL_COMPLETION_FISH)
set(_completion_fish "${CMAKE_CURRENT_BINARY_DIR}/curl.fish")
add_custom_command(OUTPUT "${_completion_fish}"
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/completion.pl"
--opts-dir "${PROJECT_SOURCE_DIR}/docs/cmdline-opts" --shell fish > "${_completion_fish}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/completion.pl"
VERBATIM
)
add_custom_target("curl-completion-fish" ALL DEPENDS "${_completion_fish}")
endif()
if(CURL_COMPLETION_ZSH)
set(_completion_zsh "${CMAKE_CURRENT_BINARY_DIR}/_curl")
add_custom_command(OUTPUT "${_completion_zsh}"
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/completion.pl"
--opts-dir "${PROJECT_SOURCE_DIR}/docs/cmdline-opts" --shell zsh > "${_completion_zsh}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/completion.pl"
VERBATIM
)
add_custom_target("curl-completion-zsh" ALL DEPENDS "${_completion_zsh}")
endif()
if(NOT CURL_DISABLE_INSTALL)
if(CURL_COMPLETION_FISH)
if(NOT CURL_COMPLETION_FISH_DIR AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_INSTALL_PREFIX)
find_package(PkgConfig QUIET)
pkg_get_variable(CURL_COMPLETION_FISH_DIR "fish" "completionsdir")
endif()
if(NOT CURL_COMPLETION_FISH_DIR AND CMAKE_INSTALL_DATAROOTDIR)
set(CURL_COMPLETION_FISH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d")
endif()
if(CURL_COMPLETION_FISH_DIR)
install(FILES "${_completion_fish}" DESTINATION "${CURL_COMPLETION_FISH_DIR}")
endif()
endif()
if(CURL_COMPLETION_ZSH)
if(NOT CURL_COMPLETION_ZSH_DIR AND CMAKE_INSTALL_DATAROOTDIR)
set(CURL_COMPLETION_ZSH_DIR "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions")
endif()
if(CURL_COMPLETION_ZSH_DIR)
install(FILES "${_completion_zsh}" DESTINATION "${CURL_COMPLETION_ZSH_DIR}")
endif()
endif()
endif()
else()
message(WARNING "No perl: cannot generate completion script")
endif()
endif()
+65
View File
@@ -0,0 +1,65 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl checksrc-all.pl \
mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck \
CMakeLists.txt perlcheck.sh pythonlint.sh randdisable wcurl top-complexity \
extract-unit-protos .checksrc
dist_bin_SCRIPTS = wcurl
if USE_ZSH_COMPLETION
ZSH_COMPLETION_FUNCTION_FILENAME = _curl
endif
if USE_FISH_COMPLETION
FISH_COMPLETION_FUNCTION_FILENAME = curl.fish
endif
CLEANFILES = $(ZSH_COMPLETION_FUNCTION_FILENAME) $(FISH_COMPLETION_FUNCTION_FILENAME)
all-local: $(ZSH_COMPLETION_FUNCTION_FILENAME) $(FISH_COMPLETION_FUNCTION_FILENAME)
if USE_ZSH_COMPLETION
$(ZSH_COMPLETION_FUNCTION_FILENAME): completion.pl
@PERL@ $(srcdir)/completion.pl --opts-dir $(top_srcdir)/docs/cmdline-opts --shell zsh > $@
endif
if USE_FISH_COMPLETION
$(FISH_COMPLETION_FUNCTION_FILENAME): completion.pl
@PERL@ $(srcdir)/completion.pl --opts-dir $(top_srcdir)/docs/cmdline-opts --shell fish > $@
endif
install-data-local:
if USE_ZSH_COMPLETION
$(MKDIR_P) $(DESTDIR)@ZSH_FUNCTIONS_DIR@
$(INSTALL_DATA) $(ZSH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)@ZSH_FUNCTIONS_DIR@/$(ZSH_COMPLETION_FUNCTION_FILENAME)
endif
if USE_FISH_COMPLETION
$(MKDIR_P) $(DESTDIR)@FISH_FUNCTIONS_DIR@
$(INSTALL_DATA) $(FISH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)@FISH_FUNCTIONS_DIR@/$(FISH_COMPLETION_FUNCTION_FILENAME)
endif
distclean:
rm -f $(CLEANFILES)
+626
View File
@@ -0,0 +1,626 @@
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = scripts
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/curl-amissl.m4 \
$(top_srcdir)/m4/curl-apple-sectrust.m4 \
$(top_srcdir)/m4/curl-compilers.m4 \
$(top_srcdir)/m4/curl-confopts.m4 \
$(top_srcdir)/m4/curl-functions.m4 \
$(top_srcdir)/m4/curl-gnutls.m4 \
$(top_srcdir)/m4/curl-mbedtls.m4 \
$(top_srcdir)/m4/curl-openssl.m4 \
$(top_srcdir)/m4/curl-override.m4 \
$(top_srcdir)/m4/curl-reentrant.m4 \
$(top_srcdir)/m4/curl-rustls.m4 \
$(top_srcdir)/m4/curl-schannel.m4 \
$(top_srcdir)/m4/curl-sysconfig.m4 \
$(top_srcdir)/m4/curl-wolfssl.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/xc-am-iface.m4 \
$(top_srcdir)/m4/xc-cc-check.m4 \
$(top_srcdir)/m4/xc-lt-iface.m4 \
$(top_srcdir)/m4/xc-val-flgs.m4 \
$(top_srcdir)/m4/zz40-xc-ovr.m4 \
$(top_srcdir)/m4/zz50-xc-ovr.m4 \
$(top_srcdir)/m4/zz60-xc-ovr.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(dist_bin_SCRIPTS) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/lib/curl_config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(bindir)"
SCRIPTS = $(dist_bin_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
APXS = @APXS@
AR = @AR@
AR_FLAGS = @AR_FLAGS@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BLANK_AT_MAKETIME = @BLANK_AT_MAKETIME@
CADDY = @CADDY@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@
CONFIGURE_OPTIONS = @CONFIGURE_OPTIONS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CURLVERSION = @CURLVERSION@
CURL_CA_BUNDLE = @CURL_CA_BUNDLE@
CURL_CA_EMBED = @CURL_CA_EMBED@
CURL_CFLAG_EXTRAS = @CURL_CFLAG_EXTRAS@
CURL_CPP = @CURL_CPP@
CURL_LIBCURL_VERSIONED_SYMBOLS_PREFIX = @CURL_LIBCURL_VERSIONED_SYMBOLS_PREFIX@
CURL_LIBCURL_VERSIONED_SYMBOLS_SONAME = @CURL_LIBCURL_VERSIONED_SYMBOLS_SONAME@
CURL_NETWORK_AND_TIME_LIBS = @CURL_NETWORK_AND_TIME_LIBS@
CYGPATH_W = @CYGPATH_W@
DANTED = @DANTED@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ENABLE_SHARED = @ENABLE_SHARED@
ENABLE_STATIC = @ENABLE_STATIC@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
FISH_FUNCTIONS_DIR = @FISH_FUNCTIONS_DIR@
GCOV = @GCOV@
GREP = @GREP@
HAVE_LIBZ = @HAVE_LIBZ@
HTTPD = @HTTPD@
HTTPD_NGHTTPX = @HTTPD_NGHTTPX@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LCOV = @LCOV@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCURL_PC_CFLAGS = @LIBCURL_PC_CFLAGS@
LIBCURL_PC_CFLAGS_PRIVATE = @LIBCURL_PC_CFLAGS_PRIVATE@
LIBCURL_PC_LDFLAGS_PRIVATE = @LIBCURL_PC_LDFLAGS_PRIVATE@
LIBCURL_PC_LIBS = @LIBCURL_PC_LIBS@
LIBCURL_PC_LIBS_PRIVATE = @LIBCURL_PC_LIBS_PRIVATE@
LIBCURL_PC_REQUIRES = @LIBCURL_PC_REQUIRES@
LIBCURL_PC_REQUIRES_PRIVATE = @LIBCURL_PC_REQUIRES_PRIVATE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKGCONFIG = @PKGCONFIG@
RANLIB = @RANLIB@
RC = @RC@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SSL_BACKENDS = @SSL_BACKENDS@
STRIP = @STRIP@
SUPPORT_FEATURES = @SUPPORT_FEATURES@
SUPPORT_PROTOCOLS = @SUPPORT_PROTOCOLS@
TEST_NGHTTPX = @TEST_NGHTTPX@
VERSION = @VERSION@
VERSIONNUM = @VERSIONNUM@
VSFTPD = @VSFTPD@
ZLIB_LIBS = @ZLIB_LIBS@
ZSH_FUNCTIONS_DIR = @ZSH_FUNCTIONS_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
libext = @libext@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl checksrc-all.pl \
mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck \
CMakeLists.txt perlcheck.sh pythonlint.sh randdisable wcurl top-complexity \
extract-unit-protos .checksrc
dist_bin_SCRIPTS = wcurl
@USE_ZSH_COMPLETION_TRUE@ZSH_COMPLETION_FUNCTION_FILENAME = _curl
@USE_FISH_COMPLETION_TRUE@FISH_COMPLETION_FUNCTION_FILENAME = curl.fish
CLEANFILES = $(ZSH_COMPLETION_FUNCTION_FILENAME) $(FISH_COMPLETION_FUNCTION_FILENAME)
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu scripts/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-dist_binSCRIPTS: $(dist_bin_SCRIPTS)
@$(NORMAL_INSTALL)
@list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n' \
-e 'h;s|.*|.|' \
-e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) { files[d] = files[d] " " $$1; \
if (++n[d] == $(am__install_max)) { \
print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
else { print "f", d "/" $$4, $$1 } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-dist_binSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 's,.*/,,;$(transform)'`; \
dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir)
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags TAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(SCRIPTS) all-local
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-data-local
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-dist_binSCRIPTS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-dist_binSCRIPTS
.MAKE: install-am install-strip
.PHONY: all all-am all-local check check-am clean clean-generic \
clean-libtool cscopelist-am ctags-am distclean \
distclean-generic distclean-libtool distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-data-local install-dist_binSCRIPTS \
install-dvi install-dvi-am install-exec install-exec-am \
install-html install-html-am install-info install-info-am \
install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags-am uninstall uninstall-am \
uninstall-dist_binSCRIPTS
.PRECIOUS: Makefile
all-local: $(ZSH_COMPLETION_FUNCTION_FILENAME) $(FISH_COMPLETION_FUNCTION_FILENAME)
@USE_ZSH_COMPLETION_TRUE@$(ZSH_COMPLETION_FUNCTION_FILENAME): completion.pl
@USE_ZSH_COMPLETION_TRUE@ @PERL@ $(srcdir)/completion.pl --opts-dir $(top_srcdir)/docs/cmdline-opts --shell zsh > $@
@USE_FISH_COMPLETION_TRUE@$(FISH_COMPLETION_FUNCTION_FILENAME): completion.pl
@USE_FISH_COMPLETION_TRUE@ @PERL@ $(srcdir)/completion.pl --opts-dir $(top_srcdir)/docs/cmdline-opts --shell fish > $@
install-data-local:
@USE_ZSH_COMPLETION_TRUE@ $(MKDIR_P) $(DESTDIR)@ZSH_FUNCTIONS_DIR@
@USE_ZSH_COMPLETION_TRUE@ $(INSTALL_DATA) $(ZSH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)@ZSH_FUNCTIONS_DIR@/$(ZSH_COMPLETION_FUNCTION_FILENAME)
@USE_FISH_COMPLETION_TRUE@ $(MKDIR_P) $(DESTDIR)@FISH_FUNCTIONS_DIR@
@USE_FISH_COMPLETION_TRUE@ $(INSTALL_DATA) $(FISH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)@FISH_FUNCTIONS_DIR@/$(FISH_COMPLETION_FUNCTION_FILENAME)
distclean:
rm -f $(CLEANFILES)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+234
View File
@@ -0,0 +1,234 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
=begin comment
This script updates a curldown file to current/better curldown.
Example: cd2cd [--in-place] <file.md> > <file.md>
--in-place: if used, it replaces the original file with the cleaned up
version. When this is used, cd2cd accepts multiple files to work
on and it ignores errors on single files.
=end comment
=cut
use strict;
use warnings;
my $cd2cd = "0.1"; # to keep check
my $dir;
my $extension;
my $inplace = 0;
while(1) {
if(@ARGV && $ARGV[0] eq "--in-place") {
shift @ARGV;
$inplace = 1;
}
else {
last;
}
}
use POSIX qw(strftime);
my @ts;
if(defined($ENV{SOURCE_DATE_EPOCH})) {
@ts = localtime($ENV{SOURCE_DATE_EPOCH});
} else {
@ts = localtime;
}
my $date = strftime "%B %d %Y", @ts;
sub outseealso {
my (@sa) = @_;
my $comma = 0;
my @o;
push @o, ".SH SEE ALSO\n";
for my $s (sort @sa) {
push @o, sprintf "%s.BR $s", $comma ? ",\n": "";
$comma = 1;
}
push @o, "\n";
return @o;
}
sub single {
my @head;
my @seealso;
my ($f)=@_;
my $title;
my $section;
my $source;
my $start = 0;
my $d;
my $line = 0;
my $salist = 0;
my $copyright;
my $spdx;
open(F, "<:crlf", "$f") ||
return 1;
while(<F>) {
$line++;
$d = $_;
if(!$start) {
if(/^---/) {
# header starts here
$start = 1;
push @head, $d;
}
next;
}
if(/^Title: *(.*)/i) {
$title=$1;
}
elsif(/^Section: *(.*)/i) {
$section=$1;
}
elsif(/^Source: *(.*)/i) {
$source=$1;
}
elsif(/^See-also: +(.*)/i) {
$salist = 0;
push @seealso, $1;
}
elsif(/^See-also: */i) {
if($seealso[0]) {
print STDERR "$f:$line:1:ERROR: bad See-Also, needs list\n";
return 2;
}
$salist = 1;
}
elsif(/^ +- (.*)/i) {
# the only list we support is the see-also
if($salist) {
push @seealso, $1;
}
}
# REUSE-IgnoreStart
elsif(/^C: (.*)/i) {
$copyright=$1;
}
elsif(/^SPDX-License-Identifier: (.*)/i) {
$spdx=$1;
}
# REUSE-IgnoreEnd
elsif(/^---/) {
# end of the header section
if(!$title) {
print STDERR "ERROR: no 'Title:' in $f\n";
return 1;
}
if(!$section) {
print STDERR "ERROR: no 'Section:' in $f\n";
return 2;
}
if(!$seealso[0]) {
print STDERR "$f:$line:1:ERROR: no 'See-also:' present\n";
return 2;
}
if(!$copyright) {
print STDERR "$f:$line:1:ERROR: no 'C:' field present\n";
return 2;
}
if(!$spdx) {
# REUSE-IgnoreStart
print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n";
# REUSE-IgnoreEnd
return 2;
}
last;
}
else {
chomp;
print STDERR "WARN: unrecognized line in $f, ignoring:\n:'$_';"
}
}
if(!$start) {
print STDERR "$f:$line:1:ERROR: no header present\n";
return 2;
}
my @desc;
push @desc, sprintf <<HEAD
---
c: Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: $title
Section: $section
Source: $source
HEAD
;
push @desc, "See-also:\n";
for my $s (sort @seealso) {
push @desc, " - $s\n" if($s);
}
push @desc, "---\n";
my $blankline = 0;
while(<F>) {
$d = $_;
$line++;
if($d =~ /^[ \t]*\n/) {
$blankline++;
}
else {
$blankline = 0;
}
# *italics* for curl symbol links get the asterisks removed
$d =~ s/\*((lib|)curl[^ ]*\(3\))\*/$1/gi;
if(length($d) > 90) {
print STDERR "$f:$line:1:WARN: excessive line length\n";
}
push @desc, $d if($blankline < 2);
}
close(F);
if($inplace) {
open(O, ">$f") || return 1;
print O @desc;
close(O);
}
else {
print @desc;
}
return 0;
}
if($inplace) {
for my $a (@ARGV) {
# this ignores errors
single($a);
}
}
elsif(@ARGV) {
exit single($ARGV[0]);
}
+584
View File
@@ -0,0 +1,584 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
=begin comment
Converts a curldown file to nroff (manpage).
=end comment
=cut
use strict;
use warnings;
my $cd2nroff = "0.1"; # to keep check
my $dir;
my $extension;
my $keepfilename;
while(@ARGV) {
if($ARGV[0] eq "-d") {
shift @ARGV;
$dir = shift @ARGV;
}
elsif($ARGV[0] eq "-e") {
shift @ARGV;
$extension = shift @ARGV;
}
elsif($ARGV[0] eq "-k") {
shift @ARGV;
$keepfilename = 1;
}
elsif($ARGV[0] eq "-h") {
print <<HELP
Usage: cd2nroff [options] [file.md]
-d <dir> Write the output to the file name from the meta-data in the
specified directory, instead of writing to stdout
-e <ext> If -d is used, this option can provide an added "extension", arbitrary
text really, to append to the file name.
-h This help text,
-v Show version then exit
HELP
;
exit 0;
}
elsif($ARGV[0] eq "-v") {
print "cd2nroff version $cd2nroff\n";
exit 0;
}
else {
last;
}
}
use POSIX qw(strftime);
my @ts;
if(defined($ENV{SOURCE_DATE_EPOCH})) {
@ts = gmtime($ENV{SOURCE_DATE_EPOCH});
} else {
@ts = localtime;
}
my $date = strftime "%Y-%m-%d", @ts;
sub outseealso {
my (@sa) = @_;
my $comma = 0;
my @o;
push @o, ".SH SEE ALSO\n";
for my $s (sort @sa) {
push @o, sprintf "%s.BR $s", $comma ? ",\n": "";
$comma = 1;
}
push @o, "\n";
return @o;
}
sub outprotocols {
my (@p) = @_;
my $comma = 0;
my @o;
push @o, ".SH PROTOCOLS\n";
if($p[0] eq "TLS") {
push @o, "This functionality affects all TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.";
}
else {
my @s = sort @p;
push @o, "This functionality affects ";
for my $e (sort @s) {
push @o, sprintf "%s%s",
$comma ? (($e eq $s[-1]) ? " and " : ", "): "",
lc($e);
$comma = 1;
}
if($#s == 0) {
if($s[0] eq "All") {
push @o, " supported protocols";
}
else {
push @o, " only";
}
}
}
push @o, "\n";
return @o;
}
sub outtls {
my (@t) = @_;
my $comma = 0;
my @o;
if($t[0] eq "All") {
push @o, "\nAll TLS backends support this option.";
}
elsif($t[0] eq "none") {
push @o, "\nNo TLS backend supports this option.";
}
else {
push @o, "\nThis option works only with the following TLS backends:\n";
my @s = sort @t;
for my $e (@s) {
push @o, sprintf "%s$e",
$comma ? (($e eq $s[-1]) ? " and " : ", "): "";
$comma = 1;
}
}
push @o, "\n";
return @o;
}
my %knownprotos = (
'DICT' => 1,
'FILE' => 1,
'FTP' => 1,
'FTPS' => 1,
'GOPHER' => 1,
'GOPHERS' => 1,
'HTTP' => 1,
'HTTPS' => 1,
'IMAP' => 1,
'IMAPS' => 1,
'LDAP' => 1,
'LDAPS' => 1,
'MQTT' => 1,
'POP3' => 1,
'POP3S' => 1,
'RTMP' => 1,
'RTMPS' => 1,
'RTSP' => 1,
'SCP' => 1,
'SFTP' => 1,
'SMB' => 1,
'SMBS' => 1,
'SMTP' => 1,
'SMTPS' => 1,
'TELNET' => 1,
'TFTP' => 1,
'WS' => 1,
'WSS' => 1,
'TLS' => 1,
'TCP' => 1,
'QUIC' => 1,
'All' => 1
);
my %knowntls = (
'GnuTLS' => 1,
'mbedTLS' => 1,
'OpenSSL' => 1,
'rustls' => 1,
'Schannel' => 1,
'wolfSSL' => 1,
'All' => 1,
'none' => 1,
);
sub single {
my @seealso;
my @proto;
my @tls;
my $d;
my ($f)=@_;
my $copyright;
my $errors = 0;
my $fh;
my $line;
my $list;
my $tlslist;
my $section;
my $source;
my $addedin;
my $spdx;
my $start = 0;
my $title;
if(defined($f)) {
if(!open($fh, "<:crlf", "$f")) {
print STDERR "cd2nroff failed to open '$f' for reading: $!\n";
return 1;
}
}
else {
$f = "STDIN";
$fh = \*STDIN;
binmode($fh, ":crlf");
}
while(<$fh>) {
$line++;
if(!$start) {
if(/^---/) {
# header starts here
$start = 1;
}
next;
}
if(/^Title: *(.*)/i) {
$title=$1;
}
elsif(/^Section: *(.*)/i) {
$section=$1;
}
elsif(/^Source: *(.*)/i) {
$source=$1;
}
elsif(/^See-also: +(.*)/i) {
$list = 1; # 1 for see-also
push @seealso, $1;
}
elsif(/^See-also: */i) {
if($seealso[0]) {
print STDERR "$f:$line:1:ERROR: bad See-Also, needs list\n";
return 2;
}
$list = 1; # 1 for see-also
}
elsif(/^Protocol:/i) {
$list = 2; # 2 for protocol
}
elsif(/^TLS-backend:/i) {
$list = 3; # 3 for TLS backend
}
elsif(/^Added-in: *(.*)/i) {
$addedin=$1;
if(($addedin !~ /^[0-9.]+[0-9]\z/) &&
($addedin ne "n/a")) {
print STDERR "$f:$line:1:ERROR: invalid version number in Added-in line: $addedin\n";
return 2;
}
}
elsif(/^ +- (.*)/i) {
# the only lists we support are see-also and protocol
if($list == 1) {
push @seealso, $1;
}
elsif($list == 2) {
push @proto, $1;
}
elsif($list == 3) {
push @tls, $1;
}
else {
print STDERR "$f:$line:1:ERROR: list item without owner?\n";
return 2;
}
}
# REUSE-IgnoreStart
elsif(/^C: (.*)/i) {
$copyright=$1;
}
elsif(/^SPDX-License-Identifier: (.*)/i) {
$spdx=$1;
}
# REUSE-IgnoreEnd
elsif(/^---/) {
# end of the header section
if(!$title) {
print STDERR "$f:$line:1:ERROR: no 'Title:' in $f\n";
return 1;
}
if(!$section) {
print STDERR "$f:$line:1:ERROR: no 'Section:' in $f\n";
return 2;
}
if(!$source) {
print STDERR "$f:$line:1:ERROR: no 'Source:' in $f\n";
return 2;
}
if(($source eq "libcurl") && !$addedin) {
print STDERR "$f:$line:1:ERROR: no 'Added-in:' in $f\n";
return 2;
}
if(!$seealso[0]) {
print STDERR "$f:$line:1:ERROR: no 'See-also:' present\n";
return 2;
}
if(!$copyright) {
print STDERR "$f:$line:1:ERROR: no 'C:' field present\n";
return 2;
}
if(!$spdx) {
# REUSE-IgnoreStart
print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n";
# REUSE-IgnoreEnd
return 2;
}
if($section == 3) {
if(!$proto[0]) {
printf STDERR "$f:$line:1:ERROR: missing Protocol:\n";
exit 2;
}
my $tls = 0;
for my $p (@proto) {
if($p eq "TLS") {
$tls = 1;
}
if(!$knownprotos{$p}) {
printf STDERR "$f:$line:1:ERROR: invalid protocol used: $p:\n";
exit 2;
}
}
# This is for TLS, require TLS-backend:
if($tls) {
if(!$tls[0]) {
printf STDERR "$f:$line:1:ERROR: missing TLS-backend:\n";
exit 2;
}
for my $t (@tls) {
if(!$knowntls{$t}) {
printf STDERR "$f:$line:1:ERROR: invalid TLS backend: $t:\n";
exit 2;
}
}
}
}
last;
}
else {
chomp;
print STDERR "$f:$line:1:ERROR: unrecognized header keyword: '$_'\n";
$errors++;
}
}
if(!$start) {
print STDERR "$f:$line:1:ERROR: no header present\n";
return 2;
}
my @desc;
my $quote = 0;
my $blankline = 0;
my $header = 0;
# cut off the leading path from the file name, if any
$f =~ s/^(.*[\\\/])//;
push @desc, ".\\\" generated by cd2nroff $cd2nroff from $f\n";
push @desc, ".TH $title $section \"$date\" $source\n";
while(<$fh>) {
$line++;
$d = $_;
if($quote) {
if($quote == 4) {
# remove the indentation
if($d =~ /^ (.*)/) {
push @desc, "$1\n";
next;
}
else {
# end of quote
$quote = 0;
push @desc, ".fi\n";
next;
}
}
if(/^~~~/) {
# end of quote
$quote = 0;
push @desc, ".fi\n";
next;
}
# convert single backslashes to doubles
$d =~ s/\\/\\\\/g;
# lines starting with a period needs it escaped
$d =~ s/^\./\\&./;
push @desc, $d;
next;
}
# remove single line HTML comments
$d =~ s/<!--.*?-->//g;
# **bold**
$d =~ s/\*\*(\S.*?)\*\*/\\fB$1\\fP/g;
# *italics*
$d =~ s/\*(\S.*?)\*/\\fI$1\\fP/g;
my $back = $d;
# remove all backticked pieces
$back =~ s/\`(.*?)\`//g;
if($back =~ /[^\\][\<\>]/) {
print STDERR "$f:$line:1:ERROR: un-escaped < or > used\n";
$errors++;
}
# convert backslash-'<' or '> to just the second character
$d =~ s/\\([<>])/$1/g;
# mentions of curl symbols with manpages use italics by default
$d =~ s/((lib|)curl([^ ]*\(3\)))/\\fI$1\\fP/gi;
# backticked becomes italics
$d =~ s/\`(.*?)\`/\\fI$1\\fP/g;
if(/^## (.*)/) {
my $word = $1;
# if there are enclosing quotes, remove them first
$word =~ s/[\"\'\`](.*)[\"\'\`]\z/$1/;
# enclose in double quotes if there is a space present
if($word =~ / /) {
push @desc, ".IP \"$word\"\n";
}
else {
push @desc, ".IP $word\n";
}
$header = 1;
}
elsif(/^##/) {
# end of IP sequence
push @desc, ".PP\n";
$header = 1;
}
elsif(/^# (.*)/) {
my $word = $1;
# if there are enclosing quotes, remove them first
$word =~ s/[\"\'](.*)[\"\']\z/$1/;
if($word eq "PROTOCOLS") {
print STDERR "$f:$line:1:WARN: PROTOCOLS section in source file\n";
}
elsif($word eq "AVAILABILITY") {
print STDERR "$f:$line:1:WARN: AVAILABILITY section in source file\n";
}
elsif($word eq "%PROTOCOLS%") {
# insert the generated PROTOCOLS section
push @desc, outprotocols(@proto);
if($proto[0] eq "TLS") {
push @desc, outtls(@tls);
}
$header = 1;
next;
}
elsif($word eq "%AVAILABILITY%") {
if($addedin ne "n/a") {
# insert the generated AVAILABILITY section
push @desc, ".SH AVAILABILITY\n";
push @desc, "Added in curl $addedin\n";
}
$header = 1;
next;
}
push @desc, ".SH $word\n";
$header = 1;
}
elsif(/^~~~c/) {
# start of a code section, not indented
$quote = 1;
push @desc, "\n" if($blankline && !$header);
$header = 0;
push @desc, ".nf\n";
}
elsif(/^~~~/) {
# start of a quote section; not code, not indented
$quote = 1;
push @desc, "\n" if($blankline && !$header);
$header = 0;
push @desc, ".nf\n";
}
elsif(/^ (.*)/) {
# quoted, indented by 4 space
$quote = 4;
push @desc, "\n" if($blankline && !$header);
$header = 0;
push @desc, ".nf\n$1\n";
}
elsif(/^[ \t]*\n/) {
# count and ignore blank lines
$blankline++;
}
else {
# don't output newlines if this is the first content after a
# header
push @desc, "\n" if($blankline && !$header);
$blankline = 0;
$header = 0;
# quote minuses in the output
$d =~ s/([^\\])-/$1\\-/g;
# replace single quotes
$d =~ s/\'/\\(aq/g;
# handle double quotes first on the line
$d =~ s/^(\s*)\"/$1\\&\"/;
# lines starting with a period needs it escaped
$d =~ s/^\./\\&./;
if($d =~ /^(.*) /) {
printf STDERR "$f:$line:%d:ERROR: 2 spaces detected\n",
length($1);
$errors++;
}
if($d =~ /^[ \t]*\n/) {
# replaced away all contents
$blankline= 1;
}
else {
push @desc, $d;
}
}
}
if($fh != \*STDIN) {
close($fh);
}
push @desc, outseealso(@seealso);
if($dir) {
if($keepfilename) {
$title = $f;
$title =~ s/\.[^.]*$//;
}
my $outfile = "$dir/$title.$section";
if(defined($extension)) {
$outfile .= $extension;
}
if(!open(O, ">", $outfile)) {
print STDERR "Failed to open $outfile : $!\n";
return 1;
}
print O @desc;
close(O);
}
else {
print @desc;
}
return $errors;
}
if(@ARGV) {
for my $f (@ARGV) {
my $r = single($f);
if($r) {
exit $r;
}
}
}
else {
exit single();
}
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# provide all dir names to scan on the cmdline
use strict;
use warnings;
sub convert {
my ($dir)=@_;
opendir(my $dh, $dir) || die "could not open $dir";
my @cd = grep { /\.md\z/ && -f "$dir/$_" } readdir($dh);
closedir $dh;
for my $cd (@cd) {
my $nroff = "$cd";
$nroff =~ s/\.md\z/.3/;
print "$dir/$cd = $dir/$nroff\n";
system("./scripts/cd2nroff -d $dir $dir/$cd");
}
}
for my $d (sort @ARGV) {
convert($d);
}
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env perl
# Copyright (C) Viktor Szakats
#
# SPDX-License-Identifier: curl
use strict;
use warnings;
use File::Basename;
use File::Find;
use Cwd 'abs_path';
my @files;
if(system('git rev-parse --is-inside-work-tree >/dev/null 2>&1') == 0) {
@files = `git ls-files '*.[ch]'`;
}
else {
find(sub { if(/\.[ch]$/) { push(@files, $File::Find::name) } }, ('.'));
}
if(@ARGV) {
find(sub { if(/\.[ch]$/) { push(@files, $File::Find::name) } }, @ARGV);
}
@files = grep !/\/CMakeFiles\//, @files;
@files = map { dirname($_) } @files;
my @dirs = sort { $a cmp $b } keys %{{ map { $_ => 1 } @files }};
my $scripts_dir = dirname(abs_path($0));
my $anyfailed = 0;
for my $dir (@dirs) {
@files = glob("$dir/*.[ch]");
if(@files && system("$scripts_dir/checksrc.pl", @files) != 0) {
$anyfailed = 1;
}
}
exit $anyfailed;
File diff suppressed because it is too large Load Diff
+81
View File
@@ -0,0 +1,81 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Dan Fandrich, <dan@coneharvesters.com>, Viktor Szakats, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# https://cmake-format.readthedocs.io/en/latest/cmake-lint.html
# https://cmake-format.readthedocs.io/en/latest/lint-usage.html
# https://github.com/cheshirekow/cmake_format/blob/master/cmakelang/configuration.py
# Run cmakelint on the curl source code. It will check all files given on the
# command-line, or else all relevant files in git, or if not in a git
# repository, all files starting in the tree rooted in the current directory.
#
# cmake-lint can be installed from PyPi with the command "python3 -m pip
# install cmakelang".
#
# The xargs invocation is portable, but does not preserve spaces in file names.
# If such a file is ever added, then this can be portably fixed by switching to
# "xargs -I{}" and appending {} to the end of the xargs arguments (which will
# call cmakelint once per file) or by using the GNU extension "xargs -d'\n'".
set -eu
cd "$(dirname "$0")"/..
{
if [ -n "${1:-}" ]; then
for A in "$@"; do printf "%s\n" "$A"; done
elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
git ls-files
else
# strip off the leading ./ to make the grep regexes work properly
find . -type f | sed 's@^\./@@'
fi
} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in|\.c)$' \
| xargs \
cmake-lint \
--suppress-decorations \
--disable \
--line-width 132 \
--tab-size 2 \
--use-tabchars false \
--disabled-codes C0113 \
--function-pattern 'curl_[0-9a-z_]+' \
--macro-pattern '(curl_[0-9a-z_]+|check_include_file_concat_curl)' \
--global-var-pattern '[A-Z][0-9A-Z_]+' \
--internal-var-pattern '_[a-z][0-9a-z_]+' \
--local-var-pattern '_[a-z][0-9a-z_]+' \
--private-var-pattern '_[0-9a-z_]+' \
--public-var-pattern '([A-Z][0-9A-Z_]+|[A-Z][A-Za-z0-9]+_FOUND|[a-z]+_SOURCES|prefix|exec_prefix|includedir|libdir|ssize_t|_FILE_OFFSET_BITS)' \
--argument-var-pattern '_[a-z][0-9a-z_]+' \
--keyword-pattern '[A-Z][0-9A-Z_]+' \
--max-conditionals-custom-parser 2 \
--min-statement-spacing 1 \
--max-statement-spacing 2 \
--max-returns 6 \
--max-branches 12 \
--max-arguments 5 \
--max-localvars 15 \
--max-statements 50 \
--
+178
View File
@@ -0,0 +1,178 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
use strict;
use warnings;
use Getopt::Long();
use Pod::Usage();
my $opts_dir = '../docs/cmdline-opts';
my $shell = 'zsh';
my $help = 0;
Getopt::Long::GetOptions(
'opts-dir=s' => \$opts_dir,
'shell=s' => \$shell,
'help' => \$help,
) or Pod::Usage::pod2usage();
Pod::Usage::pod2usage() if $help;
my @opts = parse_main_opts($opts_dir);
if($shell eq 'fish') {
print "# curl fish completion\n\n";
print "# Complete file paths after @\n";
print q(complete -c curl -n 'string match -qr "^@" -- (commandline -ct)' -k -xa "(printf '%s\n' -- @(__fish_complete_suffix --complete=(commandline -ct | string replace -r '^@' '') ''))");
print "\n\n";
print qq{$_ \n} foreach (@opts);
} elsif($shell eq 'zsh') {
my $opts_str;
$opts_str .= qq{ $_ \\\n} foreach (@opts);
chomp $opts_str;
my $tmpl = <<"EOS";
#compdef curl
# curl zsh completion
local curcontext="\$curcontext" state state_descr line
typeset -A opt_args
local rc=1
_arguments -C -S \\
$opts_str
'*:URL:_urls' && rc=0
return rc
EOS
print $tmpl;
} else {
die("Unsupported shell: $shell");
}
sub parse_main_opts {
my ($opts_dir) = @_;
my (@files, @list);
my ($dir_handle, $file_content);
opendir($dir_handle, $opts_dir) || die "Unable to open dir: $opts_dir due to error: $!";
@files = readdir($dir_handle);
closedir($dir_handle) || die "Unable to close handle on dir: $opts_dir due to error: $!";
# We want regular files that end with .md and don't start with an underscore
# Edge case: MANPAGE.md doesn't start with an underscore but also isn't documentation for an option
@files = grep { $_ =~ /\.md$/i && !/^_/ && -f "$opts_dir/$_" && $_ ne "MANPAGE.md" } @files;
for my $file (@files) {
open(my $doc_handle, '<', "$opts_dir/$file") || die "Unable to open file: $file due to error: $!";
$file_content = join('', <$doc_handle>);
close($doc_handle) || die "Unable to close file: $file due to error: $!";
# Extract the curldown header section demarcated by ---
$file_content =~ /^---\s*\n(.*?)\n---\s*\n/s || die "Unable to parse file $file";
$file_content = $1;
my ($short, $long, $arg, $desc);
if($file_content =~ /^Short:\s+(.*)\s*$/im) {$short = "-$1";}
if($file_content =~ /^Long:\s+(.*)\s*$/im) {$long = "--$1";}
if($file_content =~ /^Arg:\s+(.*)\s*$/im) {$arg = $1;}
if($file_content =~ /^Help:\s+(.*)\s*$/im) {$desc = $1;}
$arg =~ s/\:/\\\:/g if defined $arg;
$desc =~ s/'/'\\''/g if defined $desc;
$desc =~ s/\[/\\\[/g if defined $desc;
$desc =~ s/\]/\\\]/g if defined $desc;
$desc =~ s/\:/\\\:/g if defined $desc;
my $option = '';
if($shell eq 'fish') {
$option .= "complete --command curl";
$option .= " --short-option '" . strip_dash(trim($short)) . "'"
if defined $short;
$option .= " --long-option '" . strip_dash(trim($long)) . "'"
if defined $long;
$option .= " --description '" . strip_dash(trim($desc)) . "'"
if defined $desc;
} elsif($shell eq 'zsh') {
$option .= '{' . trim($short) . ',' if defined $short;
$option .= trim($long) if defined $long;
$option .= '}' if defined $short;
$option .= '\'[' . trim($desc) . ']\'' if defined $desc;
if(defined $arg) {
$option .= ":'$arg'";
if($arg =~ /<file ?(name)?>|<path>/) {
$option .= ':_files';
} elsif($arg =~ /<dir>/) {
$option .= ":'_path_files -/'";
} elsif($arg =~ /<url>/i) {
$option .= ':_urls';
} elsif($long =~ /ftp/ && $arg =~ /<method>/) {
$option .= ":'(multicwd nocwd singlecwd)'";
} elsif($arg =~ /<method>/) {
$option .= ":'(DELETE GET HEAD POST PUT)'";
}
}
}
push(@list, $option);
}
# Sort longest first, because zsh won't complete an option listed
# after one that's a prefix of it. When length is equal, fall back
# to stringwise cmp.
@list = sort {
$a =~ /([^=]*)/; my $ma = $1;
$b =~ /([^=]*)/; my $mb = $1;
length($mb) <=> length($ma) || $ma cmp $mb
} @list;
return @list;
}
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
sub strip_dash { my $s = shift; $s =~ s/^-+//g; return $s };
__END__
=head1 NAME
completion.pl - Generates tab-completion files for various shells
=head1 SYNOPSIS
completion.pl [options...]
--opts-dir path to cmdline-opts directory
--shell zsh/fish
--help prints this help
=cut
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
set -eu
autoreconf -fi
mkdir -p cvr
cd cvr
../configure --disable-shared --enable-debug --enable-maintainer-mode --enable-code-coverage
make -sj
# the regular test run
make TFLAGS=-n test-nonflaky
# make all allocs/file operations fail
#make TFLAGS=-n test-torture
# do everything event-based
make TFLAGS=-n test-event
lcov -d . -c -o cov.lcov
genhtml cov.lcov --output-directory coverage --title "curl code coverage"
tar -cjf curl-coverage.tar.bz2 coverage
+55
View File
@@ -0,0 +1,55 @@
#!/bin/sh
# docker-maketgz
#
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
set -eu
version="${1:-}"
if [ -z "$version" ]; then
echo "Specify a version number!"
exit
fi
timestamp="${2:-$(date -u +%s)}"
if test -f Makefile; then
make distclean
fi
docker build \
--no-cache \
--build-arg SOURCE_DATE_EPOCH="$timestamp" \
--build-arg UID="$(id -u)" \
--build-arg GID="$(id -g)" \
-t curl/curl .
docker run --rm -u "$(id -u):$(id -g)" \
-v "$(pwd):/usr/src" -w /usr/src curl/curl sh -c "
set -e
autoreconf -fi
./configure --without-ssl --without-libpsl
make -sj8
./scripts/maketgz $version"
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
use strict;
use warnings;
my @proto;
my %inc;
sub scanfile {
my ($file) = @_;
open(F, "<$file") || die "$file failed";
while(<F>) {
if($_ =~ /^UNITTEST .*\);/) {
push @proto, $_;
$inc{$file} = 1;
}
}
close(F);
}
foreach my $f (@ARGV) {
scanfile($f);
}
print <<HEAD
#ifndef UNITTESTPROTOS_H
#define UNITTESTPROTOS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \\| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \\___|\\___/|_| \\_\\_____|
*
* Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* SPDX-License-Identifier: curl
*
* Generated-by: extract-unit-protos
*
***************************************************************************/
HEAD
;
for my $f (sort keys %inc) {
# convert to suitable header file
$f =~ s/\.c/.h/; # .h extension
if(-f $f) {
$f =~ s/.*\///; # cut the path off
print "#include \"$f\"\n";
}
}
for my $p (@proto) {
print $p;
}
print <<FOOT
#endif /* UNITTESTPROTOS_H */
FOOT
;
+65
View File
@@ -0,0 +1,65 @@
#!/bin/sh
# ***************************************************************************
# * _ _ ____ _
# * Project ___| | | | _ \| |
# * / __| | | | |_) | |
# * | (__| |_| | _ <| |___
# * \___|\___/|_| \_\_____|
# *
# * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
# *
# * This software is licensed as described in the file COPYING, which
# * you should have received as part of this distribution. The terms
# * are also available at https://curl.se/docs/copyright.html.
# *
# * You may opt to use, copy, modify, merge, publish, distribute and/or sell
# * copies of the Software, and permit persons to whom the Software is
# * furnished to do so, under the terms of the COPYING file.
# *
# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# * KIND, either express or implied.
# *
# * SPDX-License-Identifier: curl
# *
# ***************************************************************************
# This shell script creates a fresh ca-bundle.crt file for use with libcurl.
# It extracts all ca certs it finds in the local Firefox database and converts
# them all into PEM format.
#
# It uses the "certutil" command line tool from the NSS project to perform the
# conversion. On Debian it comes in the "libnss3-tools" package.
#
set -eu
if [ -d "$HOME/Library/Application Support"/Firefox/Profiles ]; then
db=$(ls -1d "$HOME/Library/Application Support"/Firefox/Profiles/*default*)
else
db=$(ls -1d "$HOME"/.mozilla/firefox/*default*)
fi
out="${1:-}"
if test -z "$out"; then
out="ca-bundle.crt" # use a sensible default
fi
currentdate=$(date)
cat > "$out" <<EOF
##
## Bundle of CA Root Certificates
##
## Converted at: ${currentdate}
## These were converted from the local Firefox directory by the db2pem script.
##
EOF
certutil -L -h 'Builtin Object Token' -d "$db" | \
grep ' *[CcGTPpu]*,[CcGTPpu]*,[CcGTPpu]* *$' | \
sed -e 's/ *[CcGTPpu]*,[CcGTPpu]*,[CcGTPpu]* *$//' -e 's/\(.*\)/"\1"/' | \
sort | \
while read -r nickname; do
echo "$nickname" | sed 's/Builtin Object Token://g'
echo "$nickname" | xargs -I{} certutil -d "$db" -L -a -n {}
done >> "$out"
+246
View File
@@ -0,0 +1,246 @@
#!/bin/sh
# Script to build release-archives with. Note that this requires a checkout
# from git and you should first run autoreconf -fi and build curl once.
#
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
set -eu
export LC_ALL=C
export TZ=UTC
version="${1:-}"
cmd="${2:-}"
if [ -z "$version" ]; then
echo "Specify a version number!"
exit
fi
echo "$cmd"
only=""
if [ "only" = "$cmd" ]; then
echo "Setup version number only!"
only=1
fi
commit=""
if [ "commit" = "$cmd" ]; then
commit=1
fi
libversion="$version"
# we make curl the same version as libcurl
curlversion="$libversion"
major=$(echo "$libversion" | cut -d. -f1 | sed -e "s/[^0-9]//g")
minor=$(echo "$libversion" | cut -d. -f2 | sed -e "s/[^0-9]//g")
patch=$(echo "$libversion" | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g")
if test -z "$patch"; then
echo "invalid version number? needs to be z.y.z"
exit
fi
#
# As a precaution, remove all *.dist files that may be lying around, to reduce
# the risk of old leftovers getting shipped.
echo "removing all old *.dist files"
find . -name "*.dist" -exec rm {} \;
numeric="$(printf "%02x%02x%02x\n" "$major" "$minor" "$patch")"
HEADER=include/curl/curlver.h
CHEADER=src/tool_version.h
if test -z "$only"; then
ext=".dist"
# when not setting up version numbers locally
for a in $HEADER $CHEADER; do
cp "$a" "$a$ext"
done
HEADER="$HEADER$ext"
CHEADER="$CHEADER$ext"
fi
# requires a date command that knows + for format and -d for date input
timestamp=${SOURCE_DATE_EPOCH:-$(date +"%s")}
datestamp=$(date -d "@$timestamp" +"%F")
filestamp=$(date -d "@$timestamp" +"%Y%m%d%H%M.%S")
# Replace version number in header file:
sed -i \
-e "s/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION \"$libversion\"/g" \
-e "s/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x$numeric/g" \
-e "s/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR $major/g" \
-e "s/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR $minor/g" \
-e "s/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH $patch/g" \
-e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
"$HEADER"
# Replace version number in header file:
sed -i "s/#define CURL_VERSION .*/#define CURL_VERSION \"$curlversion\"/g" "$CHEADER"
if test -n "$only"; then
# done!
exit
fi
echo "curl version $curlversion"
echo "libcurl version $libversion"
echo "libcurl numerical $numeric"
echo "datestamp $datestamp"
findprog() {
file="$1"
for part in $(echo "$PATH" | tr ':' ' '); do
path="$part/$file"
if [ -x "$path" ]; then
# there it is!
return 1
fi
done
# no such executable
return 0
}
############################################################################
#
# Enforce a rerun of configure (updates the VERSION)
#
echo "Re-running config.status"
./config.status --recheck >/dev/null
echo "Recreate the built-in manual (with correct version)"
export CURL_MAKETGZ_VERSION="$version"
rm -f docs/cmdline-opts/curl.txt
make -C src
############################################################################
#
# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
# been modified.
#
if { findprog automake >/dev/null 2>/dev/null; } then
echo "- Could not find or run automake, I hope you know what you are doing!"
else
echo "Runs automake --include-deps"
automake --include-deps Makefile >/dev/null
fi
if test -n "$commit"; then
echo "produce docs/tarball-commit.txt"
git rev-parse HEAD >docs/tarball-commit.txt.dist
fi
echo "produce RELEASE-TOOLS.md"
./scripts/release-tools.sh "$timestamp" "$version" "$commit" > docs/RELEASE-TOOLS.md.dist
############################################################################
#
# Now run make dist to generate a tar.gz archive
#
echo "make dist"
targz="curl-$version.tar.gz"
make -sj dist "VERSION=$version"
res=$?
if test "$res" != 0; then
echo "make dist failed"
exit 2
fi
retar() {
tempdir=$1
rm -rf "$tempdir"
mkdir "$tempdir"
cd "$tempdir"
gzip -dc "../$targz" | tar -xf -
find curl-* -depth -exec touch -c -t "$filestamp" '{}' +
tar --create --format=ustar --owner=0 --group=0 --numeric-owner --sort=name curl-* | gzip --best --no-name > out.tar.gz
mv out.tar.gz ../
cd ..
rm -rf "$tempdir"
}
retar ".tarbuild"
echo "replace $targz with out.tar.gz"
mv out.tar.gz "$targz"
############################################################################
#
# Now make a bz2 archive from the tar.gz original
#
bzip2="curl-$version.tar.bz2"
echo "Generating $bzip2"
gzip -dc "$targz" | bzip2 --best > "$bzip2"
############################################################################
#
# Now make an xz archive from the tar.gz original
#
xz="curl-$version.tar.xz"
echo "Generating $xz"
gzip -dc "$targz" | xz -6e - > "$xz"
############################################################################
#
# Now make a zip archive from the tar.gz original
#
makezip() {
rm -rf "$tempdir"
mkdir "$tempdir"
cd "$tempdir"
gzip -dc "../$targz" | tar -xf -
find . | sort | zip -9 -X "$zip" -@ >/dev/null
mv "$zip" ../
cd ..
rm -rf "$tempdir"
}
zip="curl-$version.zip"
echo "Generating $zip"
tempdir=".builddir"
makezip
# Set deterministic timestamp
touch -c -t "$filestamp" "$targz" "$bzip2" "$xz" "$zip"
echo "------------------"
echo "maketgz report:"
echo ""
ls -l "$targz" "$bzip2" "$xz" "$zip"
sha256sum "$targz" "$bzip2" "$xz" "$zip"
echo "Run this:"
echo "gpg -b -a '$targz' && gpg -b -a '$bzip2' && gpg -b -a '$xz' && gpg -b -a '$zip'"
File diff suppressed because it is too large Load Diff
+182
View File
@@ -0,0 +1,182 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
use strict;
use warnings;
my %whitelist = (
'https://curl.se/' => 1,
'https://curl.se/changes.html' => 1,
'https://curl.se/dev/advisory.html' => 1,
'https://curl.se/dev/builds.html' => 1,
'https://curl.se/dev/code-style.html' => 1,
'https://curl.se/dev/contribute.html' => 1,
'https://curl.se/dev/internals.html' => 1,
'https://curl.se/dev/secprocess.html' => 1,
'https://curl.se/dev/sourceactivity.html' => 1,
'https://curl.se/docs/' => 1,
'https://curl.se/docs/bugbounty.html' => 1,
'https://curl.se/docs/caextract.html' => 1,
'https://curl.se/docs/copyright.html' => 1,
'https://curl.se/docs/install.html' => 1,
'https://curl.se/docs/knownbugs.html' => 1,
'https://curl.se/docs/manpage.html' => 1,
'https://curl.se/docs/security.html' => 1,
'https://curl.se/docs/sslcerts.html' => 1,
'https://curl.se/docs/thanks.html' => 1,
'https://curl.se/docs/todo.html' => 1,
'https://curl.se/docs/vulnerabilities.html' => 1,
'https://curl.se/libcurl/' => 1,
'https://curl.se/libcurl/c/CURLOPT_SSLVERSION.html' => 1,
'https://curl.se/libcurl/c/CURLOPT_SSL_CIPHER_LIST.html' => 1,
'https://curl.se/libcurl/c/CURLOPT_TLS13_CIPHERS.html' => 1,
'https://curl.se/libcurl/c/libcurl.html' => 1,
'https://curl.se/logo/curl-logo.svg' => 1,
'https://curl.se/mail/' => 1,
'https://curl.se/mail/etiquette.html' => 1,
'https://curl.se/mail/list.cgi?list=curl-distros' => 1,
'https://curl.se/mail/list.cgi?list=curl-library' => 1,
'https://curl.se/rfc/cookie_spec.html' => 1,
'https://curl.se/rfc/rfc2255.txt' => 1,
'https://curl.se/sponsors.html' => 1,
'https://curl.se/support.html' => 1,
'https://github.com/curl/curl' => 1,
'https://github.com/curl/curl-fuzzer' => 1,
'https://github.com/curl/curl-www' => 1,
'https://github.com/curl/curl/discussions' => 1,
'https://github.com/curl/curl/issues' => 1,
'https://github.com/curl/curl/labels/help%20wanted' => 1,
'https://github.com/curl/curl/pulls' => 1,
);
my %url;
my %flink;
# list all .md files in the repo
my @files=`git ls-files '**.md'`;
sub storelink {
my ($f, $line, $link) = @_;
my $o = $link;
if($link =~ /^\#/) {
# ignore local-only links
return;
}
# cut off any anchor
$link =~ s:\#.*\z::;
if($link =~ /^(https|http):/) {
$url{$link} .= "$f:$line ";
return;
}
# a file link
my $dir = $f;
$dir =~ s:([^/]*\z)::;
if($link =~ s/(^\/)//) {
# link starts with a slash, now removed
$dir = "";
}
else {
while($link =~ s:^\.\.\/::) {
$dir =~ s:([^/]*)\/\z::;
}
}
$flink{"./$dir$link"} .= "$f:$line ";
}
sub findlinks {
my ($f) = @_;
my $line = 1;
open(F, "<:crlf", "$f") ||
return;
while(<F>) {
if(/\]\(([^)]*)/) {
my $link = $1;
#print "$f:$line $link\n";
storelink($f, $line, $link);
}
$line++;
}
close(F);
}
sub checkurl {
my ($url) = @_;
if($whitelist{$url}) {
#print "$url is whitelisted\n";
return 0;
}
print "check $url\n";
my $curlcmd="curl -ILfsm10 --retry 2 --retry-delay 5 -A \"Mozilla/curl.se link-probe\"";
$url =~ s/\+/%2B/g;
if($url =~ /[\"\'\n]/) {
print STDERR "Bad URL in markdown: %s\n", $url{$url};
return 1; # fail
}
my @content = `$curlcmd \"$url\"`;
if(!$content[0]) {
print STDERR "FAIL\n";
return 1; # fail
}
return 0; # ok
}
for my $f (@files) {
chomp $f;
findlinks($f);
}
my $error;
for my $u (sort keys %url) {
my $r = checkurl($u);
if($r) {
for my $f (split(/ /, $url{$u})) {
printf "%s ERROR links to missing URL %s\n", $f, $u;
$error++;
}
}
}
for my $l (sort keys %flink) {
if(! -r $l) {
for my $f (split(/ /, $flink{$l})) {
printf "%s ERROR links to missing file %s\n", $f, $l;
$error++;
}
}
}
exit 1 if($error);
+667
View File
@@ -0,0 +1,667 @@
#!/usr/bin/env perl
# ***************************************************************************
# * _ _ ____ _
# * Project ___| | | | _ \| |
# * / __| | | | |_) | |
# * | (__| |_| | _ <| |___
# * \___|\___/|_| \_\_____|
# *
# * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
# *
# * This software is licensed as described in the file COPYING, which
# * you should have received as part of this distribution. The terms
# * are also available at https://curl.se/docs/copyright.html.
# *
# * You may opt to use, copy, modify, merge, publish, distribute and/or sell
# * copies of the Software, and permit persons to whom the Software is
# * furnished to do so, under the terms of the COPYING file.
# *
# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# * KIND, either express or implied.
# *
# * SPDX-License-Identifier: curl
# *
# ***************************************************************************
# This Perl script creates a fresh ca-bundle.crt file for use with libcurl.
# It downloads certdata.txt from Mozilla's source tree (see URL below),
# then parses certdata.txt and extracts CA Root Certificates into PEM format.
# These are then processed with the OpenSSL commandline tool to produce the
# final ca-bundle.crt file.
# The script is based on the parse-certs script written by Roland Krikava.
# This Perl script works on almost any platform since its only external
# dependency is the OpenSSL commandline tool for optional text listing.
# Hacked by Guenter Knauf.
#
use Encode;
use Getopt::Std;
use MIME::Base64;
use strict;
use warnings;
use vars qw($opt_b $opt_d $opt_f $opt_h $opt_i $opt_k $opt_l $opt_m $opt_n $opt_p $opt_q $opt_s $opt_t $opt_u $opt_v $opt_w);
use List::Util;
use Text::Wrap;
use Time::Local;
my $MOD_SHA = "Digest::SHA";
eval "require $MOD_SHA";
if($@) {
$MOD_SHA = "Digest::SHA::PurePerl";
eval "require $MOD_SHA";
}
eval "require LWP::UserAgent";
my %urls = (
'autoland' => 'https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/autoland/security/nss/lib/ckfw/builtins/certdata.txt',
'beta' => 'https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/beta/security/nss/lib/ckfw/builtins/certdata.txt',
'release' => 'https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/release/security/nss/lib/ckfw/builtins/certdata.txt',
);
$opt_d = 'release';
# If the OpenSSL commandline is not in search path you can configure it here!
my $openssl = 'openssl';
my $version = '1.29';
$opt_w = 76; # default base64 encoded lines length
# default cert types to include in the output (default is to include CAs which
# may issue SSL server certs)
my $default_mozilla_trust_purposes = "SERVER_AUTH";
my $default_mozilla_trust_levels = "TRUSTED_DELEGATOR";
$opt_p = $default_mozilla_trust_purposes . ":" . $default_mozilla_trust_levels;
my @valid_mozilla_trust_purposes = (
"DIGITAL_SIGNATURE",
"NON_REPUDIATION",
"KEY_ENCIPHERMENT",
"DATA_ENCIPHERMENT",
"KEY_AGREEMENT",
"KEY_CERT_SIGN",
"CRL_SIGN",
"SERVER_AUTH",
"CLIENT_AUTH",
"CODE_SIGNING",
"EMAIL_PROTECTION",
"IPSEC_END_SYSTEM",
"IPSEC_TUNNEL",
"IPSEC_USER",
"TIME_STAMPING",
"STEP_UP_APPROVED"
);
my @valid_mozilla_trust_levels = (
"TRUSTED_DELEGATOR", # CAs
"NOT_TRUSTED", # Don't trust these certs.
"MUST_VERIFY_TRUST", # This explicitly tells us that it ISN'T a CA but is
# otherwise ok. In other words, this should tell the
# app to ignore any other sources that claim this is
# a CA.
"TRUSTED" # This cert is trusted, but only for itself and not
# for delegates (i.e. it is not a CA).
);
my $default_signature_algorithms = $opt_s = "MD5";
my @valid_signature_algorithms = (
"MD5",
"SHA1",
"SHA256",
"SHA384",
"SHA512"
);
$0 =~ s@.*(/|\\)@@;
$Getopt::Std::STANDARD_HELP_VERSION = 1;
getopts('bd:fhiklmnp:qs:tuvw:');
if(!defined($opt_d)) {
# to make plain "-d" use not cause warnings, and actually still work
$opt_d = 'release';
}
# Use predefined URL or else custom URL specified on command line.
my $url;
if(defined($urls{$opt_d})) {
$url = $urls{$opt_d};
if(!$opt_k && $url !~ /^https:\/\//i) {
die "The URL for '$opt_d' is not HTTPS. Use -k to override (insecure).\n";
}
}
else {
$url = $opt_d;
}
if($opt_i) {
print ("=" x 78 . "\n");
print "Script Version : $version\n";
print "Perl Version : $]\n";
print "Operating System Name : $^O\n";
print "Getopt::Std.pm Version : ${Getopt::Std::VERSION}\n";
print "Encode::Encoding.pm Version : ${Encode::Encoding::VERSION}\n";
print "MIME::Base64.pm Version : ${MIME::Base64::VERSION}\n";
print "LWP::UserAgent.pm Version : ${LWP::UserAgent::VERSION}\n" if($LWP::UserAgent::VERSION);
print "LWP.pm Version : ${LWP::VERSION}\n" if($LWP::VERSION);
print "Digest::SHA.pm Version : ${Digest::SHA::VERSION}\n" if($Digest::SHA::VERSION);
print "Digest::SHA::PurePerl.pm Version : ${Digest::SHA::PurePerl::VERSION}\n" if($Digest::SHA::PurePerl::VERSION);
print ("=" x 78 . "\n");
}
sub warning_message() {
if($opt_d =~ m/^risk$/i) { # Long Form Warning and Exit
print "Warning: Use of this script may pose some risk:\n";
print "\n";
print " 1) If you use HTTP URLs they are subject to a man in the middle attack\n";
print " 2) Default to 'release', but more recent updates may be found in other trees\n";
print " 3) certdata.txt file format may change, lag time to update this script\n";
print " 4) Generally unwise to blindly trust CAs without manual review & verification\n";
print " 5) Mozilla apps use additional security checks aren't represented in certdata\n";
print " 6) Use of this script will make a security engineer grind his teeth and\n";
print " swear at you. ;)\n";
exit;
} else { # Short Form Warning
print "Warning: Use of this script may pose some risk, -d risk for more details.\n";
}
}
sub HELP_MESSAGE() {
print "Usage:\t${0} [-b] [-d<certdata>] [-f] [-i] [-k] [-l] [-n] [-p<purposes:levels>] [-q] [-s<algorithms>] [-t] [-u] [-v] [-w<l>] [<outputfile>]\n";
print "\t-b\tbackup an existing version of ca-bundle.crt\n";
print "\t-d\tspecify Mozilla tree to pull certdata.txt or custom URL\n";
print "\t\t Valid names are:\n";
print "\t\t ", join( ", ", map { ( $_ =~ m/$opt_d/ ) ? "$_ (default)" : "$_" } sort keys %urls ), "\n";
print "\t-f\tforce rebuild even if certdata.txt is current\n";
print "\t-i\tprint version info about used modules\n";
print "\t-k\tallow URLs other than HTTPS, enable HTTP fallback (insecure)\n";
print "\t-l\tprint license info about certdata.txt\n";
print "\t-m\tinclude meta data in output\n";
print "\t-n\tno download of certdata.txt (to use existing)\n";
print wrap("\t","\t\t", "-p\tlist of Mozilla trust purposes and levels for certificates to include in output. Takes the form of a comma separated list of purposes, a colon, and a comma separated list of levels. (default: $default_mozilla_trust_purposes:$default_mozilla_trust_levels)"), "\n";
print "\t\t Valid purposes are:\n";
print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_mozilla_trust_purposes ) ), "\n";
print "\t\t Valid levels are:\n";
print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_mozilla_trust_levels ) ), "\n";
print "\t-q\tbe really quiet (no progress output at all)\n";
print wrap("\t","\t\t", "-s\tcomma separated list of certificate signatures/hashes to output in plain text mode. (default: $default_signature_algorithms)\n");
print "\t\t Valid signature algorithms are:\n";
print wrap("\t\t ","\t\t ", join( ", ", "ALL", @valid_signature_algorithms ) ), "\n";
print "\t-t\tinclude plain text listing of certificates\n";
print "\t-u\tunlink (remove) certdata.txt after processing\n";
print "\t-v\tbe verbose and print out processed CAs\n";
print "\t-w <l>\twrap base64 output lines after <l> chars (default: ${opt_w})\n";
exit;
}
sub VERSION_MESSAGE() {
print "${0} version ${version} running Perl ${]} on ${^O}\n";
}
warning_message() unless ($opt_q || $url =~ m/^(ht|f)tps:/i );
HELP_MESSAGE() if($opt_h);
sub report($@) {
my $output = shift;
print STDERR $output . "\n" unless $opt_q;
}
sub is_in_list($@) {
my $target = shift;
return defined(List::Util::first { $target eq $_ } @_);
}
# Parses $param_string as a case insensitive comma separated list with optional
# whitespace validates that only allowed parameters are supplied
sub parse_csv_param($$@) {
my $description = shift;
my $param_string = shift;
my @valid_values = @_;
my @values = map {
s/^\s+//; # strip leading spaces
s/\s+$//; # strip trailing spaces
uc $_ # return the modified string as upper case
} split( ',', $param_string );
# Find all values which are not in the list of valid values or "ALL"
my @invalid = grep { !is_in_list($_,"ALL",@valid_values) } @values;
if(scalar(@invalid) > 0) {
# Tell the user which parameters were invalid and print the standard help
# message which will exit
print "Error: Invalid ", $description, scalar(@invalid) == 1 ? ": " : "s: ", join( ", ", map { "\"$_\"" } @invalid ), "\n";
HELP_MESSAGE();
}
@values = @valid_values if(is_in_list("ALL",@values));
return @values;
}
sub sha256 {
my $result;
if($Digest::SHA::VERSION || $Digest::SHA::PurePerl::VERSION) {
open(FILE, $_[0]) or die "Can't open '$_[0]': $!";
binmode(FILE);
$result = $MOD_SHA->new(256)->addfile(*FILE)->hexdigest;
close(FILE);
} else {
# Use OpenSSL command if Perl Digest::SHA modules not available
$result = `"$openssl" dgst -r -sha256 "$_[0]"`;
$result =~ s/^([0-9a-f]{64}) .+/$1/is;
}
return $result;
}
sub oldhash {
my $hash = "";
open(C, "<$_[0]") || return 0;
while(<C>) {
chomp;
if($_ =~ /^\#\# SHA256: (.*)/) {
$hash = $1;
last;
}
}
close(C);
return $hash;
}
if($opt_p !~ m/:/) {
print "Error: Mozilla trust identifier list must include both purposes and levels\n";
HELP_MESSAGE();
}
(my $included_mozilla_trust_purposes_string, my $included_mozilla_trust_levels_string) = split( ':', $opt_p );
my @included_mozilla_trust_purposes = parse_csv_param( "trust purpose", $included_mozilla_trust_purposes_string, @valid_mozilla_trust_purposes );
my @included_mozilla_trust_levels = parse_csv_param( "trust level", $included_mozilla_trust_levels_string, @valid_mozilla_trust_levels );
my @included_signature_algorithms = parse_csv_param( "signature algorithm", $opt_s, @valid_signature_algorithms );
sub should_output_cert(%) {
my %trust_purposes_by_level = @_;
foreach my $level (@included_mozilla_trust_levels) {
# for each level we want to output, see if any of our desired purposes are
# included
return 1 if(defined( List::Util::first { is_in_list( $_, @included_mozilla_trust_purposes ) } @{$trust_purposes_by_level{$level}} ));
}
return 0;
}
my $crt = $ARGV[0] || 'ca-bundle.crt';
(my $txt = $url) =~ s@(.*/|\?.*)@@g;
my $stdout = $crt eq '-';
my $resp;
my $fetched;
my $oldhash = oldhash($crt);
report "SHA256 of old file: $oldhash";
if(!$opt_n) {
report "Downloading $txt ...";
# If we have an HTTPS URL then use curl
if($url =~ /^https:\/\//i) {
my $curl = `curl -V`;
if($curl) {
if($curl =~ /^Protocols:.* https( |$)/m) {
report "Get certdata with curl!";
my $proto = !$opt_k ? "--proto =https" : "";
my $quiet = $opt_q ? "-s" : "";
my @out = `curl -Lw %{response_code} $proto $quiet -o "$txt" "$url"`;
if(!$? && @out && $out[0] == 200) {
$fetched = 1;
report "Downloaded $txt";
}
else {
report "Failed downloading via HTTPS with curl";
if(-e $txt && !unlink($txt)) {
report "Failed to remove '$txt': $!";
}
}
}
else {
report "curl lacks https support";
}
}
else {
report "curl not found";
}
}
# If nothing was fetched then use LWP
if(!$fetched) {
if($url =~ /^https:\/\//i) {
report "Falling back to HTTP";
$url =~ s/^https:\/\//http:\/\//i;
}
if(!$opt_k) {
report "URLs other than HTTPS are disabled by default, to enable use -k";
exit 1;
}
report "Get certdata with LWP!";
if(!defined(${LWP::UserAgent::VERSION})) {
report "LWP is not available (LWP::UserAgent not found)";
exit 1;
}
my $ua = new LWP::UserAgent(agent => "$0/$version");
$ua->env_proxy();
$resp = $ua->mirror($url, $txt);
if($resp && $resp->code eq '304') {
report "Not modified";
exit 0 if -e $crt && !$opt_f;
}
else {
$fetched = 1;
report "Downloaded $txt";
}
if(!$resp || $resp->code !~ /^(?:200|304)$/) {
report "Unable to download latest data: "
. ($resp? $resp->code . ' - ' . $resp->message : "LWP failed");
exit 1 if -e $crt || ! -r $txt;
}
}
}
my $filedate = $resp ? $resp->last_modified : (stat($txt))[9];
my $datesrc = "as of";
if(!$filedate) {
# mxr.mozilla.org gave us a time, hg.mozilla.org does not!
$filedate = time();
$datesrc="downloaded on";
}
# get the hash from the download file
my $newhash= sha256($txt);
if(!$opt_f && $oldhash eq $newhash) {
report "Downloaded file identical to previous run\'s source file. Exiting";
if($opt_u && -e $txt && !unlink($txt)) {
report "Failed to remove $txt: $!\n";
}
exit;
}
report "SHA256 of new file: $newhash";
my $currentdate = scalar gmtime($filedate);
my $format = $opt_t ? "plain text and " : "";
if($stdout) {
open(CRT, '> -') or die "Couldn't open STDOUT: $!\n";
} else {
open(CRT,">$crt.~") or die "Couldn't open $crt.~: $!\n";
}
print CRT <<EOT;
##
## Bundle of CA Root Certificates
##
## Certificate data from Mozilla ${datesrc}: ${currentdate} GMT
##
## Find updated versions here: https://curl.se/docs/caextract.html
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
## file (certdata.txt). This file can be found in the mozilla source tree:
## ${url}
##
## It contains the certificates in ${format}PEM format and therefore
## can be directly used with curl / libcurl / php_curl, or with
## an Apache+mod_ssl webserver for SSL client authentication.
## Just configure this file as the SSLCACertificateFile.
##
## Conversion done with mk-ca-bundle.pl version $version.
## SHA256: $newhash
##
EOT
report "Processing '$txt' ...";
my $caname;
my $certnum = 0;
my $skipnum = 0;
my $start_of_cert = 0;
my $main_block = 0;
my $main_block_name;
my $trust_block = 0;
my $trust_block_name;
my @precert;
my $cka_value;
my $valid = 0;
open(TXT,"$txt") or die "Couldn't open $txt: $!\n";
while(<TXT>) {
if(/\*\*\*\*\* BEGIN LICENSE BLOCK \*\*\*\*\*/) {
print CRT;
print if($opt_l);
while(<TXT>) {
print CRT;
print if($opt_l);
last if(/\*\*\*\*\* END LICENSE BLOCK \*\*\*\*\*/);
}
next;
}
# The input file format consists of blocks of Mozilla objects.
# The blocks are separated by blank lines but may be related.
elsif(/^\s*$/) {
$main_block = 0;
$trust_block = 0;
next;
}
# Each certificate has a main block.
elsif(/^# Certificate "(.*)"/) {
(!$main_block && !$trust_block) or die "Unexpected certificate block";
$main_block = 1;
$main_block_name = $1;
# Reset all other certificate variables.
$trust_block = 0;
$trust_block_name = "";
$valid = 0;
$start_of_cert = 0;
$caname = "";
$cka_value = "";
undef @precert;
next;
}
# Each certificate's main block is followed by a trust block.
elsif(/^# Trust for (?:Certificate )?"(.*)"/) {
(!$main_block && !$trust_block) or die "Unexpected trust block";
$trust_block = 1;
$trust_block_name = $1;
if($main_block_name ne $trust_block_name) {
die "cert name \"$main_block_name\" != trust name \"$trust_block_name\"";
}
next;
}
# Ignore other blocks.
#
# There is a documentation comment block, a BEGINDATA block, and a bunch of
# blocks starting with "# Explicitly Distrust <certname>".
#
# The latter is for certificates that have already been removed and are not
# included. Not all explicitly distrusted certificates are ignored at this
# point, just those without an actual certificate.
elsif(!$main_block && !$trust_block) {
next;
}
elsif(/^#/) {
# The commented lines in a main block are plaintext metadata that describes
# the certificate. Issuer, Subject, Fingerprint, etc.
if($main_block) {
push @precert, $_ if not /^#$/;
if(/^# Not Valid After : (.*)/) {
my $stamp = $1;
use Time::Piece;
# Not Valid After : Thu Sep 30 14:01:15 2021
my $t = Time::Piece->strptime($stamp, "%a %b %d %H:%M:%S %Y");
my $delta = ($t->epoch - time()); # negative means no longer valid
if($delta < 0) {
$skipnum++;
report "Skipping: $main_block_name is not valid anymore" if($opt_v);
$valid = 0;
}
else {
$valid = 1;
}
}
}
next;
}
elsif(!$valid) {
next;
}
chomp;
if($main_block) {
if(/^CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE/) {
!$start_of_cert or die "Duplicate CKO_CERTIFICATE object";
$start_of_cert = 1;
next;
}
elsif(!$start_of_cert) {
next;
}
elsif(/^CKA_LABEL UTF8 \"(.*)\"/) {
($caname eq "") or die "Duplicate CKA_LABEL attribute";
$caname = $1;
if($caname ne $main_block_name) {
die "caname \"$caname\" != cert name \"$main_block_name\"";
}
next;
}
elsif(/^CKA_VALUE MULTILINE_OCTAL/) {
($cka_value eq "") or die "Duplicate CKA_VALUE attribute";
while(<TXT>) {
last if(/^END/);
chomp;
my @octets = split(/\\/);
shift @octets;
for(@octets) {
$cka_value .= chr(oct);
}
}
next;
}
else {
next;
}
}
if(!$trust_block || !$start_of_cert || $caname eq "" || $cka_value eq "") {
die "Certificate extraction failed";
}
my %trust_purposes_by_level;
if(/^CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST/) {
# now scan the trust part to determine how we should trust this cert
while(<TXT>) {
if(/^\s*$/) {
$trust_block = 0;
last;
}
if(/^CKA_TRUST_([A-Z_]+)\s+CK_TRUST\s+CKT_NSS_([A-Z_]+)\s*$/) {
if(!is_in_list($1,@valid_mozilla_trust_purposes)) {
report "Warning: Unrecognized trust purpose for cert: $caname. Trust purpose: $1. Trust Level: $2";
} elsif(!is_in_list($2,@valid_mozilla_trust_levels)) {
report "Warning: Unrecognized trust level for cert: $caname. Trust purpose: $1. Trust Level: $2";
} else {
push @{$trust_purposes_by_level{$2}}, $1;
}
}
}
# Sanity check that an explicitly distrusted certificate only has trust
# purposes with a trust level of NOT_TRUSTED.
#
# Certificate objects that are explicitly distrusted are in a certificate
# block that starts # Certificate "Explicitly Distrust(ed) <certname>",
# where "Explicitly Distrust(ed) " was prepended to the original cert name.
if($caname =~ /distrust/i ||
$main_block_name =~ /distrust/i ||
$trust_block_name =~ /distrust/i) {
my @levels = keys %trust_purposes_by_level;
if(scalar(@levels) != 1 || $levels[0] ne "NOT_TRUSTED") {
die "\"$caname\" must have all trust purposes at level NOT_TRUSTED.";
}
}
if(!should_output_cert(%trust_purposes_by_level)) {
$skipnum ++;
report "Skipping: $caname lacks acceptable trust level" if($opt_v);
} else {
my $encoded = MIME::Base64::encode_base64($cka_value, '');
$encoded =~ s/(.{1,${opt_w}})/$1\n/g;
my $pem = "-----BEGIN CERTIFICATE-----\n"
. $encoded
. "-----END CERTIFICATE-----\n";
print CRT "\n$caname\n";
my $maxStringLength = length(decode('UTF-8', $caname, Encode::FB_CROAK | Encode::LEAVE_SRC));
print CRT ("=" x $maxStringLength . "\n");
if($opt_t) {
foreach my $key (sort keys %trust_purposes_by_level) {
my $string = $key . ": " . join(", ", @{$trust_purposes_by_level{$key}});
print CRT $string . "\n";
}
}
if($opt_m) {
print CRT for @precert;
}
if(!$opt_t) {
print CRT $pem;
} else {
my $pipe = "";
foreach my $hash (@included_signature_algorithms) {
$pipe = "|$openssl x509 -" . $hash . " -fingerprint -noout -inform PEM";
if(!$stdout) {
$pipe .= " >> $crt.~";
close(CRT) or die "Couldn't close $crt.~: $!";
}
open(TMP, $pipe) or die "Couldn't open openssl pipe: $!";
print TMP $pem;
close(TMP) or die "Couldn't close openssl pipe: $!";
if(!$stdout) {
open(CRT, ">>$crt.~") or die "Couldn't open $crt.~: $!";
}
}
$pipe = "|$openssl x509 -text -inform PEM";
if(!$stdout) {
$pipe .= " >> $crt.~";
close(CRT) or die "Couldn't close $crt.~: $!";
}
open(TMP, $pipe) or die "Couldn't open openssl pipe: $!";
print TMP $pem;
close(TMP) or die "Couldn't close openssl pipe: $!";
if(!$stdout) {
open(CRT, ">>$crt.~") or die "Couldn't open $crt.~: $!";
}
}
report "Processed: $caname" if($opt_v);
$certnum++;
}
}
}
close(TXT) or die "Couldn't close $txt: $!\n";
close(CRT) or die "Couldn't close $crt.~: $!\n";
unless($stdout) {
if($opt_b && -e $crt) {
my $bk = 1;
while(-e "$crt.~${bk}~") {
$bk++;
}
rename $crt, "$crt.~${bk}~" or die "Failed to create backup $crt.~$bk}~: $!\n";
} elsif(-e $crt) {
unlink($crt) or die "Failed to remove $crt: $!\n";
}
rename "$crt.~", $crt or die "Failed to rename $crt.~ to $crt: $!\n";
}
if($opt_u && -e $txt && !unlink($txt)) {
report "Failed to remove $txt: $!\n";
}
report "Done ($certnum CA certs processed, $skipnum skipped).";
+78
View File
@@ -0,0 +1,78 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Viktor Szakats
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# Helper script for "unity"-like support in autotools and to bundle up tests
# for both autotools and cmake. It generates the umbrella C source that
# includes the individual source files and tests.
use strict;
use warnings;
if(!@ARGV) {
die "Usage: $0 [--test <tests>] [--include <include-c-sources>]\n";
}
my @src;
my %include;
my $in_include = 0;
my $any_test = 0;
foreach my $src (@ARGV) {
if($src eq "--test") {
$in_include = 0;
}
elsif($src eq "--include") {
$in_include = 1;
}
elsif($in_include) {
$include{$src} = 1;
push @src, $src;
}
else {
push @src, $src;
$any_test = 1;
}
}
print "/* !checksrc! disable COPYRIGHT all */\n\n";
if($any_test) {
print "#include \"first.h\"\n\n";
}
my $tlist = "";
foreach my $src (@src) {
if($src =~ /([a-z0-9_]+)\.c$/) {
my $name = $1;
print "#include \"$src\"\n";
if(not exists $include{$src}) { # register test entry function
$tlist .= " {\"$name\", test_$name},\n";
}
}
}
if($any_test) {
print "\nconst struct entry_s s_entries[] = {\n$tlist {NULL, NULL}\n};\n";
print "\n#include \"first.c\"\n";
}
+197
View File
@@ -0,0 +1,197 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
=begin comment
This script converts an nroff file to curldown
Example: cd2nroff [options] <file.md> > <file.3>
Note: when converting .nf sections, this tool does not know if the
section is code or just regular quotes. It then assumes and uses ~~~c
for code.
=end comment
=cut
use strict;
use warnings;
my $nroff2cd = "0.1"; # to keep check
sub single {
my ($f)=@_;
open(F, "<:crlf", "$f") ||
return 1;
my $line;
my $title;
my $section;
my $source;
my @seealso;
my @desc;
my $header; # non-zero when TH is passed
my $quote = 0; # quote state
while(<F>) {
$line++;
my $d = $_;
if($_ =~ /^.\\\"/) {
# a comment we can ignore
next;
}
if(!$header) {
if($d =~ /.so (.*)/) {
# this is basically an include, so do that
my $f = $1;
# remove leading directory
$f =~ s/(.*?\/)//;
close(F);
open(F, "<:crlf", "$f") || return 1;
}
if($d =~ /^\.TH ([^ ]*) (\d) \"(.*?)\" ([^ \n]*)/) {
# header, this needs to be the first thing after leading comments
$title = $1;
$section = $2;
# date is $3
$source = $4;
# if there are enclosing quotes around source, remove them
$source =~ s/[\"\'](.*)[\"\']\z/$1/;
$header = 1;
print <<HEAD
---
c: Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: $title
Section: $section
Source: $source
HEAD
;
}
next;
}
if($quote) {
if($d =~ /^\.SH/) {
#end of quote without an .fi
$quote = 0;
push @desc, "~~~\n";
}
elsif($d =~ /^\.fi/) {
#end of quote
$quote = 0;
push @desc, "~~~\n";
next;
}
else {
# double-backslashes converted to single ones
$d =~ s/\\\\/\\/g;
push @desc, $d;
next;
}
}
if($d =~ /^\.SH (.*)/) {
my $word = $1;
# if there are enclosing quotes, remove them first
$word =~ s/[\"\'](.*)[\"\']\z/$1/;
if($word eq "SEE ALSO") {
# we just slurp up this section
next;
}
push @desc, "\n# $word\n\n";
}
elsif($d =~ /^\.(RS|RE)/) {
# ignore these
}
elsif($d =~ /^\.IP (.*)/) {
my $word = $1;
# if there are enclosing quotes, remove them first
$word =~ s/[\"\'](.*)[\"\']\z/$1/;
push @desc, "\n## $word\n\n";
}
elsif($d =~ /^\.IP/) {
# .IP with no text we just skip
}
elsif($d =~ /^\.BR (.*)/) {
# only used for SEE ALSO
my $word = $1;
# remove trailing comma
$word =~ s/,\z//;
for my $s (split(/,/, $word)) {
# remove all double quotes
$s =~ s/\"//g;
# tream leading whitespace
$s =~ s/^ +//g;
push @seealso, $s;
}
}
elsif($d =~ /^\.I (.*)/) {
push @desc, "*$1*\n";
}
elsif($d =~ /^\.B (.*)/) {
push @desc, "**$1**\n";
}
elsif($d =~ /^\.nf/) {
push @desc, "~~~c\n";
$quote = 1;
}
else {
# embolden
$d =~ s/\\fB(.*?)\\fP/**$1**/g;
# links to "curl.*()" are left bare since cd2nroff handles them
# specially
$d =~ s/\\fI(curl.*?\(3\))\\fP/$1/ig;
# emphasize
$d =~ s/\\fI(.*?)\\fP/*$1*/g;
# emphasize on a split line
$d =~ s/\\fI/*/g;
# bold on a split line
$d =~ s/\\fB/**/g;
# remove backslash amp
$d =~ s/\\&//g;
# remove backslashes
$d =~ s/\\//g;
# fix single quotes
$d =~ s/\(aq/'/g;
# fix double quotes
$d =~ s/\(dq/\"/g;
push @desc, $d;
}
}
close(F);
print "See-also:\n";
for my $s (sort @seealso) {
print " - $s\n" if($s);
}
print "---\n";
print @desc;
return !$header;
}
if(@ARGV) {
exit single($ARGV[0]);
}
+51
View File
@@ -0,0 +1,51 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Dan Fandrich, <dan@coneharvesters.com>, Viktor Szakats, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# The xargs invocation is portable, but does not preserve spaces in file names.
# If such a file is ever added, then this can be portably fixed by switching to
# "xargs -I{}" and appending {} to the end of the xargs arguments (which will
# call cmakelint once per file) or by using the GNU extension "xargs -d'\n'".
set -eu
cd "$(dirname "$0")"/..
procs=6
command -v nproc >/dev/null && procs="$(nproc)"
echo "parallel: ${procs}"
{
if [ -n "${1:-}" ]; then
for A in "$@"; do printf "%s\n" "$A"; done
elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
{
git ls-files | grep -E '\.(pl|pm)$'
git grep -l -E '^#!/usr/bin/env perl'
} | sort -u
else
# strip off the leading ./ to make the grep regexes work properly
find . -type f \( -name '*.pl' -o -name '*.pm' \) | sed 's@^\./@@'
fi
} | xargs -n 1 -P "${procs}" perl -c -Itests --
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Dan Fandrich, <dan@coneharvesters.com>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# Use ruff to perform a style analysis on all Python code in the supplied
# locations, or all Python files found in the current directory tree by
# default.
ruff check --extend-select=B007,B016,C405,C416,COM818,D200,D213,D204,D401,D415,FURB129,N818,PERF401,PERF403,PIE790,PIE808,PLW0127,Q004,RUF010,SIM101,SIM117,SIM118,TRY400,TRY401 "$@"
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env perl
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# SPDX-License-Identifier: curl
#
# This script makes a "random" build using configure and verifies that it
# builds curl correctly. It randomly adds a number of the available
# --disable-* flags to configure. When it detects a problem the script stops,
# otherwise it continues trying more combinations.
#
# 1. Figure out all existing configure --disable-* options
# 2. Generate random command line using supported options + random TLS
# 3. Run configure (exit if problem)
# 4. run "make -sj10" to build (exit if problem)
# 5. run curl -V (exit if problem)
# 6. GOTO 2
#
# Tips:
#
# - edit the @tls array to include all TLS backends you can build with
# - do a checkout in a ram-based file system
#
use strict;
use warnings;
use List::Util qw/shuffle/;
my @disable;
sub getoptions {
my @all = `./configure --help`;
for my $o (@all) {
chomp $o;
if($o =~ /(--disable-[^ ]*)/) {
if($1 !~ /FEATURE/) {
push @disable, $1;
}
}
}
}
getoptions();
# options to select a TLS
my @tls = ("--with-openssl",
"--with-wolfssl=/home/daniel/build-wolfssl",
"--with-gnutls",
"--with-mbedtls");
do {
# get a random number of disable options
my $num = rand(scalar(@disable) - 2) + 2;
my $c = 0;
my $arg;
for my $d (shuffle @disable) {
$arg .= " $d";
if(++$c >= $num) {
last;
}
}
my @stls = shuffle @tls;
$arg.= " ".$stls[0];
system("make clean");
if(system("./configure $arg")) {
print STDERR "configure problem\n";
print STDERR "./configure $arg\n";
exit 1;
}
if(system("make -sj10")) {
print STDERR "Build problem\n";
print STDERR "./configure $arg\n";
exit 1;
}
if(system("./src/curl -V 2>/dev/null")) {
print STDERR "Running problem\n";
print STDERR "./configure $arg\n";
exit 1;
}
} while(1);
+79
View File
@@ -0,0 +1,79 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
set -eu
# this should ideally be passed in
timestamp=${1:-unknown}
version=${2:-unknown}
tag=$(echo "curl-$version" | tr '.' '_')
commit=${3}
if [ -n "$commit" ] && [ -r "docs/tarball-commit.txt.dist" ]; then
# If commit is given, then the tag likely doesn't actually exist
tag="$(cat docs/tarball-commit.txt.dist)"
fi
cat <<MOO
# Release tools used for curl $version
The following tools and their Debian package version numbers were used to
produce this release tarball.
MOO
if ! command -v dpkg >/dev/null; then
echo "Error: could not find dpkg" >&2
exit 1
fi
debian() {
echo "- $1: $(dpkg -l "$1" | grep ^ii | awk '{print $3}')"
}
debian autoconf
debian automake
debian libtool
debian make
debian perl
debian git
cat <<MOO
# Reproduce the tarball
- Clone the repo and checkout the tag/commit: $tag
- Install the same set of tools + versions as listed above
## Do a standard build
- autoreconf -fi
- ./configure [...]
- make
## Generate the tarball with the same timestamp
- export SOURCE_DATE_EPOCH=$timestamp
- ./scripts/maketgz [version]
MOO
+207
View File
@@ -0,0 +1,207 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include <stdio.h>
#include <curl/curl.h>
/*
* Use this tool to generate an updated table for the Curl_getn_scheme_handler
* function in url.c.
*/
struct detail {
const char *n;
const char *ifdef;
};
static const struct detail scheme[] = {
{"dict", "#ifndef CURL_DISABLE_DICT" },
{"file", "#ifndef CURL_DISABLE_FILE" },
{"ftp", "#ifndef CURL_DISABLE_FTP" },
{"ftps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)" },
{"gopher", "#ifndef CURL_DISABLE_GOPHER" },
{"gophers", "#if defined(USE_SSL) && !defined(CURL_DISABLE_GOPHER)" },
{"http", "#ifndef CURL_DISABLE_HTTP" },
{"https", "#if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)" },
{"imap", "#ifndef CURL_DISABLE_IMAP" },
{"imaps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)" },
{"ldap", "#ifndef CURL_DISABLE_LDAP" },
{"ldaps", "#if !defined(CURL_DISABLE_LDAP) && \\\n"
" !defined(CURL_DISABLE_LDAPS) && \\\n"
" ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \\\n"
" (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))" },
{"mqtt", "#ifndef CURL_DISABLE_MQTT" },
{"pop3", "#ifndef CURL_DISABLE_POP3" },
{"pop3s", "#if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)" },
{"rtmp", "#ifdef USE_LIBRTMP" },
{"rtmpt", "#ifdef USE_LIBRTMP" },
{"rtmpe", "#ifdef USE_LIBRTMP" },
{"rtmpte", "#ifdef USE_LIBRTMP" },
{"rtmps", "#ifdef USE_LIBRTMP" },
{"rtmpts", "#ifdef USE_LIBRTMP" },
{"rtsp", "#ifndef CURL_DISABLE_RTSP" },
{"scp", "#ifdef USE_SSH" },
{"sftp", "#ifdef USE_SSH" },
{"smb", "#if !defined(CURL_DISABLE_SMB) && \\\n"
" defined(USE_CURL_NTLM_CORE) && (SIZEOF_CURL_OFF_T > 4)" },
{"smbs", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMB) && \\\n"
" defined(USE_CURL_NTLM_CORE) && (SIZEOF_CURL_OFF_T > 4)" },
{"smtp", "#ifndef CURL_DISABLE_SMTP" },
{"smtps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)" },
{"telnet", "#ifndef CURL_DISABLE_TELNET" },
{"tftp", "#ifndef CURL_DISABLE_TFTP" },
{"ws",
"#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)" },
{"wss", "#if !defined(CURL_DISABLE_WEBSOCKETS) && \\\n"
" defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)" },
{ NULL, NULL }
};
unsigned int calc(const char *s, int add, int shift)
{
const char *so = s;
unsigned int c = add;
while(*s) {
c <<= shift;
c += *s;
s++;
}
return c;
}
unsigned int num[100];
unsigned int ix[100];
static void showtable(int try, int init, int shift)
{
int nulls = 0;
int i;
for(i = 0; scheme[i].n; ++i)
num[i] = calc(scheme[i].n, init, shift);
for(i = 0; scheme[i].n; ++i)
ix[i] = num[i] % try;
printf("/*\n"
" unsigned int c = %d\n"
" while(l) {\n"
" c <<= %d;\n"
" c += Curl_raw_tolower(*s);\n"
" s++;\n"
" l--;\n"
" }\n"
"*/\n", init, shift);
printf(" static const struct Curl_handler * const protocols[%d] = {", try);
/* generate table */
for(i = 0; i < try; i++) {
int match = 0;
int j;
for(j = 0; scheme[j].n; j++) {
if(ix[j] == i) {
printf("\n");
printf("%s\n", scheme[j].ifdef);
printf(" &Curl_handler_%s,\n", scheme[j].n);
printf("#else\n NULL,\n");
printf("#endif");
match = 1;
nulls = 0;
break;
}
}
if(!match) {
if(!nulls || (nulls > 10)) {
printf("\n ");
nulls = 0;
}
printf(" NULL,", nulls);
nulls++;
}
}
printf("\n };\n");
}
int main(void)
{
int i;
int try;
int besttry = 9999;
int bestadd = 0;
int bestshift = 0;
int add;
int shift;
for(shift = 0; shift < 8; shift++) {
for(add = 0; add < 999; add++) {
for(i = 0; scheme[i].n; ++i) {
unsigned int v = calc(scheme[i].n, add, shift);
int j;
int badcombo = 0;
for(j = 0; j < i; j++) {
if(num[j] == v) {
/*
printf("NOPE: %u is a dupe (%s and %s)\n",
v, scheme[i], scheme[j]);
*/
badcombo = 1;
break;
}
}
if(badcombo)
break;
num[i] = v;
}
#if 0
for(i = 0; scheme[i].n; ++i) {
printf("%u - %s\n", num[i], scheme[i].n);
}
#endif
/* try different remainders to find smallest possible table */
for(try = 28; try < 199; try++) {
int good = 1;
for(i = 0; scheme[i].n; ++i) {
ix[i] = num[i] % try;
}
/* check for dupes */
for(i = 0; scheme[i].n && good; ++i) {
int j;
for(j = 0; j < i; j++) {
if(ix[j] == ix[i]) {
good = 0;
break;
}
}
}
if(good) {
if(try < besttry) {
besttry = try;
bestadd = add;
bestshift = shift;
}
break;
}
}
}
}
showtable(besttry, bestadd, bestshift);
}
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
use strict;
use warnings;
#######################################################################
# Check for a command in the PATH of the test server.
#
sub checkcmd {
my ($cmd)=@_;
my @paths;
if($^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'os2') {
# PATH separator is different
@paths=(split(';', $ENV{'PATH'}));
}
else {
@paths=(split(':', $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
"/sbin", "/usr/bin", "/usr/local/bin");
}
for(@paths) {
if(-x "$_/$cmd" && ! -d "$_/$cmd") {
# executable bit but not a directory!
return "$_/$cmd";
}
}
return "";
}
my $pmccabe = checkcmd("pmccabe");
if(!$pmccabe) {
print "Make sure 'pmccabe' exists in your PATH\n";
exit 1;
}
if(! -r "lib/url.c" || ! -r "lib/urldata.h") {
print "Invoke this script in the curl source tree root\n";
exit 1;
}
my @files;
open(F, "git ls-files '*.c'|");
while(<F>) {
chomp $_;
my $file = $_;
# we can't filter these with git so do it here
if($file =~ /^(lib|src)/) {
push @files, $file;
}
}
my $cmd = "$pmccabe ".join(" ", @files);
my @output=`$cmd`;
# these functions can have these scores, but not higher
my %whitelist = (
);
# functions with complexity above this level causes the function to return error
my $cutoff = 70;
# functions above this complexity level are shown
my $show = 57;
my $error = 0;
my %where;
my %perm;
my $allscore = 0;
my $alllines = 0;
# each line starts with the complexity score
# 142 417 809 1677 1305 src/tool_getparam.c(1677): getparameter
for my $l (@output) {
chomp $l;
if($l =~/^(\d+)\t\d+\t\d+\t\d+\t(\d+)\t([^\(]+).*: ([^ ]*)/) {
my ($score, $len, $path, $func)=($1, $2, $3, $4);
if($score > $show) {
my $allow = 0;
if($whitelist{$func} &&
($score <= $whitelist{$func})) {
$allow = 1;
}
$where{"$path:$func"}=$score;
$perm{"$path:$func"}=$allow;
if(($score > $cutoff) && !$allow) {
$error++;
}
}
$alllines += $len;
$allscore += ($len * $score);
}
}
my $showncutoff;
for my $e (sort {$where{$b} <=> $where{$a}} keys %where) {
if(!$showncutoff &&
($where{$e} <= $cutoff)) {
print "\n---- threshold: $cutoff ----\n\n";
$showncutoff = 1;
}
printf "%-5d %s%s\n", $where{$e}, $e,
$perm{$e} ? " [ALLOWED]": "";
}
printf "\nAverage complexity: %.2f\n", $allscore / $alllines;
exit $error;
+80
View File
@@ -0,0 +1,80 @@
#!/bin/sh
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# This script remakes a provided curl release and verifies that the newly
# built version is identical to the original file.
#
# It is designed to be invoked in a clean directory with the path to the
# release tarball as an argument.
#
set -eu
tarball="${1:-}"
if [ -z "$tarball" ]; then
echo "Provide a curl release tarball name as argument"
exit
fi
i="0"
# shellcheck disable=SC2034
for dl in curl-*; do
i=$((i + 1))
done
if test "$i" -gt 1; then
echo "multiple curl-* entries found, disambiguate please"
exit
fi
mkdir -p _tarballs
rm -rf _tarballs/*
# checksum the original tarball to compare with later
sha256sum "$tarball" >_tarballs/checksum
# extract the release contents
tar xf "$tarball"
curlver=$(grep '#define LIBCURL_VERSION ' curl-*/include/curl/curlver.h | sed 's/[^0-9.]//g')
echo "version $curlver"
timestamp=$(grep -Eo 'SOURCE_DATE_EPOCH=[0-9]*' curl-"$curlver"/docs/RELEASE-TOOLS.md | cut -d= -f2)
pwd=$(pwd)
cd "curl-$curlver"
./configure --without-ssl --without-libpsl
./scripts/dmaketgz "$curlver" "$timestamp"
mv curl-"$curlver"* ../_tarballs/
cd "$pwd"
cd "_tarballs"
# compare the new tarball against the original
sha256sum -c checksum
+348
View File
@@ -0,0 +1,348 @@
#!/bin/sh
# wcurl - a simple wrapper around curl to easily download files.
#
# Requires curl >= 7.46.0 (2015)
#
# Copyright (C) Samuel Henrique <samueloph@debian.org>, Sergio Durigan
# Junior <sergiodj@debian.org> and many contributors, see the AUTHORS
# file.
#
# 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", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 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.
#
# Except as contained in this notice, the name of a copyright holder shall not be
# used in advertising or otherwise to promote the sale, use or other dealings in
# this Software without prior written authorization of the copyright holder.
#
# SPDX-License-Identifier: curl
# Stop on errors and on usage of unset variables.
set -eu
VERSION="2025.11.04"
PROGRAM_NAME="$(basename "$0")"
readonly PROGRAM_NAME
# Display the version.
print_version()
{
cat << _EOF_
${VERSION}
_EOF_
}
# Display the program usage.
usage()
{
cat << _EOF_
${PROGRAM_NAME} -- a simple wrapper around curl to easily download files.
Usage: ${PROGRAM_NAME} <URL>...
${PROGRAM_NAME} [--curl-options <CURL_OPTIONS>]... [--no-decode-filename] [-o|-O|--output <PATH>] [--dry-run] [--] <URL>...
${PROGRAM_NAME} [--curl-options=<CURL_OPTIONS>]... [--no-decode-filename] [--output=<PATH>] [--dry-run] [--] <URL>...
${PROGRAM_NAME} -h|--help
${PROGRAM_NAME} -V|--version
Options:
--curl-options <CURL_OPTIONS>: Specify extra options to be passed when invoking curl. May be
specified more than once.
-o, -O, --output <PATH>: Use the provided output path instead of getting it from the URL. If
multiple URLs are provided, resulting files share the same name with a
number appended to the end (curl >= 7.83.0). If this option is provided
multiple times, only the last value is considered.
--no-decode-filename: Don't percent-decode the output filename, even if the percent-encoding in
the URL was done by wcurl, e.g.: The URL contained whitespace.
--dry-run: Don't actually execute curl, just print what would be invoked.
-V, --version: Print version information.
-h, --help: Print this usage message.
<CURL_OPTIONS>: Any option supported by curl can be set here. This is not used by wcurl; it is
instead forwarded to the curl invocation.
<URL>: URL to be downloaded. Anything that is not a parameter is considered
an URL. Whitespace is percent-encoded and the URL is passed to curl, which
then performs the parsing. May be specified more than once.
_EOF_
}
# Display an error message and bail out.
error()
{
printf "%s\n" "$*" > /dev/stderr
exit 1
}
# Extra curl options provided by the user.
# This is set per-URL for every URL provided.
# Some options are global, but we are erroring on the side of needlessly setting
# them multiple times instead of causing issues with parameters that needs to
# be set per-URL.
CURL_OPTIONS=""
# The URLs to be downloaded.
URLS=""
# Variable used to be set to the percent-decoded filename parsed from the URL, unless
# --output or --no-decode-filename are used.
OUTPUT_PATH=""
HAS_USER_SET_OUTPUT="false"
# The parameters that are passed per-URL to curl.
readonly PER_URL_PARAMETERS="\
--fail \
--globoff \
--location \
--proto-default https \
--remote-time \
--retry 5 "
# Valid percent-encode codes that are considered unsafe to be decoded.
# This is a list of space-separated percent-encoded uppercase
# characters.
# 2F = /
# 5C = \
readonly UNSAFE_PERCENT_ENCODE="2F 5C"
# Whether to invoke curl or not.
DRY_RUN="false"
# Sanitize parameters.
sanitize()
{
if [ -z "${URLS}" ]; then
error "You must provide at least one URL to download."
fi
readonly CURL_OPTIONS URLS DRY_RUN HAS_USER_SET_OUTPUT
}
# Indicate via exit code whether the string given in the first parameter
# consists solely of characters from the string given in the second parameter.
# In other words, it returns 0 if the first parameter only contains characters
# from the second parameter, e.g.: Are $1 characters a subset of $2 characters?
is_subset_of()
{
case "${1}" in
*[!${2}]* | '') return 1 ;;
esac
}
# Indicate via exit code whether the HTML code given in the first
# parameter is safe to be decoded.
is_safe_percent_encode()
{
upper_str=$(printf "%s" "${1}" | tr "[:lower:]" "[:upper:]")
for unsafe in ${UNSAFE_PERCENT_ENCODE}; do
if [ "${unsafe}" = "${upper_str}" ]; then
return 1
fi
done
return 0
}
# Print the given string percent-decoded.
percent_decode()
{
# Encodings of control characters (00-1F) are passed through without decoding.
# Iterate on the input character-by-character, decoding it.
printf "%s\n" "${1}" | fold -w1 | while IFS= read -r decode_out; do
# If character is a "%", read the next character as decode_hex1.
if [ "${decode_out}" = % ] && IFS= read -r decode_hex1; then
decode_out="${decode_out}${decode_hex1}"
# If there's one more character, read it as decode_hex2.
if IFS= read -r decode_hex2; then
decode_out="${decode_out}${decode_hex2}"
# Skip decoding if this is a control character (00-1F).
# Skip decoding if DECODE_FILENAME is not "true".
if [ "${DECODE_FILENAME}" = "true" ] \
&& is_subset_of "${decode_hex1}" "23456789abcdefABCDEF" \
&& is_subset_of "${decode_hex2}" "0123456789abcdefABCDEF" \
&& is_safe_percent_encode "${decode_out}"; then
# Use printf to decode it into octal and then decode it to the final format.
decode_out="$(printf "%b" "\\$(printf %o "0x${decode_hex1}${decode_hex2}")")"
fi
fi
fi
printf %s "${decode_out}"
done
}
# Print the percent-decoded filename portion of the given URL.
get_url_filename()
{
# Remove protocol and query string if present.
hostname_and_path="$(printf %s "${1}" | sed -e 's,^[^/]*//,,' -e 's,?.*$,,')"
# If what remains contains a slash, there's a path; return it percent-decoded.
case "${hostname_and_path}" in
# sed to remove everything preceding the last '/', e.g.: "example/something" becomes "something"
*/*) percent_decode "$(printf %s "${hostname_and_path}" | sed -e 's,^.*/,,')" ;;
esac
# No slash means there was just a hostname and no path; return empty string.
}
# Execute curl with the list of URLs provided by the user.
exec_curl()
{
CMD="curl "
# Store version to check if it supports --no-clobber, --parallel and --parallel-max-host.
curl_version=$($CMD --version | cut -f2 -d' ' | head -n1)
curl_version_major=$(echo "$curl_version" | cut -f1 -d.)
curl_version_minor=$(echo "$curl_version" | cut -f2 -d.)
CURL_NO_CLOBBER=""
CURL_PARALLEL=""
# --no-clobber is only supported since 7.83.0.
# --parallel is only supported since 7.66.0.
# --parallel-max-host is only supported since 8.16.0.
if [ "${curl_version_major}" -ge 8 ]; then
CURL_NO_CLOBBER="--no-clobber"
CURL_PARALLEL="--parallel"
if [ "${curl_version_minor}" -ge 16 ]; then
CURL_PARALLEL="--parallel --parallel-max-host 5"
fi
elif [ "${curl_version_major}" -eq 7 ]; then
if [ "${curl_version_minor}" -ge 83 ]; then
CURL_NO_CLOBBER="--no-clobber"
fi
if [ "${curl_version_minor}" -ge 66 ]; then
CURL_PARALLEL="--parallel"
fi
fi
# Detecting whether we need --parallel. It's easier to rely on
# the shell's argument parsing.
# shellcheck disable=SC2086
set -- $URLS
# If there are less than two URLs, don't set the parallel flag.
if [ "$#" -lt 2 ]; then
CURL_PARALLEL=""
fi
# Start assembling the command.
#
# We use 'set --' here (again) because (a) we don't have arrays on
# POSIX shell, and (b) we need better control over the way we
# split arguments.
#
# shellcheck disable=SC2086
set -- ${CMD} ${CURL_PARALLEL}
NEXT_PARAMETER=""
for url in ${URLS}; do
# If the user did not provide an output path, define one.
if [ "${HAS_USER_SET_OUTPUT}" = "false" ]; then
OUTPUT_PATH="$(get_url_filename "${url}")"
# If we could not get a path from the URL, use the default: index.html.
[ -z "${OUTPUT_PATH}" ] && OUTPUT_PATH=index.html
fi
# shellcheck disable=SC2086
set -- "$@" ${NEXT_PARAMETER} ${PER_URL_PARAMETERS} ${CURL_NO_CLOBBER} --output "${OUTPUT_PATH}" ${CURL_OPTIONS} "${url}"
NEXT_PARAMETER="--next"
done
if [ "${DRY_RUN}" = "false" ]; then
exec "$@"
else
printf "%s\n" "$@"
fi
}
# Default to decoding the output filename
DECODE_FILENAME="true"
# Use "${1-}" in order to avoid errors because of 'set -u'.
while [ -n "${1-}" ]; do
case "${1}" in
--curl-options=*)
opt=$(printf "%s\n" "${1}" | sed 's/^--curl-options=//')
CURL_OPTIONS="${CURL_OPTIONS} ${opt}"
;;
--curl-options)
shift
CURL_OPTIONS="${CURL_OPTIONS} ${1}"
;;
--dry-run)
DRY_RUN="true"
;;
--output=*)
opt=$(printf "%s\n" "${1}" | sed 's/^--output=//')
HAS_USER_SET_OUTPUT="true"
OUTPUT_PATH="${opt}"
;;
-o | -O | --output)
shift
HAS_USER_SET_OUTPUT="true"
OUTPUT_PATH="${1}"
;;
-o* | -O*)
opt=$(printf "%s\n" "${1}" | sed 's/^-[oO]//')
HAS_USER_SET_OUTPUT="true"
OUTPUT_PATH="${opt}"
;;
--no-decode-filename)
DECODE_FILENAME="false"
;;
-h | --help)
usage
exit 0
;;
-V | --version)
print_version
exit 0
;;
--)
# This is the start of the list of URLs.
shift
for url in "$@"; do
# Encode whitespace into %20, since wget supports those URLs.
newurl=$(printf "%s\n" "${url}" | sed 's/ /%20/g')
URLS="${URLS} ${newurl}"
done
break
;;
-*)
error "Unknown option: '$1'."
;;
*)
# This must be a URL.
# Encode whitespace into %20, since wget supports those URLs.
newurl=$(printf "%s\n" "${1}" | sed 's/ /%20/g')
URLS="${URLS} ${newurl}"
;;
esac
shift
done
sanitize
exec_curl