diff options
Diffstat (limited to 'docs/examples')
135 files changed, 1630 insertions, 670 deletions
diff --git a/docs/examples/10-at-a-time.c b/docs/examples/10-at-a-time.c index 1739a9e78..607775058 100644 --- a/docs/examples/10-at-a-time.c +++ b/docs/examples/10-at-a-time.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -29,7 +29,7 @@ #include <errno.h> #include <stdlib.h> #include <string.h> -#ifndef WIN32 +#ifndef _WIN32 # include <unistd.h> #endif #include <curl/curl.h> @@ -95,13 +95,14 @@ static size_t write_cb(char *data, size_t n, size_t l, void *userp) return n*l; } -static void add_transfer(CURLM *cm, int i) +static void add_transfer(CURLM *cm, int i, int *left) { CURL *eh = curl_easy_init(); curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, write_cb); curl_easy_setopt(eh, CURLOPT_URL, urls[i]); curl_easy_setopt(eh, CURLOPT_PRIVATE, urls[i]); curl_multi_add_handle(cm, eh); + (*left)++; } int main(void) @@ -110,7 +111,7 @@ int main(void) CURLMsg *msg; unsigned int transfers = 0; int msgs_left = -1; - int still_alive = 1; + int left = 0; curl_global_init(CURL_GLOBAL_ALL); cm = curl_multi_init(); @@ -118,10 +119,12 @@ int main(void) /* Limit the amount of simultaneous connections curl should allow: */ curl_multi_setopt(cm, CURLMOPT_MAXCONNECTS, (long)MAX_PARALLEL); - for(transfers = 0; transfers < MAX_PARALLEL; transfers++) - add_transfer(cm, transfers); + for(transfers = 0; transfers < MAX_PARALLEL && transfers < NUM_URLS; + transfers++) + add_transfer(cm, transfers, &left); do { + int still_alive = 1; curl_multi_perform(cm, &still_alive); while((msg = curl_multi_info_read(cm, &msgs_left))) { @@ -133,17 +136,18 @@ int main(void) msg->data.result, curl_easy_strerror(msg->data.result), url); curl_multi_remove_handle(cm, e); curl_easy_cleanup(e); + left--; } else { fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg); } if(transfers < NUM_URLS) - add_transfer(cm, transfers++); + add_transfer(cm, transfers++, &left); } - if(still_alive) + if(left) curl_multi_wait(cm, NULL, 0, 1000, NULL); - } while(still_alive || (transfers < NUM_URLS)); + } while(left); curl_multi_cleanup(cm); curl_global_cleanup(); diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am index 6759d97f1..80ccc5925 100644 --- a/docs/examples/Makefile.am +++ b/docs/examples/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 @@ -24,8 +24,8 @@ AUTOMAKE_OPTIONS = foreign nostdinc -EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.m32 \ - makefile.dj $(COMPLICATED_EXAMPLES) .checksrc +EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.mk \ + $(COMPLICATED_EXAMPLES) .checksrc # Specify our include paths here, and do it relative to $(top_srcdir) and # $(top_builddir), to ensure that these paths which belong to the library @@ -34,7 +34,8 @@ EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.m32 \ # # $(top_srcdir)/include is for libcurl's external include files -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include \ + -DCURL_DISABLE_DEPRECATION LIBDIR = $(top_builddir)/lib diff --git a/docs/examples/Makefile.example b/docs/examples/Makefile.example index b05ca8ee1..b10cdecf5 100644 --- a/docs/examples/Makefile.example +++ b/docs/examples/Makefile.example @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 @@ -34,7 +34,7 @@ CC = gcc # Compiler flags, -g for debug, -c to make an object file CFLAGS = -c -g -# This should point to a directory that holds libcurl, if it isn't +# This should point to a directory that holds libcurl, if it is not # in the system's standard lib dir # We also set a -L to include the directory where we have the openssl # libraries diff --git a/docs/examples/Makefile.in b/docs/examples/Makefile.in index dc32d817a..9286442ab 100644 --- a/docs/examples/Makefile.in +++ b/docs/examples/Makefile.in @@ -21,7 +21,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 @@ -45,7 +45,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 @@ -138,13 +138,14 @@ host_triplet = @host@ @USE_CPPFLAG_CURL_STATICLIB_TRUE@am__append_1 = -DCURL_STATICLIB check_PROGRAMS = 10-at-a-time$(EXEEXT) altsvc$(EXEEXT) \ anyauthput$(EXEEXT) certinfo$(EXEEXT) chkspeed$(EXEEXT) \ - cookie_interface$(EXEEXT) debug$(EXEEXT) \ - externalsocket$(EXEEXT) fileupload$(EXEEXT) \ - ftp-wildcard$(EXEEXT) ftpget$(EXEEXT) ftpgetinfo$(EXEEXT) \ - ftpgetresp$(EXEEXT) ftpsget$(EXEEXT) ftpupload$(EXEEXT) \ - ftpuploadfrommem$(EXEEXT) ftpuploadresume$(EXEEXT) \ - getinfo$(EXEEXT) getinmemory$(EXEEXT) getredirect$(EXEEXT) \ - getreferrer$(EXEEXT) headerapi$(EXEEXT) http-post$(EXEEXT) \ + connect-to$(EXEEXT) cookie_interface$(EXEEXT) debug$(EXEEXT) \ + default-scheme$(EXEEXT) externalsocket$(EXEEXT) \ + fileupload$(EXEEXT) ftp-wildcard$(EXEEXT) ftpget$(EXEEXT) \ + ftpgetinfo$(EXEEXT) ftpgetresp$(EXEEXT) ftpsget$(EXEEXT) \ + ftpupload$(EXEEXT) ftpuploadfrommem$(EXEEXT) \ + ftpuploadresume$(EXEEXT) getinfo$(EXEEXT) getinmemory$(EXEEXT) \ + getredirect$(EXEEXT) getreferrer$(EXEEXT) headerapi$(EXEEXT) \ + hsts-preload$(EXEEXT) http-options$(EXEEXT) http-post$(EXEEXT) \ http2-download$(EXEEXT) http2-pushinmemory$(EXEEXT) \ http2-serverpush$(EXEEXT) http2-upload$(EXEEXT) http3$(EXEEXT) \ http3-present$(EXEEXT) httpcustomheader$(EXEEXT) \ @@ -154,24 +155,27 @@ check_PROGRAMS = 10-at-a-time$(EXEEXT) altsvc$(EXEEXT) \ imap-examine$(EXEEXT) imap-fetch$(EXEEXT) imap-list$(EXEEXT) \ imap-lsub$(EXEEXT) imap-multi$(EXEEXT) imap-noop$(EXEEXT) \ imap-search$(EXEEXT) imap-ssl$(EXEEXT) imap-store$(EXEEXT) \ - imap-tls$(EXEEXT) multi-app$(EXEEXT) \ - multi-debugcallback$(EXEEXT) multi-double$(EXEEXT) \ - multi-formadd$(EXEEXT) multi-legacy$(EXEEXT) \ - multi-post$(EXEEXT) multi-single$(EXEEXT) parseurl$(EXEEXT) \ - persistent$(EXEEXT) pop3-authzid$(EXEEXT) pop3-dele$(EXEEXT) \ - pop3-list$(EXEEXT) pop3-multi$(EXEEXT) pop3-noop$(EXEEXT) \ - pop3-retr$(EXEEXT) pop3-ssl$(EXEEXT) pop3-stat$(EXEEXT) \ - pop3-tls$(EXEEXT) pop3-top$(EXEEXT) pop3-uidl$(EXEEXT) \ - post-callback$(EXEEXT) postinmemory$(EXEEXT) postit2$(EXEEXT) \ + imap-tls$(EXEEXT) interface$(EXEEXT) ipv6$(EXEEXT) \ + keepalive$(EXEEXT) localport$(EXEEXT) maxconnects$(EXEEXT) \ + multi-app$(EXEEXT) multi-debugcallback$(EXEEXT) \ + multi-double$(EXEEXT) multi-formadd$(EXEEXT) \ + multi-legacy$(EXEEXT) multi-post$(EXEEXT) \ + multi-single$(EXEEXT) parseurl$(EXEEXT) persistent$(EXEEXT) \ + pop3-authzid$(EXEEXT) pop3-dele$(EXEEXT) pop3-list$(EXEEXT) \ + pop3-multi$(EXEEXT) pop3-noop$(EXEEXT) pop3-retr$(EXEEXT) \ + pop3-ssl$(EXEEXT) pop3-stat$(EXEEXT) pop3-tls$(EXEEXT) \ + pop3-top$(EXEEXT) pop3-uidl$(EXEEXT) post-callback$(EXEEXT) \ + postinmemory$(EXEEXT) postit2$(EXEEXT) \ postit2-formadd$(EXEEXT) progressfunc$(EXEEXT) \ - resolve$(EXEEXT) sendrecv$(EXEEXT) sepheaders$(EXEEXT) \ - sftpget$(EXEEXT) sftpuploadresume$(EXEEXT) \ - shared-connection-cache$(EXEEXT) simple$(EXEEXT) \ - simplepost$(EXEEXT) simplessl$(EXEEXT) smtp-authzid$(EXEEXT) \ - smtp-expn$(EXEEXT) smtp-mail$(EXEEXT) smtp-mime$(EXEEXT) \ - smtp-multi$(EXEEXT) smtp-ssl$(EXEEXT) smtp-tls$(EXEEXT) \ - smtp-vrfy$(EXEEXT) sslbackend$(EXEEXT) url2file$(EXEEXT) \ - urlapi$(EXEEXT) + protofeats$(EXEEXT) resolve$(EXEEXT) rtsp-options$(EXEEXT) \ + sendrecv$(EXEEXT) sepheaders$(EXEEXT) sftpget$(EXEEXT) \ + sftpuploadresume$(EXEEXT) shared-connection-cache$(EXEEXT) \ + simple$(EXEEXT) simplepost$(EXEEXT) simplessl$(EXEEXT) \ + smtp-authzid$(EXEEXT) smtp-expn$(EXEEXT) smtp-mail$(EXEEXT) \ + smtp-mime$(EXEEXT) smtp-multi$(EXEEXT) smtp-ssl$(EXEEXT) \ + smtp-tls$(EXEEXT) smtp-vrfy$(EXEEXT) sslbackend$(EXEEXT) \ + unixsocket$(EXEEXT) url2file$(EXEEXT) urlapi$(EXEEXT) \ + websocket$(EXEEXT) websocket-cb$(EXEEXT) subdir = docs/examples ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/curl-amissl.m4 \ @@ -180,7 +184,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/curl-amissl.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-nss.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 \ @@ -246,6 +250,13 @@ chkspeed_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@chkspeed_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +connect_to_SOURCES = connect-to.c +connect_to_OBJECTS = connect-to.$(OBJEXT) +connect_to_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@connect_to_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@connect_to_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la cookie_interface_SOURCES = cookie_interface.c cookie_interface_OBJECTS = cookie_interface.$(OBJEXT) cookie_interface_LDADD = $(LDADD) @@ -259,6 +270,13 @@ debug_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@debug_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@debug_DEPENDENCIES = $(LIBDIR)/libcurl.la +default_scheme_SOURCES = default-scheme.c +default_scheme_OBJECTS = default-scheme.$(OBJEXT) +default_scheme_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@default_scheme_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@default_scheme_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la externalsocket_SOURCES = externalsocket.c externalsocket_OBJECTS = externalsocket.$(OBJEXT) externalsocket_LDADD = $(LDADD) @@ -364,6 +382,20 @@ headerapi_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@headerapi_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +hsts_preload_SOURCES = hsts-preload.c +hsts_preload_OBJECTS = hsts-preload.$(OBJEXT) +hsts_preload_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@hsts_preload_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@hsts_preload_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +http_options_SOURCES = http-options.c +http_options_OBJECTS = http-options.$(OBJEXT) +http_options_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@http_options_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@http_options_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la http_post_SOURCES = http-post.c http_post_OBJECTS = http-post.$(OBJEXT) http_post_LDADD = $(LDADD) @@ -544,6 +576,39 @@ imap_tls_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@imap_tls_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +interface_SOURCES = interface.c +interface_OBJECTS = interface.$(OBJEXT) +interface_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@interface_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@interface_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +ipv6_SOURCES = ipv6.c +ipv6_OBJECTS = ipv6.$(OBJEXT) +ipv6_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@ipv6_DEPENDENCIES = $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@ipv6_DEPENDENCIES = $(LIBDIR)/libcurl.la +keepalive_SOURCES = keepalive.c +keepalive_OBJECTS = keepalive.$(OBJEXT) +keepalive_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@keepalive_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@keepalive_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +localport_SOURCES = localport.c +localport_OBJECTS = localport.$(OBJEXT) +localport_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@localport_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@localport_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +maxconnects_SOURCES = maxconnects.c +maxconnects_OBJECTS = maxconnects.$(OBJEXT) +maxconnects_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@maxconnects_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@maxconnects_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la multi_app_SOURCES = multi-app.c multi_app_OBJECTS = multi-app.$(OBJEXT) multi_app_LDADD = $(LDADD) @@ -719,6 +784,13 @@ progressfunc_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@progressfunc_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +protofeats_SOURCES = protofeats.c +protofeats_OBJECTS = protofeats.$(OBJEXT) +protofeats_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@protofeats_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@protofeats_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la resolve_SOURCES = resolve.c resolve_OBJECTS = resolve.$(OBJEXT) resolve_LDADD = $(LDADD) @@ -726,6 +798,13 @@ resolve_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@resolve_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +rtsp_options_SOURCES = rtsp-options.c +rtsp_options_OBJECTS = rtsp-options.$(OBJEXT) +rtsp_options_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@rtsp_options_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@rtsp_options_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la sendrecv_SOURCES = sendrecv.c sendrecv_OBJECTS = sendrecv.$(OBJEXT) sendrecv_LDADD = $(LDADD) @@ -845,6 +924,13 @@ sslbackend_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@sslbackend_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +unixsocket_SOURCES = unixsocket.c +unixsocket_OBJECTS = unixsocket.$(OBJEXT) +unixsocket_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@unixsocket_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@unixsocket_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la url2file_SOURCES = url2file.c url2file_OBJECTS = url2file.$(OBJEXT) url2file_LDADD = $(LDADD) @@ -859,6 +945,20 @@ urlapi_LDADD = $(LDADD) @USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la @USE_EXPLICIT_LIB_DEPS_TRUE@urlapi_DEPENDENCIES = \ @USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +websocket_SOURCES = websocket.c +websocket_OBJECTS = websocket.$(OBJEXT) +websocket_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@websocket_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@websocket_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la +websocket_cb_SOURCES = websocket-cb.c +websocket_cb_OBJECTS = websocket-cb.$(OBJEXT) +websocket_cb_LDADD = $(LDADD) +@USE_EXPLICIT_LIB_DEPS_FALSE@websocket_cb_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_FALSE@ $(LIBDIR)/libcurl.la +@USE_EXPLICIT_LIB_DEPS_TRUE@websocket_cb_DEPENDENCIES = \ +@USE_EXPLICIT_LIB_DEPS_TRUE@ $(LIBDIR)/libcurl.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -877,7 +977,8 @@ am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/10-at-a-time.Po \ ./$(DEPDIR)/altsvc.Po ./$(DEPDIR)/anyauthput.Po \ ./$(DEPDIR)/certinfo.Po ./$(DEPDIR)/chkspeed.Po \ - ./$(DEPDIR)/cookie_interface.Po ./$(DEPDIR)/debug.Po \ + ./$(DEPDIR)/connect-to.Po ./$(DEPDIR)/cookie_interface.Po \ + ./$(DEPDIR)/debug.Po ./$(DEPDIR)/default-scheme.Po \ ./$(DEPDIR)/externalsocket.Po ./$(DEPDIR)/fileupload.Po \ ./$(DEPDIR)/ftp-wildcard.Po ./$(DEPDIR)/ftpget.Po \ ./$(DEPDIR)/ftpgetinfo.Po ./$(DEPDIR)/ftpgetresp.Po \ @@ -885,7 +986,8 @@ am__depfiles_remade = ./$(DEPDIR)/10-at-a-time.Po \ ./$(DEPDIR)/ftpuploadfrommem.Po ./$(DEPDIR)/ftpuploadresume.Po \ ./$(DEPDIR)/getinfo.Po ./$(DEPDIR)/getinmemory.Po \ ./$(DEPDIR)/getredirect.Po ./$(DEPDIR)/getreferrer.Po \ - ./$(DEPDIR)/headerapi.Po ./$(DEPDIR)/http-post.Po \ + ./$(DEPDIR)/headerapi.Po ./$(DEPDIR)/hsts-preload.Po \ + ./$(DEPDIR)/http-options.Po ./$(DEPDIR)/http-post.Po \ ./$(DEPDIR)/http2-download.Po \ ./$(DEPDIR)/http2-pushinmemory.Po \ ./$(DEPDIR)/http2-serverpush.Po ./$(DEPDIR)/http2-upload.Po \ @@ -900,29 +1002,34 @@ am__depfiles_remade = ./$(DEPDIR)/10-at-a-time.Po \ ./$(DEPDIR)/imap-multi.Po ./$(DEPDIR)/imap-noop.Po \ ./$(DEPDIR)/imap-search.Po ./$(DEPDIR)/imap-ssl.Po \ ./$(DEPDIR)/imap-store.Po ./$(DEPDIR)/imap-tls.Po \ - ./$(DEPDIR)/multi-app.Po ./$(DEPDIR)/multi-debugcallback.Po \ - ./$(DEPDIR)/multi-double.Po ./$(DEPDIR)/multi-formadd.Po \ - ./$(DEPDIR)/multi-legacy.Po ./$(DEPDIR)/multi-post.Po \ - ./$(DEPDIR)/multi-single.Po ./$(DEPDIR)/parseurl.Po \ - ./$(DEPDIR)/persistent.Po ./$(DEPDIR)/pop3-authzid.Po \ - ./$(DEPDIR)/pop3-dele.Po ./$(DEPDIR)/pop3-list.Po \ - ./$(DEPDIR)/pop3-multi.Po ./$(DEPDIR)/pop3-noop.Po \ - ./$(DEPDIR)/pop3-retr.Po ./$(DEPDIR)/pop3-ssl.Po \ - ./$(DEPDIR)/pop3-stat.Po ./$(DEPDIR)/pop3-tls.Po \ - ./$(DEPDIR)/pop3-top.Po ./$(DEPDIR)/pop3-uidl.Po \ - ./$(DEPDIR)/post-callback.Po ./$(DEPDIR)/postinmemory.Po \ - ./$(DEPDIR)/postit2-formadd.Po ./$(DEPDIR)/postit2.Po \ - ./$(DEPDIR)/progressfunc.Po ./$(DEPDIR)/resolve.Po \ - ./$(DEPDIR)/sendrecv.Po ./$(DEPDIR)/sepheaders.Po \ - ./$(DEPDIR)/sftpget.Po ./$(DEPDIR)/sftpuploadresume.Po \ + ./$(DEPDIR)/interface.Po ./$(DEPDIR)/ipv6.Po \ + ./$(DEPDIR)/keepalive.Po ./$(DEPDIR)/localport.Po \ + ./$(DEPDIR)/maxconnects.Po ./$(DEPDIR)/multi-app.Po \ + ./$(DEPDIR)/multi-debugcallback.Po ./$(DEPDIR)/multi-double.Po \ + ./$(DEPDIR)/multi-formadd.Po ./$(DEPDIR)/multi-legacy.Po \ + ./$(DEPDIR)/multi-post.Po ./$(DEPDIR)/multi-single.Po \ + ./$(DEPDIR)/parseurl.Po ./$(DEPDIR)/persistent.Po \ + ./$(DEPDIR)/pop3-authzid.Po ./$(DEPDIR)/pop3-dele.Po \ + ./$(DEPDIR)/pop3-list.Po ./$(DEPDIR)/pop3-multi.Po \ + ./$(DEPDIR)/pop3-noop.Po ./$(DEPDIR)/pop3-retr.Po \ + ./$(DEPDIR)/pop3-ssl.Po ./$(DEPDIR)/pop3-stat.Po \ + ./$(DEPDIR)/pop3-tls.Po ./$(DEPDIR)/pop3-top.Po \ + ./$(DEPDIR)/pop3-uidl.Po ./$(DEPDIR)/post-callback.Po \ + ./$(DEPDIR)/postinmemory.Po ./$(DEPDIR)/postit2-formadd.Po \ + ./$(DEPDIR)/postit2.Po ./$(DEPDIR)/progressfunc.Po \ + ./$(DEPDIR)/protofeats.Po ./$(DEPDIR)/resolve.Po \ + ./$(DEPDIR)/rtsp-options.Po ./$(DEPDIR)/sendrecv.Po \ + ./$(DEPDIR)/sepheaders.Po ./$(DEPDIR)/sftpget.Po \ + ./$(DEPDIR)/sftpuploadresume.Po \ ./$(DEPDIR)/shared-connection-cache.Po ./$(DEPDIR)/simple.Po \ ./$(DEPDIR)/simplepost.Po ./$(DEPDIR)/simplessl.Po \ ./$(DEPDIR)/smtp-authzid.Po ./$(DEPDIR)/smtp-expn.Po \ ./$(DEPDIR)/smtp-mail.Po ./$(DEPDIR)/smtp-mime.Po \ ./$(DEPDIR)/smtp-multi.Po ./$(DEPDIR)/smtp-ssl.Po \ ./$(DEPDIR)/smtp-tls.Po ./$(DEPDIR)/smtp-vrfy.Po \ - ./$(DEPDIR)/sslbackend.Po ./$(DEPDIR)/url2file.Po \ - ./$(DEPDIR)/urlapi.Po + ./$(DEPDIR)/sslbackend.Po ./$(DEPDIR)/unixsocket.Po \ + ./$(DEPDIR)/url2file.Po ./$(DEPDIR)/urlapi.Po \ + ./$(DEPDIR)/websocket-cb.Po ./$(DEPDIR)/websocket.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -943,49 +1050,57 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = 10-at-a-time.c altsvc.c anyauthput.c certinfo.c chkspeed.c \ - cookie_interface.c debug.c externalsocket.c fileupload.c \ - ftp-wildcard.c ftpget.c ftpgetinfo.c ftpgetresp.c ftpsget.c \ - ftpupload.c ftpuploadfrommem.c ftpuploadresume.c getinfo.c \ - getinmemory.c getredirect.c getreferrer.c headerapi.c \ - http-post.c http2-download.c http2-pushinmemory.c \ - http2-serverpush.c http2-upload.c http3.c http3-present.c \ - httpcustomheader.c httpput.c httpput-postfields.c https.c \ - imap-append.c imap-authzid.c imap-copy.c imap-create.c \ - imap-delete.c imap-examine.c imap-fetch.c imap-list.c \ - imap-lsub.c imap-multi.c imap-noop.c imap-search.c imap-ssl.c \ - imap-store.c imap-tls.c multi-app.c multi-debugcallback.c \ - multi-double.c multi-formadd.c multi-legacy.c multi-post.c \ - multi-single.c parseurl.c persistent.c pop3-authzid.c \ - pop3-dele.c pop3-list.c pop3-multi.c pop3-noop.c pop3-retr.c \ - pop3-ssl.c pop3-stat.c pop3-tls.c pop3-top.c pop3-uidl.c \ - post-callback.c postinmemory.c postit2.c postit2-formadd.c \ - progressfunc.c resolve.c sendrecv.c sepheaders.c sftpget.c \ - sftpuploadresume.c shared-connection-cache.c simple.c \ - simplepost.c simplessl.c smtp-authzid.c smtp-expn.c \ + connect-to.c cookie_interface.c debug.c default-scheme.c \ + externalsocket.c fileupload.c ftp-wildcard.c ftpget.c \ + ftpgetinfo.c ftpgetresp.c ftpsget.c ftpupload.c \ + ftpuploadfrommem.c ftpuploadresume.c getinfo.c getinmemory.c \ + getredirect.c getreferrer.c headerapi.c hsts-preload.c \ + http-options.c http-post.c http2-download.c \ + http2-pushinmemory.c http2-serverpush.c http2-upload.c http3.c \ + http3-present.c httpcustomheader.c httpput.c \ + httpput-postfields.c https.c imap-append.c imap-authzid.c \ + imap-copy.c imap-create.c imap-delete.c imap-examine.c \ + imap-fetch.c imap-list.c imap-lsub.c imap-multi.c imap-noop.c \ + imap-search.c imap-ssl.c imap-store.c imap-tls.c interface.c \ + ipv6.c keepalive.c localport.c maxconnects.c multi-app.c \ + multi-debugcallback.c multi-double.c multi-formadd.c \ + multi-legacy.c multi-post.c multi-single.c parseurl.c \ + persistent.c pop3-authzid.c pop3-dele.c pop3-list.c \ + pop3-multi.c pop3-noop.c pop3-retr.c pop3-ssl.c pop3-stat.c \ + pop3-tls.c pop3-top.c pop3-uidl.c post-callback.c \ + postinmemory.c postit2.c postit2-formadd.c progressfunc.c \ + protofeats.c resolve.c rtsp-options.c sendrecv.c sepheaders.c \ + sftpget.c sftpuploadresume.c shared-connection-cache.c \ + simple.c simplepost.c simplessl.c smtp-authzid.c smtp-expn.c \ smtp-mail.c smtp-mime.c smtp-multi.c smtp-ssl.c smtp-tls.c \ - smtp-vrfy.c sslbackend.c url2file.c urlapi.c + smtp-vrfy.c sslbackend.c unixsocket.c url2file.c urlapi.c \ + websocket.c websocket-cb.c DIST_SOURCES = 10-at-a-time.c altsvc.c anyauthput.c certinfo.c \ - chkspeed.c cookie_interface.c debug.c externalsocket.c \ - fileupload.c ftp-wildcard.c ftpget.c ftpgetinfo.c ftpgetresp.c \ - ftpsget.c ftpupload.c ftpuploadfrommem.c ftpuploadresume.c \ - getinfo.c getinmemory.c getredirect.c getreferrer.c \ - headerapi.c http-post.c http2-download.c http2-pushinmemory.c \ - http2-serverpush.c http2-upload.c http3.c http3-present.c \ - httpcustomheader.c httpput.c httpput-postfields.c https.c \ - imap-append.c imap-authzid.c imap-copy.c imap-create.c \ - imap-delete.c imap-examine.c imap-fetch.c imap-list.c \ - imap-lsub.c imap-multi.c imap-noop.c imap-search.c imap-ssl.c \ - imap-store.c imap-tls.c multi-app.c multi-debugcallback.c \ - multi-double.c multi-formadd.c multi-legacy.c multi-post.c \ - multi-single.c parseurl.c persistent.c pop3-authzid.c \ - pop3-dele.c pop3-list.c pop3-multi.c pop3-noop.c pop3-retr.c \ - pop3-ssl.c pop3-stat.c pop3-tls.c pop3-top.c pop3-uidl.c \ - post-callback.c postinmemory.c postit2.c postit2-formadd.c \ - progressfunc.c resolve.c sendrecv.c sepheaders.c sftpget.c \ - sftpuploadresume.c shared-connection-cache.c simple.c \ - simplepost.c simplessl.c smtp-authzid.c smtp-expn.c \ + chkspeed.c connect-to.c cookie_interface.c debug.c \ + default-scheme.c externalsocket.c fileupload.c ftp-wildcard.c \ + ftpget.c ftpgetinfo.c ftpgetresp.c ftpsget.c ftpupload.c \ + ftpuploadfrommem.c ftpuploadresume.c getinfo.c getinmemory.c \ + getredirect.c getreferrer.c headerapi.c hsts-preload.c \ + http-options.c http-post.c http2-download.c \ + http2-pushinmemory.c http2-serverpush.c http2-upload.c http3.c \ + http3-present.c httpcustomheader.c httpput.c \ + httpput-postfields.c https.c imap-append.c imap-authzid.c \ + imap-copy.c imap-create.c imap-delete.c imap-examine.c \ + imap-fetch.c imap-list.c imap-lsub.c imap-multi.c imap-noop.c \ + imap-search.c imap-ssl.c imap-store.c imap-tls.c interface.c \ + ipv6.c keepalive.c localport.c maxconnects.c multi-app.c \ + multi-debugcallback.c multi-double.c multi-formadd.c \ + multi-legacy.c multi-post.c multi-single.c parseurl.c \ + persistent.c pop3-authzid.c pop3-dele.c pop3-list.c \ + pop3-multi.c pop3-noop.c pop3-retr.c pop3-ssl.c pop3-stat.c \ + pop3-tls.c pop3-top.c pop3-uidl.c post-callback.c \ + postinmemory.c postit2.c postit2-formadd.c progressfunc.c \ + protofeats.c resolve.c rtsp-options.c sendrecv.c sepheaders.c \ + sftpget.c sftpuploadresume.c shared-connection-cache.c \ + simple.c simplepost.c simplessl.c smtp-authzid.c smtp-expn.c \ smtp-mail.c smtp-mime.c smtp-multi.c smtp-ssl.c smtp-tls.c \ - smtp-vrfy.c sslbackend.c url2file.c urlapi.c + smtp-vrfy.c sslbackend.c unixsocket.c url2file.c urlapi.c \ + websocket.c websocket-cb.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -1014,6 +1129,8 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APACHECTL = @APACHECTL@ +APXS = @APXS@ AR = @AR@ AR_FLAGS = @AR_FLAGS@ AS = @AS@ @@ -1022,6 +1139,7 @@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BLANK_AT_MAKETIME = @BLANK_AT_MAKETIME@ +CADDY = @CADDY@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -1085,6 +1203,8 @@ HAVE_LIBZ = @HAVE_LIBZ@ HAVE_OPENSSL_SRP = @HAVE_OPENSSL_SRP@ HAVE_PROTO_BSDSOCKET_H = @HAVE_PROTO_BSDSOCKET_H@ HAVE_ZSTD = @HAVE_ZSTD@ +HTTPD = @HTTPD@ +HTTPD_NGHTTPX = @HTTPD_NGHTTPX@ IDN_ENABLED = @IDN_ENABLED@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -1114,7 +1234,6 @@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NROFF = @NROFF@ -NSS_LIBS = @NSS_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ @@ -1145,6 +1264,7 @@ SSL_LIBS = @SSL_LIBS@ STRIP = @STRIP@ SUPPORT_FEATURES = @SUPPORT_FEATURES@ SUPPORT_PROTOCOLS = @SUPPORT_PROTOCOLS@ +TEST_NGHTTPX = @TEST_NGHTTPX@ USE_ARES = @USE_ARES@ USE_BEARSSL = @USE_BEARSSL@ USE_GNUTLS = @USE_GNUTLS@ @@ -1158,9 +1278,8 @@ USE_NGHTTP2 = @USE_NGHTTP2@ USE_NGHTTP3 = @USE_NGHTTP3@ USE_NGTCP2 = @USE_NGTCP2@ USE_NGTCP2_CRYPTO_GNUTLS = @USE_NGTCP2_CRYPTO_GNUTLS@ -USE_NGTCP2_CRYPTO_OPENSSL = @USE_NGTCP2_CRYPTO_OPENSSL@ +USE_NGTCP2_CRYPTO_QUICTLS = @USE_NGTCP2_CRYPTO_QUICTLS@ USE_NGTCP2_CRYPTO_WOLFSSL = @USE_NGTCP2_CRYPTO_WOLFSSL@ -USE_NSS = @USE_NSS@ USE_OPENLDAP = @USE_OPENLDAP@ USE_QUICHE = @USE_QUICHE@ USE_RUSTLS = @USE_RUSTLS@ @@ -1232,8 +1351,8 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign nostdinc -EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.m32 \ - makefile.dj $(COMPLICATED_EXAMPLES) .checksrc +EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.mk \ + $(COMPLICATED_EXAMPLES) .checksrc # Specify our include paths here, and do it relative to $(top_srcdir) and @@ -1244,7 +1363,8 @@ EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.m32 \ # $(top_srcdir)/include is for libcurl's external include files # Avoid libcurl obsolete stuff -AM_CPPFLAGS = -I$(top_srcdir)/include -DCURL_NO_OLDIES $(am__append_1) +AM_CPPFLAGS = -I$(top_srcdir)/include -DCURL_DISABLE_DEPRECATION \ + -DCURL_NO_OLDIES $(am__append_1) LIBDIR = $(top_builddir)/lib @USE_EXPLICIT_LIB_DEPS_FALSE@LDADD = $(LIBDIR)/libcurl.la @@ -1252,11 +1372,10 @@ LIBDIR = $(top_builddir)/lib @USE_EXPLICIT_LIB_DEPS_TRUE@LDADD = $(LIBDIR)/libcurl.la @LIBCURL_LIBS@ # These examples require external dependencies that may not be commonly -# available on POSIX systems, so don't bother attempting to compile them here. +# available on POSIX systems, so do not bother attempting to compile them here. COMPLICATED_EXAMPLES = \ cacertinmem.c \ crawler.c \ - curlgtk.c \ ephiperfifo.c \ evhiperfifo.c \ ghiper.c \ @@ -1267,7 +1386,6 @@ COMPLICATED_EXAMPLES = \ multi-event.c \ multi-uv.c \ multithread.c \ - opensslthreadlock.c \ sessioninfo.c \ smooth-gtk-thread.c \ synctime.c \ @@ -1344,6 +1462,10 @@ chkspeed$(EXEEXT): $(chkspeed_OBJECTS) $(chkspeed_DEPENDENCIES) $(EXTRA_chkspeed @rm -f chkspeed$(EXEEXT) $(AM_V_CCLD)$(LINK) $(chkspeed_OBJECTS) $(chkspeed_LDADD) $(LIBS) +connect-to$(EXEEXT): $(connect_to_OBJECTS) $(connect_to_DEPENDENCIES) $(EXTRA_connect_to_DEPENDENCIES) + @rm -f connect-to$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(connect_to_OBJECTS) $(connect_to_LDADD) $(LIBS) + cookie_interface$(EXEEXT): $(cookie_interface_OBJECTS) $(cookie_interface_DEPENDENCIES) $(EXTRA_cookie_interface_DEPENDENCIES) @rm -f cookie_interface$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cookie_interface_OBJECTS) $(cookie_interface_LDADD) $(LIBS) @@ -1352,6 +1474,10 @@ debug$(EXEEXT): $(debug_OBJECTS) $(debug_DEPENDENCIES) $(EXTRA_debug_DEPENDENCIE @rm -f debug$(EXEEXT) $(AM_V_CCLD)$(LINK) $(debug_OBJECTS) $(debug_LDADD) $(LIBS) +default-scheme$(EXEEXT): $(default_scheme_OBJECTS) $(default_scheme_DEPENDENCIES) $(EXTRA_default_scheme_DEPENDENCIES) + @rm -f default-scheme$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(default_scheme_OBJECTS) $(default_scheme_LDADD) $(LIBS) + externalsocket$(EXEEXT): $(externalsocket_OBJECTS) $(externalsocket_DEPENDENCIES) $(EXTRA_externalsocket_DEPENDENCIES) @rm -f externalsocket$(EXEEXT) $(AM_V_CCLD)$(LINK) $(externalsocket_OBJECTS) $(externalsocket_LDADD) $(LIBS) @@ -1412,6 +1538,14 @@ headerapi$(EXEEXT): $(headerapi_OBJECTS) $(headerapi_DEPENDENCIES) $(EXTRA_heade @rm -f headerapi$(EXEEXT) $(AM_V_CCLD)$(LINK) $(headerapi_OBJECTS) $(headerapi_LDADD) $(LIBS) +hsts-preload$(EXEEXT): $(hsts_preload_OBJECTS) $(hsts_preload_DEPENDENCIES) $(EXTRA_hsts_preload_DEPENDENCIES) + @rm -f hsts-preload$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(hsts_preload_OBJECTS) $(hsts_preload_LDADD) $(LIBS) + +http-options$(EXEEXT): $(http_options_OBJECTS) $(http_options_DEPENDENCIES) $(EXTRA_http_options_DEPENDENCIES) + @rm -f http-options$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(http_options_OBJECTS) $(http_options_LDADD) $(LIBS) + http-post$(EXEEXT): $(http_post_OBJECTS) $(http_post_DEPENDENCIES) $(EXTRA_http_post_DEPENDENCIES) @rm -f http-post$(EXEEXT) $(AM_V_CCLD)$(LINK) $(http_post_OBJECTS) $(http_post_LDADD) $(LIBS) @@ -1516,6 +1650,26 @@ imap-tls$(EXEEXT): $(imap_tls_OBJECTS) $(imap_tls_DEPENDENCIES) $(EXTRA_imap_tls @rm -f imap-tls$(EXEEXT) $(AM_V_CCLD)$(LINK) $(imap_tls_OBJECTS) $(imap_tls_LDADD) $(LIBS) +interface$(EXEEXT): $(interface_OBJECTS) $(interface_DEPENDENCIES) $(EXTRA_interface_DEPENDENCIES) + @rm -f interface$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(interface_OBJECTS) $(interface_LDADD) $(LIBS) + +ipv6$(EXEEXT): $(ipv6_OBJECTS) $(ipv6_DEPENDENCIES) $(EXTRA_ipv6_DEPENDENCIES) + @rm -f ipv6$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(ipv6_OBJECTS) $(ipv6_LDADD) $(LIBS) + +keepalive$(EXEEXT): $(keepalive_OBJECTS) $(keepalive_DEPENDENCIES) $(EXTRA_keepalive_DEPENDENCIES) + @rm -f keepalive$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(keepalive_OBJECTS) $(keepalive_LDADD) $(LIBS) + +localport$(EXEEXT): $(localport_OBJECTS) $(localport_DEPENDENCIES) $(EXTRA_localport_DEPENDENCIES) + @rm -f localport$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(localport_OBJECTS) $(localport_LDADD) $(LIBS) + +maxconnects$(EXEEXT): $(maxconnects_OBJECTS) $(maxconnects_DEPENDENCIES) $(EXTRA_maxconnects_DEPENDENCIES) + @rm -f maxconnects$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(maxconnects_OBJECTS) $(maxconnects_LDADD) $(LIBS) + multi-app$(EXEEXT): $(multi_app_OBJECTS) $(multi_app_DEPENDENCIES) $(EXTRA_multi_app_DEPENDENCIES) @rm -f multi-app$(EXEEXT) $(AM_V_CCLD)$(LINK) $(multi_app_OBJECTS) $(multi_app_LDADD) $(LIBS) @@ -1616,10 +1770,18 @@ progressfunc$(EXEEXT): $(progressfunc_OBJECTS) $(progressfunc_DEPENDENCIES) $(EX @rm -f progressfunc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(progressfunc_OBJECTS) $(progressfunc_LDADD) $(LIBS) +protofeats$(EXEEXT): $(protofeats_OBJECTS) $(protofeats_DEPENDENCIES) $(EXTRA_protofeats_DEPENDENCIES) + @rm -f protofeats$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(protofeats_OBJECTS) $(protofeats_LDADD) $(LIBS) + resolve$(EXEEXT): $(resolve_OBJECTS) $(resolve_DEPENDENCIES) $(EXTRA_resolve_DEPENDENCIES) @rm -f resolve$(EXEEXT) $(AM_V_CCLD)$(LINK) $(resolve_OBJECTS) $(resolve_LDADD) $(LIBS) +rtsp-options$(EXEEXT): $(rtsp_options_OBJECTS) $(rtsp_options_DEPENDENCIES) $(EXTRA_rtsp_options_DEPENDENCIES) + @rm -f rtsp-options$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(rtsp_options_OBJECTS) $(rtsp_options_LDADD) $(LIBS) + sendrecv$(EXEEXT): $(sendrecv_OBJECTS) $(sendrecv_DEPENDENCIES) $(EXTRA_sendrecv_DEPENDENCIES) @rm -f sendrecv$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sendrecv_OBJECTS) $(sendrecv_LDADD) $(LIBS) @@ -1688,6 +1850,10 @@ sslbackend$(EXEEXT): $(sslbackend_OBJECTS) $(sslbackend_DEPENDENCIES) $(EXTRA_ss @rm -f sslbackend$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sslbackend_OBJECTS) $(sslbackend_LDADD) $(LIBS) +unixsocket$(EXEEXT): $(unixsocket_OBJECTS) $(unixsocket_DEPENDENCIES) $(EXTRA_unixsocket_DEPENDENCIES) + @rm -f unixsocket$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(unixsocket_OBJECTS) $(unixsocket_LDADD) $(LIBS) + url2file$(EXEEXT): $(url2file_OBJECTS) $(url2file_DEPENDENCIES) $(EXTRA_url2file_DEPENDENCIES) @rm -f url2file$(EXEEXT) $(AM_V_CCLD)$(LINK) $(url2file_OBJECTS) $(url2file_LDADD) $(LIBS) @@ -1696,6 +1862,14 @@ urlapi$(EXEEXT): $(urlapi_OBJECTS) $(urlapi_DEPENDENCIES) $(EXTRA_urlapi_DEPENDE @rm -f urlapi$(EXEEXT) $(AM_V_CCLD)$(LINK) $(urlapi_OBJECTS) $(urlapi_LDADD) $(LIBS) +websocket$(EXEEXT): $(websocket_OBJECTS) $(websocket_DEPENDENCIES) $(EXTRA_websocket_DEPENDENCIES) + @rm -f websocket$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(websocket_OBJECTS) $(websocket_LDADD) $(LIBS) + +websocket-cb$(EXEEXT): $(websocket_cb_OBJECTS) $(websocket_cb_DEPENDENCIES) $(EXTRA_websocket_cb_DEPENDENCIES) + @rm -f websocket-cb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(websocket_cb_OBJECTS) $(websocket_cb_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -1707,8 +1881,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/anyauthput.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/certinfo.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkspeed.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect-to.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cookie_interface.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/default-scheme.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/externalsocket.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileupload.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftp-wildcard.Po@am__quote@ # am--include-marker @@ -1724,6 +1900,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getredirect.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getreferrer.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/headerapi.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hsts-preload.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http-options.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http-post.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http2-download.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http2-pushinmemory.Po@am__quote@ # am--include-marker @@ -1750,6 +1928,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imap-ssl.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imap-store.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imap-tls.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipv6.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keepalive.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localport.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maxconnects.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi-app.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi-debugcallback.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi-double.Po@am__quote@ # am--include-marker @@ -1775,7 +1958,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/postit2-formadd.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/postit2.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progressfunc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protofeats.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolve.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtsp-options.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendrecv.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sepheaders.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftpget.Po@am__quote@ # am--include-marker @@ -1793,8 +1978,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smtp-tls.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smtp-vrfy.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sslbackend.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unixsocket.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/url2file.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/urlapi.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/websocket-cb.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/websocket.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -1962,8 +2150,10 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/anyauthput.Po -rm -f ./$(DEPDIR)/certinfo.Po -rm -f ./$(DEPDIR)/chkspeed.Po + -rm -f ./$(DEPDIR)/connect-to.Po -rm -f ./$(DEPDIR)/cookie_interface.Po -rm -f ./$(DEPDIR)/debug.Po + -rm -f ./$(DEPDIR)/default-scheme.Po -rm -f ./$(DEPDIR)/externalsocket.Po -rm -f ./$(DEPDIR)/fileupload.Po -rm -f ./$(DEPDIR)/ftp-wildcard.Po @@ -1979,6 +2169,8 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/getredirect.Po -rm -f ./$(DEPDIR)/getreferrer.Po -rm -f ./$(DEPDIR)/headerapi.Po + -rm -f ./$(DEPDIR)/hsts-preload.Po + -rm -f ./$(DEPDIR)/http-options.Po -rm -f ./$(DEPDIR)/http-post.Po -rm -f ./$(DEPDIR)/http2-download.Po -rm -f ./$(DEPDIR)/http2-pushinmemory.Po @@ -2005,6 +2197,11 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/imap-ssl.Po -rm -f ./$(DEPDIR)/imap-store.Po -rm -f ./$(DEPDIR)/imap-tls.Po + -rm -f ./$(DEPDIR)/interface.Po + -rm -f ./$(DEPDIR)/ipv6.Po + -rm -f ./$(DEPDIR)/keepalive.Po + -rm -f ./$(DEPDIR)/localport.Po + -rm -f ./$(DEPDIR)/maxconnects.Po -rm -f ./$(DEPDIR)/multi-app.Po -rm -f ./$(DEPDIR)/multi-debugcallback.Po -rm -f ./$(DEPDIR)/multi-double.Po @@ -2030,7 +2227,9 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/postit2-formadd.Po -rm -f ./$(DEPDIR)/postit2.Po -rm -f ./$(DEPDIR)/progressfunc.Po + -rm -f ./$(DEPDIR)/protofeats.Po -rm -f ./$(DEPDIR)/resolve.Po + -rm -f ./$(DEPDIR)/rtsp-options.Po -rm -f ./$(DEPDIR)/sendrecv.Po -rm -f ./$(DEPDIR)/sepheaders.Po -rm -f ./$(DEPDIR)/sftpget.Po @@ -2048,8 +2247,11 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/smtp-tls.Po -rm -f ./$(DEPDIR)/smtp-vrfy.Po -rm -f ./$(DEPDIR)/sslbackend.Po + -rm -f ./$(DEPDIR)/unixsocket.Po -rm -f ./$(DEPDIR)/url2file.Po -rm -f ./$(DEPDIR)/urlapi.Po + -rm -f ./$(DEPDIR)/websocket-cb.Po + -rm -f ./$(DEPDIR)/websocket.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -2100,8 +2302,10 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/anyauthput.Po -rm -f ./$(DEPDIR)/certinfo.Po -rm -f ./$(DEPDIR)/chkspeed.Po + -rm -f ./$(DEPDIR)/connect-to.Po -rm -f ./$(DEPDIR)/cookie_interface.Po -rm -f ./$(DEPDIR)/debug.Po + -rm -f ./$(DEPDIR)/default-scheme.Po -rm -f ./$(DEPDIR)/externalsocket.Po -rm -f ./$(DEPDIR)/fileupload.Po -rm -f ./$(DEPDIR)/ftp-wildcard.Po @@ -2117,6 +2321,8 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/getredirect.Po -rm -f ./$(DEPDIR)/getreferrer.Po -rm -f ./$(DEPDIR)/headerapi.Po + -rm -f ./$(DEPDIR)/hsts-preload.Po + -rm -f ./$(DEPDIR)/http-options.Po -rm -f ./$(DEPDIR)/http-post.Po -rm -f ./$(DEPDIR)/http2-download.Po -rm -f ./$(DEPDIR)/http2-pushinmemory.Po @@ -2143,6 +2349,11 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/imap-ssl.Po -rm -f ./$(DEPDIR)/imap-store.Po -rm -f ./$(DEPDIR)/imap-tls.Po + -rm -f ./$(DEPDIR)/interface.Po + -rm -f ./$(DEPDIR)/ipv6.Po + -rm -f ./$(DEPDIR)/keepalive.Po + -rm -f ./$(DEPDIR)/localport.Po + -rm -f ./$(DEPDIR)/maxconnects.Po -rm -f ./$(DEPDIR)/multi-app.Po -rm -f ./$(DEPDIR)/multi-debugcallback.Po -rm -f ./$(DEPDIR)/multi-double.Po @@ -2168,7 +2379,9 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/postit2-formadd.Po -rm -f ./$(DEPDIR)/postit2.Po -rm -f ./$(DEPDIR)/progressfunc.Po + -rm -f ./$(DEPDIR)/protofeats.Po -rm -f ./$(DEPDIR)/resolve.Po + -rm -f ./$(DEPDIR)/rtsp-options.Po -rm -f ./$(DEPDIR)/sendrecv.Po -rm -f ./$(DEPDIR)/sepheaders.Po -rm -f ./$(DEPDIR)/sftpget.Po @@ -2186,8 +2399,11 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/smtp-tls.Po -rm -f ./$(DEPDIR)/smtp-vrfy.Po -rm -f ./$(DEPDIR)/sslbackend.Po + -rm -f ./$(DEPDIR)/unixsocket.Po -rm -f ./$(DEPDIR)/url2file.Po -rm -f ./$(DEPDIR)/urlapi.Po + -rm -f ./$(DEPDIR)/websocket-cb.Po + -rm -f ./$(DEPDIR)/websocket.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/docs/examples/Makefile.inc b/docs/examples/Makefile.inc index 42247fe61..1f1996c37 100644 --- a/docs/examples/Makefile.inc +++ b/docs/examples/Makefile.inc @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 @@ -29,8 +29,10 @@ check_PROGRAMS = \ anyauthput \ certinfo \ chkspeed \ + connect-to \ cookie_interface \ debug \ + default-scheme \ externalsocket \ fileupload \ ftp-wildcard \ @@ -46,6 +48,8 @@ check_PROGRAMS = \ getredirect \ getreferrer \ headerapi \ + hsts-preload \ + http-options \ http-post \ http2-download \ http2-pushinmemory \ @@ -72,6 +76,11 @@ check_PROGRAMS = \ imap-ssl \ imap-store \ imap-tls \ + interface \ + ipv6 \ + keepalive \ + localport \ + maxconnects \ multi-app \ multi-debugcallback \ multi-double \ @@ -97,7 +106,9 @@ check_PROGRAMS = \ postit2 \ postit2-formadd \ progressfunc \ + protofeats \ resolve \ + rtsp-options \ sendrecv \ sepheaders \ sftpget \ @@ -115,15 +126,17 @@ check_PROGRAMS = \ smtp-tls \ smtp-vrfy \ sslbackend \ + unixsocket \ url2file \ - urlapi + urlapi \ + websocket \ + websocket-cb # These examples require external dependencies that may not be commonly -# available on POSIX systems, so don't bother attempting to compile them here. +# available on POSIX systems, so do not bother attempting to compile them here. COMPLICATED_EXAMPLES = \ cacertinmem.c \ crawler.c \ - curlgtk.c \ ephiperfifo.c \ evhiperfifo.c \ ghiper.c \ @@ -134,7 +147,6 @@ COMPLICATED_EXAMPLES = \ multi-event.c \ multi-uv.c \ multithread.c \ - opensslthreadlock.c \ sessioninfo.c \ smooth-gtk-thread.c \ synctime.c \ diff --git a/docs/examples/Makefile.m32 b/docs/examples/Makefile.mk index 076608216..599acee0b 100644 --- a/docs/examples/Makefile.m32 +++ b/docs/examples/Makefile.mk @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1999 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 @@ -22,37 +22,53 @@ # #*************************************************************************** -# Build libcurl via lib/Makefile.m32 first. +# Build libcurl via lib/Makefile.mk first. PROOT := ../.. +ifeq ($(findstring -static,$(CFG)),) + DYN := 1 +endif + +### Common + +include $(PROOT)/lib/Makefile.mk + +### Local + +CPPFLAGS += -DCURL_NO_OLDIES LDFLAGS += -L$(PROOT)/lib -LIBS += -lcurl +LIBS := -lcurl $(LIBS) -ifeq ($(findstring -static,$(CFG)),) +ifdef DYN curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a - DYN := 1 else curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a - CPPFLAGS += -DCURL_STATICLIB - LDFLAGS += -static + ifdef WIN32 + CPPFLAGS += -DCURL_STATICLIB + LDFLAGS += -static + endif endif -LIBS += -lws2_32 +ifdef WIN32 + LIBS += -lws2_32 +endif ### Sources and targets # Provides check_PROGRAMS include Makefile.inc -TARGETS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS) synctime)) -TOCLEAN := $(TARGETS:.exe=.o) +ifdef WIN32 +check_PROGRAMS += synctime +endif -### Local rules +TARGETS := $(patsubst %,%$(BIN_EXT),$(strip $(check_PROGRAMS))) +TOCLEAN := $(TARGETS) -%.exe: %.o $(curl_DEPENDENCIES) - $(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $< $(LIBS) +### Rules -### Global script +%$(BIN_EXT): %.c $(curl_DEPENDENCIES) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(CURL_LDFLAGS_BIN) $< -o $@ $(LIBS) -include $(PROOT)/lib/Makefile.m32 +all: $(TARGETS) diff --git a/docs/examples/README.md b/docs/examples/README.md index c74dc9416..3f95f03c0 100644 --- a/docs/examples/README.md +++ b/docs/examples/README.md @@ -1,5 +1,5 @@ <!-- -Copyright (C) 1998 - 2022 Daniel Stenberg, <daniel@haxx.se>, et al. +Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. SPDX-License-Identifier: curl --> diff --git a/docs/examples/altsvc.c b/docs/examples/altsvc.c index 7fa47c2c2..28e9794e8 100644 --- a/docs/examples/altsvc.c +++ b/docs/examples/altsvc.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index b5764327c..1f4340f4d 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -33,7 +33,7 @@ #include <curl/curl.h> -#ifdef WIN32 +#ifdef _WIN32 # define FILENO(fp) _fileno(fp) #else # define FILENO(fp) fileno(fp) @@ -44,7 +44,7 @@ #endif /* - * This example shows a HTTP PUT operation with authentication using "any" + * This example shows an HTTP PUT operation with authentication using "any" * type. It PUTs a file given as a command line argument to the URL also given * on the command line. * @@ -60,7 +60,7 @@ static int my_seek(void *userp, curl_off_t offset, int origin) FILE *fp = (FILE *) userp; if(-1 == fseek(fp, (long) offset, origin)) - /* couldn't seek */ + /* could not seek */ return CURL_SEEKFUNC_CANTSEEK; return CURL_SEEKFUNC_OK; /* success! */ diff --git a/docs/examples/cacertinmem.c b/docs/examples/cacertinmem.c index a16d319d2..647b495b4 100644 --- a/docs/examples/cacertinmem.c +++ b/docs/examples/cacertinmem.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,7 +22,7 @@ * ***************************************************************************/ /* <DESC> - * CA cert in memory with OpenSSL to get a HTTPS page. + * CA cert in memory with OpenSSL to get an HTTPS page. * </DESC> */ diff --git a/docs/examples/certinfo.c b/docs/examples/certinfo.c index 381ee5110..795be6c3d 100644 --- a/docs/examples/certinfo.c +++ b/docs/examples/certinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/chkspeed.c b/docs/examples/chkspeed.c index a467913a7..45765b988 100644 --- a/docs/examples/chkspeed.c +++ b/docs/examples/chkspeed.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/connect-to.c b/docs/examples/connect-to.c new file mode 100644 index 000000000..fcdd2cc4f --- /dev/null +++ b/docs/examples/connect-to.c @@ -0,0 +1,70 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Use CURLOPT_CONNECT_TO to connect to "wrong" host name + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + /* + Each single string should be written using the format + HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT where HOST is the host of the + request, PORT is the port of the request, CONNECT-TO-HOST is the host name + to connect to, and CONNECT-TO-PORT is the port to connect to. + */ + /* instead of curl.se:443, it will resolve and use example.com:443 but in + other aspects work as if it still is curl.se */ + struct curl_slist *host = curl_slist_append(NULL, + "curl.se:443:example.com:443"); + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_CONNECT_TO, host); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); + + /* since this connects to the wrong host, checking the host name in the + server certificate will fail, so unless we disable the check libcurl + returns CURLE_PEER_FAILED_VERIFICATION */ + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); + + /* Letting the wrong host name in the certificate be okay, the transfer + goes through but will (most likely) cause a 404 or similar because it + sends an unknown name in the Host: header field */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + curl_slist_free_all(host); + + return (int)res; +} diff --git a/docs/examples/cookie_interface.c b/docs/examples/cookie_interface.c index 62e9dd798..120049830 100644 --- a/docs/examples/cookie_interface.c +++ b/docs/examples/cookie_interface.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -91,14 +91,14 @@ main(void) printf("-----------------------------------------------\n" "Setting a cookie \"PREF\" via cookie interface:\n"); -#ifdef WIN32 +#ifdef _WIN32 #define snprintf _snprintf #endif /* Netscape format cookie */ snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0f\t%s\t%s", ".example.com", "TRUE", "/", "FALSE", difftime(time(NULL) + 31337, (time_t)0), - "PREF", "hello example, i like you very much!"); + "PREF", "hello example, i like you!"); res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline); if(res != CURLE_OK) { fprintf(stderr, "Curl curl_easy_setopt failed: %s\n", diff --git a/docs/examples/crawler.c b/docs/examples/crawler.c index 1859c274e..2ff4ae714 100644 --- a/docs/examples/crawler.c +++ b/docs/examples/crawler.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2018 - 2022 Jeroen Ooms <jeroenooms@gmail.com> + * Copyright (C) Jeroen Ooms <jeroenooms@gmail.com> * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -95,8 +95,17 @@ CURL *make_handle(char *url) curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, ""); curl_easy_setopt(handle, CURLOPT_TIMEOUT, 5L); curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L); + /* only allow redirects to HTTP and HTTPS URLs */ + curl_easy_setopt(handle, CURLOPT_REDIR_PROTOCOLS_STR, "http,https"); + curl_easy_setopt(handle, CURLOPT_AUTOREFERER, 1L); curl_easy_setopt(handle, CURLOPT_MAXREDIRS, 10L); - curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, 2L); + /* each transfer needs to be done within 20 seconds! */ + curl_easy_setopt(handle, CURLOPT_TIMEOUT_MS, 20000L); + /* connect fast or fail */ + curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT_MS, 2000L); + /* skip files larger than a gigabyte */ + curl_easy_setopt(handle, CURLOPT_MAXFILESIZE_LARGE, + (curl_off_t)1024*1024*1024); curl_easy_setopt(handle, CURLOPT_COOKIEFILE, ""); curl_easy_setopt(handle, CURLOPT_FILETIME, 1L); curl_easy_setopt(handle, CURLOPT_USERAGENT, "mini crawler"); diff --git a/docs/examples/curlgtk.c b/docs/examples/curlgtk.c deleted file mode 100644 index 756894121..000000000 --- a/docs/examples/curlgtk.c +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (c) 2000 - 2022 David Odin (aka DindinX) for MandrakeSoft - * - * 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 - * - ***************************************************************************/ -/* <DESC> - * use the libcurl in a gtk-threaded application - * </DESC> - */ - -#include <stdio.h> -#include <gtk/gtk.h> - -#include <curl/curl.h> - -GtkWidget *Bar; - -static size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - return fwrite(ptr, size, nmemb, stream); -} - -static size_t my_read_func(char *ptr, size_t size, size_t nmemb, FILE *stream) -{ - return fread(ptr, size, nmemb, stream); -} - -static int my_progress_func(GtkWidget *bar, - double t, /* dltotal */ - double d, /* dlnow */ - double ultotal, - double ulnow) -{ -/* printf("%d / %d (%g %%)\n", d, t, d*100.0/t);*/ - gdk_threads_enter(); - gtk_progress_set_value(GTK_PROGRESS(bar), d*100.0/t); - gdk_threads_leave(); - return 0; -} - -static void *my_thread(void *ptr) -{ - CURL *curl; - - curl = curl_easy_init(); - if(curl) { - gchar *url = ptr; - const char *filename = "test.curl"; - FILE *outfile = fopen(filename, "wb"); - - curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar); - - curl_easy_perform(curl); - - fclose(outfile); - /* always cleanup */ - curl_easy_cleanup(curl); - } - - return NULL; -} - -int main(int argc, char **argv) -{ - GtkWidget *Window, *Frame, *Frame2; - GtkAdjustment *adj; - - /* Must initialize libcurl before any threads are started */ - curl_global_init(CURL_GLOBAL_ALL); - - /* Init thread */ - g_thread_init(NULL); - - gtk_init(&argc, &argv); - Window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - Frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(Frame), GTK_SHADOW_OUT); - gtk_container_add(GTK_CONTAINER(Window), Frame); - Frame2 = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(Frame2), GTK_SHADOW_IN); - gtk_container_add(GTK_CONTAINER(Frame), Frame2); - gtk_container_set_border_width(GTK_CONTAINER(Frame2), 5); - adj = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); - Bar = gtk_progress_bar_new_with_adjustment(adj); - gtk_container_add(GTK_CONTAINER(Frame2), Bar); - gtk_widget_show_all(Window); - - if(!g_thread_create(&my_thread, argv[1], FALSE, NULL) != 0) - g_warning("cannot create the thread"); - - gdk_threads_enter(); - gtk_main(); - gdk_threads_leave(); - return 0; -} diff --git a/docs/examples/debug.c b/docs/examples/debug.c index aeef8290a..684a18327 100644 --- a/docs/examples/debug.c +++ b/docs/examples/debug.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/default-scheme.c b/docs/examples/default-scheme.c new file mode 100644 index 000000000..525dcc3c3 --- /dev/null +++ b/docs/examples/default-scheme.c @@ -0,0 +1,57 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Change default scheme when none is provided in the URL + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "example.com"); + + /* Change the default protocol (scheme) for schemeless URLs from plain + "http" to use a secure one instead. */ + curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/ephiperfifo.c b/docs/examples/ephiperfifo.c index 7079846fd..0ce68de5d 100644 --- a/docs/examples/ephiperfifo.c +++ b/docs/examples/ephiperfifo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -166,7 +166,7 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g) memset(&its, 0, sizeof(struct itimerspec)); } - timerfd_settime(g->tfd, /*flags=*/0, &its, NULL); + timerfd_settime(g->tfd, /* flags= */0, &its, NULL); return 0; } @@ -197,7 +197,7 @@ static void check_multi_info(GlobalInfo *g) } } -/* Called by libevent when we get action on a multi socket filedescriptor*/ +/* Called by libevent when we get action on a multi socket filedescriptor */ static void event_cb(GlobalInfo *g, int fd, int revents) { CURLMcode rc; @@ -386,8 +386,8 @@ static void new_conn(char *url, GlobalInfo *g) rc = curl_multi_add_handle(g->multi, conn->easy); mcode_or_die("new_conn: curl_multi_add_handle", rc); - /* note that the add_handle() will set a time-out to trigger very soon so - that the necessary socket_action() call will be called by this app */ + /* note that the add_handle() will set a time-out to trigger soon so that + the necessary socket_action() call will be called by this app */ } /* This gets called whenever data is received from the fifo */ diff --git a/docs/examples/evhiperfifo.c b/docs/examples/evhiperfifo.c index 3c9ca57dd..17bff2b65 100644 --- a/docs/examples/evhiperfifo.c +++ b/docs/examples/evhiperfifo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -364,8 +364,8 @@ static void new_conn(char *url, GlobalInfo *g) rc = curl_multi_add_handle(g->multi, conn->easy); mcode_or_die("new_conn: curl_multi_add_handle", rc); - /* note that the add_handle() will set a time-out to trigger very soon so - that the necessary socket_action() call will be called by this app */ + /* note that the add_handle() will set a time-out to trigger soon so that + the necessary socket_action() call will be called by this app */ } /* This gets called whenever data is received from the fifo */ diff --git a/docs/examples/externalsocket.c b/docs/examples/externalsocket.c index dfdd1c275..270a31996 100644 --- a/docs/examples/externalsocket.c +++ b/docs/examples/externalsocket.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,8 +22,7 @@ * ***************************************************************************/ /* <DESC> - * An example demonstrating how an application can pass in a custom - * socket to libcurl to use. This example also handles the connect itself. + * Pass in a custom socket for libcurl to use. * </DESC> */ #include <stdio.h> @@ -31,7 +30,7 @@ #include <stdlib.h> #include <curl/curl.h> -#ifdef WIN32 +#ifdef _WIN32 #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> @@ -97,7 +96,7 @@ int main(void) struct sockaddr_in servaddr; /* socket address structure */ curl_socket_t sockfd; -#ifdef WIN32 +#ifdef _WIN32 WSADATA wsaData; int initwsa = WSAStartup(MAKEWORD(2, 2), &wsaData); if(initwsa) { @@ -169,7 +168,7 @@ int main(void) } } -#ifdef WIN32 +#ifdef _WIN32 WSACleanup(); #endif return 0; diff --git a/docs/examples/fileupload.c b/docs/examples/fileupload.c index 8d3e6cdf8..9e3bd84f7 100644 --- a/docs/examples/fileupload.c +++ b/docs/examples/fileupload.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/ftp-wildcard.c b/docs/examples/ftp-wildcard.c index 9c1c913f1..f80543247 100644 --- a/docs/examples/ftp-wildcard.c +++ b/docs/examples/ftp-wildcard.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/ftpget.c b/docs/examples/ftpget.c index 3229dbf7b..94609fe0d 100644 --- a/docs/examples/ftpget.c +++ b/docs/examples/ftpget.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -66,7 +66,7 @@ int main(void) */ curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/curl/curl-7.9.2.tar.gz"); - /* Define our callback to get called when there's data to be written */ + /* Define our callback to get called when there is data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); diff --git a/docs/examples/ftpgetinfo.c b/docs/examples/ftpgetinfo.c index d95753d3e..be24fa71e 100644 --- a/docs/examples/ftpgetinfo.c +++ b/docs/examples/ftpgetinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/ftpgetresp.c b/docs/examples/ftpgetresp.c index 1bee903db..238885dfe 100644 --- a/docs/examples/ftpgetresp.c +++ b/docs/examples/ftpgetresp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/ftpsget.c b/docs/examples/ftpsget.c index 521ad5cb6..dbe7d14bf 100644 --- a/docs/examples/ftpsget.c +++ b/docs/examples/ftpsget.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -70,7 +70,7 @@ int main(void) */ curl_easy_setopt(curl, CURLOPT_URL, "ftp://user@server/home/user/file.txt"); - /* Define our callback to get called when there's data to be written */ + /* Define our callback to get called when there is data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c index 046166a43..92bb0b8a0 100644 --- a/docs/examples/ftpupload.c +++ b/docs/examples/ftpupload.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -29,7 +29,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <errno.h> -#ifdef WIN32 +#ifdef _WIN32 #include <io.h> #else #include <unistd.h> diff --git a/docs/examples/ftpuploadfrommem.c b/docs/examples/ftpuploadfrommem.c index b32020e80..9613cca26 100644 --- a/docs/examples/ftpuploadfrommem.c +++ b/docs/examples/ftpuploadfrommem.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/ftpuploadresume.c b/docs/examples/ftpuploadresume.c index 5014e3f23..42d31a2bb 100644 --- a/docs/examples/ftpuploadresume.c +++ b/docs/examples/ftpuploadresume.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,7 +22,7 @@ * ***************************************************************************/ /* <DESC> - * Upload to FTP, resuming failed transfers. + * Upload to FTP, resuming failed transfers. Active mode. * </DESC> */ @@ -96,8 +96,12 @@ static int upload(CURL *curlhandle, const char *remotepath, curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, readfunc); curl_easy_setopt(curlhandle, CURLOPT_READDATA, f); - /* disable passive mode */ + /* enable active mode */ curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); + + /* allow the server no more than 7 seconds to connect back */ + curl_easy_setopt(curlhandle, CURLOPT_ACCEPTTIMEOUT_MS, 7000L); + curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/getinfo.c b/docs/examples/getinfo.c index d63b030aa..9c178c2c8 100644 --- a/docs/examples/getinfo.c +++ b/docs/examples/getinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/getinmemory.c b/docs/examples/getinmemory.c index 085ece7b7..8ec84142d 100644 --- a/docs/examples/getinmemory.c +++ b/docs/examples/getinmemory.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/getredirect.c b/docs/examples/getredirect.c index 85ea382b7..9163c9b07 100644 --- a/docs/examples/getredirect.c +++ b/docs/examples/getredirect.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/getreferrer.c b/docs/examples/getreferrer.c index d320c104d..6073f9fca 100644 --- a/docs/examples/getreferrer.c +++ b/docs/examples/getreferrer.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/ghiper.c b/docs/examples/ghiper.c index e18ca6e5b..5a4f4a705 100644 --- a/docs/examples/ghiper.c +++ b/docs/examples/ghiper.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -323,8 +323,8 @@ static void new_conn(char *url, GlobalInfo *g) rc = curl_multi_add_handle(g->multi, conn->easy); mcode_or_die("new_conn: curl_multi_add_handle", rc); - /* note that the add_handle() will set a time-out to trigger very soon so - that the necessary socket_action() call will be called by this app */ + /* note that the add_handle() will set a time-out to trigger soon so that + the necessary socket_action() call will be called by this app */ } /* This gets called by glib whenever data is received from the fifo */ diff --git a/docs/examples/headerapi.c b/docs/examples/headerapi.c index 58c858629..4df6cbd67 100644 --- a/docs/examples/headerapi.c +++ b/docs/examples/headerapi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c index ea0cdb185..9fba341bb 100644 --- a/docs/examples/hiperfifo.c +++ b/docs/examples/hiperfifo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -358,8 +358,8 @@ static void new_conn(char *url, GlobalInfo *g) rc = curl_multi_add_handle(g->multi, conn->easy); mcode_or_die("new_conn: curl_multi_add_handle", rc); - /* note that the add_handle() will set a time-out to trigger very soon so - that the necessary socket_action() call will be called by this app */ + /* note that the add_handle() will set a time-out to trigger soon so that + the necessary socket_action() call will be called by this app */ } /* This gets called whenever data is received from the fifo */ diff --git a/docs/examples/href_extractor.c b/docs/examples/href_extractor.c index b73157b8d..5c92b0c23 100644 --- a/docs/examples/href_extractor.c +++ b/docs/examples/href_extractor.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/hsts-preload.c b/docs/examples/hsts-preload.c new file mode 100644 index 000000000..ee4253533 --- /dev/null +++ b/docs/examples/hsts-preload.c @@ -0,0 +1,118 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Preload domains to HSTS + * </DESC> + */ +#include <stdio.h> +#include <string.h> +#include <curl/curl.h> + +struct entry { + const char *name; + const char *exp; +}; + +static const struct entry preload_hosts[] = { + { "example.com", "20370320 01:02:03" }, + { "curl.se", "20370320 03:02:01" }, + { NULL, NULL } /* end of list marker */ +}; + +struct state { + int index; +}; + +/* "read" is from the point of the library, it wants data from us. One domain + entry per invoke. */ +static CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *e, + void *userp) +{ + const char *host; + const char *expire; + struct state *s = (struct state *)userp; + (void)easy; + host = preload_hosts[s->index].name; + expire = preload_hosts[s->index++].exp; + + if(host && (strlen(host) < e->namelen)) { + strcpy(e->name, host); + e->includeSubDomains = 0; + strcpy(e->expire, expire); + fprintf(stderr, "HSTS preload '%s' until '%s'\n", host, expire); + } + else + return CURLSTS_DONE; + return CURLSTS_OK; +} + +static CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *e, + struct curl_index *i, void *userp) +{ + (void)easy; + (void)userp; /* we have no custom input */ + printf("[%u/%u] %s %s\n", (unsigned int)i->index, (unsigned int)i->total, + e->name, e->expire); + return CURLSTS_OK; +} + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + struct state st = {0}; + + /* enable HSTS for this handle */ + curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE); + + /* function to call at first to populate the cache before the transfer */ + curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hstsread); + curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &st); + + /* function to call after transfer to store the new state of the HSTS + cache */ + curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hstswrite); + curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, NULL); + + /* use the domain with HTTP but due to the preload, it should do the + transfer using HTTPS */ + curl_easy_setopt(curl, CURLOPT_URL, "http://curl.se"); + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/htmltidy.c b/docs/examples/htmltidy.c index 97e3eac73..cc6f63e1c 100644 --- a/docs/examples/htmltidy.c +++ b/docs/examples/htmltidy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/htmltitle.cpp b/docs/examples/htmltitle.cpp index b5c78f796..ee3e023a2 100644 --- a/docs/examples/htmltitle.cpp +++ b/docs/examples/htmltitle.cpp @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -272,7 +272,7 @@ int main(int argc, char *argv[]) // Initialize CURL connection if(!init(conn, argv[1])) { - fprintf(stderr, "Connection initializion failed\n"); + fprintf(stderr, "Connection initialization failed\n"); exit(EXIT_FAILURE); } diff --git a/docs/examples/http-options.c b/docs/examples/http-options.c new file mode 100644 index 000000000..964e0ef37 --- /dev/null +++ b/docs/examples/http-options.c @@ -0,0 +1,59 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Issue an HTTP 'OPTIONS *' request + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); + + /* issue an OPTIONS * request (no leading slash) */ + curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*"); + + /* if this operation fails, allow risking a memory leak and do quick exit + from libcurl as this will exit() anyway */ + curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index df0e5a7a4..2cacefee4 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -40,7 +40,7 @@ int main(void) curl = curl_easy_init(); if(curl) { /* First set the URL that is about to receive our POST. This URL can - just as well be a https:// URL if that is what should receive the + just as well be an https:// URL if that is what should receive the data. */ curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi"); /* Now specify the POST data */ diff --git a/docs/examples/http2-download.c b/docs/examples/http2-download.c index e88f578cd..a2291a8c7 100644 --- a/docs/examples/http2-download.c +++ b/docs/examples/http2-download.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -170,13 +170,12 @@ static void setup(struct transfer *t, int num) curl_easy_setopt(hnd, CURLOPT_DEBUGFUNCTION, my_trace); curl_easy_setopt(hnd, CURLOPT_DEBUGDATA, t); + /* enlarge the receive buffer for potentially higher transfer speeds */ + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 100000L); + /* HTTP/2 please */ curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); - /* we use a self-signed test server, skip verification during debugging */ - curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0L); - curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 0L); - #if (CURLPIPE_MULTIPLEX > 0) /* wait for pipe connection to confirm */ curl_easy_setopt(hnd, CURLOPT_PIPEWAIT, 1L); diff --git a/docs/examples/http2-pushinmemory.c b/docs/examples/http2-pushinmemory.c index 78273c9db..74c64e0a6 100644 --- a/docs/examples/http2-pushinmemory.c +++ b/docs/examples/http2-pushinmemory.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -92,7 +92,7 @@ static void setup(CURL *hnd) curl_easy_setopt(hnd, CURLOPT_PIPEWAIT, 1L); } -/* called when there's an incoming push */ +/* called when there is an incoming push */ static int server_push_callback(CURL *parent, CURL *easy, size_t num_headers, diff --git a/docs/examples/http2-serverpush.c b/docs/examples/http2-serverpush.c index f27935516..b5ebe2eb9 100644 --- a/docs/examples/http2-serverpush.c +++ b/docs/examples/http2-serverpush.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -130,7 +130,7 @@ int my_trace(CURL *handle, curl_infotype type, #define OUTPUTFILE "dl" -static int setup(CURL *hnd) +static int setup(CURL *hnd, const char *url) { FILE *out = fopen(OUTPUTFILE, "wb"); if(!out) @@ -141,7 +141,7 @@ static int setup(CURL *hnd) curl_easy_setopt(hnd, CURLOPT_WRITEDATA, out); /* set the same URL */ - curl_easy_setopt(hnd, CURLOPT_URL, "https://localhost:8443/index.html"); + curl_easy_setopt(hnd, CURLOPT_URL, url); /* please be verbose */ curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); @@ -161,7 +161,7 @@ static int setup(CURL *hnd) return 0; /* all is good */ } -/* called when there's an incoming push */ +/* called when there is an incoming push */ static int server_push_callback(CURL *parent, CURL *easy, size_t num_headers, @@ -211,12 +211,16 @@ static int server_push_callback(CURL *parent, /* * Download a file over HTTP/2, take care of server push. */ -int main(void) +int main(int argc, char *argv[]) { CURL *easy; CURLM *multi_handle; int transfers = 1; /* we start with one */ struct CURLMsg *m; + const char *url = "https://localhost:8443/index.html"; + + if(argc == 2) + url = argv[1]; /* init a multi stack */ multi_handle = curl_multi_init(); @@ -224,7 +228,7 @@ int main(void) easy = curl_easy_init(); /* set options */ - if(setup(easy)) { + if(setup(easy, url)) { fprintf(stderr, "failed\n"); return 1; } diff --git a/docs/examples/http2-upload.c b/docs/examples/http2-upload.c index d0d54695e..5889d0c36 100644 --- a/docs/examples/http2-upload.c +++ b/docs/examples/http2-upload.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/http3-present.c b/docs/examples/http3-present.c index 3e189203c..56ba0f572 100644 --- a/docs/examples/http3-present.c +++ b/docs/examples/http3-present.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/http3.c b/docs/examples/http3.c index 6463ccfd0..900e11920 100644 --- a/docs/examples/http3.c +++ b/docs/examples/http3.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -37,10 +37,9 @@ int main(void) if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - /* Forcing HTTP/3 will make the connection fail if the server is not - accessible over QUIC + HTTP/3 on the given host and port. - Consider using CURLOPT_ALTSVC instead! */ - curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_3); + /* Use HTTP/3 but fallback to earlier HTTP if necessary */ + curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, + (long)CURL_HTTP_VERSION_3); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/docs/examples/httpcustomheader.c b/docs/examples/httpcustomheader.c index c72a474e0..a3881674c 100644 --- a/docs/examples/httpcustomheader.c +++ b/docs/examples/httpcustomheader.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/httpput-postfields.c b/docs/examples/httpput-postfields.c index f8a5c43a6..98d7c3d74 100644 --- a/docs/examples/httpput-postfields.c +++ b/docs/examples/httpput-postfields.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -43,7 +43,7 @@ static const char olivertwist[]= 509 byte limit. */ /* - * This example shows a HTTP PUT operation that sends a fixed buffer with + * This example shows an HTTP PUT operation that sends a fixed buffer with * CURLOPT_POSTFIELDS to the URL given as an argument. */ diff --git a/docs/examples/httpput.c b/docs/examples/httpput.c index 00ad99cb7..b9a6c87b7 100644 --- a/docs/examples/httpput.c +++ b/docs/examples/httpput.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -31,7 +31,7 @@ #include <curl/curl.h> /* - * This example shows a HTTP PUT operation. PUTs a file given as a command + * This example shows an HTTP PUT operation. PUTs a file given as a command * line argument to the URL also given on the command line. * * This example also uses its own read callback. @@ -101,8 +101,8 @@ int main(int argc, char **argv) /* now specify which file to upload */ curl_easy_setopt(curl, CURLOPT_READDATA, hd_src); - /* provide the size of the upload, we specicially typecast the value - to curl_off_t since we must be sure to use the correct data size */ + /* provide the size of the upload, we typecast the value to curl_off_t + since we must be sure to use the correct data size */ curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); diff --git a/docs/examples/https.c b/docs/examples/https.c index 7be330a8e..2a34e37d8 100644 --- a/docs/examples/https.c +++ b/docs/examples/https.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -63,6 +63,9 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif + /* cache the CA cert bundle in memory for a week */ + curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 604800L); + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); /* Check for errors */ diff --git a/docs/examples/imap-append.c b/docs/examples/imap-append.c index b66d8687e..33566bb64 100644 --- a/docs/examples/imap-append.c +++ b/docs/examples/imap-append.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to send emails + * Send email with IMAP * </DESC> */ @@ -49,11 +49,11 @@ static const char *payload_text = "Message-ID: " "<dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>\r\n" "Subject: IMAP example message\r\n" - "\r\n" /* empty line to divide headers from body, see RFC5322 */ + "\r\n" /* empty line to divide headers from body, see RFC 5322 */ "The body of the message starts here.\r\n" "\r\n" "It could be a lot of lines, could be MIME encoded, whatever.\r\n" - "Check RFC5322.\r\n"; + "Check RFC 5322.\r\n"; struct upload_status { size_t bytes_read; @@ -99,10 +99,8 @@ int main(void) curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); - /* This will create a new message 100. Note that you should perform an - * EXAMINE command to obtain the UID of the next message to create and a - * SELECT to ensure you are creating the message in the OUTBOX. */ - curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/100"); + /* This will create a new message in folder "Sent". */ + curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/Sent"); /* In this case, we are using a callback function to specify the data. You * could just use the CURLOPT_READDATA option to specify a FILE pointer to diff --git a/docs/examples/imap-authzid.c b/docs/examples/imap-authzid.c index 62eca4a68..af0732064 100644 --- a/docs/examples/imap-authzid.c +++ b/docs/examples/imap-authzid.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to retreieve emails from a shared mailed box + * Retrieve emails from a shared IMAP mailbox * </DESC> */ diff --git a/docs/examples/imap-copy.c b/docs/examples/imap-copy.c index 81ec5be70..0920f0944 100644 --- a/docs/examples/imap-copy.c +++ b/docs/examples/imap-copy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to copy an email from one folder to another + * Copy an email from one IMAP folder to another * </DESC> */ diff --git a/docs/examples/imap-create.c b/docs/examples/imap-create.c index 12e7113f3..6a9b56534 100644 --- a/docs/examples/imap-create.c +++ b/docs/examples/imap-create.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to create a new folder + * Create a new IMAP folder * </DESC> */ diff --git a/docs/examples/imap-delete.c b/docs/examples/imap-delete.c index 467b06010..e43ab2e98 100644 --- a/docs/examples/imap-delete.c +++ b/docs/examples/imap-delete.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to delete a folder + * Delete an IMAP folder * </DESC> */ diff --git a/docs/examples/imap-examine.c b/docs/examples/imap-examine.c index 68cc63693..34217bfa4 100644 --- a/docs/examples/imap-examine.c +++ b/docs/examples/imap-examine.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to obtain information about a folder + * Obtain information about an IMAP folder * </DESC> */ diff --git a/docs/examples/imap-fetch.c b/docs/examples/imap-fetch.c index d6237c386..3361d7cfe 100644 --- a/docs/examples/imap-fetch.c +++ b/docs/examples/imap-fetch.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to retreieve emails + * Retrieve IMAP emails * </DESC> */ diff --git a/docs/examples/imap-list.c b/docs/examples/imap-list.c index 85bddac07..2f3780f2d 100644 --- a/docs/examples/imap-list.c +++ b/docs/examples/imap-list.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example to list the folders within a mailbox + * List the folders within an IMAP mailbox * </DESC> */ diff --git a/docs/examples/imap-lsub.c b/docs/examples/imap-lsub.c index 1b22fa1e2..cf45a5fc2 100644 --- a/docs/examples/imap-lsub.c +++ b/docs/examples/imap-lsub.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example to list the subscribed folders + * List the subscribed IMAP folders * </DESC> */ @@ -50,7 +50,7 @@ int main(void) /* This is just the server URL */ curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com"); - /* Set the LSUB command. Note the syntax is very similar to that of a LIST + /* Set the LSUB command. Note the syntax is similar to that of a LIST command. */ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "LSUB \"\" *"); diff --git a/docs/examples/imap-multi.c b/docs/examples/imap-multi.c index 3b5c63368..6a5f4b070 100644 --- a/docs/examples/imap-multi.c +++ b/docs/examples/imap-multi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example using the multi interface + * Get IMAP email with the multi interface * </DESC> */ diff --git a/docs/examples/imap-noop.c b/docs/examples/imap-noop.c index ee1a7772d..9e5a3da2d 100644 --- a/docs/examples/imap-noop.c +++ b/docs/examples/imap-noop.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to perform a noop + * Perform an IMAP noop * </DESC> */ diff --git a/docs/examples/imap-search.c b/docs/examples/imap-search.c index 7b175b27c..141b06f64 100644 --- a/docs/examples/imap-search.c +++ b/docs/examples/imap-search.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to search for new emails + * Search for new IMAP emails * </DESC> */ diff --git a/docs/examples/imap-ssl.c b/docs/examples/imap-ssl.c index 5b0befbc2..e920720c0 100644 --- a/docs/examples/imap-ssl.c +++ b/docs/examples/imap-ssl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example using SSL + * IMAP with implicit SSL * </DESC> */ @@ -73,7 +73,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif - /* Since the traffic will be encrypted, it is very useful to turn on debug + /* Since the traffic will be encrypted, it is useful to turn on debug * information within libcurl to see what is happening during the * transfer */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/imap-store.c b/docs/examples/imap-store.c index 6a4c75677..d04a6072c 100644 --- a/docs/examples/imap-store.c +++ b/docs/examples/imap-store.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example showing how to modify the properties of an email + * Modify the properties of an email over IMAP * </DESC> */ diff --git a/docs/examples/imap-tls.c b/docs/examples/imap-tls.c index dbebbc722..d98f5ef9f 100644 --- a/docs/examples/imap-tls.c +++ b/docs/examples/imap-tls.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * IMAP example using TLS + * IMAP using TLS * </DESC> */ @@ -73,7 +73,7 @@ int main(void) * for more information. */ curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); - /* Since the traffic will be encrypted, it is very useful to turn on debug + /* Since the traffic will be encrypted, it is useful to turn on debug * information within libcurl to see what is happening during the * transfer */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/interface.c b/docs/examples/interface.c new file mode 100644 index 000000000..f1a2016ce --- /dev/null +++ b/docs/examples/interface.c @@ -0,0 +1,52 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Use CURLOPT_INTERFACE to bind the outgoing socket to an interface + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* The interface needs to be a local existing interface over which you can + connect to the host in the URL. It can also specify an IP address, but + that address needs to be assigned one of the local network + interfaces. */ + curl_easy_setopt(curl, CURLOPT_INTERFACE, "enp3s0"); + curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); + + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + return (int)res; +} diff --git a/docs/examples/ipv6.c b/docs/examples/ipv6.c new file mode 100644 index 000000000..dc305a072 --- /dev/null +++ b/docs/examples/ipv6.c @@ -0,0 +1,62 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * HTTP GET to an IPv6 address with specific scope + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +#ifndef _WIN32 +#include <net/if.h> +#endif + +int main(void) +{ +#ifndef _WIN32 + /* Windows users need to find how to use if_nametoindex() */ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + long my_scope_id; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + my_scope_id = if_nametoindex("eth0"); + curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } +#endif + return 0; +} diff --git a/docs/examples/keepalive.c b/docs/examples/keepalive.c new file mode 100644 index 000000000..1c876bb1f --- /dev/null +++ b/docs/examples/keepalive.c @@ -0,0 +1,55 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Use the TCP keep-alive options + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* enable TCP keep-alive for this transfer */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); + + /* keep-alive idle time to 120 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); + + /* interval time between keep-alive probes: 60 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); + + curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } + + return (int)res; +} diff --git a/docs/examples/localport.c b/docs/examples/localport.c new file mode 100644 index 000000000..56e0b62cf --- /dev/null +++ b/docs/examples/localport.c @@ -0,0 +1,53 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Use CURLOPT_LOCALPORT to control local port number + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* Try to use a local port number between 20000-20009 */ + curl_easy_setopt(curl, CURLOPT_LOCALPORT, 20000L); + /* 10 means number of attempts, which starts with the number set in + CURLOPT_LOCALPORT. The lowe value set, the smaller the change it will + work. */ + curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 10L); + curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); + + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + return (int)res; +} diff --git a/docs/examples/makefile.dj b/docs/examples/makefile.dj deleted file mode 100644 index 9f0de6690..000000000 --- a/docs/examples/makefile.dj +++ /dev/null @@ -1,57 +0,0 @@ -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) 1998 - 2022, 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 -# -########################################################################### - -TOPDIR = ../.. - -include $(TOPDIR)/packages/DOS/common.dj - -CFLAGS += -DFALSE=0 -DTRUE=1 - -LIBS = $(TOPDIR)/lib/libcurl.a - -ifeq ($(USE_SSL),1) - LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a -endif - -ifeq ($(USE_IDNA),1) - LIBS += $(LIBIDN_ROOT)/lib/dj_obj/libidn.a -liconv -endif - -LIBS += $(WATT32_ROOT)/lib/libwatt.a $(ZLIB_ROOT)/libz.a - -include Makefile.inc - -PROGRAMS = $(patsubst %,%.exe,$(check_PROGRAMS)) - -all: $(PROGRAMS) - @echo Welcome to libcurl example program - -%.exe: %.c - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - @echo - -clean vclean realclean: - - rm -f $(PROGRAMS) depend.dj - --include depend.dj diff --git a/docs/examples/maxconnects.c b/docs/examples/maxconnects.c new file mode 100644 index 000000000..84fefd7bc --- /dev/null +++ b/docs/examples/maxconnects.c @@ -0,0 +1,66 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) James Fuller, <jim@webcomposite.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 + * + ***************************************************************************/ +/* <DESC> + * Set maximum number of persistent connections to 1. + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + const char *urls[] = { "https://example.com", + "https://curl.se", + "https://www.example/", + NULL /* end of list */ + }; + int i = 0; + + /* Change the maximum number of persistent connection */ + curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 1L); + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* loop over the URLs */ + while(urls[i]) { + curl_easy_setopt(curl, CURLOPT_URL, urls[i]); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + i++; + } + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c index 813623865..3dbc46483 100644 --- a/docs/examples/multi-app.c +++ b/docs/examples/multi-app.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -38,7 +38,7 @@ #include <curl/curl.h> /* - * Download a HTTP file and upload an FTP file simultaneously. + * Download an HTTP file and upload an FTP file simultaneously. */ #define HANDLECOUNT 2 /* Number of simultaneous transfers */ diff --git a/docs/examples/multi-debugcallback.c b/docs/examples/multi-debugcallback.c index 16d5d56ca..8bdb58800 100644 --- a/docs/examples/multi-debugcallback.c +++ b/docs/examples/multi-debugcallback.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -36,13 +36,10 @@ /* curl stuff */ #include <curl/curl.h> -typedef char bool; #define TRUE 1 -static -void dump(const char *text, - FILE *stream, unsigned char *ptr, size_t size, - bool nohex) +static void dump(const char *text, FILE *stream, unsigned char *ptr, + size_t size, char nohex) { size_t i; size_t c; @@ -126,7 +123,7 @@ int my_trace(CURL *handle, curl_infotype type, } /* - * Simply download a HTTP file. + * Simply download an HTTP file. */ int main(void) { diff --git a/docs/examples/multi-double.c b/docs/examples/multi-double.c index b9bba520d..62295a92c 100644 --- a/docs/examples/multi-double.c +++ b/docs/examples/multi-double.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/multi-event.c b/docs/examples/multi-event.c index 4f61f5e4b..5a24bb203 100644 --- a/docs/examples/multi-event.c +++ b/docs/examples/multi-event.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/multi-formadd.c b/docs/examples/multi-formadd.c index e62de32ab..801b61e6d 100644 --- a/docs/examples/multi-formadd.c +++ b/docs/examples/multi-formadd.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/multi-legacy.c b/docs/examples/multi-legacy.c index f9bc699dd..f36139fe1 100644 --- a/docs/examples/multi-legacy.c +++ b/docs/examples/multi-legacy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -38,7 +38,7 @@ #include <curl/curl.h> /* - * Download a HTTP file and upload an FTP file simultaneously. + * Download an HTTP file and upload an FTP file simultaneously. */ #define HANDLECOUNT 2 /* Number of simultaneous transfers */ @@ -102,7 +102,7 @@ int main(void) if(timeout.tv_sec > 1) timeout.tv_sec = 1; else - timeout.tv_usec = (curl_timeo % 1000) * 1000; + timeout.tv_usec = (int)(curl_timeo % 1000) * 1000; } /* get file descriptors from the transfers */ diff --git a/docs/examples/multi-post.c b/docs/examples/multi-post.c index c141c68e9..112f3c0cd 100644 --- a/docs/examples/multi-post.c +++ b/docs/examples/multi-post.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/multi-single.c b/docs/examples/multi-single.c index 373ede34b..c5933627a 100644 --- a/docs/examples/multi-single.c +++ b/docs/examples/multi-single.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -37,7 +37,7 @@ #include <curl/curl.h> /* - * Simply download a HTTP file. + * Simply download an HTTP file. */ int main(void) { diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index fe7b357e8..6581b9fa6 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/multithread.c b/docs/examples/multithread.c index 4f2c85574..cc4ce7c12 100644 --- a/docs/examples/multithread.c +++ b/docs/examples/multithread.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,7 +22,7 @@ * ***************************************************************************/ /* <DESC> - * A multi-threaded example that uses pthreads to fetch several files at once + * A multi-threaded program using pthreads to fetch several files at once * </DESC> */ diff --git a/docs/examples/opensslthreadlock.c b/docs/examples/opensslthreadlock.c deleted file mode 100644 index a7de777ca..000000000 --- a/docs/examples/opensslthreadlock.c +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2022, 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 - * - ***************************************************************************/ -/* <DESC> - * one way to set the necessary OpenSSL locking callbacks if you want to do - * multi-threaded transfers with HTTPS/FTPS with libcurl built to use OpenSSL. - * </DESC> - */ -/* - * This is not a complete stand-alone example. - * - * Author: Jeremy Brown - */ - -#include <stdio.h> -#include <pthread.h> -#include <openssl/err.h> - -#define MUTEX_TYPE pthread_mutex_t -#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL) -#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x)) -#define MUTEX_LOCK(x) pthread_mutex_lock(&(x)) -#define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x)) -#define THREAD_ID pthread_self() - - -void handle_error(const char *file, int lineno, const char *msg) -{ - fprintf(stderr, "** %s:%d %s\n", file, lineno, msg); - ERR_print_errors_fp(stderr); - /* exit(-1); */ -} - -/* This array will store all of the mutexes available to OpenSSL. */ -static MUTEX_TYPE *mutex_buf = NULL; - -static void locking_function(int mode, int n, const char *file, int line) -{ - if(mode & CRYPTO_LOCK) - MUTEX_LOCK(mutex_buf[n]); - else - MUTEX_UNLOCK(mutex_buf[n]); -} - -static unsigned long id_function(void) -{ - return ((unsigned long)THREAD_ID); -} - -int thread_setup(void) -{ - int i; - - mutex_buf = malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE)); - if(!mutex_buf) - return 0; - for(i = 0; i < CRYPTO_num_locks(); i++) - MUTEX_SETUP(mutex_buf[i]); - CRYPTO_set_id_callback(id_function); - CRYPTO_set_locking_callback(locking_function); - return 1; -} - -int thread_cleanup(void) -{ - int i; - - if(!mutex_buf) - return 0; - CRYPTO_set_id_callback(NULL); - CRYPTO_set_locking_callback(NULL); - for(i = 0; i < CRYPTO_num_locks(); i++) - MUTEX_CLEANUP(mutex_buf[i]); - free(mutex_buf); - mutex_buf = NULL; - return 1; -} diff --git a/docs/examples/parseurl.c b/docs/examples/parseurl.c index d6682d70b..688336f02 100644 --- a/docs/examples/parseurl.c +++ b/docs/examples/parseurl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -74,7 +74,7 @@ int main(void) curl_free(path); } - fail: +fail: curl_url_cleanup(h); /* free url handle */ return 0; } diff --git a/docs/examples/persistent.c b/docs/examples/persistent.c index 6ddfc40ac..51bd8c352 100644 --- a/docs/examples/persistent.c +++ b/docs/examples/persistent.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,7 +22,7 @@ * ***************************************************************************/ /* <DESC> - * re-using handles to do HTTP persistent connections + * reusing handles to do HTTP persistent connections * </DESC> */ #include <stdio.h> diff --git a/docs/examples/pop3-authzid.c b/docs/examples/pop3-authzid.c index 8e0c2f2c6..a948e95c6 100644 --- a/docs/examples/pop3-authzid.c +++ b/docs/examples/pop3-authzid.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example showing how to retrieve emails from a shared mailbox + * Retrieve emails from a shared POP3 mailbox * </DESC> */ diff --git a/docs/examples/pop3-dele.c b/docs/examples/pop3-dele.c index d0281cb76..fe3795c24 100644 --- a/docs/examples/pop3-dele.c +++ b/docs/examples/pop3-dele.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example showing how to delete emails + * Delete POP3 emails * </DESC> */ diff --git a/docs/examples/pop3-list.c b/docs/examples/pop3-list.c index 991ff2417..2e8b3baee 100644 --- a/docs/examples/pop3-list.c +++ b/docs/examples/pop3-list.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example to list the contents of a mailbox + * List the contents of a POP3 mailbox * </DESC> */ diff --git a/docs/examples/pop3-multi.c b/docs/examples/pop3-multi.c index 69a108857..b4fad1925 100644 --- a/docs/examples/pop3-multi.c +++ b/docs/examples/pop3-multi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example using the multi interface + * Get POP3 email using the multi interface * </DESC> */ diff --git a/docs/examples/pop3-noop.c b/docs/examples/pop3-noop.c index a3ecb8821..16181d287 100644 --- a/docs/examples/pop3-noop.c +++ b/docs/examples/pop3-noop.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example showing how to perform a noop + * Perform a POP3 noop * </DESC> */ diff --git a/docs/examples/pop3-retr.c b/docs/examples/pop3-retr.c index 1df065716..4940e0781 100644 --- a/docs/examples/pop3-retr.c +++ b/docs/examples/pop3-retr.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example showing how to retrieve emails + * Retrieve POP3 email * </DESC> */ diff --git a/docs/examples/pop3-ssl.c b/docs/examples/pop3-ssl.c index 6f3455a69..e72cf6f38 100644 --- a/docs/examples/pop3-ssl.c +++ b/docs/examples/pop3-ssl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example using SSL + * Get POP3 email using implicit SSL * </DESC> */ @@ -72,7 +72,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif - /* Since the traffic will be encrypted, it is very useful to turn on debug + /* Since the traffic will be encrypted, it is useful to turn on debug * information within libcurl to see what is happening during the * transfer */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/pop3-stat.c b/docs/examples/pop3-stat.c index 3df35719d..419859bfa 100644 --- a/docs/examples/pop3-stat.c +++ b/docs/examples/pop3-stat.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example showing how to obtain message statistics + * Obtain POP3 message statistics * </DESC> */ diff --git a/docs/examples/pop3-tls.c b/docs/examples/pop3-tls.c index d58b5e49a..04e6e3b71 100644 --- a/docs/examples/pop3-tls.c +++ b/docs/examples/pop3-tls.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example using TLS + * POP3 using TLS * </DESC> */ @@ -72,7 +72,7 @@ int main(void) * for more information. */ curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); - /* Since the traffic will be encrypted, it is very useful to turn on debug + /* Since the traffic will be encrypted, it is useful to turn on debug * information within libcurl to see what is happening during the * transfer */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/pop3-top.c b/docs/examples/pop3-top.c index c63b43c73..7ceba881b 100644 --- a/docs/examples/pop3-top.c +++ b/docs/examples/pop3-top.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/pop3-uidl.c b/docs/examples/pop3-uidl.c index 308de3b44..496e5b08d 100644 --- a/docs/examples/pop3-uidl.c +++ b/docs/examples/pop3-uidl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * POP3 example to list the contents of a mailbox by unique ID + * List the contents of a POP3 mailbox by unique ID * </DESC> */ diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index dabcef056..a802c3582 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -101,7 +101,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* - If you use POST to a HTTP 1.1 server, you can send data without knowing + If you use POST to an HTTP 1.1 server, you can send data without knowing the size before starting the POST if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you must diff --git a/docs/examples/postinmemory.c b/docs/examples/postinmemory.c index bbe145773..1610ad5a5 100644 --- a/docs/examples/postinmemory.c +++ b/docs/examples/postinmemory.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,7 +22,7 @@ * ***************************************************************************/ /* <DESC> - * Make a HTTP POST with data from memory and receive response in memory. + * Make an HTTP POST with data from memory and receive response in memory. * </DESC> */ #include <stdio.h> diff --git a/docs/examples/postit2-formadd.c b/docs/examples/postit2-formadd.c index 502776960..27761fcda 100644 --- a/docs/examples/postit2-formadd.c +++ b/docs/examples/postit2-formadd.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -28,7 +28,7 @@ /* * Example code that uploads a file name 'foo' to a remote script that accepts - * "HTML form based" (as described in RFC1738) uploads using HTTP POST. + * "HTML form based" (as described in RFC 1738) uploads using HTTP POST. * * Warning: this example uses the deprecated form api. See "postit2.c" * for a similar example using the mime api. diff --git a/docs/examples/postit2.c b/docs/examples/postit2.c index 5e9c609d3..a1fb12b0f 100644 --- a/docs/examples/postit2.c +++ b/docs/examples/postit2.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -26,7 +26,7 @@ * </DESC> */ /* Example code that uploads a file name 'foo' to a remote script that accepts - * "HTML form based" (as described in RFC1738) uploads using HTTP POST. + * "HTML form based" (as described in RFC 1738) uploads using HTTP POST. * * The imaginary form we will fill in looks like: * diff --git a/docs/examples/progressfunc.c b/docs/examples/progressfunc.c index be32b67aa..e164f03ca 100644 --- a/docs/examples/progressfunc.c +++ b/docs/examples/progressfunc.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/protofeats.c b/docs/examples/protofeats.c new file mode 100644 index 000000000..3e762218a --- /dev/null +++ b/docs/examples/protofeats.c @@ -0,0 +1,52 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Outputs all protocols and features supported + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +#if !CURL_AT_LEAST_VERSION(7,87,0) +#error "too old libcurl" +#endif + +int main(void) +{ + curl_version_info_data *ver; + const char *const *ptr; + + curl_global_init(CURL_GLOBAL_ALL); + + ver = curl_version_info(CURLVERSION_NOW); + printf("Protocols:\n"); + for(ptr = ver->protocols; *ptr; ++ptr) + printf(" %s\n", *ptr); + printf("Features:\n"); + for(ptr = ver->feature_names; *ptr; ++ptr) + printf(" %s\n", *ptr); + + curl_global_cleanup(); + return 0; +} diff --git a/docs/examples/resolve.c b/docs/examples/resolve.c index 40bdfb345..a16f45954 100644 --- a/docs/examples/resolve.c +++ b/docs/examples/resolve.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/rtsp-options.c b/docs/examples/rtsp-options.c new file mode 100644 index 000000000..e4a623048 --- /dev/null +++ b/docs/examples/rtsp-options.c @@ -0,0 +1,55 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Very simple RTSP request sending OPTIONS. + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + + curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, "12345"); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/sendrecv.c b/docs/examples/sendrecv.c index 7da740a09..b935bee10 100644 --- a/docs/examples/sendrecv.c +++ b/docs/examples/sendrecv.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -22,7 +22,7 @@ * ***************************************************************************/ /* <DESC> - * An example of curl_easy_send() and curl_easy_recv() usage. + * Demonstrate curl_easy_send() and curl_easy_recv() usage. * </DESC> */ @@ -38,7 +38,7 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms) int res; tv.tv_sec = timeout_ms / 1000; - tv.tv_usec = (timeout_ms % 1000) * 1000; + tv.tv_usec = (int)(timeout_ms % 1000) * 1000; FD_ZERO(&infd); FD_ZERO(&outfd); diff --git a/docs/examples/sepheaders.c b/docs/examples/sepheaders.c index a398d0568..0d090ed81 100644 --- a/docs/examples/sepheaders.c +++ b/docs/examples/sepheaders.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/sessioninfo.c b/docs/examples/sessioninfo.c index 4a848b9fe..befb8f3c0 100644 --- a/docs/examples/sessioninfo.c +++ b/docs/examples/sessioninfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/sftpget.c b/docs/examples/sftpget.c index 05041b18b..6f0cb2ad4 100644 --- a/docs/examples/sftpget.c +++ b/docs/examples/sftpget.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -77,7 +77,7 @@ int main(void) */ curl_easy_setopt(curl, CURLOPT_URL, "sftp://user@server/home/user/file.txt"); - /* Define our callback to get called when there's data to be written */ + /* Define our callback to get called when there is data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); diff --git a/docs/examples/sftpuploadresume.c b/docs/examples/sftpuploadresume.c index 7c72e5d09..aabe5c395 100644 --- a/docs/examples/sftpuploadresume.c +++ b/docs/examples/sftpuploadresume.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/shared-connection-cache.c b/docs/examples/shared-connection-cache.c index ac9eb5492..26bfb1a46 100644 --- a/docs/examples/shared-connection-cache.c +++ b/docs/examples/shared-connection-cache.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 38134c394..8579b0ba5 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/simplepost.c b/docs/examples/simplepost.c index 95564d75f..89435afa6 100644 --- a/docs/examples/simplepost.c +++ b/docs/examples/simplepost.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c index 879672b3f..9d933ce82 100644 --- a/docs/examples/simplessl.c +++ b/docs/examples/simplessl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -118,7 +118,7 @@ int main(void) /* set the private key (file or ID in engine) */ curl_easy_setopt(curl, CURLOPT_SSLKEY, pKeyName); - /* set the file with the certs vaildating the server */ + /* set the file with the certs validating the server */ curl_easy_setopt(curl, CURLOPT_CAINFO, pCACertFile); /* disconnect if we cannot validate server's cert */ diff --git a/docs/examples/smooth-gtk-thread.c b/docs/examples/smooth-gtk-thread.c index c9923746f..906660f99 100644 --- a/docs/examples/smooth-gtk-thread.c +++ b/docs/examples/smooth-gtk-thread.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/smtp-authzid.c b/docs/examples/smtp-authzid.c index d48a811c8..dc24d7f4d 100644 --- a/docs/examples/smtp-authzid.c +++ b/docs/examples/smtp-authzid.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -39,7 +39,7 @@ */ /* The libcurl options want plain addresses, the viewable headers in the mail - * can very well get a full name as well. + * can get a full name as well. */ #define FROM_ADDR "<ursel@example.org>" #define SENDER_ADDR "<kurt@example.org>" @@ -57,11 +57,11 @@ static const char *payload_text = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "rfcpedant.example.org>\r\n" "Subject: SMTP example message\r\n" - "\r\n" /* empty line to divide headers from body, see RFC5322 */ + "\r\n" /* empty line to divide headers from body, see RFC 5322 */ "The body of the message starts here.\r\n" "\r\n" "It could be a lot of lines, could be MIME encoded, whatever.\r\n" - "Check RFC5322.\r\n"; + "Check RFC 5322.\r\n"; struct upload_status { size_t bytes_read; @@ -148,12 +148,12 @@ int main(void) curl_slist_free_all(recipients); /* curl will not send the QUIT command until you call cleanup, so you - * should be able to re-use this connection for additional messages + * should be able to reuse this connection for additional messages * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and * calling curl_easy_perform() again. It may not be a good idea to keep - * the connection open for a very long time though (more than a few - * minutes may result in the server timing out the connection), and you do - * want to clean up in the end. + * the connection open for a long time though (more than a few minutes may + * result in the server timing out the connection), and you do want to + * clean up in the end. */ curl_easy_cleanup(curl); } diff --git a/docs/examples/smtp-expn.c b/docs/examples/smtp-expn.c index 6d9d4a4b8..e61b6b4ee 100644 --- a/docs/examples/smtp-expn.c +++ b/docs/examples/smtp-expn.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * SMTP example showing how to expand an email mailing list + * Expand an SMTP email mailing list * </DESC> */ @@ -69,9 +69,9 @@ int main(void) curl_slist_free_all(recipients); /* curl will not send the QUIT command until you call cleanup, so you - * should be able to re-use this connection for additional requests. It - * may not be a good idea to keep the connection open for a very long time - * though (more than a few minutes may result in the server timing out the + * should be able to reuse this connection for additional requests. It may + * not be a good idea to keep the connection open for a long time though + * (more than a few minutes may result in the server timing out the * connection) and you do want to clean up in the end. */ curl_easy_cleanup(curl); diff --git a/docs/examples/smtp-mail.c b/docs/examples/smtp-mail.c index 5f3fcfddb..742787824 100644 --- a/docs/examples/smtp-mail.c +++ b/docs/examples/smtp-mail.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -36,7 +36,7 @@ */ /* The libcurl options want plain addresses, the viewable headers in the mail - * can very well get a full name as well. + * can get a full name as well. */ #define FROM_ADDR "<sender@example.org>" #define TO_ADDR "<addressee@example.net>" @@ -54,11 +54,11 @@ static const char *payload_text = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "rfcpedant.example.org>\r\n" "Subject: SMTP example message\r\n" - "\r\n" /* empty line to divide headers from body, see RFC5322 */ + "\r\n" /* empty line to divide headers from body, see RFC 5322 */ "The body of the message starts here.\r\n" "\r\n" "It could be a lot of lines, could be MIME encoded, whatever.\r\n" - "Check RFC5322.\r\n"; + "Check RFC 5322.\r\n"; struct upload_status { size_t bytes_read; @@ -136,12 +136,12 @@ int main(void) curl_slist_free_all(recipients); /* curl will not send the QUIT command until you call cleanup, so you - * should be able to re-use this connection for additional messages + * should be able to reuse this connection for additional messages * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and * calling curl_easy_perform() again. It may not be a good idea to keep - * the connection open for a very long time though (more than a few - * minutes may result in the server timing out the connection), and you do - * want to clean up in the end. + * the connection open for a long time though (more than a few minutes may + * result in the server timing out the connection), and you do want to + * clean up in the end. */ curl_easy_cleanup(curl); } diff --git a/docs/examples/smtp-mime.c b/docs/examples/smtp-mime.c index ce95582b3..36703a1d8 100644 --- a/docs/examples/smtp-mime.c +++ b/docs/examples/smtp-mime.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * SMTP example showing how to send mime emails + * Send SMTP mime emails * </DESC> */ @@ -102,6 +102,9 @@ int main(void) recipients = curl_slist_append(recipients, CC); curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients); + /* allow one of the recipients to fail and still consider it okay */ + curl_easy_setopt(curl, CURLOPT_MAIL_RCPT_ALLOWFAILS, 1L); + /* Build and set the message header list. */ for(cpp = headers_text; *cpp; cpp++) headers = curl_slist_append(headers, *cpp); @@ -148,12 +151,12 @@ int main(void) curl_slist_free_all(headers); /* curl will not send the QUIT command until you call cleanup, so you - * should be able to re-use this connection for additional messages + * should be able to reuse this connection for additional messages * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and * calling curl_easy_perform() again. It may not be a good idea to keep - * the connection open for a very long time though (more than a few - * minutes may result in the server timing out the connection), and you do - * want to clean up in the end. + * the connection open for a long time though (more than a few minutes may + * result in the server timing out the connection), and you do want to + * clean up in the end. */ curl_easy_cleanup(curl); diff --git a/docs/examples/smtp-multi.c b/docs/examples/smtp-multi.c index 385827c0c..e5bc4011c 100644 --- a/docs/examples/smtp-multi.c +++ b/docs/examples/smtp-multi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * SMTP example using the multi interface + * Send SMTP email with the multi interface * </DESC> */ @@ -47,11 +47,11 @@ static const char *payload_text = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "rfcpedant.example.org>\r\n" "Subject: SMTP example message\r\n" - "\r\n" /* empty line to divide headers from body, see RFC5322 */ + "\r\n" /* empty line to divide headers from body, see RFC 5322 */ "The body of the message starts here.\r\n" "\r\n" "It could be a lot of lines, could be MIME encoded, whatever.\r\n" - "Check RFC5322.\r\n"; + "Check RFC 5322.\r\n"; struct upload_status { size_t bytes_read; diff --git a/docs/examples/smtp-ssl.c b/docs/examples/smtp-ssl.c index 70b204591..89708408d 100644 --- a/docs/examples/smtp-ssl.c +++ b/docs/examples/smtp-ssl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * SMTP example using SSL + * Send SMTP email using implicit SSL * </DESC> */ @@ -51,11 +51,11 @@ static const char *payload_text = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "rfcpedant.example.org>\r\n" "Subject: SMTP example message\r\n" - "\r\n" /* empty line to divide headers from body, see RFC5322 */ + "\r\n" /* empty line to divide headers from body, see RFC 5322 */ "The body of the message starts here.\r\n" "\r\n" "It could be a lot of lines, could be MIME encoded, whatever.\r\n" - "Check RFC5322.\r\n"; + "Check RFC 5322.\r\n"; struct upload_status { size_t bytes_read; @@ -146,7 +146,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - /* Since the traffic will be encrypted, it is very useful to turn on debug + /* Since the traffic will be encrypted, it is useful to turn on debug * information within libcurl to see what is happening during the * transfer */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/smtp-tls.c b/docs/examples/smtp-tls.c index e30f4788e..83aab69cb 100644 --- a/docs/examples/smtp-tls.c +++ b/docs/examples/smtp-tls.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * SMTP example using TLS + * Send SMTP email using implicit TLS * </DESC> */ @@ -51,11 +51,11 @@ static const char *payload_text = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@" "rfcpedant.example.org>\r\n" "Subject: SMTP example message\r\n" - "\r\n" /* empty line to divide headers from body, see RFC5322 */ + "\r\n" /* empty line to divide headers from body, see RFC 5322 */ "The body of the message starts here.\r\n" "\r\n" "It could be a lot of lines, could be MIME encoded, whatever.\r\n" - "Check RFC5322.\r\n"; + "Check RFC 5322.\r\n"; struct upload_status { size_t bytes_read; @@ -101,7 +101,7 @@ int main(void) /* This is the URL for your mailserver. Note the use of port 587 here, * instead of the normal SMTP port (25). Port 587 is commonly used for - * secure mail submission (see RFC4403), but you should use whatever + * secure mail submission (see RFC 4403), but you should use whatever * matches your server configuration. */ curl_easy_setopt(curl, CURLOPT_URL, "smtp://mainserver.example.net:587"); @@ -148,8 +148,9 @@ int main(void) curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - /* Since the traffic will be encrypted, it is very useful to turn on debug - * information within libcurl to see what is happening during the transfer. + /* Since the traffic will be encrypted, it is useful to turn on debug + * information within libcurl to see what is happening during the + * transfer. */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/docs/examples/smtp-vrfy.c b/docs/examples/smtp-vrfy.c index e6815b6cb..70da41b06 100644 --- a/docs/examples/smtp-vrfy.c +++ b/docs/examples/smtp-vrfy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -23,7 +23,7 @@ ***************************************************************************/ /* <DESC> - * SMTP example showing how to verify an email address + * Verify an SMTP email address * </DESC> */ @@ -69,9 +69,9 @@ int main(void) curl_slist_free_all(recipients); /* curl will not send the QUIT command until you call cleanup, so you - * should be able to re-use this connection for additional requests. It - * may not be a good idea to keep the connection open for a very long time - * though (more than a few minutes may result in the server timing out the + * should be able to reuse this connection for additional requests. It may + * not be a good idea to keep the connection open for a long time though + * (more than a few minutes may result in the server timing out the * connection) and you do want to clean up in the end. */ curl_easy_cleanup(curl); diff --git a/docs/examples/sslbackend.c b/docs/examples/sslbackend.c index e07d1905e..fd2b57534 100644 --- a/docs/examples/sslbackend.c +++ b/docs/examples/sslbackend.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -49,7 +49,7 @@ int main(int argc, char **argv) const curl_ssl_backend **list; int i; - result = curl_global_sslset((curl_sslbackend)-1, NULL, &list); + result = curl_global_sslset(CURLSSLBACKEND_NONE, NULL, &list); assert(result == CURLSSLSET_UNKNOWN_BACKEND); for(i = 0; list[i]; i++) @@ -64,7 +64,7 @@ int main(int argc, char **argv) result = curl_global_sslset((curl_sslbackend)id, NULL, NULL); } else - result = curl_global_sslset((curl_sslbackend)-1, name, NULL); + result = curl_global_sslset(CURLSSLBACKEND_NONE, name, NULL); if(result == CURLSSLSET_UNKNOWN_BACKEND) { fprintf(stderr, "Unknown SSL backend id: %s\n", name); diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c index b617dd6ab..fcf25d941 100644 --- a/docs/examples/synctime.c +++ b/docs/examples/synctime.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -41,7 +41,7 @@ * * Synchronising your computer clock via Internet time server usually relies * on DAYTIME, TIME, or NTP protocols. These protocols provide good accurate - * time synchronization but it does not work very well through a + * time synchronization but it does not work well through a * firewall/proxy. Some adjustment has to be made to the firewall/proxy for * these protocols to work properly. * @@ -54,7 +54,7 @@ * 2. Webserver system time must in sync with the NTP time server, * or at least provide an accurate time keeping. * 3. Webserver HTTP header does not provide the milliseconds units, - * so there is no way to get very accurate time. + * so there is no way to get an accurate time. * 4. This software could only provide an accuracy of +- a few seconds, * as Round-Trip delay time is not taken into consideration. * Compensation of network, firewall/proxy delay cannot be simply divide diff --git a/docs/examples/threaded-ssl.c b/docs/examples/threaded-ssl.c index 09292c49a..f58e44741 100644 --- a/docs/examples/threaded-ssl.c +++ b/docs/examples/threaded-ssl.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/unixsocket.c b/docs/examples/unixsocket.c new file mode 100644 index 000000000..53c5fd2de --- /dev/null +++ b/docs/examples/unixsocket.c @@ -0,0 +1,67 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * Access HTTP server over unix domain socket + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +#ifdef USE_ABSTRACT +/* + * The abstract socket namespace is a nonportable Linux extension. The name + * has no connection with filesystem pathnames. + */ +#define ABSTRACT "http-unix-domain" +#else +#define PATH "/tmp/http-unix-domain" +#endif + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); + +#ifdef USE_ABSTRACT + curl_easy_setopt(curl, CURLOPT_ABSTRACT_UNIX_SOCKET, ABSTRACT); +#else + curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, PATH); +#endif + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/url2file.c b/docs/examples/url2file.c index c01bcf3e4..f95d57464 100644 --- a/docs/examples/url2file.c +++ b/docs/examples/url2file.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 diff --git a/docs/examples/urlapi.c b/docs/examples/urlapi.c index 11962abc5..2ed78eb11 100644 --- a/docs/examples/urlapi.c +++ b/docs/examples/urlapi.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -58,6 +58,9 @@ int main(void) curl_easy_setopt(curl, CURLOPT_CURLU, urlp); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + /* only allow HTTP, TFTP and SFTP */ + curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp"); + res = curl_easy_perform(curl); /* Check for errors */ if(res != CURLE_OK) @@ -67,7 +70,7 @@ int main(void) goto cleanup; } - cleanup: +cleanup: curl_url_cleanup(urlp); curl_easy_cleanup(curl); return 0; diff --git a/docs/examples/usercertinmem.c b/docs/examples/usercertinmem.c index 89a0c3c40..12a2b7937 100644 --- a/docs/examples/usercertinmem.c +++ b/docs/examples/usercertinmem.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2013 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 @@ -94,7 +94,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) "omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n"\ "-----END CERTIFICATE-----\n"; -/*replace the XXX with the actual RSA key*/ +/* replace the XXX with the actual RSA key */ const char *mykey = "-----BEGIN RSA PRIVATE KEY-----\n"\ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"\ @@ -133,25 +133,25 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) printf("PEM_read_bio_X509 failed...\n"); } - /*tell SSL to use the X509 certificate*/ + /* tell SSL to use the X509 certificate */ ret = SSL_CTX_use_certificate((SSL_CTX*)sslctx, cert); if(ret != 1) { printf("Use certificate failed\n"); } - /*create a bio for the RSA key*/ + /* create a bio for the RSA key */ kbio = BIO_new_mem_buf((char *)mykey, -1); if(!kbio) { printf("BIO_new_mem_buf failed\n"); } - /*read the key bio into an RSA object*/ + /* read the key bio into an RSA object */ rsa = PEM_read_bio_RSAPrivateKey(kbio, NULL, 0, NULL); if(!rsa) { printf("Failed to create key bio\n"); } - /*tell SSL to use the RSA key from memory*/ + /* tell SSL to use the RSA key from memory */ ret = SSL_CTX_use_RSAPrivateKey((SSL_CTX*)sslctx, rsa); if(ret != 1) { printf("Use Key failed\n"); @@ -192,7 +192,7 @@ int main(void) curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); /* both VERIFYPEER and VERIFYHOST are set to 0 in this case because there is - no CA certificate*/ + no CA certificate */ curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(ch, CURLOPT_SSL_VERIFYHOST, 0L); diff --git a/docs/examples/version-check.pl b/docs/examples/version-check.pl index aca37995a..932d154bd 100755 --- a/docs/examples/version-check.pl +++ b/docs/examples/version-check.pl @@ -6,7 +6,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. +# 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 diff --git a/docs/examples/websocket-cb.c b/docs/examples/websocket-cb.c new file mode 100644 index 000000000..7adbf4489 --- /dev/null +++ b/docs/examples/websocket-cb.c @@ -0,0 +1,68 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * WebSocket download-only using write callback + * </DESC> + */ +#include <stdio.h> +#include <curl/curl.h> + +static size_t writecb(char *b, size_t size, size_t nitems, void *p) +{ + CURL *easy = p; + size_t i; + const struct curl_ws_frame *frame = curl_ws_meta(easy); + fprintf(stderr, "Type: %s\n", frame->flags & CURLWS_BINARY ? + "binary" : "text"); + fprintf(stderr, "Bytes: %u", (unsigned int)(nitems * size)); + for(i = 0; i < nitems; i++) + fprintf(stderr, "%02x ", (unsigned char)b[i]); + return nitems; +} + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "wss://example.com"); + + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); + /* pass the easy handle to the callback */ + curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/websocket.c b/docs/examples/websocket.c new file mode 100644 index 000000000..dbcd044f5 --- /dev/null +++ b/docs/examples/websocket.c @@ -0,0 +1,131 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + * + ***************************************************************************/ +/* <DESC> + * WebSocket using CONNECT_ONLY + * </DESC> + */ +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <curl/curl.h> + +static int ping(CURL *curl, const char *send_payload) +{ + size_t sent; + CURLcode result = + curl_ws_send(curl, send_payload, strlen(send_payload), &sent, 0, + CURLWS_PING); + return (int)result; +} + +static int recv_pong(CURL *curl, const char *expected_payload) +{ + size_t rlen; + const struct curl_ws_frame *meta; + char buffer[256]; + CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta); + if(!result) { + if(meta->flags & CURLWS_PONG) { + int same = 0; + fprintf(stderr, "ws: got PONG back\n"); + if(rlen == strlen(expected_payload)) { + if(!memcmp(expected_payload, buffer, rlen)) { + fprintf(stderr, "ws: got the same payload back\n"); + same = 1; + } + } + if(!same) + fprintf(stderr, "ws: did NOT get the same payload back\n"); + } + else { + fprintf(stderr, "recv_pong: got %u bytes rflags %x\n", (int)rlen, + meta->flags); + } + } + fprintf(stderr, "ws: curl_ws_recv returned %u, received %u\n", + (unsigned int)result, (unsigned int)rlen); + return (int)result; +} + +static int recv_any(CURL *curl) +{ + size_t rlen; + const struct curl_ws_frame *meta; + char buffer[256]; + CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta); + if(result) + return result; + + return 0; +} + +/* close the connection */ +static void websocket_close(CURL *curl) +{ + size_t sent; + (void)curl_ws_send(curl, "", 0, &sent, 0, CURLWS_CLOSE); +} + +static void websocket(CURL *curl) +{ + int i = 0; + do { + recv_any(curl); + if(ping(curl, "foobar")) + return; + if(recv_pong(curl, "foobar")) { + return; + } + sleep(2); + } while(i++ < 10); + websocket_close(curl); +} + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "wss://example.com"); + + curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 2L); /* websocket style */ + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + else { + /* connected and ready */ + websocket(curl); + } + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/docs/examples/xmlstream.c b/docs/examples/xmlstream.c index ae5963b95..76a8e48cc 100644 --- a/docs/examples/xmlstream.c +++ b/docs/examples/xmlstream.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * 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 |