]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
docs: make all examples in all libcurl man pages compile
authorDaniel Stenberg <daniel@haxx.se>
Mon, 4 Dec 2023 09:50:42 +0000 (10:50 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 4 Dec 2023 09:50:42 +0000 (10:50 +0100)
Closes #12448

478 files changed:
.github/scripts/verify-examples.pl
docs/libcurl/curl_easy_cleanup.3
docs/libcurl/curl_easy_duphandle.3
docs/libcurl/curl_easy_escape.3
docs/libcurl/curl_easy_getinfo.3
docs/libcurl/curl_easy_header.3
docs/libcurl/curl_easy_init.3
docs/libcurl/curl_easy_nextheader.3
docs/libcurl/curl_easy_option_by_id.3
docs/libcurl/curl_easy_option_by_name.3
docs/libcurl/curl_easy_option_next.3
docs/libcurl/curl_easy_pause.3
docs/libcurl/curl_easy_perform.3
docs/libcurl/curl_easy_recv.3
docs/libcurl/curl_easy_reset.3
docs/libcurl/curl_easy_send.3
docs/libcurl/curl_easy_setopt.3
docs/libcurl/curl_easy_strerror.3
docs/libcurl/curl_easy_unescape.3
docs/libcurl/curl_easy_upkeep.3
docs/libcurl/curl_escape.3
docs/libcurl/curl_formadd.3
docs/libcurl/curl_formfree.3
docs/libcurl/curl_formget.3
docs/libcurl/curl_free.3
docs/libcurl/curl_getdate.3
docs/libcurl/curl_getenv.3
docs/libcurl/curl_global_cleanup.3
docs/libcurl/curl_global_init.3
docs/libcurl/curl_global_init_mem.3
docs/libcurl/curl_global_sslset.3
docs/libcurl/curl_global_trace.3
docs/libcurl/curl_mime_addpart.3
docs/libcurl/curl_mime_data.3
docs/libcurl/curl_mime_data_cb.3
docs/libcurl/curl_mime_encoder.3
docs/libcurl/curl_mime_filedata.3
docs/libcurl/curl_mime_filename.3
docs/libcurl/curl_mime_free.3
docs/libcurl/curl_mime_headers.3
docs/libcurl/curl_mime_init.3
docs/libcurl/curl_mime_name.3
docs/libcurl/curl_mime_subparts.3
docs/libcurl/curl_mime_type.3
docs/libcurl/curl_mprintf.3
docs/libcurl/curl_multi_add_handle.3
docs/libcurl/curl_multi_assign.3
docs/libcurl/curl_multi_cleanup.3
docs/libcurl/curl_multi_fdset.3
docs/libcurl/curl_multi_get_handles.3
docs/libcurl/curl_multi_info_read.3
docs/libcurl/curl_multi_init.3
docs/libcurl/curl_multi_perform.3
docs/libcurl/curl_multi_poll.3
docs/libcurl/curl_multi_remove_handle.3
docs/libcurl/curl_multi_setopt.3
docs/libcurl/curl_multi_socket.3
docs/libcurl/curl_multi_socket_action.3
docs/libcurl/curl_multi_strerror.3
docs/libcurl/curl_multi_timeout.3
docs/libcurl/curl_multi_wait.3
docs/libcurl/curl_multi_wakeup.3
docs/libcurl/curl_pushheader_byname.3
docs/libcurl/curl_pushheader_bynum.3
docs/libcurl/curl_share_cleanup.3
docs/libcurl/curl_share_init.3
docs/libcurl/curl_share_setopt.3
docs/libcurl/curl_share_strerror.3
docs/libcurl/curl_slist_append.3
docs/libcurl/curl_slist_free_all.3
docs/libcurl/curl_strequal.3
docs/libcurl/curl_unescape.3
docs/libcurl/curl_url.3
docs/libcurl/curl_url_cleanup.3
docs/libcurl/curl_url_dup.3
docs/libcurl/curl_url_get.3
docs/libcurl/curl_url_set.3
docs/libcurl/curl_url_strerror.3
docs/libcurl/curl_version.3
docs/libcurl/curl_version_info.3
docs/libcurl/curl_ws_meta.3
docs/libcurl/curl_ws_recv.3
docs/libcurl/curl_ws_send.3
docs/libcurl/opts/CURLINFO_ACTIVESOCKET.3
docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.3
docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.3
docs/libcurl/opts/CURLINFO_CAINFO.3
docs/libcurl/opts/CURLINFO_CAPATH.3
docs/libcurl/opts/CURLINFO_CERTINFO.3
docs/libcurl/opts/CURLINFO_CONDITION_UNMET.3
docs/libcurl/opts/CURLINFO_CONNECT_TIME.3
docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.3
docs/libcurl/opts/CURLINFO_CONN_ID.3
docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.3
docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.3
docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3
docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.3
docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3
docs/libcurl/opts/CURLINFO_COOKIELIST.3
docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.3
docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.3
docs/libcurl/opts/CURLINFO_FILETIME.3
docs/libcurl/opts/CURLINFO_FILETIME_T.3
docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3
docs/libcurl/opts/CURLINFO_HEADER_SIZE.3
docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3
docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3
docs/libcurl/opts/CURLINFO_HTTP_VERSION.3
docs/libcurl/opts/CURLINFO_LASTSOCKET.3
docs/libcurl/opts/CURLINFO_LOCAL_IP.3
docs/libcurl/opts/CURLINFO_LOCAL_PORT.3
docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.3
docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.3
docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3
docs/libcurl/opts/CURLINFO_OS_ERRNO.3
docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.3
docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.3
docs/libcurl/opts/CURLINFO_PRIMARY_IP.3
docs/libcurl/opts/CURLINFO_PRIMARY_PORT.3
docs/libcurl/opts/CURLINFO_PRIVATE.3
docs/libcurl/opts/CURLINFO_PROTOCOL.3
docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.3
docs/libcurl/opts/CURLINFO_PROXY_ERROR.3
docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.3
docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.3
docs/libcurl/opts/CURLINFO_REDIRECT_TIME.3
docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.3
docs/libcurl/opts/CURLINFO_REDIRECT_URL.3
docs/libcurl/opts/CURLINFO_REFERER.3
docs/libcurl/opts/CURLINFO_REQUEST_SIZE.3
docs/libcurl/opts/CURLINFO_RESPONSE_CODE.3
docs/libcurl/opts/CURLINFO_RETRY_AFTER.3
docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.3
docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.3
docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.3
docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.3
docs/libcurl/opts/CURLINFO_SCHEME.3
docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.3
docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.3
docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.3
docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.3
docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.3
docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.3
docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.3
docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.3
docs/libcurl/opts/CURLINFO_SSL_ENGINES.3
docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.3
docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.3
docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.3
docs/libcurl/opts/CURLINFO_TLS_SESSION.3
docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3
docs/libcurl/opts/CURLINFO_TOTAL_TIME.3
docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.3
docs/libcurl/opts/CURLINFO_XFER_ID.3
docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.3
docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.3
docs/libcurl/opts/CURLMOPT_MAXCONNECTS.3
docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.3
docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.3
docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.3
docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.3
docs/libcurl/opts/CURLMOPT_PIPELINING.3
docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.3
docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.3
docs/libcurl/opts/CURLMOPT_PUSHDATA.3
docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.3
docs/libcurl/opts/CURLMOPT_SOCKETDATA.3
docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.3
docs/libcurl/opts/CURLMOPT_TIMERDATA.3
docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.3
docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.3
docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.3
docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.3
docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.3
docs/libcurl/opts/CURLOPT_ALTSVC.3
docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.3
docs/libcurl/opts/CURLOPT_APPEND.3
docs/libcurl/opts/CURLOPT_AUTOREFERER.3
docs/libcurl/opts/CURLOPT_AWS_SIGV4.3
docs/libcurl/opts/CURLOPT_BUFFERSIZE.3
docs/libcurl/opts/CURLOPT_CAINFO.3
docs/libcurl/opts/CURLOPT_CAINFO_BLOB.3
docs/libcurl/opts/CURLOPT_CAPATH.3
docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.3
docs/libcurl/opts/CURLOPT_CERTINFO.3
docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.3
docs/libcurl/opts/CURLOPT_CHUNK_DATA.3
docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.3
docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.3
docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.3
docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3
docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.3
docs/libcurl/opts/CURLOPT_CONNECT_ONLY.3
docs/libcurl/opts/CURLOPT_CONNECT_TO.3
docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.3
docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.3
docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.3
docs/libcurl/opts/CURLOPT_COOKIE.3
docs/libcurl/opts/CURLOPT_COOKIEFILE.3
docs/libcurl/opts/CURLOPT_COOKIEJAR.3
docs/libcurl/opts/CURLOPT_COOKIELIST.3
docs/libcurl/opts/CURLOPT_COOKIESESSION.3
docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.3
docs/libcurl/opts/CURLOPT_CRLF.3
docs/libcurl/opts/CURLOPT_CRLFILE.3
docs/libcurl/opts/CURLOPT_CURLU.3
docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.3
docs/libcurl/opts/CURLOPT_DEBUGDATA.3
docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.3
docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.3
docs/libcurl/opts/CURLOPT_DIRLISTONLY.3
docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.3
docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.3
docs/libcurl/opts/CURLOPT_DNS_INTERFACE.3
docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.3
docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.3
docs/libcurl/opts/CURLOPT_DNS_SERVERS.3
docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.3
docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.3
docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.3
docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.3
docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.3
docs/libcurl/opts/CURLOPT_DOH_URL.3
docs/libcurl/opts/CURLOPT_EGDSOCKET.3
docs/libcurl/opts/CURLOPT_ERRORBUFFER.3
docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.3
docs/libcurl/opts/CURLOPT_FAILONERROR.3
docs/libcurl/opts/CURLOPT_FILETIME.3
docs/libcurl/opts/CURLOPT_FNMATCH_DATA.3
docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.3
docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.3
docs/libcurl/opts/CURLOPT_FORBID_REUSE.3
docs/libcurl/opts/CURLOPT_FRESH_CONNECT.3
docs/libcurl/opts/CURLOPT_FTPPORT.3
docs/libcurl/opts/CURLOPT_FTPSSLAUTH.3
docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.3
docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.3
docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.3
docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.3
docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.3
docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.3
docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.3
docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.3
docs/libcurl/opts/CURLOPT_FTP_USE_PRET.3
docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.3
docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3
docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.3
docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.3
docs/libcurl/opts/CURLOPT_HEADER.3
docs/libcurl/opts/CURLOPT_HEADERDATA.3
docs/libcurl/opts/CURLOPT_HEADERFUNCTION.3
docs/libcurl/opts/CURLOPT_HEADEROPT.3
docs/libcurl/opts/CURLOPT_HSTS.3
docs/libcurl/opts/CURLOPT_HSTSREADDATA.3
docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.3
docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.3
docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.3
docs/libcurl/opts/CURLOPT_HSTS_CTRL.3
docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.3
docs/libcurl/opts/CURLOPT_HTTP200ALIASES.3
docs/libcurl/opts/CURLOPT_HTTPAUTH.3
docs/libcurl/opts/CURLOPT_HTTPGET.3
docs/libcurl/opts/CURLOPT_HTTPHEADER.3
docs/libcurl/opts/CURLOPT_HTTPPOST.3
docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.3
docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.3
docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.3
docs/libcurl/opts/CURLOPT_HTTP_VERSION.3
docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.3
docs/libcurl/opts/CURLOPT_INFILESIZE.3
docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.3
docs/libcurl/opts/CURLOPT_INTERFACE.3
docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.3
docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.3
docs/libcurl/opts/CURLOPT_IOCTLDATA.3
docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.3
docs/libcurl/opts/CURLOPT_IPRESOLVE.3
docs/libcurl/opts/CURLOPT_ISSUERCERT.3
docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.3
docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.3
docs/libcurl/opts/CURLOPT_KEYPASSWD.3
docs/libcurl/opts/CURLOPT_KRBLEVEL.3
docs/libcurl/opts/CURLOPT_LOCALPORT.3
docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.3
docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.3
docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.3
docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.3
docs/libcurl/opts/CURLOPT_MAIL_AUTH.3
docs/libcurl/opts/CURLOPT_MAIL_FROM.3
docs/libcurl/opts/CURLOPT_MAIL_RCPT.3
docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.3
docs/libcurl/opts/CURLOPT_MAXAGE_CONN.3
docs/libcurl/opts/CURLOPT_MAXCONNECTS.3
docs/libcurl/opts/CURLOPT_MAXFILESIZE.3
docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.3
docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.3
docs/libcurl/opts/CURLOPT_MAXREDIRS.3
docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.3
docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.3
docs/libcurl/opts/CURLOPT_MIMEPOST.3
docs/libcurl/opts/CURLOPT_MIME_OPTIONS.3
docs/libcurl/opts/CURLOPT_NETRC.3
docs/libcurl/opts/CURLOPT_NETRC_FILE.3
docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.3
docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.3
docs/libcurl/opts/CURLOPT_NOBODY.3
docs/libcurl/opts/CURLOPT_NOPROGRESS.3
docs/libcurl/opts/CURLOPT_NOPROXY.3
docs/libcurl/opts/CURLOPT_NOSIGNAL.3
docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.3
docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.3
docs/libcurl/opts/CURLOPT_PASSWORD.3
docs/libcurl/opts/CURLOPT_PATH_AS_IS.3
docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.3
docs/libcurl/opts/CURLOPT_PIPEWAIT.3
docs/libcurl/opts/CURLOPT_PORT.3
docs/libcurl/opts/CURLOPT_POST.3
docs/libcurl/opts/CURLOPT_POSTFIELDS.3
docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.3
docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.3
docs/libcurl/opts/CURLOPT_POSTQUOTE.3
docs/libcurl/opts/CURLOPT_POSTREDIR.3
docs/libcurl/opts/CURLOPT_PREQUOTE.3
docs/libcurl/opts/CURLOPT_PREREQDATA.3
docs/libcurl/opts/CURLOPT_PREREQFUNCTION.3
docs/libcurl/opts/CURLOPT_PRE_PROXY.3
docs/libcurl/opts/CURLOPT_PRIVATE.3
docs/libcurl/opts/CURLOPT_PROGRESSDATA.3
docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3
docs/libcurl/opts/CURLOPT_PROTOCOLS.3
docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.3
docs/libcurl/opts/CURLOPT_PROXY.3
docs/libcurl/opts/CURLOPT_PROXYAUTH.3
docs/libcurl/opts/CURLOPT_PROXYHEADER.3
docs/libcurl/opts/CURLOPT_PROXYPASSWORD.3
docs/libcurl/opts/CURLOPT_PROXYPORT.3
docs/libcurl/opts/CURLOPT_PROXYTYPE.3
docs/libcurl/opts/CURLOPT_PROXYUSERNAME.3
docs/libcurl/opts/CURLOPT_PROXYUSERPWD.3
docs/libcurl/opts/CURLOPT_PROXY_CAINFO.3
docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.3
docs/libcurl/opts/CURLOPT_PROXY_CAPATH.3
docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.3
docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.3
docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.3
docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.3
docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.3
docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.3
docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.3
docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.3
docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.3
docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.3
docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.3
docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.3
docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.3
docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.3
docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.3
docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.3
docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.3
docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.3
docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.3
docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.3
docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.3
docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.3
docs/libcurl/opts/CURLOPT_PUT.3
docs/libcurl/opts/CURLOPT_QUICK_EXIT.3
docs/libcurl/opts/CURLOPT_QUOTE.3
docs/libcurl/opts/CURLOPT_RANDOM_FILE.3
docs/libcurl/opts/CURLOPT_RANGE.3
docs/libcurl/opts/CURLOPT_READDATA.3
docs/libcurl/opts/CURLOPT_READFUNCTION.3
docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.3
docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.3
docs/libcurl/opts/CURLOPT_REFERER.3
docs/libcurl/opts/CURLOPT_REQUEST_TARGET.3
docs/libcurl/opts/CURLOPT_RESOLVE.3
docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.3
docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.3
docs/libcurl/opts/CURLOPT_RESUME_FROM.3
docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3
docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.3
docs/libcurl/opts/CURLOPT_RTSP_REQUEST.3
docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.3
docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.3
docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.3
docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.3
docs/libcurl/opts/CURLOPT_SASL_AUTHZID.3
docs/libcurl/opts/CURLOPT_SASL_IR.3
docs/libcurl/opts/CURLOPT_SEEKDATA.3
docs/libcurl/opts/CURLOPT_SEEKFUNCTION.3
docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.3
docs/libcurl/opts/CURLOPT_SERVICE_NAME.3
docs/libcurl/opts/CURLOPT_SHARE.3
docs/libcurl/opts/CURLOPT_SOCKOPTDATA.3
docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.3
docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.3
docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.3
docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.3
docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.3
docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.3
docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.3
docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.3
docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.3
docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.3
docs/libcurl/opts/CURLOPT_SSH_KEYDATA.3
docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.3
docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.3
docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.3
docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.3
docs/libcurl/opts/CURLOPT_SSLCERT.3
docs/libcurl/opts/CURLOPT_SSLCERTTYPE.3
docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.3
docs/libcurl/opts/CURLOPT_SSLENGINE.3
docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.3
docs/libcurl/opts/CURLOPT_SSLKEY.3
docs/libcurl/opts/CURLOPT_SSLKEYTYPE.3
docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.3
docs/libcurl/opts/CURLOPT_SSLVERSION.3
docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3
docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3
docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.3
docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.3
docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.3
docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.3
docs/libcurl/opts/CURLOPT_SSL_FALSESTART.3
docs/libcurl/opts/CURLOPT_SSL_OPTIONS.3
docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.3
docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.3
docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.3
docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.3
docs/libcurl/opts/CURLOPT_STDERR.3
docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.3
docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.3
docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.3
docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.3
docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3
docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.3
docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3
docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3
docs/libcurl/opts/CURLOPT_TCP_NODELAY.3
docs/libcurl/opts/CURLOPT_TELNETOPTIONS.3
docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.3
docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.3
docs/libcurl/opts/CURLOPT_TIMECONDITION.3
docs/libcurl/opts/CURLOPT_TIMEOUT.3
docs/libcurl/opts/CURLOPT_TIMEOUT_MS.3
docs/libcurl/opts/CURLOPT_TIMEVALUE.3
docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.3
docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.3
docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.3
docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.3
docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.3
docs/libcurl/opts/CURLOPT_TRAILERDATA.3
docs/libcurl/opts/CURLOPT_TRANSFERTEXT.3
docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.3
docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.3
docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.3
docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.3
docs/libcurl/opts/CURLOPT_UPLOAD.3
docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.3
docs/libcurl/opts/CURLOPT_URL.3
docs/libcurl/opts/CURLOPT_USERAGENT.3
docs/libcurl/opts/CURLOPT_USERNAME.3
docs/libcurl/opts/CURLOPT_USERPWD.3
docs/libcurl/opts/CURLOPT_USE_SSL.3
docs/libcurl/opts/CURLOPT_VERBOSE.3
docs/libcurl/opts/CURLOPT_WILDCARDMATCH.3
docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3
docs/libcurl/opts/CURLOPT_WS_OPTIONS.3
docs/libcurl/opts/CURLOPT_XFERINFODATA.3
docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.3
docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.3
docs/libcurl/opts/CURLSHOPT_LOCKFUNC.3
docs/libcurl/opts/CURLSHOPT_SHARE.3
docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.3
docs/libcurl/opts/CURLSHOPT_UNSHARE.3
docs/libcurl/opts/CURLSHOPT_USERDATA.3
include/curl/curl.h

index e36eb085e457396dcf4a1fa54bbb9545dab75a00..ff275569e154f20f5d96dbbeb3d8b5797959ee3c 100755 (executable)
@@ -50,8 +50,6 @@ sub extract {
     open(F, "<$f");
     open(O, ">$cfile");
     print O "#include <curl/curl.h>\n";
-    print O "extern struct CURLM *multi;\n";
-    print O "extern struct CURL *easy;\n";
     while(<F>) {
         $iline++;
         if(/^.SH EXAMPLE/) {
index d40ba67a8326f3ee94395bc9c5a383d07a3cf958..9d54d2e255434f8b1983b756401aae570301f943 100644 (file)
@@ -57,12 +57,17 @@ Passing in a NULL pointer in \fIhandle\fP makes this function return
 immediately with no action.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res)
+      printf("error: %s\\n", curl_easy_strerror(res));
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 007efa57e788380946a1909bd6eb8eab81280ddf..5459386545accb631c937b9c5cea0e6dcdcb30de 100644 (file)
@@ -52,15 +52,18 @@ In multi-threaded programs, this function must be called in a synchronous way,
 the input handle may not be in use when cloned.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-CURL *nother;
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  nother = curl_easy_duphandle(curl);
-  res = curl_easy_perform(nother);
-  curl_easy_cleanup(nother);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    CURL *nother;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    nother = curl_easy_duphandle(curl);
+    res = curl_easy_perform(nother);
+    curl_easy_cleanup(nother);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e9ad9ff60a3cb66522c2289764f700f566a37a68..5aa01a964a0d656bff1fc853de0e0626457e2c3c 100644 (file)
@@ -57,14 +57,17 @@ The caller of \fIcurl_easy_escape(3)\fP must make sure that the data passed in
 to the function is encoded correctly.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  char *output = curl_easy_escape(curl, "data to convert", 15);
-  if(output) {
-    printf("Encoded: %s\\n", output);
-    curl_free(output);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    char *output = curl_easy_escape(curl, "data to convert", 15);
+    if(output) {
+      printf("Encoded: %s\\n", output);
+      curl_free(output);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index b0d8ae89dcee05d093b121f7bd599512f56cb61d..f3c9f946ce903d219af4a24209fa27ebb90bb133 100644 (file)
@@ -298,8 +298,11 @@ pretransfer and transfer before final transaction was started. So, this is
 zero if no redirection took place.
 .SH EXAMPLE
 .nf
-  curl = curl_easy_init();
+int main(void)
+{
+  CURL *curl = curl_easy_init();
   if(curl) {
+    CURLcode res;
     curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
     res = curl_easy_perform(curl);
 
@@ -315,6 +318,7 @@ zero if no redirection took place.
     /* always cleanup */
     curl_easy_cleanup(curl);
   }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.4.1
index 4898180ed1283d0d8158e6c476133d8637d065db..a5f44db1ca7f84ba3c97da6704a507f5dce0bcee 100644 (file)
@@ -127,9 +127,18 @@ response that might happen before the "real" response.
 The header is an HTTP/2 or HTTP/3 pseudo header
 .SH EXAMPLE
 .nf
-struct curl_header *type;
-CURLHcode h =
-  curl_easy_header(easy, "Content-Type", 0, CURLH_HEADER, -1, &type);
+int main(void)
+{
+  struct curl_header *type;
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLHcode h;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_perform(curl);
+    h = curl_easy_header(curl, "Content-Type", 0, CURLH_HEADER, -1, &type);
+    curl_easy_cleanup(curl);
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.83.0. Officially supported since 7.84.0.
index 0fd90169950980baec7d2f5ffa74865810e13b03..23801698614a5f7093f558edb5b2ebac3c43957c 100644 (file)
@@ -57,12 +57,15 @@ this function.
 
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b704e76437507545660ff43c0816672508c062ec..44262463da156103578e1f7da15e5f78d0f3cc57 100644 (file)
@@ -68,20 +68,29 @@ is associated with the easy handle. Applications must copy the data if they
 want it to survive subsequent API calls or the life-time of the easy handle.
 .SH EXAMPLE
 .nf
-struct curl_header *prev = NULL;
-struct curl_header *h;
+int main(void)
+{
+  struct curl_header *prev = NULL;
+  struct curl_header *h;
 
-/* extract the normal headers from the first request */
-while((h = curl_easy_nextheader(easy, CURLH_HEADER, 0, prev))) {
-   printf("%s: %s\\n", h->name, h->value);
-   prev = h;
-}
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_perform(curl);
+
+    /* extract the normal headers from the first request */
+    while((h = curl_easy_nextheader(curl, CURLH_HEADER, 0, prev))) {
+      printf("%s: %s\\n", h->name, h->value);
+      prev = h;
+    }
 
-/* extract the normal headers + 1xx + trailers from the last request */
-unsigned int origin = CURLH_HEADER| CURLH_1XX | CURLH_TRAILER;
-while((h = curl_easy_nextheader(easy, origin, -1, prev))) {
-   printf("%s: %s\\n", h->name, h->value);
-   prev = h;
+    /* extract the normal headers + 1xx + trailers from the last request */
+    unsigned int origin = CURLH_HEADER| CURLH_1XX | CURLH_TRAILER;
+    while((h = curl_easy_nextheader(curl, origin, -1, prev))) {
+      printf("%s: %s\\n", h->name, h->value);
+      prev = h;
+    }
+  }
 }
 .fi
 .SH AVAILABILITY
index 3be1151821f12251ff544156fbff013216b18da9..ded364bcabcd638474557e3040bf97b0eaf4fbc6 100644 (file)
@@ -41,9 +41,12 @@ well.
 If libcurl has no option with the given id, this function returns NULL.
 .SH EXAMPLE
 .nf
-const struct curl_easyoption *opt = curl_easy_option_by_id(CURLOPT_URL);
-if(opt) {
-  printf("This option wants type %x\\n", opt->type);
+int main(void)
+{
+  const struct curl_easyoption *opt = curl_easy_option_by_id(CURLOPT_URL);
+  if(opt) {
+    printf("This option wants type %x\\n", opt->type);
+  }
 }
 .fi
 .SH AVAILABILITY
index 7015877926b9ba677d2c384319b7f1dac95ea1d4..87652e7238ad7d4633f9e1992503dc4aba662632 100644 (file)
@@ -40,9 +40,12 @@ insensitive.
 If libcurl has no option with the given name, this function returns NULL.
 .SH EXAMPLE
 .nf
-const struct curl_easyoption *opt = curl_easy_option_by_name("URL");
-if(opt) {
-  printf("This option wants CURLoption %x\\n", (int)opt->id);
+int main(void)
+{
+  const struct curl_easyoption *opt = curl_easy_option_by_name("URL");
+  if(opt) {
+    printf("This option wants CURLoption %x\\n", (int)opt->id);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2f636451fd9c788e18416282eed6b5699aa9c100..e2b35c522c94468a8a434c819a9ea60216a8b673 100644 (file)
@@ -70,12 +70,15 @@ struct curl_easyoption {
 .fi
 .SH EXAMPLE
 .nf
-/* iterate over all available options */
-const struct curl_easyoption *opt;
-opt = curl_easy_option_next(NULL);
-while(opt) {
-  printf("Name: %s\\n", opt->name);
-  opt = curl_easy_option_next(opt);
+int main(void)
+{
+  /* iterate over all available options */
+  const struct curl_easyoption *opt;
+  opt = curl_easy_option_next(NULL);
+  while(opt) {
+    printf("Name: %s\\n", opt->name);
+    opt = curl_easy_option_next(opt);
+  }
 }
 .fi
 .SH AVAILABILITY
index 068d0c447ba9770a5932c61c9868a2c838394fd6..e5ff8827d5ecee31227c91869bf554cd401cd032 100644 (file)
@@ -92,8 +92,15 @@ When such a paused stream is unpaused again, any buffered data is delivered
 first.
 .SH EXAMPLE
 .nf
-/* pause a transfer in both directions */
-curl_easy_pause(curl, CURL_READFUNC_PAUSE | CURL_WRITEFUNC_PAUSE);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* pause a transfer in both directions */
+    curl_easy_pause(curl, CURL_READFUNC_PAUSE | CURL_WRITEFUNC_PAUSE);
+
+  }
+}
 .fi
 .SH "MEMORY USE"
 When pausing a download transfer by returning the magic return code from a
index 7852d764f99161c1844b560a5f4d217c6272bb7e..18430771a3df4d8097f119a72df19bab462843cf 100644 (file)
@@ -63,12 +63,15 @@ While the \fBeasy_handle\fP is added to a multi handle, it cannot be used by
 \fIcurl_easy_perform(3)\fP.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3d724696f9259d0f4b0270804dcf619ba4f04dba..5238f97b6b3e18e931a0c57b7bea5e71657667bd 100644 (file)
@@ -63,18 +63,29 @@ Furthermore if you wait on the socket and it tells you there is data to read,
 read was for internal SSL processing, and no other data is available.
 .SH EXAMPLE
 .nf
- curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
- /* Do not do the transfer - only connect to host */
- curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
- res = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    /* Do not do the transfer - only connect to host */
+    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
+    res = curl_easy_perform(curl);
 
- if(res == CURLE_OK) {
-   /* Extract the socket from the curl handle - we need it for waiting. */
-   res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
+    if(res == CURLE_OK) {
+      char buf[256];
+      size_t nread;
+      long sockfd;
 
-   /* read data */
-   res = curl_easy_recv(curl, buf, sizeof(buf), &nread);
- }
+      /* Extract the socket from the curl handle - we need it for waiting. */
+      res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
+
+      /* read data */
+      res = curl_easy_recv(curl, buf, sizeof(buf), &nread);
+    }
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.18.2.
index c7615655db63b512e5f306b05df26cb95b1317f8..5fa9b13b3543621682bdba92e1c094be1144e760 100644 (file)
@@ -40,11 +40,15 @@ connections, the Session ID cache, the DNS cache, the cookies, the shares or
 the alt-svc cache.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
 
-/* ... the handle is used and options are set ... */
-
-curl_easy_reset(curl);
+    /* ... the handle is used and options are set ... */
+    curl_easy_reset(curl);
+  }
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.12.1
index 95fdc0779c93841e8cd052a3424aee5438be447b..820029ec055c38d3c8fa712f34432b4b12f26e03 100644 (file)
@@ -58,18 +58,27 @@ Furthermore if you wait on the socket and it tells you it's writable,
 sent was for internal SSL processing, and no other data could be sent.
 .SH EXAMPLE
 .nf
- curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
- /* Do not do the transfer - only connect to host */
- curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
- res = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    /* Do not do the transfer - only connect to host */
+    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
+    res = curl_easy_perform(curl);
 
- if(res == CURLE_OK) {
-   /* Extract the socket from the curl handle - we need it for waiting. */
-   res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
+    if(res == CURLE_OK) {
+      long sockfd;
+      size_t sent;
+      /* Extract the socket from the curl handle - we need it for waiting. */
+      res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
 
-   /* send data */
-   res = curl_easy_send(curl, "hello", 5, &sent);
- }
+      /* send data */
+      res = curl_easy_send(curl, "hello", 5, &sent);
+    }
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.18.2.
index ae43811ab0208a8a7f4e2e64e6e74424ac5a28ed..7e7819f643bdf15d5124f8b77853cb6e65c66a6a 100644 (file)
@@ -709,12 +709,15 @@ To be set by toplevel tools like "curl" to skip lengthy cleanups when they are a
 TELNET options. See \fICURLOPT_TELNETOPTIONS(3)\fP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 393ef420ad2bfa2503eb9bc6945ea6dc4f6802e4..87a8f77b98cfe5a8157a90b92dec102543c1e12b 100644 (file)
@@ -38,12 +38,20 @@ Typically applications also appreciate \fICURLOPT_ERRORBUFFER(3)\fP for more
 specific error descriptions generated at runtime.
 .SH EXAMPLE
 .nf
-  /* Perform the entire transfer */
-  res = curl_easy_perform(curl);
-  /* Check for errors */
-  if(res != CURLE_OK)
-    fprintf(stderr, "curl_easy_perform() failed: %s\\n",
-            curl_easy_strerror(res));
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    /* set options */
+    /* Perform the entire transfer */
+    res = curl_easy_perform(curl);
+    /* Check for errors */
+    if(res != CURLE_OK)
+      fprintf(stderr, "curl_easy_perform() failed: %s\\n",
+              curl_easy_strerror(res));
+  }
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.12.0
index 26bf7e1262619a43118ba723bbd3230d75e5ffd7..9c52cbfa546d4e2f5aa67651d1959f39bf506655 100644 (file)
@@ -54,17 +54,20 @@ TPF, but it was otherwise ignored.
 You must \fIcurl_free(3)\fP the returned string when you are done with it.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  int decodelen;
-  char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
-  if(decoded) {
-    /* do not assume printf() works on the decoded data! */
-    printf("Decoded: ");
-    /* ... */
-    curl_free(decoded);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    int decodelen;
+    char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
+    if(decoded) {
+      /* do not assume printf() works on the decoded data! */
+      printf("Decoded: ");
+      /* ... */
+      curl_free(decoded);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index ade0a5d463b402d4fb04eaa38aaee55937d82f6f..b4d35716f4eba0fb22b526ebc56c1e8cf5f5e25f 100644 (file)
@@ -47,27 +47,30 @@ The connection upkeep interval is set with
 \fICURLOPT_UPKEEP_INTERVAL_MS(3)\fP.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  /* Make a connection to an HTTP/2 server. */
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* Make a connection to an HTTP/2 server. */
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Set the interval to 30000ms / 30s */
-  curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
+    /* Set the interval to 30000ms / 30s */
+    curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* Perform more work here. */
+    /* Perform more work here. */
 
-  /* While the connection is being held open, curl_easy_upkeep() can be
-     called. If curl_easy_upkeep() is called and the time since the last
-     upkeep exceeds the interval, then an HTTP/2 PING is sent. */
-  curl_easy_upkeep(curl);
+    /* While the connection is being held open, curl_easy_upkeep() can be
+       called. If curl_easy_upkeep() is called and the time since the last
+       upkeep exceeds the interval, then an HTTP/2 PING is sent. */
+    curl_easy_upkeep(curl);
 
-  /* Perform more work here. */
+    /* Perform more work here. */
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b379b7a6b51ca79dfe30259cfe047ec5c23fcb28..1cd2625401c081295b6edfe378d375f51ad6ea99 100644 (file)
@@ -44,10 +44,13 @@ on \fBstring\fP to find out the size.
 You must \fIcurl_free(3)\fP the returned string when you are done with it.
 .SH EXAMPLE
 .nf
-char *output = curl_escape("data to convert", 15);
-if(output) {
-  printf("Encoded: %s\\n", output);
-  curl_free(output);
+int main(void)
+{
+  char *output = curl_escape("data to convert", 15);
+  if(output) {
+    printf("Encoded: %s\\n", output);
+    curl_free(output);
+  }
 }
 .fi
 .SH AVAILABILITY
index b379d0acb0bc5093e9c218a03208b1c0e270c226..8d8e91d898cadd64444a1e64243014cf21570555 100644 (file)
@@ -175,82 +175,99 @@ for the curl handle.
 See example below.
 .SH EXAMPLE
 .nf
- struct curl_httppost *post = NULL;
- struct curl_httppost *last = NULL;
- char namebuffer[] = "name buffer";
- long namelength = strlen(namebuffer);
- char buffer[] = "test buffer";
- char htmlbuffer[] = "<HTML>test buffer</HTML>";
- long htmlbufferlength = strlen(htmlbuffer);
- struct curl_forms forms[3];
- char file1[] = "my-face.jpg";
- char file2[] = "your-face.jpg";
- /* add null character into htmlbuffer, to demonstrate that
-    transfers of buffers containing null characters actually work
- */
- htmlbuffer[8] = '\\0';
-
- /* Add simple name/content section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
-              CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
-
- /* Add simple name/content/contenttype section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
-              CURLFORM_COPYCONTENTS, "<HTML></HTML>",
-              CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
-
- /* Add name/ptrcontent section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
-              CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
-
- /* Add ptrname/ptrcontent section */
- curl_formadd(&post, &last, CURLFORM_PTRNAME, namebuffer,
-              CURLFORM_PTRCONTENTS, buffer, CURLFORM_NAMELENGTH,
-              namelength, CURLFORM_END);
-
- /* Add name/ptrcontent/contenttype section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "html_code_with_hole",
-              CURLFORM_PTRCONTENTS, htmlbuffer,
-              CURLFORM_CONTENTSLENGTH, htmlbufferlength,
-              CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
-
- /* Add simple file section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "picture",
-              CURLFORM_FILE, "my-face.jpg", CURLFORM_END);
-
- /* Add file/contenttype section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "picture",
-              CURLFORM_FILE, "my-face.jpg",
-              CURLFORM_CONTENTTYPE, "image/jpeg", CURLFORM_END);
-
- /* Add two file section */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "pictures",
-              CURLFORM_FILE, "my-face.jpg",
-              CURLFORM_FILE, "your-face.jpg", CURLFORM_END);
-
- /* Add two file section using CURLFORM_ARRAY */
- forms[0].option = CURLFORM_FILE;
- forms[0].value  = file1;
- forms[1].option = CURLFORM_FILE;
- forms[1].value  = file2;
- forms[2].option  = CURLFORM_END;
-
- /* Add a buffer to upload */
- curl_formadd(&post, &last,
-              CURLFORM_COPYNAME, "name",
-              CURLFORM_BUFFER, "data",
-              CURLFORM_BUFFERPTR, record,
-              CURLFORM_BUFFERLENGTH, record_length,
-              CURLFORM_END);
-
- /* no option needed for the end marker */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "pictures",
-              CURLFORM_ARRAY, forms, CURLFORM_END);
- /* Add the content of a file as a normal post text value */
- curl_formadd(&post, &last, CURLFORM_COPYNAME, "filecontent",
-              CURLFORM_FILECONTENT, ".bashrc", CURLFORM_END);
- /* Set the form info */
- curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
+#include <string.h> /* for strlen */
+
+static const char record[]="data in a buffer";
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct curl_httppost *post = NULL;
+    struct curl_httppost *last = NULL;
+    char namebuffer[] = "name buffer";
+    long namelength = strlen(namebuffer);
+    char buffer[] = "test buffer";
+    char htmlbuffer[] = "<HTML>test buffer</HTML>";
+    long htmlbufferlength = strlen(htmlbuffer);
+    struct curl_forms forms[3];
+    char file1[] = "my-face.jpg";
+    char file2[] = "your-face.jpg";
+    /* add null character into htmlbuffer, to demonstrate that
+       transfers of buffers containing null characters actually work
+    */
+    htmlbuffer[8] = '\\0';
+
+    /* Add simple name/content section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
+                 CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
+
+    /* Add simple name/content/contenttype section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
+                 CURLFORM_COPYCONTENTS, "<HTML></HTML>",
+                 CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
+
+    /* Add name/ptrcontent section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
+                 CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
+
+    /* Add ptrname/ptrcontent section */
+    curl_formadd(&post, &last, CURLFORM_PTRNAME, namebuffer,
+                 CURLFORM_PTRCONTENTS, buffer, CURLFORM_NAMELENGTH,
+                 namelength, CURLFORM_END);
+
+    /* Add name/ptrcontent/contenttype section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "html_code_with_hole",
+                 CURLFORM_PTRCONTENTS, htmlbuffer,
+                 CURLFORM_CONTENTSLENGTH, htmlbufferlength,
+                 CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
+
+    /* Add simple file section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "picture",
+                 CURLFORM_FILE, "my-face.jpg", CURLFORM_END);
+
+    /* Add file/contenttype section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "picture",
+                 CURLFORM_FILE, "my-face.jpg",
+                 CURLFORM_CONTENTTYPE, "image/jpeg", CURLFORM_END);
+
+    /* Add two file section */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "pictures",
+                 CURLFORM_FILE, "my-face.jpg",
+                 CURLFORM_FILE, "your-face.jpg", CURLFORM_END);
+
+    /* Add two file section using CURLFORM_ARRAY */
+    forms[0].option = CURLFORM_FILE;
+    forms[0].value  = file1;
+    forms[1].option = CURLFORM_FILE;
+    forms[1].value  = file2;
+    forms[2].option  = CURLFORM_END;
+
+    /* Add a buffer to upload */
+    curl_formadd(&post, &last,
+                 CURLFORM_COPYNAME, "name",
+                 CURLFORM_BUFFER, "data",
+                 CURLFORM_BUFFERPTR, record,
+                 CURLFORM_BUFFERLENGTH, sizeof(record),
+                 CURLFORM_END);
+
+    /* no option needed for the end marker */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "pictures",
+                 CURLFORM_ARRAY, forms, CURLFORM_END);
+    /* Add the content of a file as a normal post text value */
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "filecontent",
+                 CURLFORM_FILECONTENT, ".bashrc", CURLFORM_END);
+    /* Set the form info */
+    curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
+
+    curl_easy_perform(curl);
+
+    curl_easy_cleanup(curl);
+
+    curl_formfree(post);
+  }
+}
+.fi
 .SH AVAILABILITY
 Deprecated in 7.56.0. Before this release, field names were allowed to
 contain zero-valued bytes. The pseudo-filename "-" to read stdin is
index cb0129da5be5895abe253e126d1d83c49c115baa..b3166745e159cb090417f5502ada5a0ee6ae01b7 100644 (file)
@@ -48,19 +48,28 @@ Passing in a NULL pointer in \fIform\fP makes this function return immediately
 with no action.
 .SH EXAMPLE
 .nf
-  /* Fill in a file upload field */
-  curl_formadd(&formpost,
-               &lastptr,
-               CURLFORM_COPYNAME, "file",
-               CURLFORM_FILE, "nice-image.jpg",
-               CURLFORM_END);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct curl_httppost *formpost;
+    struct curl_httppost *lastptr;
 
-  curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+    /* Fill in a file upload field */
+    curl_formadd(&formpost,
+                 &lastptr,
+                 CURLFORM_COPYNAME, "file",
+                 CURLFORM_FILE, "nice-image.jpg",
+                 CURLFORM_END);
 
-  curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
 
-  /* then cleanup the formpost chain */
-  curl_formfree(formpost);
+    curl_easy_perform(curl);
+
+    /* then cleanup the formpost chain */
+    curl_formfree(formpost);
+  }
+}
 .fi
 .SH AVAILABILITY
 Deprecated in 7.56.0.
index cd6b76926b98fade1fa3fbc6c37e441a45a2ce37..395ae7df69abe7fef0abc8afeb1241b0b9371b94 100644 (file)
@@ -50,21 +50,22 @@ request. This, because first then does libcurl known which actual read
 callback to use!
 .SH EXAMPLE
 .nf
- size_t print_httppost_callback(void *arg, const char *buf, size_t len)
- {
-   fwrite(buf, len, 1, stdout);
-   (*(size_t *) arg) += len;
-   return len;
- }
+size_t print_httppost_callback(void *arg, const char *buf, size_t len)
+{
+  fwrite(buf, len, 1, stdout);
+  (*(size_t *) arg) += len;
+  return len;
+}
 
- size_t print_httppost(struct curl_httppost *post)
- {
-   size_t total_size = 0;
-   if(curl_formget(post, &total_size, print_httppost_callback)) {
-     return (size_t) -1;
-   }
-   return total_size;
- }
+size_t print_httppost(struct curl_httppost *post)
+{
+  size_t total_size = 0;
+  if(curl_formget(post, &total_size, print_httppost_callback)) {
+    return (size_t) -1;
+  }
+  return total_size;
+}
+.fi
 .SH AVAILABILITY
 This function was added in libcurl 7.15.5. The form API is deprecated in
 libcurl 7.56.0.
index 9192b9303183cf29e737b5f1d6ac7946a9e9fc58..f29d8f1e1db8bea3e50d4265f49b12440b9f008c 100644 (file)
@@ -39,11 +39,14 @@ Passing in a NULL pointer in \fIptr\fP makes this function return immediately
 with no action.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   char *width = curl_getenv("COLUMNS");
   if(width) {
     /* it was set! */
     curl_free(width);
   }
+}
 .fi
 .SH AVAILABILITY
 Always
index b4c07e8c9555ea967e0fc2597fca1ba408eb825e..42dc29997e063088ddf670e54203400d9f523414 100644 (file)
@@ -70,29 +70,32 @@ year, MM as the month number and DD as the day of the month, for the specified
 calendar date.
 .SH EXAMPLE
 .nf
- time_t t;
- t = curl_getdate("Sun, 06 Nov 1994 08:49:37 GMT", NULL);
- t = curl_getdate("Sunday, 06-Nov-94 08:49:37 GMT", NULL);
- t = curl_getdate("Sun Nov  6 08:49:37 1994", NULL);
- t = curl_getdate("06 Nov 1994 08:49:37 GMT", NULL);
- t = curl_getdate("06-Nov-94 08:49:37 GMT", NULL);
- t = curl_getdate("Nov  6 08:49:37 1994", NULL);
- t = curl_getdate("06 Nov 1994 08:49:37", NULL);
- t = curl_getdate("06-Nov-94 08:49:37", NULL);
- t = curl_getdate("1994 Nov 6 08:49:37", NULL);
- t = curl_getdate("GMT 08:49:37 06-Nov-94 Sunday", NULL);
- t = curl_getdate("94 6 Nov 08:49:37", NULL);
- t = curl_getdate("1994 Nov 6", NULL);
- t = curl_getdate("06-Nov-94", NULL);
- t = curl_getdate("Sun Nov 6 94", NULL);
- t = curl_getdate("1994.Nov.6", NULL);
- t = curl_getdate("Sun/Nov/6/94/GMT", NULL);
- t = curl_getdate("Sun, 06 Nov 1994 08:49:37 CET", NULL);
- t = curl_getdate("06 Nov 1994 08:49:37 EST", NULL);
- t = curl_getdate("Sun, 12 Sep 2004 15:05:58 -0700", NULL);
- t = curl_getdate("Sat, 11 Sep 2004 21:32:11 +0200", NULL);
- t = curl_getdate("20040912 15:05:58 -0700", NULL);
- t = curl_getdate("20040911 +0200", NULL);
+int main(void)
+{
+  time_t t;
+  t = curl_getdate("Sun, 06 Nov 1994 08:49:37 GMT", NULL);
+  t = curl_getdate("Sunday, 06-Nov-94 08:49:37 GMT", NULL);
+  t = curl_getdate("Sun Nov  6 08:49:37 1994", NULL);
+  t = curl_getdate("06 Nov 1994 08:49:37 GMT", NULL);
+  t = curl_getdate("06-Nov-94 08:49:37 GMT", NULL);
+  t = curl_getdate("Nov  6 08:49:37 1994", NULL);
+  t = curl_getdate("06 Nov 1994 08:49:37", NULL);
+  t = curl_getdate("06-Nov-94 08:49:37", NULL);
+  t = curl_getdate("1994 Nov 6 08:49:37", NULL);
+  t = curl_getdate("GMT 08:49:37 06-Nov-94 Sunday", NULL);
+  t = curl_getdate("94 6 Nov 08:49:37", NULL);
+  t = curl_getdate("1994 Nov 6", NULL);
+  t = curl_getdate("06-Nov-94", NULL);
+  t = curl_getdate("Sun Nov 6 94", NULL);
+  t = curl_getdate("1994.Nov.6", NULL);
+  t = curl_getdate("Sun/Nov/6/94/GMT", NULL);
+  t = curl_getdate("Sun, 06 Nov 1994 08:49:37 CET", NULL);
+  t = curl_getdate("06 Nov 1994 08:49:37 EST", NULL);
+  t = curl_getdate("Sun, 12 Sep 2004 15:05:58 -0700", NULL);
+  t = curl_getdate("Sat, 11 Sep 2004 21:32:11 +0200", NULL);
+  t = curl_getdate("20040912 15:05:58 -0700", NULL);
+  t = curl_getdate("20040911 +0200", NULL);
+}
 .fi
 .SH STANDARDS
 This parser handles date formats specified in RFC 822 (including the update in
index e74357f8af416ebc5f95761eebc48313a9fad3a8..a13d596710fa756d005809df4b8646c469d75cc5 100644 (file)
@@ -38,11 +38,14 @@ systems libcurl builds on (including win32).
 You must \fIcurl_free(3)\fP the returned string when you are done with it.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   char *width = curl_getenv("COLUMNS");
   if(width) {
     /* it was set! */
     curl_free(width);
   }
+}
 .fi
 .SH AVAILABILITY
 Always
index b409494111b440335cb5f5e543be37ce2558c147..75a0a01ac198f92ebf2db7186c1843f783f43dd4 100644 (file)
@@ -58,11 +58,14 @@ recommend you do not run libcurl from any module that may be unloaded
 dynamically. This behavior may be addressed in the future.
 .SH EXAMPLE
 .nf
- curl_global_init(CURL_GLOBAL_DEFAULT);
+int main(void)
+{
+  curl_global_init(CURL_GLOBAL_DEFAULT);
 
- /* use libcurl, then before exiting... */
 /* use libcurl, then before exiting... */
 
- curl_global_cleanup();
+  curl_global_cleanup();
+}
 .fi
 .SH AVAILABILITY
 Added in 7.8
index 74658c6334a332ad4c4f2d07630166ca50dedadb..b769991007701e75d8db9793521e2997cee1a3a3 100644 (file)
@@ -101,11 +101,14 @@ connecting or when waiting for data. Otherwise, curl waits until full timeout
 elapses. (Added in 7.30.0)
 .SH EXAMPLE
 .nf
- curl_global_init(CURL_GLOBAL_DEFAULT);
+int main(void)
+{
+  curl_global_init(CURL_GLOBAL_DEFAULT);
 
- /* use libcurl, then before exiting... */
 /* use libcurl, then before exiting... */
 
- curl_global_cleanup();
+  curl_global_cleanup();
+}
 .fi
 .SH AVAILABILITY
 Added in 7.8
index 99f0f963c298164bd379c0188a5090aae9c19ced..3aa65ba934aa12e5a138b4d06ee32290f581e3f4 100644 (file)
@@ -65,9 +65,18 @@ Manipulating these gives considerable powers to the application to severely
 screw things up for libcurl. Take care!
 .SH EXAMPLE
 .nf
- curl_global_init_mem(CURL_GLOBAL_DEFAULT, curl_malloc_cb,
-                      curl_free_cb, curl_realloc_cb,
-                      curl_strdup_cb, curl_calloc_cb);
+extern void *malloc_cb(size_t);
+extern void free_cb(void *);
+extern void *realloc_cb(void *, size_t);
+extern char *strdup_cb(const char *);
+extern void *calloc_cb(size_t, size_t);
+
+int main(void)
+{
+  curl_global_init_mem(CURL_GLOBAL_DEFAULT, malloc_cb,
+                       free_cb, realloc_cb,
+                       strdup_cb, calloc_cb);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.12.0
index e9fd54b22791cea7e5dfc4c28703999960fc0fff..3384b551a27a44760e4bd5927cd153bd8c4bccfb 100644 (file)
@@ -103,6 +103,9 @@ typedef enum {
 .fi
 .SH EXAMPLE
 .nf
+int main(void)
+{
+  int i;
   /* choose a specific backend */
   curl_global_sslset(CURLSSLBACKEND_WOLFSSL, NULL, NULL);
 
@@ -113,6 +116,7 @@ typedef enum {
   for(i = 0; list[i]; i++)
     printf("SSL backend #%d: '%s' (ID: %d)\\n",
            i, list[i]->name, list[i]->id);
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.56.0. Before this version, there was no
index 686896fde92a13d609df5a25153f5c41fcb16e0f..926a86b1dc076b4fa359e4842d42ff4ceda6a63b 100644 (file)
@@ -91,11 +91,14 @@ trace.
 
 .SH EXAMPLE
 .nf
- /* log details of HTTP/2 and SSL handling */
- curl_global_trace("http/2,ssl");
+int main(void)
+{
+  /* log details of HTTP/2 and SSL handling */
+  curl_global_trace("http/2,ssl");
 
- /* log all details, except SSL handling */
- curl_global_trace("all,-ssl");
+  /* log all details, except SSL handling */
+  curl_global_trace("all,-ssl");
+}
 .fi
 
 Below is a trace sample where "http/2" was configured. The trace output
index 34d365b1061cfedc2a942e9471a0772076455c1d..c9eccf55bf9e036b8699db9574fb73283d63877c 100644 (file)
@@ -39,18 +39,24 @@ subsequently be populated using functions from the mime API.
 appended.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
- /* add a part */
- part = curl_mime_addpart(mime);
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* continue and set name + data to the part */
- curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
- curl_mime_name(part, "data");
+    /* continue and set name + data to the part */
+    curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
+    curl_mime_name(part, "data");
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index baeb281b2ccdda53ad1b685be6e4efd001d26407..71042daa1a377e1e2e0f5978f709a9006860afc1 100644 (file)
@@ -52,17 +52,23 @@ Setting large data is memory consuming: one might consider using
 \fIcurl_mime_data_cb(3)\fP in such a case.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
- /* add a part */
- part = curl_mime_addpart(mime);
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* add data to the part  */
- curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
+    /* add data to the part  */
+    curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index 03e6bd86db15d95b37af0c7d3bdc1784b69cf6bd..8ca3df3e3be88bb293c460f5787c7a3dbe4048de 100644 (file)
@@ -104,7 +104,7 @@ to avoid overhead resources consumption, one might want to use a callback
 source to avoid data duplication. In this case, original data must be retained
 until after the transfer terminates.
 .nf
-
+#include <string.h> /* for memcpy */
 char hugedata[512000];
 
 struct ctl {
@@ -146,17 +146,22 @@ int seek_callback(void *arg, curl_off_t offset, int origin)
   return CURL_SEEKFUNC_OK;
 }
 
- CURL *easy = curl_easy_init();
- curl_mime *mime = curl_mime_init(easy);
- curl_mimepart *part = curl_mime_addpart(mime);
- struct ctl hugectl;
-
- hugectl.buffer = hugedata;
- hugectl.size = sizeof hugedata;
- hugectl.position = 0;
- curl_mime_data_cb(part, hugectl.size, read_callback, seek_callback, NULL,
-                   &hugectl);
-
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_mime *mime = curl_mime_init(curl);
+    curl_mimepart *part = curl_mime_addpart(mime);
+    struct ctl hugectl;
+
+    hugectl.buffer = hugedata;
+    hugectl.size = sizeof(hugedata);
+    hugectl.position = 0;
+    curl_mime_data_cb(part, hugectl.size, read_callback, seek_callback, NULL,
+                      &hugectl);
+  }
+}
+.fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
 .SH RETURN VALUE
index 7e61d93d2aad911a173afc28b21bb8c7cca975f0..64c2636e3185bfedb2685e1e6e7c8205152f7dc9 100644 (file)
@@ -74,20 +74,26 @@ a part with content set with \fIcurl_mime_subparts(3)\fP is strongly
 discouraged.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
- /* add a part */
- part = curl_mime_addpart(mime);
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* send a file */
- curl_mime_filedata(part, "image.png");
   /* send a file */
   curl_mime_filedata(part, "image.png");
 
- /* encode file data in base64 for transfer */
- curl_mime_encoder(part, "base64");
+    /* encode file data in base64 for transfer */
+    curl_mime_encoder(part, "base64");
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index 085ebbf0cb4262304cba8fec614be1b617c8e033..cb20fea42a67ffc523f30fb1f191f6a3e2ce4e1a 100644 (file)
@@ -58,20 +58,26 @@ Setting a part's contents multiple times is valid: only the value set by the
 last call is retained.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
- /* add a part */
- part = curl_mime_addpart(mime);
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* send data from this file */
- curl_mime_filedata(part, "image.png");
   /* send data from this file */
   curl_mime_filedata(part, "image.png");
 
- /* set name */
- curl_mime_name(part, "data");
+    /* set name */
+    curl_mime_name(part, "data");
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index 1241dfb77a91d9e6aef5192dd3911ad705d9a801..a10bf803ec06d1a43c9437368f91523c2a6a773d 100644 (file)
@@ -47,23 +47,32 @@ storage may safely be released or reused after call. Setting a part's file
 name multiple times is valid: only the value set by the last call is retained.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+static char imagebuf[]="imagedata";
 
- /* add a part */
- part = curl_mime_addpart(mime);
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* send image data from memory */
- curl_mime_data(part, imagebuf, imagebuf_len);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
/* set a file name to make it look like a file upload */
curl_mime_filename(part, "image.png");
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* set name */
- curl_mime_name(part, "data");
+    /* send image data from memory */
+    curl_mime_data(part, imagebuf, sizeof(imagebuf));
+
+    /* set a file name to make it look like a file upload */
+    curl_mime_filename(part, "image.png");
+
+    /* set name */
+    curl_mime_name(part, "data");
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index 8d4d32862ca617c365628eca37d43237fc0ac47c..b37b1580307ca77f69142164a6cbe18a0fc4c6ad 100644 (file)
@@ -47,13 +47,19 @@ Passing in a NULL pointer in \fImime\fP makes this function return immediately
 with no action.
 .SH EXAMPLE
 .nf
-  /* Build the mime message. */
-  mime = curl_mime_init(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* Build the mime message. */
+    curl_mime *mime = curl_mime_init(curl);
 
-  /* ... */
+    /* send off the transfer */
 
-  /* Free multipart message. */
-  curl_mime_free(mime);
+    /* Free multipart message. */
+    curl_mime_free(mime);
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index e25ebef87e73105c87327c413f237204a5c4a479..dd6a416694478bcc39075831b156c86ee0c2f0ac 100644 (file)
@@ -47,18 +47,32 @@ Setting a part's custom headers list multiple times is valid: only the value
 set by the last call is retained.
 .SH EXAMPLE
 .nf
- struct curl_slist *headers = NULL;
+int main(void)
+{
+  struct curl_slist *headers = NULL;
+  CURL *easy = curl_easy_init();
+  curl_mime *mime;
+  curl_mimepart *part;
 
- headers = curl_slist_append(headers, "Custom-Header: mooo");
 headers = curl_slist_append(headers, "Custom-Header: mooo");
 
- /* use these headers, please take ownership */
curl_mime_headers(part, headers, TRUE);
+  mime = curl_mime_init(easy);
 part = curl_mime_addpart(mime);
 
/* pass on this data */
curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED);
 /* use these headers in the part, takes ownership */
 curl_mime_headers(part, headers, 1);
 
- /* set name */
- curl_mime_name(part, "numbers");
+  /* pass on this data */
+  curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED);
+
+  /* set name */
+  curl_mime_name(part, "numbers");
+
+  /* Post and send it. */
+  curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
+  curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
+  curl_easy_perform(easy);
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index b48de436fbdcfa01dd4be7e94778a16654d68cc4..dc93fd15fd62a91246514053579f16290ad203bb 100644 (file)
@@ -44,24 +44,28 @@ Using a mime handle is the recommended way to post an HTTP form, format and
 send a multi-part email with SMTP or upload such an email to an IMAP server.
 .SH EXAMPLE
 .nf
- CURL *easy = curl_easy_init();
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  CURL *easy = curl_easy_init();
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* Build an HTTP form with a single field named "data", */
- mime = curl_mime_init(easy);
- part = curl_mime_addpart(mime);
- curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
- curl_mime_name(part, "data");
 /* Build an HTTP form with a single field named "data", */
 mime = curl_mime_init(easy);
 part = curl_mime_addpart(mime);
 curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
 curl_mime_name(part, "data");
 
- /* Post and send it. */
- curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
- curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
- curl_easy_perform(easy);
 /* Post and send it. */
 curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
 curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
 curl_easy_perform(easy);
 
- /* Clean-up. */
- curl_easy_cleanup(easy);
- curl_mime_free(mime);
+  /* Clean-up. */
+  curl_easy_cleanup(easy);
+  curl_mime_free(mime);
+}
+.fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
 .SH RETURN VALUE
index a4ddeb83ad4ff6da5f0a77a5dc1cce9248fffd0f..52953e5487f316ec404552f9431ce67bff88c948 100644 (file)
@@ -44,17 +44,23 @@ is valid: only the value set by the last call is retained. It is possible to
 reset the name of a part by setting \fIname\fP to NULL.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
- /* add a part */
- part = curl_mime_addpart(mime);
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* give the part a name */
- curl_mime_name(part, "shoe_size");
+    /* give the part a name */
+    curl_mime_name(part, "shoe_size");
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index 45bc62c86b8f90c13de5b67fecc003da38ddf9b1..459f3cdcc7c8e4bc6ba7ff5cae2568fa495f3c6b 100644 (file)
@@ -46,25 +46,38 @@ last call is retained. It is possible to unassign previous part's contents by
 setting \fIsubparts\fP to NULL.
 .SH EXAMPLE
 .nf
- /* The inline part is an alternative proposing the html and the text
-    versions of the email. */
- alt = curl_mime_init(curl);
 
- /* HTML message. */
- part = curl_mime_addpart(alt);
- curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED);
- curl_mime_type(part, "text/html");
+static char *inline_html = "<title>example</title>";
+static char *inline_text = "once upon the time";
 
- /* Text message. */
- part = curl_mime_addpart(alt);
- curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct curl_slist *slist;
 
- /* Create the inline part. */
- part = curl_mime_addpart(mime);
- curl_mime_subparts(part, alt);
- curl_mime_type(part, "multipart/alternative");
- slist = curl_slist_append(NULL, "Content-Disposition: inline");
- curl_mime_headers(part, slist, 1);
+    /* The inline part is an alternative proposing the html and the text
+       versions of the email. */
+    curl_mime *alt = curl_mime_init(curl);
+    curl_mimepart *part;
+
+    /* HTML message. */
+    part = curl_mime_addpart(alt);
+    curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED);
+    curl_mime_type(part, "text/html");
+
+    /* Text message. */
+    part = curl_mime_addpart(alt);
+    curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED);
+
+    /* Create the inline part. */
+    part = curl_mime_addpart(alt);
+    curl_mime_subparts(part, alt);
+    curl_mime_type(part, "multipart/alternative");
+    slist = curl_slist_append(NULL, "Content-Disposition: inline");
+    curl_mime_headers(part, slist, 1);
+  }
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index 74d7d94162f787776ee5042b52556ae7c674872d..6d0c6a87299ccd0ba215c94b3739f85cea32697c 100644 (file)
@@ -57,23 +57,29 @@ extension, or application/octet-stream by default.
 - text/plain in other cases.
 .SH EXAMPLE
 .nf
- curl_mime *mime;
- curl_mimepart *part;
+int main(void)
+{
+  curl_mime *mime;
+  curl_mimepart *part;
 
- /* create a mime handle */
- mime = curl_mime_init(easy);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* create a mime handle */
+    mime = curl_mime_init(curl);
 
- /* add a part */
- part = curl_mime_addpart(mime);
   /* add a part */
   part = curl_mime_addpart(mime);
 
- /* get data from this file */
- curl_mime_filedata(part, "image.png");
   /* get data from this file */
   curl_mime_filedata(part, "image.png");
 
- /* content-type for this part */
- curl_mime_type(part, "image/png");
   /* content-type for this part */
   curl_mime_type(part, "image/png");
 
- /* set name */
- curl_mime_name(part, "image");
+    /* set name */
+    curl_mime_name(part, "image");
+}
+}
 .fi
 .SH AVAILABILITY
 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
index c7e0a35ddb684175ae558e0a28d8981c81f88062..c60ef0a812928ee9b088569a91049229c67646c4 100644 (file)
@@ -237,8 +237,13 @@ by the corresponding argument.
 A '%' is written. No argument is converted.
 .SH EXAMPLE
 .nf
+const char *name = "John";
+
+int main(void)
+{
   curl_mprintf("My name is %s\\n", name);
-  curl_mprintf("Pi is almost %f\\n", 25/8);
+  curl_mprintf("Pi is almost %f\\n", (double)25.0/8);
+}
 .fi
 .SH AVAILABILITY
 These functions might be removed from the public libcurl API in the future. Do
index f53673bd5ac7374b06ceb431fca6f68227864fd8..749b24e672e53d1b975389fe41471e9a9fdeaec4 100644 (file)
@@ -67,12 +67,19 @@ first the easy handle and then the multi handle:
 3 - \fIcurl_multi_cleanup(3)\fP
 .SH EXAMPLE
 .nf
+int main(void)
+{
   /* init a multi stack */
-  multi_handle = curl_multi_init();
+  CURLM *multi = curl_multi_init();
+
+  /* create two easy handles */
+  CURL *http_handle = curl_easy_init();
+  CURL *http_handle2 = curl_easy_init();
 
   /* add individual transfers */
-  curl_multi_add_handle(multi_handle, http_handle);
-  curl_multi_add_handle(multi_handle, http_handle2);
+  curl_multi_add_handle(multi, http_handle);
+  curl_multi_add_handle(multi, http_handle2);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.9.6
index 78714aa8f12d15288cf5f7183bf8ee20d02c06df..5b61705366899c75d91db1c151fa218f65317a27 100644 (file)
@@ -54,8 +54,17 @@ functionality.
 It is acceptable to call this function from your multi callback functions.
 .SH EXAMPLE
 .nf
- /* make our struct pointer associated with socket fd */
- mc = curl_multi_assign(multi_handle, fd, ourstructp);
+int main(void)
+{
+  CURLM *multi = curl_multi_init();
+  void *ourstructp; /* pointer to our data */
+  curl_socket_t fd; /* file descriptor to associate our data with */
+
+  /* make our struct pointer associated with socket fd */
+  CURLMcode mc = curl_multi_assign(multi, fd, ourstructp);
+  if(mc)
+    printf("error: %s\\n", curl_multi_strerror(mc));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.15.5
index 8b41b78c4932d09956bd377195585de4df3eb947..751bce9fd921a029294692fb3a3ab417329ebfe0 100644 (file)
@@ -48,10 +48,15 @@ Passing in a NULL pointer in \fImulti_handle\fP makes this function return
 CURLM_BAD_HANDLE immediately with no other action.
 .SH EXAMPLE
 .nf
- /* when the multi transfer is done ... */
+int main(void)
+{
+  CURLM *multi = curl_multi_init();
 
- /* remove all easy handles, then: */
- curl_multi_cleanup(multi_handle);
+  /* when the multi transfer is done ... */
+
+  /* remove all easy handles, then: */
+  curl_multi_cleanup(multi);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.9.6
index d569b84e92364027889fdb690b7256c49627a72e..8a3ae965a6593ee54f76c36b17312df46b30e0bc 100644 (file)
@@ -80,16 +80,35 @@ save you from the crash, but makes your program NOT wait for sockets it should
 wait for...
 .SH EXAMPLE
 .nf
- /* get file descriptors from the transfers */
- mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
+int main(void)
+{
+  fd_set fdread;
+  fd_set fdwrite;
+  fd_set fdexcep;
+  int maxfd;
+  int rc;
+  CURLMcode mc;
+  struct timeval timeout = {1, 0};
 
- if(mc != CURLM_OK) {
-   fprintf(stderr, "curl_multi_fdset() failed, code %d.\\n", mc);
-   break;
- }
+  CURLM *multi = curl_multi_init();
 
- /* wait for activity on one of the sockets */
- rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
+  do {
+
+    /* call curl_multi_perform() */
+
+    /* get file descriptors from the transfers */
+    mc = curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+    if(mc != CURLM_OK) {
+      fprintf(stderr, "curl_multi_fdset() failed, code %d.\\n", mc);
+      break;
+    }
+
+    /* wait for activity on one of the sockets */
+    rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+  } while(!mc);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.9.6
index 7ee6c734e98b924efdd63ee6e96c23f1839ef267..060c6e65143bdab60ea0af6226c020a8d92ae0b2 100644 (file)
@@ -47,22 +47,29 @@ The order of the easy handles within the array is not guaranteed.
 The returned array must be freed with a call to \fIcurl_free(3)\fP after use.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   /* init a multi stack */
-  multi_handle = curl_multi_init();
+  CURLM *multi = curl_multi_init();
+  CURL *curl = curl_easy_init();
 
-  /* add a transfer */
-  curl_multi_add_handle(multi_handle, http_handle);
+  if(curl) {
+    /* add the transfer */
+    curl_multi_add_handle(multi, curl);
 
-  /* extract all added handles */
-  CURL **list = curl_multi_get_handles(multi_handle);
+    /* extract all added handles */
+    CURL **list = curl_multi_get_handles(multi);
 
-  if(list) {
-    /* remove all added handles */
-    for(i = 0; list[i]; i++) {
-      curl_multi_remove_handle(multi_handle, list[i]);
+    if(list) {
+      int i;
+      /* remove all added handles */
+      for(i = 0; list[i]; i++) {
+        curl_multi_remove_handle(multi, list[i]);
+      }
+      curl_free(list);
     }
-    curl_free(list);
   }
+}
 .fi
 .SH AVAILABILITY
 Added in 8.4.0
index 2a15ad582d42e40c6723d7db00a794dbc70fecc0..c833548c89865003c5852f999d984d18dd4da80c 100644 (file)
@@ -72,21 +72,28 @@ that just completed.
 At this point, there are no other \fBmsg\fP types defined.
 .SH EXAMPLE
 .nf
-struct CURLMsg *m;
+int main(void)
+{
+  CURLM *multi = curl_multi_init();
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct CURLMsg *m;
 
-/* call curl_multi_perform or curl_multi_socket_action first, then loop
-   through and check if there are any transfers that have completed */
+    /* call curl_multi_perform or curl_multi_socket_action first, then loop
+       through and check if there are any transfers that have completed */
 
-do {
-  int msgq = 0;
-  m = curl_multi_info_read(multi_handle, &msgq);
-  if(m && (m->msg == CURLMSG_DONE)) {
-    CURL *e = m->easy_handle;
-    transfers--;
-    curl_multi_remove_handle(multi_handle, e);
-    curl_easy_cleanup(e);
+    do {
+      int msgq = 0;
+      m = curl_multi_info_read(multi, &msgq);
+      if(m && (m->msg == CURLMSG_DONE)) {
+        CURL *e = m->easy_handle;
+        /* m->data.result holds the error code for the transfer */
+        curl_multi_remove_handle(multi, e);
+        curl_easy_cleanup(e);
+      }
+    } while(m);
   }
-} while(m);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.9.6
index 5fe21b781aa355757b16fe01fd35eab86f479b11..9b589a11ec0ca0c839499934f94ba371768609cb 100644 (file)
@@ -37,12 +37,17 @@ places in the documentation. This init call MUST have a corresponding call to
 \fIcurl_multi_cleanup(3)\fP when the operation is complete.
 .SH EXAMPLE
 .nf
-/* init a multi stack */
-multi_handle = curl_multi_init();
+int main(void)
+{
+  /* init a multi stack */
+  CURLM *multi = curl_multi_init();
+  CURL *curl = curl_easy_init();
+  CURL *curl2 = curl_easy_init();
 
-/* add individual transfers */
-curl_multi_add_handle(multi_handle, http_handle);
-curl_multi_add_handle(multi_handle, http_handle2);
+  /* add individual transfers */
+  curl_multi_add_handle(multi, curl);
+  curl_multi_add_handle(multi, curl2);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.9.6
index 49ad6e02c582d9b7445188eb2ef373d29eb09f78..8088c433e3db1bd3bd014bed88a36c31dbd484f2 100644 (file)
@@ -62,21 +62,29 @@ again on the same multi handle after an error has been returned, unless first
 removing all the handles and adding new ones.
 .SH EXAMPLE
 .nf
-int still_running;
-do {
-  CURLMcode mc = curl_multi_perform(multi_handle, &still_running);
+int main(void)
+{
+  int still_running;
+  CURL *multi = curl_multi_init();
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_multi_add_handle(multi, curl);
+    do {
+      CURLMcode mc = curl_multi_perform(multi, &still_running);
 
-  if(!mc && still_running)
-    /* wait for activity, timeout or "nothing" */
-    mc = curl_multi_poll(multi_handle, NULL, 0, 1000, NULL);
+      if(!mc && still_running)
+        /* wait for activity, timeout or "nothing" */
+        mc = curl_multi_poll(multi, NULL, 0, 1000, NULL);
 
-  if(mc) {
-    fprintf(stderr, "curl_multi_poll() failed, code %d.\\n", (int)mc);
-    break;
-  }
+      if(mc) {
+        fprintf(stderr, "curl_multi_poll() failed, code %d.\\n", (int)mc);
+        break;
+      }
 
-/* if there are still transfers, loop! */
-} while(still_running);
+    /* if there are still transfers, loop! */
+    } while(still_running);
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.9.6
index 8ea7bd10244a80c12702c584d779f479f7d2b21c..dfc5bbd55f7984f18fba7c2eca482819f39e9593 100644 (file)
@@ -83,31 +83,35 @@ Bit flag to curl_waitfd.events indicating the socket should poll on write
 events such as the socket being clear to write without blocking.
 .SH EXAMPLE
 .nf
-CURL *easy_handle;
-CURLM *multi_handle;
+int main(void)
+{
+  CURL *easy_handle;
+  CURLM *multi_handle;
+  int still_running = 0;
 
-/* add the individual easy handle */
-curl_multi_add_handle(multi_handle, easy_handle);
+  /* add the individual easy handle */
+  curl_multi_add_handle(multi_handle, easy_handle);
 
-do {
-  CURLMcode mc;
-  int numfds;
+  do {
+    CURLMcode mc;
+    int numfds;
 
-  mc = curl_multi_perform(multi_handle, &still_running);
+    mc = curl_multi_perform(multi_handle, &still_running);
 
-  if(mc == CURLM_OK) {
-    /* wait for activity or timeout */
-    mc = curl_multi_poll(multi_handle, NULL, 0, 1000, &numfds);
-  }
+    if(mc == CURLM_OK) {
+      /* wait for activity or timeout */
+      mc = curl_multi_poll(multi_handle, NULL, 0, 1000, &numfds);
+    }
 
-  if(mc != CURLM_OK) {
-    fprintf(stderr, "curl_multi failed, code %d.\\n", mc);
-    break;
-  }
+    if(mc != CURLM_OK) {
+      fprintf(stderr, "curl_multi failed, code %d.\\n", mc);
+      break;
+    }
 
-} while(still_running);
+  } while(still_running);
 
-curl_multi_remove_handle(multi_handle, easy_handle);
+  curl_multi_remove_handle(multi_handle, easy_handle);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.66.0.
index dccf75f9275406c9d831ce4c7043e98117698b1d..eb2aaf399b1a64b87399133def81f26267f682ad 100644 (file)
@@ -52,13 +52,19 @@ multi handle, ready to get reused for a future transfer using this multi
 handle.
 .SH EXAMPLE
 .nf
-/* when an easy handle has completed, remove it */
-msg = curl_multi_info_read(multi_handle, &queued);
-if(msg) {
-  if(msg->msg == CURLMSG_DONE) {
-    /* a transfer ended */
-    fprintf(stderr, "Transfer completed\\n");
-    curl_multi_remove_handle(multi_handle, msg->easy_handle);
+int main(void)
+{
+  CURLM *multi = curl_multi_init();
+  int queued = 0;
+
+  /* when an easy handle has completed, remove it */
+  CURLMsg *msg = curl_multi_info_read(multi, &queued);
+  if(msg) {
+    if(msg->msg == CURLMSG_DONE) {
+      /* a transfer ended */
+      fprintf(stderr, "Transfer completed\\n");
+      curl_multi_remove_handle(multi, msg->easy_handle);
+    }
   }
 }
 .fi
index 38e170656a332d26b22e304f4b48791247560483..1752fe4fdbbd9deb78431f512f0b7078c62534ec 100644 (file)
@@ -74,10 +74,17 @@ See \fICURLMOPT_TIMERDATA(3)\fP
 .IP CURLMOPT_MAX_CONCURRENT_STREAMS
 See \fICURLMOPT_MAX_CONCURRENT_STREAMS(3)\fP
 .SH EXAMPLE
-.fi
-  /* Limit the amount of simultaneous connections curl should allow: */
-  curl_multi_setopt(handle, CURLMOPT_MAXCONNECTS, (long)MAX_PARALLEL);
 .nf
+
+#define MAX_PARALLEL 45
+
+int main(void)
+{
+  CURLM *multi;
+  /* Limit the amount of simultaneous connections curl should allow: */
+  curl_multi_setopt(multi, CURLMOPT_MAXCONNECTS, (long)MAX_PARALLEL);
+}
+.fi
 .SH AVAILABILITY
 Added in 7.15.4
 .SH RETURN VALUE
index 140776f3dcb925051a729fa98e1f3dc79bb0b606..e4759eb2d0d69087edb1623b7b32e848a71bc8f5 100644 (file)
@@ -70,10 +70,16 @@ just a single one by calling \fIcurl_multi_socket_all(3)\fP. Note that there
 should not be any reason to use this function.
 .SH EXAMPLE
 .nf
-/* the event-library gets told when there activity on the socket 'fd',
-   which we translate to a call to curl_multi_socket_action() */
-int running;
-rc = curl_multi_socket(multi_handle, fd, &running);
+int main(void)
+{
+  /* the event-library gets told when there activity on the socket 'fd',
+     which we translate to a call to curl_multi_socket_action() */
+  int running;
+  int rc;
+  int fd;
+  CURLM *multi;
+  rc = curl_multi_socket(multi, fd, &running);
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.15.4, and is deemed stable since
index 265a9f85a8be0582a034769301a8b79ec611d7e2..445ac2c8d6afe70106f8063a0ddcf3ac423aff21 100644 (file)
@@ -97,11 +97,18 @@ socket(s) that got action. If no activity is detected and the timeout expires,
 call \fIcurl_multi_socket_action(3)\fP with \fICURL_SOCKET_TIMEOUT\fP.
 .SH EXAMPLE
 .nf
-/* the event-library gets told when there activity on the socket 'fd',
-   which we translate to a call to curl_multi_socket_action() */
-int running;
-rc = curl_multi_socket_action(multi_handle, fd, EVENT,
-                              &running);
+int main(void)
+{
+  /* the event-library gets told when there activity on the socket 'fd',
+     which we translate to a call to curl_multi_socket_action() */
+  int running;
+  CURLM *multi; /* the stack we work with */
+  int fd; /* the descriptor that had action */
+  int bitmask; /* what activity that happened */
+  CURLMcode mc = curl_multi_socket_action(multi, fd, bitmask, &running);
+  if(mc)
+    printf("error: %s\\n", curl_multi_strerror(mc));
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.15.4, and is deemed stable since 7.16.0.
index 11538b0e01ecff867f50dbee6902613a7d2b9e1f..5987679103fefc0477c5c0beb9ba2e06715107cf 100644 (file)
@@ -35,11 +35,15 @@ This function returns a string describing the \fICURLMcode\fP error code
 passed in the argument \fIerrornum\fP.
 .SH EXAMPLE
 .nf
-int still_running;
+int main(void)
+{
+  int still_running;
+  CURLM *multi = curl_multi_init();
 
-CURLMcode mc = curl_multi_perform(multi_handle, &still_running);
-if(mc)
-  printf("error: %s\\n", curl_multi_strerror(mc));
+  CURLMcode mc = curl_multi_perform(multi, &still_running);
+  if(mc)
+    printf("error: %s\\n", curl_multi_strerror(mc));
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.12.0
index 23abe9491baf0327eac80776709c2bf558c6de8c..1951282eef4ae19a36de2f5dfb428a761b1c5160 100644 (file)
@@ -54,19 +54,27 @@ currently has no stored timeout value. You must not wait too long (more than a
 few seconds perhaps) before you call \fIcurl_multi_perform(3)\fP again.
 .SH EXAMPLE
 .nf
-struct timeval timeout;
-long timeo;
+int main(void)
+{
+  struct timeval timeout;
+  long timeo;
+  fd_set fdread;
+  fd_set fdwrite;
+  fd_set fdexcep;
+  int maxfd;
+  CURLM *multi = curl_multi_init();
 
-curl_multi_timeout(multi_handle, &timeo);
-if(timeo < 0)
-  /* no set timeout, use a default */
-  timeo = 980;
+  curl_multi_timeout(multi, &timeo);
+  if(timeo < 0)
+    /* no set timeout, use a default */
+    timeo = 980;
 
-timeout.tv_sec = timeo / 1000;
-timeout.tv_usec = (timeo % 1000) * 1000;
+  timeout.tv_sec = timeo / 1000;
+  timeout.tv_usec = (timeo % 1000) * 1000;
 
-/* wait for activities no longer than the set timeout */
-select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+  /* wait for activities no longer than the set timeout */
+  select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
+}
 .fi
 .SH TYPICAL USAGE
 Call \fIcurl_multi_timeout(3)\fP, then wait for action on the sockets. Figure
index 0698bcad730e4aa11e69181ca70759151a2fc78c..1f73dc3541f1a078b117ce1fdfce2dad4197d787 100644 (file)
@@ -77,45 +77,35 @@ Bit flag to \fIcurl_waitfd.events\fP indicating the socket should poll on
 write events such as the socket being clear to write without blocking.
 .SH EXAMPLE
 .nf
-CURL *easy_handle;
-CURLM *multi_handle;
+int main(void)
+{
+  CURL *easy;
+  CURLM *multi = curl_multi_init();
+  int still_running;
 
-/* add the individual easy handle */
-curl_multi_add_handle(multi_handle, easy_handle);
+  /* add the individual easy handle */
+  curl_multi_add_handle(multi, easy);
 
-do {
-  CURLMcode mc;
-  int numfds;
+  do {
+    CURLMcode mc;
+    int numfds;
 
-  mc = curl_multi_perform(multi_handle, &still_running);
+    mc = curl_multi_perform(multi, &still_running);
 
-  if(mc == CURLM_OK ) {
-    /* wait for activity, timeout or "nothing" */
-    mc = curl_multi_wait(multi_handle, NULL, 0, 1000, &numfds);
-  }
-
-  if(mc != CURLM_OK) {
-    fprintf(stderr, "curl_multi failed, code %d.\\n", mc);
-    break;
-  }
-
-  /* 'numfds' being zero means either a timeout or no file descriptors to
-     wait for. Try timeout on first occurrence, then assume no file
-     descriptors and no file descriptors to wait for means wait for 100
-     milliseconds. */
+    if(mc == CURLM_OK) {
+      /* wait for activity, timeout or "nothing" */
+      mc = curl_multi_wait(multi, NULL, 0, 1000, &numfds);
+    }
 
-  if(!numfds) {
-    repeats++; /* count number of repeated zero numfds */
-    if(repeats > 1) {
-      WAITMS(100); /* sleep 100 milliseconds */
+    if(mc != CURLM_OK) {
+      fprintf(stderr, "curl_multi failed, code %d.\\n", mc);
+      break;
     }
-  }
-  else
-    repeats = 0;
 
-} while(still_running);
+  } while(still_running);
 
-curl_multi_remove_handle(multi_handle, easy_handle);
+  curl_multi_remove_handle(multi, easy);
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.28.0.
index c4a71b678b493355dd83e732776e901140ec201d..9809232794b28215ae87e5506d92869fdd8dc6a7 100644 (file)
@@ -45,40 +45,47 @@ that multiple calls to this function wake up the same waiting operation.
 This function has no effect on \fIcurl_multi_wait(3)\fP calls.
 .SH EXAMPLE
 .nf
-CURL *easy_handle;
-CURLM *multi_handle;
+extern int time_to_die(void);
+extern int set_something_to_signal_thread_1_to_exit(void);
+extern int decide_to_stop_thread1();
 
-/* add the individual easy handle */
-curl_multi_add_handle(multi_handle, easy_handle);
+int main(void)
+{
+  CURL *easy;
+  CURLM *multi;
+  int still_running;
 
-/* this is thread 1 */
-do {
-  CURLMcode mc;
-  int numfds;
+  /* add the individual easy handle */
+  curl_multi_add_handle(multi, easy);
 
-  mc = curl_multi_perform(multi_handle, &still_running);
+  /* this is thread 1 */
+  do {
+    CURLMcode mc;
+    int numfds;
 
-  if(mc == CURLM_OK) {
-    /* wait for activity, timeout or wakeup */
-    mc = curl_multi_poll(multi_handle, NULL, 0, 10000, &numfds);
-  }
+    mc = curl_multi_perform(multi, &still_running);
 
-  if(time_to_die())
-    exit(1);
+    if(mc == CURLM_OK) {
+      /* wait for activity, timeout or wakeup */
+      mc = curl_multi_poll(multi, NULL, 0, 10000, &numfds);
+    }
 
-} while(still_running);
+    if(time_to_die())
+      return 1;
 
-curl_multi_remove_handle(multi_handle, easy_handle);
+  } while(still_running);
 
-/* this is thread 2 */
+  curl_multi_remove_handle(multi, easy);
 
-if(something makes us decide to stop thread 1) {
+  /* this is thread 2 */
 
-  set_something_to_signal_thread_1_to_exit();
+  if(decide_to_stop_thread1()) {
 
-  curl_multi_wakeup(multi_handle);
-}
+    set_something_to_signal_thread_1_to_exit();
 
+    curl_multi_wakeup(multi);
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.68.0
index 4b0aff7b65c24714f9b342d2ac776b3189c5119e..ad8459c36b5d7ea9eaad02a23b701cd533dbc694 100644 (file)
@@ -43,11 +43,13 @@ one header field use the same name, this returns only the first one.
 
 .SH EXAMPLE
 .nf
-int curl_push_callback(CURL *parent,
-                       CURL *easy,
-                       size_t num_headers,
-                       struct curl_pushheaders *headers,
-                       void *clientp)
+#include <string.h> /* for strncmp */
+
+static int push_cb(CURL *parent,
+                   CURL *easy,
+                   size_t num_headers,
+                   struct curl_pushheaders *headers,
+                   void *clientp)
 {
   char *headp;
   int *transfers = (int *)clientp;
@@ -69,8 +71,13 @@ int curl_push_callback(CURL *parent,
   return CURL_PUSH_DENY;
 }
 
-curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, curl_push_callback);
-curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
+int main(void)
+{
+  int counter;
+  CURLM *multi = curl_multi_init();
+  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_cb);
+  curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.44.0
index 491c004321c465e35f0c01cf18ffedd19abe0ddb..da951bafb94f84381127817ac5dc472621bca5b5 100644 (file)
@@ -43,13 +43,13 @@ libcurl when this callback returns. The returned pointer points to a
 .SH EXAMPLE
 .nf
 /* output all the incoming push request headers */
-int curl_push_callback(CURL *parent,
-                       CURL *easy,
-                       size_t num_headers,
-                       struct curl_pushheaders *headers,
-                       void *clientp)
+static int push_cb(CURL *parent,
+                   CURL *easy,
+                   size_t num_headers,
+                   struct curl_pushheaders *headers,
+                   void *clientp)
 {
-  sizt_t i = 0;
+  int i = 0;
   char *field;
   do {
      field = curl_pushheader_bynum(headers, i);
@@ -60,7 +60,11 @@ int curl_push_callback(CURL *parent,
   return CURL_PUSH_OK; /* permission granted */
 }
 
-curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, curl_push_callback);
+int main(void)
+{
+  CURLM *multi = curl_multi_init();
+  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_cb);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.44.0
index 93f098e2aea10dbd61995347ac631a0092635ea3..ad49857f26b2241403c782384eb92101f6b5e81c 100644 (file)
@@ -38,11 +38,14 @@ Passing in a NULL pointer in \fIshare_handle\fP makes this function return
 immediately with no action.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
   /* use the share, then ... */
   curl_share_cleanup(share);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index f414a14f3c3042732ce337618d8d501a9708039d..b68c4bd8d98fc47c48b8fcfb7a55200cbda60311 100644 (file)
@@ -42,11 +42,14 @@ This \fIshare handle\fP is what you pass to curl using the
 specific curl handle use the data in this share.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index d894291ba225f2544a67054c5cc706946ed6d004..96035499168b8a88eff72b03000f18eff4e57343 100644 (file)
@@ -45,11 +45,14 @@ See \fICURLSHOPT_UNSHARE(3)\fP.
 See \fICURLSHOPT_USERDATA(3)\fP.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index a8329efa06dc1948e708e55e2ab29204161659d3..b1f5e2f39c738111c7a07a82e94c1a84a49b3ab9 100644 (file)
@@ -35,11 +35,14 @@ The \fIcurl_share_strerror(3)\fP function returns a string describing the
 \fICURLSHcode\fP error code passed in the argument \fIerrornum\fP.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 This function was added in libcurl 7.12.0
index b869d3aeadb8c856747bdf86ef7386cd3f71740f..09dbc99a4642227ba585f6a4d760d44e7618f6e0 100644 (file)
@@ -42,29 +42,32 @@ The list should be freed again (after usage) with
 \fIcurl_slist_free_all(3)\fP.
 .SH EXAMPLE
 .nf
-CURL *handle;
-struct curl_slist *slist=NULL;
-struct curl_slist *temp=NULL;
+int main(void)
+{
+  CURL *handle;
+  struct curl_slist *slist = NULL;
+  struct curl_slist *temp = NULL;
 
-slist = curl_slist_append(slist, "pragma:");
+  slist = curl_slist_append(slist, "pragma:");
 
-if (slist == NULL)
-  return -1;
+  if(!slist)
+    return -1;
 
-temp = curl_slist_append(slist, "Accept:")
+  temp = curl_slist_append(slist, "Accept:");
 
-if (temp == NULL) {
-  curl_slist_free_all(slist);
-  return -1;
-}
+  if(!temp) {
+    curl_slist_free_all(slist);
+    return -1;
+  }
 
-slist = temp;
+  slist = temp;
 
-curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
+  curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
 
-curl_easy_perform(handle);
+  curl_easy_perform(handle);
 
-curl_slist_free_all(slist); /* free the list again */
+  curl_slist_free_all(slist); /* free the list again */
+}
 .fi
 .SH AVAILABILITY
 Always
index 5b562a063252f92c258e6c74b6c6d37d0a0f6960..4eeb54132e6dd4be7dcb8d364e46d5172fc1cce4 100644 (file)
@@ -38,19 +38,22 @@ Passing in a NULL pointer in \fIlist\fP makes this function return immediately
 with no action.
 .SH EXAMPLE
 .nf
-CURL *handle;
-struct curl_slist *slist=NULL;
+int main(void)
+{
+  CURL *handle;
+  struct curl_slist *slist = NULL;
 
-slist = curl_slist_append(slist, "X-libcurl: coolness");
+  slist = curl_slist_append(slist, "X-libcurl: coolness");
 
-if (slist == NULL)
-  return -1;
+  if(!slist)
+    return -1;
 
-curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
+  curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
 
-curl_easy_perform(handle);
+  curl_easy_perform(handle);
 
-curl_slist_free_all(slist); /* free the list again */
+  curl_slist_free_all(slist); /* free the list again */
+}
 .fi
 .SH AVAILABILITY
 Always
index 881b0d70de2623faa20a24eef2cb372c4f353fef..89eec323f519f98b2f66ff31eb2a9b0a9e009207 100644 (file)
@@ -46,10 +46,14 @@ strings in a truly portable manner. There are no standard portable case
 insensitive string comparison functions. These two work on all platforms.
 .SH EXAMPLE
 .nf
-if(curl_strequal(name, input))
-  printf("Name and input matches\\n");
-if(curl_strnequal(name, input, 5))
-  printf("Name and input matches in the 5 first bytes\\n");
+int main(int argc, char **argv)
+{
+  const char *name = "compare";
+  if(curl_strequal(name, argv[1]))
+    printf("Name and input matches\\n");
+  if(curl_strnequal(name, argv[1], 5))
+    printf("Name and input matches in the 5 first bytes\\n");
+}
 .fi
 .SH AVAILABILITY
 Always
index d91349282403658926d3089b590e7b655e3dabed..5df8a8f82ff07729e8561bc1aa76a382c069f882 100644 (file)
@@ -44,15 +44,17 @@ strlen() on \fBinput\fP to find out the size.
 You must \fIcurl_free(3)\fP the returned string when you are done with it.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  int decodelen;
-  char *decoded = curl_unescape("%63%75%72%6c", 12, &decodelen);
-  if(decoded) {
-    /* do not assume printf() works on the decoded data! */
-    printf("Decoded: ");
-    /* ... */
-    curl_free(decoded);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    char *decoded = curl_unescape("%63%75%72%6c", 12);
+    if(decoded) {
+      /* do not assume printf() works on the decoded data! */
+      printf("Decoded: ");
+      /* ... */
+      curl_free(decoded);
+    }
   }
 }
 .fi
index 01eb55e613415614eb7c13d0464a62395f83a506..3f6eb0c0116e248845578ab93829d622fdc6eba5 100644 (file)
@@ -40,6 +40,8 @@ stored. They are then set in the object with the \fIcurl_url_set(3)\fP
 function.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLUcode rc;
   CURLU *url = curl_url();
   rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
@@ -52,6 +54,7 @@ function.
     }
     curl_url_cleanup(url);
   }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.62.0
index 7dc5f61a7292c8579b3cd136155dcc839f4ba214..94507efc37d5a1e944e0254471f4e9057634e136 100644 (file)
@@ -37,9 +37,12 @@ Passing in a NULL pointer in \fIhandle\fP makes this function return
 immediately with no action.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLU *url = curl_url();
   curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
   curl_url_cleanup(url);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.62.0
index 059515e1d051fd5f6b690a47c88e588a6184a181..2288347714cbd530b79cd45254700c0f32c95366 100644 (file)
@@ -36,6 +36,8 @@ returns a pointer to the copy as a new \fICURLU\fP handle. The new handle also
 needs to be freed with \fIcurl_url_cleanup(3)\fP.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLUcode rc;
   CURLU *url = curl_url();
   CURLU *url2;
@@ -45,6 +47,7 @@ needs to be freed with \fIcurl_url_cleanup(3)\fP.
     curl_url_cleanup(url2);
   }
   curl_url_cleanup(url);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.62.0
index 34c56c3cd7ab32b8cab4dfa09df512f4b6503b02..1940f4b6a4c11f74df03e3441eb7aff1461c14da 100644 (file)
@@ -145,6 +145,8 @@ The initial hash sign that denotes the beginning of the fragment is a
 delimiter only. It is not part of the fragment contents.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLUcode rc;
   CURLU *url = curl_url();
   rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
@@ -157,6 +159,7 @@ delimiter only. It is not part of the fragment contents.
     }
     curl_url_cleanup(url);
   }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.62.0. CURLUPART_ZONEID was added in 7.65.0.
index 912694f7b6af3c96084ebaf0e32bdaaf162e3e61..e5b1790b8cce5146ba775e4cb3ba9427f975642a 100644 (file)
@@ -179,15 +179,17 @@ If set, the URL parser does not accept embedded credentials for the
 such URLs.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLUcode rc;
   CURLU *url = curl_url();
   rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
   if(!rc) {
-    char *scheme;
     /* change it to an FTP URL */
     rc = curl_url_set(url, CURLUPART_SCHEME, "ftp", 0);
   }
   curl_url_cleanup(url);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.62.0. CURLUPART_ZONEID was added in 7.65.0.
index 382a4049d2f56a93ea759db529f3537394ed7e03..38af12e9c5c524d2a1a12125af9bb7f38d608ac3 100644 (file)
@@ -35,14 +35,16 @@ This function returns a string describing the CURLUcode error code passed in
 the argument \fIerrornum\fP.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLUcode rc;
   CURLU *url = curl_url();
   rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
   if(rc)
     printf("URL error: %s\\n", curl_url_strerror(rc));
   curl_url_cleanup(url);
+}
 .fi
-
 .SH AVAILABILITY
 Added in 7.80.0
 .SH RETURN VALUE
index 0036778e70605a3c2c5a65e5999fe27ba4b4f107..fdf09d1ba3d40cd0590401ebfb6f41d7305fb946 100644 (file)
@@ -37,7 +37,10 @@ its important components (like OpenSSL version).
 We recommend using \fIcurl_version_info(3)\fP instead!
 .SH EXAMPLE
 .nf
-printf("libcurl version %s\\n", curl_version());
+int main(void)
+{
+  printf("libcurl version %s\\n", curl_version());
+}
 .fi
 
 .SH AVAILABILITY
index ac07abee3ec9f2ae5a66967025866996d5188915..e7fb8af659c3414f75e6f6db8a45af41d060489c 100644 (file)
@@ -306,11 +306,14 @@ names are the same as would be used in URLs. The array is terminated by a NULL
 entry.
 .SH EXAMPLE
 .nf
-curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
-printf("libcurl version %u.%u.%u\\n",
-       (ver->version_num >> 16) & 0xff,
-       (ver->version_num >> 8) & 0xff,
-       ver->version_num & 0xff);
+int main(void)
+{
+  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
+  printf("libcurl version %u.%u.%u\\n",
+         (ver->version_num >> 16) & 0xff,
+         (ver->version_num >> 8) & 0xff,
+         ver->version_num & 0xff);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index 04b6759270c3a3681a4098ba29c7183b3d673d71..8623ad08942284be5d1b9fcde273d74bb24a9ed0 100644 (file)
@@ -96,15 +96,22 @@ static size_t writecb(unsigned char *buffer,
   struct customdata *c = (struct customdata *)p;
   const struct curl_ws_frame *m = curl_ws_meta(c->easy);
 
-  /* m->flags tells us about the traffic */
+  printf("flags: %x\\n", m->flags);
 }
 
+int main(void)
 {
-  struct customdata custom;
-  custom.easy = easy;
-  custom.ptr = NULL;
-  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
-  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &custom);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct customdata custom;
+    custom.easy = curl;
+    custom.ptr = NULL;
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &custom);
+
+    curl_easy_perform(curl);
+
+  }
 }
 .fi
 .SH AVAILABILITY
index dcfcbe5d8d58a4f00b3f6b05a1581f3a48227885..e35d936885316dae424a93d3a4c4854e341a3dd6 100644 (file)
@@ -48,10 +48,18 @@ that contains information about the received data. See the
 \fIcurl_ws_meta(3)\fP for details on that struct.
 .SH EXAMPLE
 .nf
+int main(void)
+{
   size_t rlen;
   const struct curl_ws_frame *meta;
   char buffer[256];
-  CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
+    if(res)
+      printf("error: %s\\n", curl_easy_strerror(res));
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.86.0.
index 0dd52fcfe0b34bee5f43ee63e5e311170231a97d..95873b78746c239cb8076c5c007931b1afa35619 100644 (file)
@@ -79,13 +79,22 @@ expected fragment size in the first call and it needs to be zero in subsequent
 calls.
 .SH EXAMPLE
 .nf
-int ping(CURL *curl, const char *send_payload)
+#include <string.h> /* for strlen */
+
+const char *send_payload = "magic";
+
+int main(void)
 {
   size_t sent;
-  CURLcode result =
-    curl_ws_send(curl, send_payload, strlen(send_payload), &sent, 0,
-                 CURLWS_PING);
-  return (int)result;
+  CURLcode res;
+  CURL *curl = curl_easy_init();
+  curl_easy_setopt(curl, CURLOPT_URL, "wss://example.com/");
+  curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 2L);
+  curl_easy_perform(curl);
+  res = curl_ws_send(curl, send_payload, strlen(send_payload), &sent, 0,
+                     CURLWS_PING);
+  curl_easy_cleanup(curl);
+  return (int)res;
 }
 .fi
 .SH AVAILABILITY
index 0ef47f4432ecf919e81bd3c047ae31e0398b9add..b1f5b9883517e95b0998791f48a4b8f3644b0d00 100644 (file)
@@ -48,21 +48,25 @@ is complete, and is typically used in combination with
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_socket_t sockfd;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_socket_t sockfd;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Do not do the transfer - only connect to host */
-  curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
-  res = curl_easy_perform(curl);
+    /* Do not do the transfer - only connect to host */
+    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
+    res = curl_easy_perform(curl);
 
-  /* Extract the socket from the curl handle */
-  res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
+    /* Extract the socket from the curl handle */
+    res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
 
-  if(res != CURLE_OK) {
-    printf("Error: %s\\n", curl_easy_strerror(res));
-    return 1;
+    if(res != CURLE_OK) {
+      printf("Error: %s\\n", curl_easy_strerror(res));
+      return 1;
+    }
   }
 }
 .fi
index 000ad83636fd9a2ed0c03d4501734e48b31a8c8f..977ef5736bbf3f4258dfdc3dbdaae7341c6fda52 100644 (file)
@@ -46,19 +46,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double connect;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &connect);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double connect;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", connect);
+      res = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &connect);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", connect);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 2a23557fb6091fddce7dbdae40b8e516c2c49ae0..7a2ecff23b40fea35314225af9437c600aa7a93e 100644 (file)
@@ -47,20 +47,24 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t connect;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME_T, &connect);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t connect;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
-             (long)(connect % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME_T, &connect);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
+               (long)(connect % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 1ab5113e81f71d31167ca35987c6a32d93ee3bcd..61c3e14feaff77aa2d32d5cd0c7d9a3b63f1ecc8 100644 (file)
@@ -47,15 +47,17 @@ The \fBpath\fP pointer is set to NULL if there is no default path.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  char *cainfo = NULL;
-  curl_easy_getinfo(curl, CURLINFO_CAINFO, &cainfo);
-  if(cainfo)
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    char *cainfo = NULL;
+    curl_easy_getinfo(curl, CURLINFO_CAINFO, &cainfo);
+    if(cainfo) {
       printf("default ca info path: %s\\n", cainfo);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index d93e9fb111e5ec56b0939a4d01145e8d252368bb..56f05d1824d06d74473e19dc23fcdf3f73ffbd0a 100644 (file)
@@ -47,15 +47,17 @@ The \fBpath\fP pointer is set to NULL if there is no default path.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  char *capath = NULL;
-  curl_easy_getinfo(curl, CURLINFO_CAPATH, &capath);
-  if(capath)
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    char *capath = NULL;
+    curl_easy_getinfo(curl, CURLINFO_CAPATH, &capath);
+    if(capath) {
       printf("default ca path: %s\\n", capath);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 277b6033f78214cfa93cd7b5bf3923098a37543d..46e93ccd3fe7b1b921208ed490c356111332bd86 100644 (file)
@@ -54,34 +54,39 @@ the SSL backend and the certificate.
 All TLS-based
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
 
-  /* connect to any HTTPS site, trusted or not */
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
+    /* connect to any HTTPS site, trusted or not */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
 
-  curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
+    curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if (!res) {
-    struct curl_certinfo *ci;
-    res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
+    if(!res) {
+      int i;
+      struct curl_certinfo *ci;
+      res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
 
-    if (!res) {
-      printf("%d certs!\\n", ci->num_of_certs);
+      if(!res) {
+        printf("%d certs!\\n", ci->num_of_certs);
 
-      for(i = 0; i < ci->num_of_certs; i++) {
-        struct curl_slist *slist;
+        for(i = 0; i < ci->num_of_certs; i++) {
+          struct curl_slist *slist;
 
-        for(slist = ci->certinfo[i]; slist; slist = slist->next)
-          printf("%s\\n", slist->data);
+          for(slist = ci->certinfo[i]; slist; slist = slist->next)
+            printf("%s\\n", slist->data);
+        }
       }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 
index 1d1627b3cb6d7c8afb33759a4db7b0ab0a227430..d59d16adbea566bc2c56c9821da05352b0afecb0 100644 (file)
@@ -44,26 +44,31 @@ custom "If-Match-*" header.
 HTTP and some
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
 
-  /* January 1, 2020 is 1577833200 */
-  curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* If-Modified-Since the above time stamp */
-  curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
-                   (long)CURL_TIMECOND_IFMODSINCE);
+    /* January 1, 2020 is 1577833200 */
+    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* If-Modified-Since the above time stamp */
+    curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
+                     (long)CURL_TIMECOND_IFMODSINCE);
+
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the time condition */
-    long unmet;
-    res = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
     if(!res) {
-      printf("The time condition was %sfulfilled\\n", unmet?"NOT":"");
+      /* check the time condition */
+      long unmet;
+      res = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
+      if(!res) {
+        printf("The time condition was %sfulfilled\\n", unmet?"NOT":"");
+      }
     }
   }
 }
index cf0ce8a856940a24f59e8f17015b6a4ee27292a8..299e2d5200ca1b45bc280accaa2b9e086b93640a 100644 (file)
@@ -42,19 +42,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double connect;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double connect;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", connect);
+      res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", connect);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 8641de0ac694a2230b79083b9a6a906254dbe5be..d215839c2552fe721a81956070a0ec90d33c2107 100644 (file)
@@ -43,20 +43,24 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t connect;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &connect);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t connect;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
-             (long)(connect % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &connect);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
+               (long)(connect % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 3a63520e0f43225ba6b1877cfba666d0c263f91d..1b9da9338d51c8ac6e34164366f0d4134b5cbddb 100644 (file)
@@ -44,18 +44,23 @@ same multi handle.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    curl_off_t conn_id;
-    res = curl_easy_getinfo(curl, CURLINFO_CONN_ID, &conn_id);
     if(!res) {
-      printf("Connection used: %" CURL_FORMAT_CURL_OFF_T "\\n", conn_id);
+      curl_off_t conn_id;
+      res = curl_easy_getinfo(curl, CURLINFO_CONN_ID, &conn_id);
+      if(!res) {
+        printf("Connection used: %" CURL_FORMAT_CURL_OFF_T "\\n", conn_id);
+      }
     }
   }
 }
index 474c21af00ad7e27d19a14e21638be10ae884d0c..fbb89b223eacd2260057112d7e7ee989f0f49ec7 100644 (file)
@@ -43,19 +43,23 @@ sensible variable type.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the size */
-    double cl;
-    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
     if(!res) {
-      printf("Size: %.0f\\n", cl);
+      /* check the size */
+      double cl;
+      res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
+      if(!res) {
+        printf("Size: %.0f\\n", cl);
+      }
     }
   }
 }
index cea6ad0f6213f7e1805842611aaf6ee48eee3934..f924df26d289628e649437b3d566c38384399738 100644 (file)
@@ -40,19 +40,23 @@ the size is not known.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the size */
-    curl_off_t cl;
-    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl);
     if(!res) {
-      printf("Download size: %" CURL_FORMAT_CURL_OFF_T "\\n", cl);
+      /* check the size */
+      curl_off_t cl;
+      res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl);
+      if(!res) {
+        printf("Download size: %" CURL_FORMAT_CURL_OFF_T "\\n", cl);
+      }
     }
   }
 }
index b2da1af2560298032db19c601eeb3ae54ea8dec2..418e3c7208e94a4281a6cd8ebacfad6bac2c90d9 100644 (file)
@@ -42,19 +42,23 @@ more sensible variable type.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the upload */
-  res = curl_easy_perform(curl);
+    /* Perform the upload */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the size */
-    double cl;
-    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &cl);
     if(!res) {
-      printf("Size: %.0f\\n", cl);
+      /* check the size */
+      double cl;
+      res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &cl);
+      if(!res) {
+        printf("Size: %.0f\\n", cl);
+      }
     }
   }
 }
index 61a1fde5f24e45da27c7e6c44e5aec2e029d8ace..170c1080a96e61caabf6fef6decc059644bec183 100644 (file)
@@ -39,19 +39,23 @@ upload. Stores -1 if the size is not known.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the upload */
-  res = curl_easy_perform(curl);
+    /* Perform the upload */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the size */
-    curl_off_t cl;
-    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &cl);
     if(!res) {
-      printf("Upload size: %" CURL_FORMAT_CURL_OFF_T "\\n", cl);
+      /* check the size */
+      curl_off_t cl;
+      res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &cl);
+      if(!res) {
+        printf("Upload size: %" CURL_FORMAT_CURL_OFF_T "\\n", cl);
+      }
     }
   }
 }
index 56caea7dfa42e36c4079dbd5958a5a94a41da8a4..1045821b5b6b0fba4a97e28765eb520bf634098f 100644 (file)
@@ -47,21 +47,25 @@ The modern way to get this header from a response is to instead use the
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* extract the content-type */
-    char *ct = NULL;
-    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
-    if(!res && ct) {
-      printf("Content-Type: %s\\n", ct);
+    if(!res) {
+      /* extract the content-type */
+      char *ct = NULL;
+      res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
+      if(!res && ct) {
+        printf("Content-Type: %s\\n", ct);
+      }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 29c8983ce40b02d7ed078ac3d90c517eee42950e..02e2490eb02e39e1e4ae73dd42db0407fcf9ae17 100644 (file)
@@ -45,31 +45,35 @@ domain name are not exported by this option.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* enable the cookie engine */
-  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
+    /* enable the cookie engine */
+    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* extract all known cookies */
-    struct curl_slist *cookies = NULL;
-    res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
-    if(!res && cookies) {
-      /* a linked list of cookies in cookie file format */
-      struct curl_slist *each = cookies;
-      while(each) {
-        printf("%s\\n", each->data);
-        each = each->next;
+    if(!res) {
+      /* extract all known cookies */
+      struct curl_slist *cookies = NULL;
+      res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
+      if(!res && cookies) {
+        /* a linked list of cookies in cookie file format */
+        struct curl_slist *each = cookies;
+        while(each) {
+          printf("%s\\n", each->data);
+          each = each->next;
+        }
+        /* we must free these cookies when we are done */
+        curl_slist_free_all(cookies);
       }
-      /* we must free these cookies when we are done */
-      curl_slist_free_all(cookies);
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 4129a63fa30397b170afdedabe03a9fee4503d80..50f028b57a4d11b0740f856406c445170be0e911 100644 (file)
@@ -46,20 +46,23 @@ corresponding CURL handle.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data");
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    char *method = NULL;
-    curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_METHOD, &method);
-    if(method)
-      printf("Redirected to method: %s\\n", method);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data");
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      char *method = NULL;
+      curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_METHOD, &method);
+      if(method)
+        printf("Redirected to method: %s\\n", method);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 987a179d4b45153c45d9b22f25f1f3e9b07c4e97..810e7873e3c873e41f94f203d1742580462bb734 100644 (file)
@@ -44,19 +44,22 @@ CURL handle.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    char *url = NULL;
-    curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
-    if(url)
-      printf("Redirect to: %s\\n", url);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      char *url = NULL;
+      curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
+      if(url)
+        printf("Redirect to: %s\\n", url);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index e8da80cf383259bf192dec46e0a43ba3f8783ac7..ae08db367aebec97f4d5326c11fe65a475521094 100644 (file)
@@ -48,21 +48,26 @@ the year 2038 on systems using 32 bit longs (Windows).
 HTTP(S), FTP(S), SFTP
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  /* Ask for filetime */
-  curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
-    if((CURLE_OK == res) && (filetime >= 0)) {
-      time_t file_time = (time_t)filetime;
-      printf("filetime %s: %s", filename, ctime(&file_time));
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    /* Ask for filetime */
+    curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
+    res = curl_easy_perform(curl);
+    if(CURLE_OK == res) {
+      long filetime = 0;
+      res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
+      if((CURLE_OK == res) && (filetime >= 0)) {
+        time_t file_time = (time_t)filetime;
+        printf("filetime: %s", ctime(&file_time));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index ffed1667756ef422df245e025c1040d852062fdf..48ddc41636faa3a06d548d9ee0b0f4cee47e22b1 100644 (file)
@@ -50,22 +50,26 @@ range.
 HTTP(S), FTP(S), SFTP
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  /* Ask for filetime */
-  curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    curl_off_t filetime;
-    res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
-    if((CURLE_OK == res) && (filetime >= 0)) {
-      time_t file_time = (time_t)filetime;
-      printf("filetime %s: %s", filename, ctime(&file_time));
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* Ask for filetime */
+    curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
+    res = curl_easy_perform(curl);
+    if(CURLE_OK == res) {
+      curl_off_t filetime;
+      res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
+      if((CURLE_OK == res) && (filetime >= 0)) {
+        time_t file_time = (time_t)filetime;
+        printf("filetime: %s", ctime(&file_time));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 8ca9a0571d7f1ffb9225d84104cdbff5bbbc603a..8e0f1a23b17b3294e56874406cb60597f4f3dced 100644 (file)
@@ -44,21 +44,25 @@ CURL handle.
 FTP(S) and SFTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* extract the entry path */
-    char *ep = NULL;
-    res = curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &ep);
-    if(!res && ep) {
-      printf("Entry path was: %s\\n", ep);
+    if(!res) {
+      /* extract the entry path */
+      char *ep = NULL;
+      res = curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &ep);
+      if(!res && ep) {
+        printf("Entry path was: %s\\n", ep);
+      }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index bce4b8a3c1539f308098b01b38b83e7afacb1b75..2c9d8faede4d1d261aabc64d2637f47c10461bb4 100644 (file)
@@ -41,18 +41,21 @@ The total includes the size of any received headers suppressed by
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long size;
-    res = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &size);
-    if(!res)
-      printf("Header size: %ld bytes\\n", size);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long size;
+      res = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &size);
+      if(!res)
+        printf("Header size: %ld bytes\\n", size);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 07c9675476d80a44be6135398e2b63182425904c..7ceb790b4eb9c3a347f9bcc2d2a495e1c1d521cb 100644 (file)
@@ -40,29 +40,33 @@ bits is explained in the \fICURLOPT_HTTPAUTH(3)\fP option for
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* extract the available authentication types */
-    long auth;
-    res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
     if(!res) {
-      if(!auth)
-        printf("No auth available, perhaps no 401?\\n");
-      else {
-        printf("%s%s%s%s\\n",
-               auth & CURLAUTH_BASIC ? "Basic ":"",
-               auth & CURLAUTH_DIGEST ? "Digest ":"",
-               auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
-               auth % CURLAUTH_NTLM ? "NTLM ":"");
+      /* extract the available authentication types */
+      long auth;
+      res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
+      if(!res) {
+        if(!auth)
+          printf("No auth available, perhaps no 401?\\n");
+        else {
+          printf("%s%s%s%s\\n",
+                 auth & CURLAUTH_BASIC ? "Basic ":"",
+                 auth & CURLAUTH_DIGEST ? "Digest ":"",
+                 auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
+                 auth % CURLAUTH_NTLM ? "NTLM ":"");
+        }
       }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 3262aa686a85016ca622e0de2c136c31afd5e3c4..b4b3ac3fe1a390e68c62430b997ee97cf94ada31 100644 (file)
@@ -39,21 +39,24 @@ available.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* typically CONNECT is used to do HTTPS over HTTP proxies */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long code;
-    res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &code);
-    if(!res && code)
-      printf("The CONNECT response code: %03ld\\n", code);
+    /* typically CONNECT is used to do HTTPS over HTTP proxies */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long code;
+      res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &code);
+      if(!res && code)
+        printf("The CONNECT response code: %03ld\\n", code);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 8058c47b67dfd3dc49b901b91b4134173deeec6e..d4d4e89407ea67626769d1430bd6cd3c53d9e055 100644 (file)
@@ -40,16 +40,19 @@ CURL_HTTP_VERSION_3 or 0 if the version cannot be determined.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long http_version;
-    curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION, &http_version);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long http_version;
+      curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION, &http_version);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index efc13794625412f907f0f0be2ef1451c8ac99b39..88a7345a9f9fd5230fc1ea906c77f07c702268c4 100644 (file)
@@ -48,21 +48,25 @@ type is 64 bits large while its 'long' is 32 bits. Use the
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  long sockfd; /* does not work on win64! */
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    long sockfd; /* does not work on win64! */
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Do not do the transfer - only connect to host */
-  curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
-  res = curl_easy_perform(curl);
+    /* Do not do the transfer - only connect to host */
+    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
+    res = curl_easy_perform(curl);
 
-  /* Extract the socket from the curl handle */
-  res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
+    /* Extract the socket from the curl handle */
+    res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
 
-  if(res != CURLE_OK) {
-    printf("Error: %s\\n", curl_easy_strerror(res));
-    return 1;
+    if(res != CURLE_OK) {
+      printf("Error: %s\\n", curl_easy_strerror(res));
+      return 1;
+    }
   }
 }
 .fi
index 151340301495c9f59b9cbdb2c44f94ced7cc9b88..5501ba7f93f56fe38957d4bd5e23ee629da3b20e 100644 (file)
@@ -45,8 +45,11 @@ CURL handle.
 All
 .SH EXAMPLE
 .nf
+int main(void)
 {
   char *ip;
+  CURLcode res;
+  CURL *curl = curl_easy_init();
 
   curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
index 9a5d16a0d6c73dc8c87d6a04c922ca66e2275ebe..31617ac316bfe7811950253ef901d9989cbc7d3f 100644 (file)
@@ -38,6 +38,7 @@ connection done with this \fBcurl\fP handle.
 All
 .SH EXAMPLE
 .nf
+int main(void)
 {
   CURL *curl;
   CURLcode res;
index 473342fac276b238b0cc9ba430da5e215438406b..4ad0e95229b834768f57ccd27cfa5dcb4d4dd211 100644 (file)
@@ -43,19 +43,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double namelookup;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &namelookup);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double namelookup;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", namelookup);
+      res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &namelookup);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", namelookup);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 0cedd39fcff81352d410996e124ca14564c07b6b..91be68a29230eb84c5675b79c3e0c4f9d2dd0dbf 100644 (file)
@@ -43,20 +43,24 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t namelookup;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &namelookup);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t namelookup;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", namelookup / 1000000,
-             (long)(namelookup % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &namelookup);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", namelookup / 1000000,
+               (long)(namelookup % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index aec2d709c96615f51d12d3fdb42039dde6e7b8e4..b151f1e268e854a6890ed057ff3d792c0f6c6ceb 100644 (file)
@@ -42,19 +42,22 @@ to make persistent connections to save time.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long connects;
-    res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
-    if(res)
-      printf("It needed %d connects\\n", connects);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long connects;
+      res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
+      if(res)
+        printf("It needed %ld connects\\n", connects);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 96b3b9dfaa22773017c8f6c208eb2fcb515a38bb..cafeb68a1377b65d0ab7819669dd8ca6b08f95d8 100644 (file)
@@ -39,19 +39,22 @@ operation. The number is OS and system specific.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res != CURLE_OK) {
-    long error;
-    res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
-    if(res && error) {
-      printf("Errno: %ld\\n", error);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res != CURLE_OK) {
+      long error;
+      res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
+      if(res && error) {
+        printf("Errno: %ld\\n", error);
+      }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 7042a3b2b2476f24741e3156d6e8d9bc14d2f322..01f90f214efdc1bddc08ef9dbaf6760a0b2d907f 100644 (file)
@@ -47,19 +47,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double pretransfer;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &pretransfer);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double pretransfer;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", pretransfer);
+      res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &pretransfer);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", pretransfer);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index d5de3cc647cdc540ca19485dc680a95d3a63452a..f05543446179502d83dd8967c36f855064f00615 100644 (file)
@@ -47,20 +47,25 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t pretransfer;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T, &pretransfer);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t pretransfer;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", pretransfer / 1000000,
-             (long)(pretransfer % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T, &pretransfer);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld\\n",
+               pretransfer / 1000000,
+               (long)(pretransfer % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 6431e36eb86ea254e10982b250e148d44afbd538..597a797ec5487537ffd4f3a33f800502e5d598ac 100644 (file)
@@ -45,8 +45,11 @@ CURL handle.
 All network based ones
 .SH EXAMPLE
 .nf
+int main(void)
 {
   char *ip;
+  CURLcode res;
+  CURL *curl = curl_easy_init();
 
   curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
index 85799959567249815dd228a7b739920ab7d0b426..51d2b746f5f3ae7a66b62e119914c2366e01345f 100644 (file)
@@ -43,18 +43,21 @@ accessed URL.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long port;
-    res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);
-    if(!res)
-      printf("Connected to remote port: %ld\\n", port);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long port;
+      res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);
+      if(!res)
+        printf("Connected to remote port: %ld\\n", port);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 58459752f228325db8c92e798faed5240b898077..2c63e3e48c8050e70e48003dc246ba1020676c37 100644 (file)
@@ -40,19 +40,26 @@ pointer, although effectively being a 'void *'.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  void *pointer = 0x2345454;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    void *pointer = (void *)0x2345454;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* set the private pointer */
-  curl_easy_setopt(curl, CURLOPT_PRIVATE, pointer);
-  ret = curl_easy_perform(curl);
+    /* set the private pointer */
+    curl_easy_setopt(curl, CURLOPT_PRIVATE, pointer);
+    res = curl_easy_perform(curl);
 
-  /* extract the private pointer again */
-  ret = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &pointer);
+    /* extract the private pointer again */
+    res = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &pointer);
 
-  curl_easy_cleanup(curl);
+    if(res)
+      printf("error: %s\\n", curl_easy_strerror(res));
+
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 94b2dacf80cf6d58609ce016c7a8bc4e0c903478..aac7e9f3f1b616c6b12347e078bd84187dd7cd57 100644 (file)
@@ -51,16 +51,19 @@ CURLPROTO_SMTPS, CURLPROTO_TELNET, CURLPROTO_TFTP, CURLPROTO_MQTT
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long protocol;
-    curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long protocol;
+      curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 4d0789bf6fa229d1613aa05e88a2a9732958eb49..3d6e5494829b80d826fdb74ac84dbfbf4779817e 100644 (file)
@@ -41,30 +41,34 @@ bits is explained in the \fICURLOPT_PROXYAUTH(3)\fP option for
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* extract the available proxy authentication types */
-    long auth;
-    res = curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_AVAIL, &auth);
     if(!res) {
-      if(!auth)
-        printf("No proxy auth available, perhaps no 407?\\n");
-      else {
-        printf("%s%s%s%s\\n",
-               auth & CURLAUTH_BASIC ? "Basic ":"",
-               auth & CURLAUTH_DIGEST ? "Digest ":"",
-               auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
-               auth % CURLAUTH_NTLM ? "NTLM ":"");
+      /* extract the available proxy authentication types */
+      long auth;
+      res = curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_AVAIL, &auth);
+      if(!res) {
+        if(!auth)
+          printf("No proxy auth available, perhaps no 407?\\n");
+        else {
+          printf("%s%s%s%s\\n",
+                 auth & CURLAUTH_BASIC ? "Basic ":"",
+                 auth & CURLAUTH_DIGEST ? "Digest ":"",
+                 auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
+                 auth % CURLAUTH_NTLM ? "NTLM ":"");
+        }
       }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 17f6fcf7e5a44153345632537e7c121fc78e19b4..f4ce84918b0b4792463063e73b8244f5ebb8ac6f 100644 (file)
@@ -79,20 +79,23 @@ The error code is zero (\fBCURLPX_OK\fP) if no response code was available.
 All that can be done over SOCKS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://127.0.0.1");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_PROXY) {
-    long proxycode;
-    res = curl_easy_getinfo(curl, CURLINFO_PROXY_ERROR, &proxycode);
-    if(!res && proxycode)
-      printf("The detailed proxy error: %ld\\n", proxycode);
+    curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://127.0.0.1");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_PROXY) {
+      long proxycode;
+      res = curl_easy_getinfo(curl, CURLINFO_PROXY_ERROR, &proxycode);
+      if(!res && proxycode)
+        printf("The detailed proxy error: %ld\\n", proxycode);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 3b266f75bc63fed24bb11f826ffc1e70d10d0f86..c2a311a2ac4c5348aa6f359d8c8a4dc0796282bf 100644 (file)
@@ -40,17 +40,22 @@ option. This is only used for HTTPS proxies.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  long verifyresult;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
-  res = curl_easy_perform(curl);
-  curl_easy_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT, &verifyresult);
-  printf("The peer verification said %s\\n", verifyresult?
-         "fine":"BAAAD");
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    long verifyresult;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
+    res = curl_easy_perform(curl);
+    if(res)
+      printf("error: %s\\n", curl_easy_strerror(res));
+    curl_easy_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT, &verifyresult);
+    printf("The peer verification said %s\\n", verifyresult?
+           "fine" : "bad");
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 034c00e2f8e9dc50853f69189f370cdd0a93c981..a0017d7067c83c2b857f7f1072167932f944063d 100644 (file)
@@ -39,17 +39,20 @@ actually followed.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long redirects;
-    curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &redirects);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long redirects;
+      curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &redirects);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 7d3870acd5e6e3713a59a0249b959b55c9cf7382..ece2055c0fba2256af63c3a931c1fe11d3364a71 100644 (file)
@@ -43,19 +43,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double redirect;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &redirect);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double redirect;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", redirect);
+      res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &redirect);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", redirect);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 444bbae77b3c70866ff816a74799c36978c1aff3..cbda42035402933582dc901a6eb81f53231b6a0f 100644 (file)
@@ -44,20 +44,24 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t redirect;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME_T, &redirect);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t redirect;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", redirect / 1000000,
-             (long)(redirect % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME_T, &redirect);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", redirect / 1000000,
+               (long)(redirect % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index aa39803eb0a3e33674da5108677e66f1d591f5ab..61422f6db6743c8054d23e64260e979a866e9b88 100644 (file)
@@ -44,18 +44,21 @@ redirect to happen (since 7.54.1).
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    char *url = NULL;
-    curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &url);
-    if(url)
-      printf("Redirect to: %s\\n", url);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      char *url = NULL;
+      curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &url);
+      if(url)
+        printf("Redirect to: %s\\n", url);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index fe4afd0b734915b1296083ed1e20d94a8dccd8fb..550ccf9aee538419f82f3264a7b9e6f9d40eda0b 100644 (file)
@@ -41,19 +41,22 @@ CURL handle.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    char *hdr = NULL;
-    curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr);
-    if(hdr)
-      printf("Referrer header: %s\\n", hdr);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      char *hdr = NULL;
+      curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr);
+      if(hdr)
+        printf("Referrer header: %s\\n", hdr);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index fca67a9b8a2b79d78e1323daa7f61c850cb79ab8..9f702910703c1f2013877f08d517a7bd93829d84 100644 (file)
@@ -39,18 +39,21 @@ than one request if \fICURLOPT_FOLLOWLOCATION(3)\fP is enabled.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long req;
-    res = curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &req);
-    if(!res)
-      printf("Request size: %ld bytes\\n", req);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long req;
+      res = curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &req);
+      if(!res)
+        printf("Request size: %ld bytes\\n", req);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 9cda1030f66ab3f964f56ca9f324c938c6fdd458..c006a1580846bfcf6019fe3f376635fce57655c3 100644 (file)
@@ -43,16 +43,19 @@ Note that a proxy's CONNECT response should be read with
 HTTP, FTP, SMTP and LDAP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long response_code;
-    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long response_code;
+      curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 2c761d7317518fd4ade02907bd68456657896bed..5a7450ccba99f549006f0ab8dcce2e4fa85dcf65 100644 (file)
@@ -46,18 +46,21 @@ Returns zero delay if there was no header.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    curl_off_t wait = 0;
-    curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
-    if(wait)
-      printf("Wait for %" CURL_FORMAT_CURL_OFF_T " seconds\\n", wait);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      curl_off_t wait = 0;
+      curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
+      if(wait)
+        printf("Wait for %" CURL_FORMAT_CURL_OFF_T " seconds\\n", wait);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index caad1935e5aa9d4d07050a15fa0a6dc97fe119da..bd8ec271ec6d4d6188abd6f1dc40109af5e0e8c0 100644 (file)
@@ -39,16 +39,19 @@ by the application.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long cseq;
-    curl_easy_getinfo(curl, CURLINFO_RTSP_CLIENT_CSEQ, &cseq);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long cseq;
+      curl_easy_getinfo(curl, CURLINFO_RTSP_CLIENT_CSEQ, &cseq);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 5331de260157699048b37b31659a99091134510d..dc840a8474e87a1fd7a5dd8b9439c179e7db092a 100644 (file)
@@ -40,16 +40,19 @@ value.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long cseq;
-    curl_easy_getinfo(curl, CURLINFO_RTSP_CSEQ_RECV, &cseq);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long cseq;
+      curl_easy_getinfo(curl, CURLINFO_RTSP_CSEQ_RECV, &cseq);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 478b25836d55b55066b26bedbafdaedf80d3cd3f..8cf052261157227a628d7a647b24505fdbdd02e5 100644 (file)
@@ -44,16 +44,19 @@ retrieve this info before closing the active connection.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    long cseq;
-    curl_easy_getinfo(curl, CURLINFO_RTSP_SERVER_CSEQ, &cseq);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      long cseq;
+      curl_easy_getinfo(curl, CURLINFO_RTSP_SERVER_CSEQ, &cseq);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 3758792739db7eff4ce8219d204f504286fba5b8..fe1e3fd0de14bb901e33723c7107eb96235165b7 100644 (file)
@@ -45,16 +45,19 @@ CURL handle.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    char *id;
-    curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &id);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      char *id;
+      curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &id);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index a736dd81ccbdb22ee9870e7edb568f236e976dc5..018866a68e43d9bf256b9d7af88d4896c16520fb 100644 (file)
@@ -43,18 +43,21 @@ corresponding CURL handle.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  if(res == CURLE_OK) {
-    char *scheme = NULL;
-    curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
-    if(scheme)
-      printf("scheme: %s\\n", scheme); /* scheme: HTTP */
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res == CURLE_OK) {
+      char *scheme = NULL;
+      curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
+      if(scheme)
+        printf("scheme: %s\\n", scheme); /* scheme: HTTP */
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index c3a2f264161cf12f29679a4049172936a0fa1ee9..7ac1f9231caa4f00e9617a3aea025ea1e086b422 100644 (file)
@@ -44,19 +44,23 @@ sensible variable type.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the size */
-    double dl;
-    res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &dl);
     if(!res) {
-      printf("Downloaded %.0f bytes\\n", cl);
+      /* check the size */
+      double dl;
+      res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &dl);
+      if(!res) {
+        printf("Downloaded %.0f bytes\\n", dl);
+      }
     }
   }
 }
index c3bb7f195c9b26d50124ce87879d6009713648a6..5e424f2351b77998f32f78125c581adca98e1a40 100644 (file)
@@ -41,19 +41,23 @@ commonly called body. All meta and header data is excluded from this amount.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    /* check the size */
-    curl_off_t dl;
-    res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &dl);
     if(!res) {
-      printf("Downloaded %" CURL_FORMAT_CURL_OFF_T " bytes\\n", dl);
+      /* check the size */
+      curl_off_t dl;
+      res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &dl);
+      if(!res) {
+        printf("Downloaded %" CURL_FORMAT_CURL_OFF_T " bytes\\n", dl);
+      }
     }
   }
 }
index 89228b01120809a6c2fe67e3fdf4abf65ecb711e..ba01b311923affef3b24221d6f56626e602a1399 100644 (file)
@@ -42,18 +42,22 @@ sensible variable type.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    double ul;
-    res = curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &ul);
     if(!res) {
-      printf("Uploaded %.0f bytes\\n", ul);
+      double ul;
+      res = curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &ul);
+      if(!res) {
+        printf("Uploaded %.0f bytes\\n", ul);
+      }
     }
   }
 }
index ea77bd7ccfa2b419c29d0a6dbd0c5bd061b774bf..24230c04687c7887723911fda95840b56103cf4b 100644 (file)
@@ -39,18 +39,22 @@ were uploaded.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    curl_off_t ul;
-    res = curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD_T, &ul);
     if(!res) {
-      printf("Uploaded %" CURL_FORMAT_CURL_OFF_T " bytes\\n", ul);
+      curl_off_t ul;
+      res = curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD_T, &ul);
+      if(!res) {
+        printf("Uploaded %" CURL_FORMAT_CURL_OFF_T " bytes\\n", ul);
+      }
     }
   }
 }
index c79e48a71574bffd6a466f6faf794674872e7ed7..7c277d51dd4d4b8d50c4193504bc9188f32e7666 100644 (file)
@@ -41,18 +41,22 @@ sensible variable type.
 .SH PROTOCOLS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    double speed;
-    res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &speed);
     if(!res) {
-      printf("Download speed %.0f bytes/sec\\n", speed);
+      double speed;
+      res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &speed);
+      if(!res) {
+        printf("Download speed %.0f bytes/sec\\n", speed);
+      }
     }
   }
 }
index 9d308c6bf68551c04254e102ce8ef9ff9e7767bd..b17d282815a149226614ade4541f01830d8e4e01 100644 (file)
@@ -38,18 +38,23 @@ that curl measured for the complete download. Measured in bytes/second.
 .SH PROTOCOLS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    curl_off_t speed;
-    res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &speed);
     if(!res) {
-      printf("Download speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\\n", speed);
+      curl_off_t speed;
+      res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &speed);
+      if(!res) {
+        printf("Download speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\\n",
+               speed);
+      }
     }
   }
 }
index 814a4fa8e9052c70133c15390bc3fc52c509ab02..c42f3b517081aecc8c6b4726f40a3dec7963b620 100644 (file)
@@ -40,18 +40,22 @@ sensible variable type.
 .SH PROTOCOLS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    double speed;
-    res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed);
     if(!res) {
-      printf("Upload speed %.0f bytes/sec\\n", speed);
+      double speed;
+      res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed);
+      if(!res) {
+        printf("Upload speed %.0f bytes/sec\\n", speed);
+      }
     }
   }
 }
index eff8554c066bf8cbfb323740989b564d7805367f..f2bf1d735b0d8cd4c4a4443d66b00035e34f90b2 100644 (file)
@@ -38,18 +38,22 @@ curl measured for the complete upload. Measured in bytes/second.
 .SH PROTOCOLS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    curl_off_t speed;
-    res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed);
     if(!res) {
-      printf("Upload speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\\n", speed);
+      curl_off_t speed;
+      res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed);
+      if(!res) {
+        printf("Upload speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\\n", speed);
+      }
     }
   }
 }
index 0375e79a411702db5381d14bb7e83bd3a53b0e6f..03db5bbb445263aeadbd66dc5139992fdfc0dbea 100644 (file)
@@ -43,17 +43,20 @@ data for you.
 All TLS based ones.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  struct curl_slist *engines;
-  res = curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
-  if((res == CURLE_OK) && engines) {
-    /* we have a list, free it when done using it */
-    curl_slist_free_all(engines);
-  }
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_slist *engines;
+    res = curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
+    if((res == CURLE_OK) && engines) {
+      /* we have a list, free it when done using it */
+      curl_slist_free_all(engines);
+    }
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index d66d7df60969d27b1ce6069d30e6043d71c777c5..cf881ec81181315868df9e9f24858540e36aa646 100644 (file)
@@ -42,16 +42,21 @@ option).
 All using TLS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  long verifyresult;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &verifyresult);
-  printf("The peer verification said %s\\n", verifyresult?
-         "BAAAD":"fine");
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    long verifyresult;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res)
+      printf("error: %s\\n", curl_easy_strerror(res));
+    curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &verifyresult);
+    printf("The peer verification said %s\\n", verifyresult?
+           "BAAAD":"fine");
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0c179323225e837f67a7747a858ebdd4c921cd2d..c9879d2e5e05e7c07a657f79f1a4db56657c25d6 100644 (file)
@@ -45,19 +45,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double start;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &start);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double start;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", start);
+      res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &start);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", start);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 3ad2d525f969dcb866c4c9761b117d3af0de2b87..7638f115ee61742ad761dc7b5ee717d8f20c426a 100644 (file)
@@ -46,20 +46,24 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t start;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T, &start);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t start;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", start / 1000000,
-             (long)(start % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T, &start);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", start / 1000000,
+               (long)(start % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 88166b0997992a958551e691424fd96583ceda5f..60d648552c1e81c3c0c7e278cbe96a52327397ed 100644 (file)
@@ -52,14 +52,19 @@ that document for more information.
 All TLS-based
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  struct curl_tlssessioninfo *tls;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  res = curl_easy_perform(curl);
-  curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &tls);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_tlssessioninfo *tls;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
+    if(res)
+      printf("error: %s\\n", curl_easy_strerror(res));
+    curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &tls);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 53d084d48789b99970c01255bae9cf8bc65f83aa..8c5f2525e034c7943c0f73b2922d7097b19f5283 100644 (file)
@@ -133,13 +133,13 @@ static size_t wf(void *ptr, size_t size, size_t nmemb, void *stream)
   CURLcode res = curl_easy_getinfo(curl, CURLINFO_TLS_SSL_PTR, &info);
   if(info && !res) {
     if(CURLSSLBACKEND_OPENSSL == info->backend) {
-       printf("OpenSSL ver. %s\\n", SSL_get_version((SSL*)info->internals));
+      printf("OpenSSL ver. %s\\n", SSL_get_version((SSL*)info->internals));
     }
   }
   return size * nmemb;
 }
 
-int main(int argc, char** argv)
+int main(int argc, char **argv)
 {
   CURLcode res;
   curl = curl_easy_init();
index 12a8efa3a61c50a396c26bb37ebee2d680e44e32..c5519fcb029904bcd675ec10b6706c478e02dc46 100644 (file)
@@ -43,19 +43,23 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  double total;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    double total;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %.1f", total);
+      res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total);
+      if(CURLE_OK == res) {
+        printf("Time: %.1f", total);
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index d2bc9e88637eab81e4647bcf6b2e625496c45127..54a0d547c6c0ee64c16570250cfc9e141c981fb6 100644 (file)
@@ -44,20 +44,24 @@ See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_off_t total;
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_off_t total;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    res = curl_easy_perform(curl);
     if(CURLE_OK == res) {
-      printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", total / 1000000,
-             (long)(total % 1000000));
+      res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total);
+      if(CURLE_OK == res) {
+        printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", total / 1000000,
+               (long)(total % 1000000));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index c10e5d55e025ebe23726c36d2b5f692071550bcf..b166b20bff77f39c46132ee75dc376e5193485bd 100644 (file)
@@ -45,18 +45,22 @@ same multi handle.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Perform the request */
-  res = curl_easy_perform(curl);
+    /* Perform the request */
+    res = curl_easy_perform(curl);
 
-  if(!res) {
-    curl_off_t xfer_id;
-    res = curl_easy_getinfo(curl, CURLINFO_XFER_ID, &xfer_id);
     if(!res) {
-      printf("Transfer ID: %" CURL_FORMAT_CURL_OFF_T "\\n", xfer_id);
+      curl_off_t xfer_id;
+      res = curl_easy_getinfo(curl, CURLINFO_XFER_ID, &xfer_id);
+      if(!res) {
+        printf("Transfer ID: %" CURL_FORMAT_CURL_OFF_T "\\n", xfer_id);
+      }
     }
   }
 }
index 589b624bf3452d95f8fc7102fe53fa4cd086d035..932e333976e2cb50746103f00b2a76550bbeb3a4 100644 (file)
@@ -46,9 +46,12 @@ The default value is 0, which means that the penalization is inactive.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-long maxchunk = 10000;
-curl_multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, maxchunk);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  long maxchunk = 10000;
+  curl_multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, maxchunk);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index 5a66d058e4c2648d44e66b3f3edaddf86c1376be..30bbe99ec0c42d74f0f6b68b4e7b50debab65627 100644 (file)
@@ -46,9 +46,12 @@ The default value is 0, which means that the size penalization is inactive.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-long maxlength = 10000;
-curl_multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, maxlength);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  long maxlength = 10000;
+  curl_multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, maxlength);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index 97468201e4779405b798b1a2dcf2c846c72585d1..e0d75f2d5d5700934512c206db26d97157b294f3 100644 (file)
@@ -56,9 +56,12 @@ See DESCRIPTION
 All
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-/* only keep 10 connections in the cache */
-curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  /* only keep 10 connections in the cache */
+  curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.16.3
index d53f0460e8a8bfe8926015ef8762f19ce5daa53d..7b5741e58a86ef0282629ce4346a580a800a9ac5 100644 (file)
@@ -45,9 +45,12 @@ value passed here would be honored based on other system resources properties.
 All
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLM *m = curl_multi_init();
   /* max concurrent streams 200 */
   curl_multi_setopt(m, CURLMOPT_MAX_CONCURRENT_STREAMS, 200L);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.67.0
index a9bf0ad786ef1293438eafbecf19b52544ff0ac3..fb0f6787ce114083ed2c66700342275bb662211f 100644 (file)
@@ -58,9 +58,12 @@ timeout is however treated as a per-connect timeout.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-/* do no more than 2 connections per host */
-curl_multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  /* do no more than 2 connections per host */
+  curl_multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index 1785eb427eee477271da4a4a2120b0626a0496a0..9f2c6ffbe800d880b9bc3d27113294bb4e36973f 100644 (file)
@@ -50,9 +50,12 @@ total number of requests in-flight is \fICURLMOPT_MAX_HOST_CONNECTIONS(3)\fP *
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-/* set a more conservative pipe length */
-curl_multi_setopt(m, CURLMOPT_MAX_PIPELINE_LENGTH, 3L);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  /* set a more conservative pipe length */
+  curl_multi_setopt(m, CURLMOPT_MAX_PIPELINE_LENGTH, 3L);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index 0b70944143524937de08336226eb88c72194d89a..130822f569266764f5f0930b7857a216ca9ba285 100644 (file)
@@ -56,9 +56,12 @@ controlled by the number of easy handles added.
 All
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-/* never do more than 15 connections */
-curl_multi_setopt(m, CURLMOPT_MAX_TOTAL_CONNECTIONS, 15L);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  /* never do more than 15 connections */
+  curl_multi_setopt(m, CURLMOPT_MAX_TOTAL_CONNECTIONS, 15L);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index de7ccc9670637a5f4c99f802441bc49b8530c6bd..88777320fab65be03c1fc8e4ba16ab2db254afc3 100644 (file)
@@ -53,9 +53,12 @@ Before that, default was \fBCURLPIPE_NOTHING\fP.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURLM *m = curl_multi_init();
-/* try HTTP/2 multiplexing */
-curl_multi_setopt(m, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
+int main(void)
+{
+  CURLM *m = curl_multi_init();
+  /* try HTTP/2 multiplexing */
+  curl_multi_setopt(m, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.16.0. Multiplex support bit added in 7.43.0. HTTP/1 Pipelining
index 95d475dbe6e08c5d09b9dfa47bd96d4e26c146b4..b59232fb8c96e06d4246db907f93225be57c0def 100644 (file)
@@ -50,14 +50,17 @@ The default value is NULL, which means that there is no block list.
 .SH PROTOCOLS
 .SH EXAMPLE
 .nf
-  char *server_block_list[] =
-  {
-    "Microsoft-IIS/6.0",
-    "nginx/0.8.54",
-    NULL
-  };
-
+static char *server_block_list[] =
+{
+  "Microsoft-IIS/6.0",
+  "nginx/0.8.54",
+  NULL
+};
+int main(void)
+{
+  CURLM *m = curl_multi_init();
   curl_multi_setopt(m, CURLMOPT_PIPELINING_SERVER_BL, server_block_list);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index 0e4e52e1a0d8472045c5f3114e2e8a3314e232c2..2bbfbfe2672afd345737c98021a2a7850afdcdb3 100644 (file)
@@ -46,14 +46,18 @@ The default value is NULL, which means that there is no block list.
 HTTP(S)
 .SH EXAMPLE
 .nf
-  char *site_block_list[] =
-  {
-    "www.haxx.se",
-    "www.example.com:1234",
-    NULL
-  };
+static char *site_block_list[] =
+{
+  "www.haxx.se",
+  "www.example.com:1234",
+  NULL
+};
 
+int main(void)
+{
+  CURLM *m = curl_multi_init();
   curl_multi_setopt(m, CURLMOPT_PIPELINING_SITE_BL, site_block_list);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.30.0
index 2b1968417735542eb805d08d49f9f6d9d032d5c9..8ff04bbe0b9475d8ed1303dceda3643171693957 100644 (file)
@@ -41,6 +41,8 @@ NULL
 HTTP(S)
 .SH EXAMPLE
 .nf
+#include <string.h>
+
 /* only allow pushes for file names starting with "push-" */
 int push_callback(CURL *parent,
                   CURL *easy,
@@ -68,8 +70,13 @@ int push_callback(CURL *parent,
   return CURL_PUSH_DENY;
 }
 
-curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
-curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
+int main(void)
+{
+  int counter;
+  CURLM *multi = curl_multi_init();
+  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
+  curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.44.0
index 9e0d8b9f27ec84b339b451de9663046456d8da88..e1a96218f59b80813752b9a89b7dae8c3bf7e5b7 100644 (file)
@@ -91,6 +91,8 @@ NULL, no callback
 HTTP(S) (HTTP/2 only)
 .SH EXAMPLE
 .nf
+#include <string.h>
+
 /* only allow pushes for file names starting with "push-" */
 int push_callback(CURL *parent,
                   CURL *easy,
@@ -118,8 +120,13 @@ int push_callback(CURL *parent,
   return CURL_PUSH_DENY;
 }
 
-curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
-curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
+int main(void)
+{
+  int counter;
+  CURLM *multi = curl_multi_init();
+  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
+  curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.44.0
index 4dd103beeca9c6f51c7f1fc104ad22691a45d737..aeb04dabaf610d1a35cf7121d66bfd0f73650dc4 100644 (file)
@@ -42,28 +42,32 @@ NULL
 All
 .SH EXAMPLE
 .nf
+struct priv {
+  void *ours;
+};
+
 static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
 {
-  GlobalInfo *g = (GlobalInfo*) cbp;
-  SockInfo *fdp = (SockInfo*) sockp;
+  struct priv *p = sockp;
+  printf("my ptr: %p\\n", p->ours);
 
   if(what == CURL_POLL_REMOVE) {
-    remsock(fdp);
+    /* remove the socket from our collection */
+  }
+  if(what & CURL_POLL_IN) {
+    /* wait for read on this socket */
   }
-  else {
-    if(!fdp) {
-      addsock(s, e, what, g);
-    }
-    else {
-      setsock(fdp, s, e, what, g);
-    }
+  if(what & CURL_POLL_OUT) {
+    /* wait for write on this socket */
   }
+
   return 0;
 }
 
-main()
+int main(void)
 {
-  GlobalInfo setup;
+  struct priv setup;
+  CURLM *multi = curl_multi_init();
   /* ... use socket callback and custom pointer */
   curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
   curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
index fa4272e13f4a03d905a6bfa467a4eb7006d403f1..701715dd25e0671df9d30b67b35843712f355597 100644 (file)
@@ -85,28 +85,32 @@ NULL (no callback)
 All
 .SH EXAMPLE
 .nf
+struct priv {
+  void *ours;
+};
+
 static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
 {
-  GlobalInfo *g = cbp;
-  SockInfo *fdp = sockp;
+  struct priv *p = sockp;
+  printf("our ptr: %p\\n", p->ours);
 
   if(what == CURL_POLL_REMOVE) {
-    remsock(fdp);
+    /* remove the socket from our collection */
+  }
+  if(what & CURL_POLL_IN) {
+    /* wait for read on this socket */
   }
-  else {
-    if(!fdp) {
-      addsock(s, e, what, g);
-    }
-    else {
-      setsock(fdp, s, e, what, g);
-    }
+  if(what & CURL_POLL_OUT) {
+    /* wait for write on this socket */
   }
+
   return 0;
 }
 
-main()
+int main(void)
 {
-  GlobalInfo setup;
+  struct priv setup;
+  CURLM *multi = curl_multi_init();
   /* ... use socket callback and custom pointer */
   curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
   curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
index 1da6d4a286d81f1dec83916dff05e44c35ac49a7..b3f853d2317e781d2dd23beb0cd5a099236b8331 100644 (file)
@@ -42,39 +42,30 @@ NULL
 All
 .SH EXAMPLE
 .nf
-static gboolean timeout_cb(gpointer user_data)
-{
-  int running;
-  if(user_data) {
-    g_free(user_data);
-    curl_multi_setopt(curl_handle, CURLMOPT_TIMERDATA, NULL);
-  }
-  curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running);
-  return G_SOURCE_REMOVE;
-}
+struct priv {
+  void *custom;
+};
 
 static int timerfunc(CURLM *multi, long timeout_ms, void *clientp)
 {
-  guint *id = clientp;
-
-  if(id)
-    g_source_remove(*id);
+ struct priv *mydata = clientp;
+ printf("our ptr: %p\\n", mydata->custom);
 
-  /* -1 means we should just delete our timer. */
-  if(timeout_ms == -1) {
-    g_free(id);
-    id = NULL;
-  }
-  else {
-    if(!id)
-      id = g_new(guint, 1);
-    *id = g_timeout_add(timeout_ms, timeout_cb, id);
-  }
-  current_timer = id;
-  return 0;
+ if(timeout_ms) {
+   /* this is the new single timeout to wait for */
+ }
+ else {
+   /* delete the timeout, nothing to wait for now */
+ }
 }
 
-curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
+int main(void)
+{
+  struct priv mydata;
+  CURLM *multi = curl_multi_init();
+  curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
+  curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.16.0
index 4914dc6f908ba32ac77303596edcd6d210ab6e58..69ad1516723fc8b18e68e0d96e1654dce67922dc 100644 (file)
@@ -70,39 +70,30 @@ NULL
 All
 .SH EXAMPLE
 .nf
-static gboolean timeout_cb(gpointer user_data)
-{
-  int running;
-  if(user_data) {
-    g_free(user_data);
-    curl_multi_setopt(curl_handle, CURLMOPT_TIMERDATA, NULL);
-  }
-  curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running);
-  return G_SOURCE_REMOVE;
-}
+struct priv {
+  void *custom;
+};
 
 static int timerfunc(CURLM *multi, long timeout_ms, void *clientp)
 {
-  guint *id = clientp;
-
-  if(id)
-    g_source_remove(*id);
+ struct priv *mydata = clientp;
+ printf("our ptr: %p\\n", mydata->custom);
 
-  /* -1 means we should just delete our timer. */
-  if(timeout_ms == -1) {
-    g_free(id);
-    id = NULL;
-  }
-  else {
-    if(!id)
-      id = g_new(guint, 1);
-    *id = g_timeout_add(timeout_ms, timeout_cb, id);
-  }
-  current_timer = id;
-  return 0;
+ if(timeout_ms) {
+   /* this is the new single timeout to wait for */
+ }
+ else {
+   /* delete the timeout, nothing to wait for now */
+ }
 }
 
-curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
+int main(void)
+{
+  struct priv mydata;
+  CURLM *multi = curl_multi_init();
+  curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
+  curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.16.0
index dcb34296ffcfb234284dc68eaef552f94efed607..0e89be55fd488384811c92bb706fa11513b341d4 100644 (file)
@@ -52,10 +52,18 @@ Default is NULL.
 All
 .SH EXAMPLE
 .nf
-  curl_easy_setopt(curl_handle, CURLOPT_ABSTRACT_UNIX_SOCKET, "/tmp/foo.sock");
-  curl_easy_setopt(curl_handle, CURLOPT_URL, "http://localhost/");
-.fi
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_ABSTRACT_UNIX_SOCKET, "/tmp/foo.sock");
+    curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/");
 
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
+}
+.fi
 .SH AVAILABILITY
 Added in 7.53.0.
 .SH RETURN VALUE
index 92dcf8757b50b315d2fad5b4b636c9f31728afa2..b93142599fe7ba1d21d10e485de4c0e643b63690 100644 (file)
@@ -40,14 +40,17 @@ server to connect back to libcurl when an active FTP connection is used.
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/path/file");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/path/file");
 
-  /* wait no more than 5 seconds for FTP server responses */
-  curl_easy_setopt(curl, CURLOPT_ACCEPTTIMEOUT_MS, 5000L);
+    /* wait no more than 5 seconds for FTP server responses */
+    curl_easy_setopt(curl, CURLOPT_ACCEPTTIMEOUT_MS, 5000L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 821bf2f28d49e26c71ea300903de04369e630dd7..230b6b07f6138a5f4a2ad4f22f1696455a26676e 100644 (file)
@@ -82,15 +82,18 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* enable all supported built-in compressions */
-  curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
+    /* enable all supported built-in compressions */
+    curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e3d3e128ae781fc967aa9a1c2f7b3425f278bef7..eea7f88477a5668bb51df09ca53a3d117dc8123c 100644 (file)
@@ -39,15 +39,20 @@ Pass a long specifying the scope id value to use when connecting to IPv6 address
 All, when using IPv6
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  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);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+#include <net/if.h> /* for if_nametoindex() */
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    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);
+    ret = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 7338580f5250e9b1f7a46c785e41000f16d0894d..5af38437d937e4261313596b170884be855e867a 100644 (file)
@@ -44,11 +44,14 @@ NULL. The alt-svc cache is not read nor written to file.
 HTTPS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1);
-  curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1);
+    curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH "FILE FORMAT"
index c8318f8d03ed2dfde0e1a4403b0988bbbda3e1d0..5ba91c4408c722768b328befc51417d3a4d45d6d 100644 (file)
@@ -71,11 +71,14 @@ only set if libcurl was built with support for those versions.
 HTTPS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)CURLALTSVC_H1);
-  curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)CURLALTSVC_H1);
+    curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3ab46b47bde8c452d22aa7b19e5fc35f24fd0df4..0830c1a50a753e40b88e425f8d7e6af2f493ccd5 100644 (file)
@@ -40,14 +40,17 @@ instead of overwrite it. This is only useful when uploading to an FTP site.
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
 
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
-  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
-  curl_easy_setopt(curl, CURLOPT_APPEND, 1L);
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+    curl_easy_setopt(curl, CURLOPT_APPEND, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 478e221adbd21bdc399ba6b67eae16701b4a7982..5f94efc0090edb54d149a32ff8f9dbd2e4b5cdb0 100644 (file)
@@ -45,19 +45,23 @@ considered a minor privacy leak by some.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* follow redirects */
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    /* follow redirects */
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
 
-  /* set Referer: automatically when following redirects */
-  curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
+    /* set Referer: automatically when following redirects */
+    curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9dfc3e16626b8e3458f96959384d7afdd71b1d65..0cea12d02e87d727e2555b96d4acdf69da185ba6 100644 (file)
@@ -67,20 +67,23 @@ as calling this with \fB"aws:amz"\fP in parameter.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
+int main(void)
+{
+  CURL *curl = curl_easy_init();
 
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL,
-                  "https://service.region.example.com/uri");
-  curl_easy_setopt(c, CURLOPT_AWS_SIGV4, "provider1:provider2");
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL,
+                    "https://service.region.example.com/uri");
+    curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2");
 
-  /* service and region can also be set in CURLOPT_AWS_SIGV4 */
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/uri");
-  curl_easy_setopt(c, CURLOPT_AWS_SIGV4,
-                   "provider1:provider2:region:service");
+    /* service and region can also be set in CURLOPT_AWS_SIGV4 */
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/uri");
+    curl_easy_setopt(curl, CURLOPT_AWS_SIGV4,
+                     "provider1:provider2:region:service");
 
-  curl_easy_setopt(c, CURLOPT_USERPWD, "MY_ACCESS_KEY:MY_SECRET_KEY");
-  curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_USERPWD, "MY_ACCESS_KEY:MY_SECRET_KEY");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6a14076eee3de55f14ee25af6843cd0300055078..f90c7729506c52e4c368fdacce9d719ca65655fa 100644 (file)
@@ -54,16 +54,20 @@ CURL_MAX_WRITE_SIZE (16kB)
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");
 
-  /* ask libcurl to allocate a larger receive buffer */
-  curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 120000L);
+    /* ask libcurl to allocate a larger receive buffer */
+    curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 120000L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index dc94c0cdc5b8576de3000f1db56334fcb0cd3b1f..f4e151eff1800a0adb9f07e73555ab8ae8bfc1a5 100644 (file)
@@ -62,12 +62,15 @@ Schannel, this option is not set by default.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem");
+    curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index d3e26d3d05fa0ec8ce444082f2ce146e0300ae33..db3bed9411f6f4e8d3ac43c823fbc2425a55a47a 100644 (file)
@@ -51,17 +51,23 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-char *strpem; /* strpem must point to a PEM string */
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  blob.data = strpem;
-  blob.len = strlen(strpem);
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+#include <string.h>
+
+int main(void)
+{
+  char *strpem; /* strpem must point to a PEM string */
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    blob.data = strpem;
+    blob.len = strlen(strpem);
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5a453becad9e72e8cfb18936c73eb71343cc3092..8288ee334fa2064b8a148e70e6ef39c0f557e9e0 100644 (file)
@@ -51,12 +51,16 @@ A default path detected at build time.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/cert-dir");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/cert-dir");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index cbe0db4a3571181e6a9105aae5847de4b78b8200..8c2635120a11c4df4f4cdb0b4659f99e6ab2a62a 100644 (file)
@@ -49,20 +49,24 @@ store remain forever. By default, libcurl caches this info for 24 hours.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* only reuse certificate stores for a short time */
-  curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 60L);
+    /* only reuse certificate stores for a short time */
+    curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 60L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  /* in this second request, the cache is not used if more than
-     sixty seconds passed since the previous connection */
-  ret = curl_easy_perform(curl);
+    /* in this second request, the cache is not used if more than
+       sixty seconds passed since the previous connection */
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 146362960e7984242a8ac874ff5d0ab9ab6cda97..7b20134076477f3808174d52ed87f72e403de040 100644 (file)
@@ -43,34 +43,39 @@ its option \fICURLINFO_CERTINFO(3)\fP.
 All TLS-based
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
 
-  /* connect to any HTTPS site, trusted or not */
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
+    /* connect to any HTTPS site, trusted or not */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
 
-  curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
+    curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  if (!res) {
-    struct curl_certinfo *ci;
-    res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
+    if(!res) {
+      struct curl_certinfo *ci;
+      res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
 
-    if (!res) {
-      printf("%d certs!\\n", ci->num_of_certs);
+      if(!res) {
+        int i;
+        printf("%d certs!\\n", ci->num_of_certs);
 
-      for(i = 0; i < ci->num_of_certs; i++) {
-        struct curl_slist *slist;
+        for(i = 0; i < ci->num_of_certs; i++) {
+          struct curl_slist *slist;
 
-        for(slist = ci->certinfo[i]; slist; slist = slist->next)
-          printf("%s\\n", slist->data);
+          for(slist = ci->certinfo[i]; slist; slist = slist->next)
+            printf("%s\\n", slist->data);
+        }
       }
     }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index a8b2273572f265994b990d64e9c0919df86ea6fc..88f3768c9550e5f515dfcf0a9d627d8f643aa279 100644 (file)
@@ -90,10 +90,17 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
+#include <stdio.h>
+
+struct callback_data {
+   FILE *output;
+};
+
 static long file_is_coming(struct curl_fileinfo *finfo,
-                           struct callback_data *data,
+                           void *ptr,
                            int remains)
 {
+  struct callback_data *data = ptr;
   printf("%3d %40s %10luB ", remains, finfo->filename,
          (unsigned long)finfo->size);
 
@@ -130,6 +137,8 @@ int main()
   /* data for callback */
   struct callback_data callback_info;
 
+  CURL *curl = curl_easy_init();
+
   /* callback is called before download of concrete file started */
   curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
   curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
index 785c010cf200badb051c0daf08a5c855d8699392..a4e35244da8ad7499ac81cdd8b67baf9fe8908d1 100644 (file)
@@ -41,10 +41,17 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
+#include <stdio.h>
+
+struct callback_data {
+   FILE *output;
+};
+
 static long file_is_coming(struct curl_fileinfo *finfo,
-                           struct callback_data *data,
+                           void *ptr,
                            int remains)
 {
+  struct callback_data *data = ptr;
   printf("%3d %40s %10luB ", remains, finfo->filename,
          (unsigned long)finfo->size);
 
@@ -81,6 +88,8 @@ int main()
   /* data for callback */
   struct callback_data callback_info;
 
+  CURL *curl = curl_easy_init();
+
   /* callback is called before download of concrete file started */
   curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
   curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
index c5b752b67ac308fa6383ba4545cf1b968f794ce0..c6bf88e4539660d492130f33b5d28e5be9c5dc69 100644 (file)
@@ -48,6 +48,12 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
+#include <stdio.h>
+
+struct callback_data {
+   FILE *output;
+};
+
 static long file_is_downloaded(struct callback_data *data)
 {
   if(data->output) {
@@ -61,6 +67,9 @@ int main()
 {
   /* data for callback */
   struct callback_data callback_info;
+
+  CURL *curl = curl_easy_init();
+
   curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
   curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
 }
index 25601d4a6033329bf9b2fd4b6cf0fd7463a5fbed..d1f870575ba112df0df9ba7725ebf4497bb92dee 100644 (file)
@@ -42,15 +42,31 @@ The default value of this parameter is NULL.
 All except file:
 .SH EXAMPLE
 .nf
+struct priv {
+  void *custom;
+};
+
 static int closesocket(void *clientp, curl_socket_t item)
 {
+  struct priv *my = clientp;
+  printf("our ptr: %p\\n", my->custom);
+
   printf("libcurl wants to close %d now\\n", (int)item);
   return 0;
 }
 
-/* call this function to close sockets */
-curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket);
-curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &sockfd);
+int main(void)
+{
+  struct priv myown;
+  CURL *curl = curl_easy_init();
+
+  /* call this function to close sockets */
+  curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket);
+  curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown);
+
+  curl_easy_perform(curl);
+  curl_easy_cleanup(curl);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.21.7
index 27efd61afdd27e9a2f059ed434397019a1fc232c..fb81f696f91522fca93a35480fbb8c6103fdecdc 100644 (file)
@@ -53,15 +53,31 @@ By default libcurl uses the standard socket close function.
 All
 .SH EXAMPLE
 .nf
+struct priv {
+  void *custom;
+};
+
 static int closesocket(void *clientp, curl_socket_t item)
 {
+  struct priv *my = clientp;
+  printf("our ptr: %p\\n", my->custom);
+
   printf("libcurl wants to close %d now\\n", (int)item);
   return 0;
 }
 
-/* call this function to close sockets */
-curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket);
-curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &sockfd);
+int main(void)
+{
+  struct priv myown;
+  CURL *curl = curl_easy_init();
+
+  /* call this function to close sockets */
+  curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket);
+  curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown);
+
+  curl_easy_perform(curl);
+  curl_easy_cleanup(curl);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.21.7
index c9091cb52df9460f7a40765c2bf32f09f956b7fe..1d4a2ed548b4346ce8a7706b14ea901c3e8eb807 100644 (file)
@@ -66,14 +66,17 @@ signals to be used unless \fICURLOPT_NOSIGNAL(3)\fP is set.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* complete connection within 10 seconds */
-  curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
+    /* complete connection within 10 seconds */
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ec83ca35bc98bf7fdea426024fad95611ab52ac9..67c0097ef60c1b458620d805b5beea60453e77c7 100644 (file)
@@ -43,14 +43,17 @@ See \fICURLOPT_CONNECTTIMEOUT(3)\fP for details.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* complete connection within 10000 milliseconds */
-  curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L);
+    /* complete connection within 10000 milliseconds */
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ca71a669af1507b3dcc8de535be0bafc3c6a78f4..014c5f2cfa72172e37a659c4003c404b9eaf9ef5 100644 (file)
@@ -60,14 +60,17 @@ application wants to use it. Once it has been removed with
 HTTP, SMTP, POP3 and IMAP. For WS and WSS starting in 7.86.0.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
-  ret = curl_easy_perform(curl);
-  if(ret == CURLE_OK) {
-    /* only connected! */
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
+    ret = curl_easy_perform(curl);
+    if(ret == CURLE_OK) {
+      /* only connected! */
+    }
   }
 }
 .fi
index 1c4b80b64f5b6b35d0260d3785efa5c842c2bc15..e0a45031bb78ac2dffb23bd852a1e862e024df94 100644 (file)
@@ -88,22 +88,25 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl;
-struct curl_slist *connect_to = NULL;
-connect_to = curl_slist_append(NULL, "example.com::server1.example.com:");
+int main(void)
+{
+  CURL *curl;
+  struct curl_slist *connect_to = NULL;
+  connect_to = curl_slist_append(NULL, "example.com::server1.example.com:");
 
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+  curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
-}
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 
-curl_slist_free_all(connect_to);
+  curl_slist_free_all(connect_to);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.49.0
index 9d14df7cd81e82e53569f55fd5478ed917961b07..2baf5f46f72bf3f54a4880715cec6b628131b284 100644 (file)
@@ -77,12 +77,12 @@ FTP, SMTP, IMAP, POP3
 .nf
 static CURLcode my_conv_from_ascii_to_ebcdic(char *buffer, size_t length)
 {
-  char *tempptrin, *tempptrout;
-  size_t bytes = length;
-  int rc;
-  tempptrin = tempptrout = buffer;
-  rc = platform_a2e(&tempptrin, &bytes, &tempptrout, &bytes);
-  if(rc == PLATFORM_CONV_OK) {
+  int rc = 0;
+
+  /* in-place convert 'buffer' from ASCII to EBCDIC */
+
+  if(rc == 0) {
+    /* success */
     return CURLE_OK;
   }
   else {
@@ -90,9 +90,14 @@ static CURLcode my_conv_from_ascii_to_ebcdic(char *buffer, size_t length)
   }
 }
 
-/* use platform-specific functions for codeset conversions */
-curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION,
-                 my_conv_from_ascii_to_ebcdic);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+
+  /* use platform-specific functions for codeset conversions */
+  curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION,
+                   my_conv_from_ascii_to_ebcdic);
+}
 .fi
 .SH AVAILABILITY
 Not available and deprecated since 7.82.0.
index d4ae0c54d1a9473f0abf18988588e06a88b09cb1..e6ab8bf5b903eea57d4444c481e8d4cc31cae5b2 100644 (file)
@@ -76,12 +76,10 @@ TLS-based protocols.
 .nf
 static CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length)
 {
-  char *tempptrin, *tempptrout;
-  size_t bytes = length;
-  int rc;
-  tempptrin = tempptrout = buffer;
-  rc = platform_u2e(&tempptrin, &bytes, &tempptrout, &bytes);
-  if(rc == PLATFORM_CONV_OK) {
+  int rc = 0;
+  /* in-place convert 'buffer' from UTF-8 to EBCDIC */
+  if(rc == 0) {
+    /* success */
     return CURLE_OK;
   }
   else {
@@ -89,8 +87,12 @@ static CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length)
   }
 }
 
-curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION,
-                 my_conv_from_utf8_to_ebcdic);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION,
+                   my_conv_from_utf8_to_ebcdic);
+}
 .fi
 .SH AVAILABILITY
 Not available and deprecated since 7.82.0.
index a334078a47843b0c650f897aafe0b7ea21673c28..e2dc7d6064a89df1d7d00bd8f842c264926c786d 100644 (file)
@@ -77,12 +77,10 @@ FTP, SMTP, IMAP, POP3
 .nf
 static CURLcode my_conv_from_ebcdic_to_ascii(char *buffer, size_t length)
 {
-  char *tempptrin, *tempptrout;
-  size_t bytes = length;
-  int rc;
-  tempptrin = tempptrout = buffer;
-  rc = platform_e2a(&tempptrin, &bytes, &tempptrout, &bytes);
-  if(rc == PLATFORM_CONV_OK) {
+  int rc = 0;
+  /* in-place convert 'buffer' from EBCDIC to ASCII */
+  if(rc == 0) {
+    /* success */
     return CURLE_OK;
   }
   else {
@@ -90,8 +88,13 @@ static CURLcode my_conv_from_ebcdic_to_ascii(char *buffer, size_t length)
   }
 }
 
-curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION,
-                 my_conv_from_ebcdic_to_ascii);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+
+  curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION,
+                   my_conv_from_ebcdic_to_ascii);
+}
 .fi
 .SH AVAILABILITY
 Not available and deprecated since 7.82.0.
index b7de3ebe21633d9ad1d8da8518a8bc69ec725f91..e21d54c5f67af6b56be7ac6ec598140109a51ddb 100644 (file)
@@ -68,13 +68,16 @@ NULL, no cookies
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;");
+    curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 08e9582fc2f76274c7cbd7d9a89fe65ad5bfef4a..e1d5dbd9653bcb7da01a478297a785332315a67a 100644 (file)
@@ -72,16 +72,20 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* get cookies from an existing file */
-  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
+    /* get cookies from an existing file */
+    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH "Cookie file format"
index f84d99a1683166895044a734c0558f4bbce7e3f9..f8d75bea4354a82659e9b55f3d548894e042d265 100644 (file)
@@ -60,17 +60,21 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* export cookies to this file when closing the handle */
-  curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
+    /* export cookies to this file when closing the handle */
+    curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  /* close the handle, write the cookies! */
-  curl_easy_cleanup(curl);
+    /* close the handle, write the cookies! */
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index da9ca290a228340f9a394bbc8b80f8bc97f307f8..41862311a13808e87719891bf40420ae00e5651d 100644 (file)
@@ -74,35 +74,41 @@ HTTP
 
 #define SEP  "\\t"  /* Tab separates the fields */
 
-char *my_cookie =
-  "example.com"    /* Hostname */
-  SEP "FALSE"      /* Include subdomains */
-  SEP "/"          /* Path */
-  SEP "FALSE"      /* Secure */
-  SEP "0"          /* Expiry in epoch time format. 0 == Session */
-  SEP "foo"        /* Name */
-  SEP "bar";       /* Value */
-
-/* my_cookie is imported immediately via CURLOPT_COOKIELIST. */
-curl_easy_setopt(curl, CURLOPT_COOKIELIST, my_cookie);
-
-/* The list of cookies in cookies.txt are not be imported until right
-   before a transfer is performed. Cookies in the list that have the same
-   hostname, path and name as in my_cookie are skipped. That is because
-   libcurl has already imported my_cookie and it's considered a "live"
-   cookie. A live cookie is not replaced by one read from a file.
-*/
-curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt");  /* import */
-
-/* Cookies are exported after curl_easy_cleanup is called. The server
-   may have added, deleted or modified cookies by then. The cookies that
-   were skipped on import are not exported.
-*/
-curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt");  /* export */
-
-curl_easy_perform(curl);  /* cookies imported from cookies.txt */
-
-curl_easy_cleanup(curl);  /* cookies exported to cookies.txt */
+int main(void)
+{
+  char *my_cookie =
+    "example.com"    /* Hostname */
+    SEP "FALSE"      /* Include subdomains */
+    SEP "/"          /* Path */
+    SEP "FALSE"      /* Secure */
+    SEP "0"          /* Expiry in epoch time format. 0 == Session */
+    SEP "foo"        /* Name */
+    SEP "bar";       /* Value */
+
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* my_cookie is imported immediately via CURLOPT_COOKIELIST. */
+    curl_easy_setopt(curl, CURLOPT_COOKIELIST, my_cookie);
+
+    /* The list of cookies in cookies.txt are not be imported until right
+       before a transfer is performed. Cookies in the list that have the same
+       hostname, path and name as in my_cookie are skipped. That is because
+       libcurl has already imported my_cookie and it's considered a "live"
+       cookie. A live cookie is not replaced by one read from a file.
+    */
+    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt");  /* import */
+
+    /* Cookies are exported after curl_easy_cleanup is called. The server
+       may have added, deleted or modified cookies by then. The cookies that
+       were skipped on import are not exported.
+    */
+    curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt");  /* export */
+
+    curl_easy_perform(curl);  /* cookies imported from cookies.txt */
+
+    curl_easy_cleanup(curl);  /* cookies exported to cookies.txt */
+  }
+}
 .fi
 .SH "Cookie file format"
 The cookie file format and general cookie concepts in curl are described
index 3578b828785ea3f083f09bc07bebf46f7fd2e7d7..b8894d0fe8eedfa22f94d67ab29a5e1a2859d7a3 100644 (file)
@@ -48,19 +48,23 @@ the same session.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* new "session", do not load session cookies */
-  curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L);
+    /* new "session", do not load session cookies */
+    curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L);
 
-  /* get the (non session) cookies from this file */
-  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
+    /* get the (non session) cookies from this file */
+    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 870bb670befda9ebfb9feb731791d095bb4a7109..447c66833cab32d3143dd1565a9f730d6769bb5b 100644 (file)
@@ -51,18 +51,21 @@ NULL
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  char local_buffer[1024]="data to send";
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    char local_buffer[1024]="data to send";
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* size of the data to copy from the buffer and send in the request */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
+    /* size of the data to copy from the buffer and send in the request */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
 
-  /* send data from the local stack */
-  curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer);
+    /* send data from the local stack */
+    curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index abcdcefa40ed499705ca1ee11727f379e3622ea2..b758f2985d475c40dace3cc52ca4e10800812ceb 100644 (file)
@@ -43,13 +43,16 @@ This is a legacy option of questionable use.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_CRLF, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_CRLF, 1L);
+    ret = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index da6d639ead5857ec690f5d54318ab6c3c36ddd3b..30a6ad1ad847b32290d09f2601f40a8a97645fbf 100644 (file)
@@ -61,12 +61,16 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_CRLFILE, "/etc/certs/crl.pem");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_CRLFILE, "/etc/certs/crl.pem");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5b16f21152b979a948712d820148841cd2e4dead..34e9c53b433995d8200f10ec748ce9680bb9dfb8 100644 (file)
@@ -49,19 +49,22 @@ The default value of this parameter is NULL.
 All
 .SH EXAMPLE
 .nf
-CURL *handle = curl_easy_init();
-CURLU *urlp = curl_url();
-int res = 0;
-if(curl) {
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  CURLU *urlp = curl_url();
+  if(curl) {
+    CURLcode res;
+    CURLUcode ret;
+    ret = curl_url_set(urlp, CURLUPART_URL, "https://example.com", 0);
 
-  res = curl_url_set(urlp, CURLUPART_URL, "https://example.com", 0);
+    curl_easy_setopt(curl, CURLOPT_CURLU, urlp);
 
-  curl_easy_setopt(handle, CURLOPT_CURLU, urlp);
+    res = curl_easy_perform(curl);
 
-  ret = curl_easy_perform(handle);
-
-  curl_url_cleanup(urlp);
-  curl_easy_cleanup(handle);
+    curl_url_cleanup(urlp);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0f2d16bf5b395b9eeb91b1290e3458df9757acd9..6a1f0eeeb924d49d0451cae6541cd9014f728c76 100644 (file)
@@ -96,16 +96,20 @@ NULL
 HTTP, FTP, IMAP, POP3 and SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* DELETE the given path */
-  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
+    /* DELETE the given path */
+    curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b7db29309babc45dbf00c8a14e98b3f829d8e184..1b569e9831d3bb52c2e6b74249928c5b5077d097 100644 (file)
@@ -41,6 +41,20 @@ NULL
 All
 .SH EXAMPLE
 .nf
+struct data {
+  void *custom;
+};
+
+static int my_trace(CURL *handle, curl_infotype type,
+                    char *data, size_t size,
+                    void *clientp)
+{
+  struct data *mine = clientp;
+  printf("our ptr: %p\\n", mine->custom);
+
+  /* output debug info */
+}
+
 int main(void)
 {
   CURL *curl;
index c3a08f14f72436c4bcce547a5bbc0ce0efc08cbb..78c9e76a3370953b5171e85a11f419768f16e37f 100644 (file)
@@ -99,25 +99,25 @@ void dump(const char *text,
 {
   size_t i;
   size_t c;
-  unsigned int width=0x10;
+  unsigned int width = 0x10;
 
   fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\\n",
           text, (long)size, (long)size);
 
-  for(i=0; i<size; i+= width) {
+  for(i = 0; i < size; i += width) {
     fprintf(stream, "%4.4lx: ", (long)i);
 
     /* show hex to the left */
     for(c = 0; c < width; c++) {
-      if(i+c < size)
-        fprintf(stream, "%02x ", ptr[i+c]);
+      if(i + c < size)
+        fprintf(stream, "%02x ", ptr[i + c]);
       else
         fputs("   ", stream);
     }
 
     /* show data on the right */
-    for(c = 0; (c < width) && (i+c < size); c++) {
-      char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x80) ? ptr[i+c] : '.';
+    for(c = 0; (c < width) && (i + c < size); c++) {
+      char x = (ptr[i + c] >= 0x20 && ptr[i + c] < 0x80) ? ptr[i + c] : '.';
       fputc(x, stream);
     }
 
@@ -134,7 +134,7 @@ int my_trace(CURL *handle, curl_infotype type,
   (void)handle; /* prevent compiler warning */
   (void)clientp;
 
-  switch (type) {
+  switch(type) {
   case CURLINFO_TEXT:
     fputs("== Info: ", stderr);
     fwrite(data, size, 1, stderr);
index 60d79d1f0a5ff2ae764824ca5584614d43116fdd..ef7b24e9638ffec2c766af430cac0168eb77e179 100644 (file)
@@ -62,16 +62,19 @@ NULL (make a guess based on the host)
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  /* set a URL without a scheme */
-  curl_easy_setopt(curl, CURLOPT_URL, "example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* set a URL without a scheme */
+    curl_easy_setopt(curl, CURLOPT_URL, "example.com");
 
-  /* set the default protocol (scheme) for schemeless URLs */
-  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
+    /* set the default protocol (scheme) for schemeless URLs */
+    curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a301cf9a5a1b0b62e59f7a22bcb438b9c5a3e0e1..62dac240cefef5f7bad36c06ebd538c9ade42805 100644 (file)
@@ -56,16 +56,20 @@ effectively breaks that feature.
 FTP, SFTP and POP3
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/");
 
-  /* list only */
-  curl_easy_setopt(curl, CURLOPT_DIRLISTONLY, 1L);
+    /* list only */
+    curl_easy_setopt(curl, CURLOPT_DIRLISTONLY, 1L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e21cbe6b1bf2cf87017d37a69735e924d3bcf9f1..077fbd8db0dc33fba9764ba1582d6b8b926f5cb9 100644 (file)
@@ -44,13 +44,16 @@ This is the equivalent to the \fICURLU_DISALLOW_USER\fP flag for the
 Several
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_DISALLOW_USERNAME_IN_URL, 1L);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_DISALLOW_USERNAME_IN_URL, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e14eb74077ff6914854ad066f83ae065b73f22f4..2cdb3967ade0e7c413505f71f6e301d7aa5db7f8 100644 (file)
@@ -60,20 +60,24 @@ Since version 8.1.0, libcurl prunes entries from the DNS cache if it exceeds
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* only reuse addresses for a short time */
-  curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, 2L);
+    /* only reuse addresses for a short time */
+    curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, 2L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  /* in this second request, the cache is not be used if more than
-     two seconds have passed since the previous name resolve */
-  ret = curl_easy_perform(curl);
+    /* in this second request, the cache is not be used if more than
+       two seconds have passed since the previous name resolve */
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4f8d3106e692b58b122002b64a205aacc1d31be0..dfeabb3864425c81f6f761b9742df095ad625f52 100644 (file)
@@ -45,12 +45,16 @@ NULL
 All protocols except file:// - protocols that resolve host names.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_DNS_INTERFACE, "eth0");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_DNS_INTERFACE, "eth0");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 210e37fbf18ad5d577d300d9888a75a94c36a139..6f8ad2cf8b75cc4d899f30baf59d31d27fd7db09 100644 (file)
@@ -45,12 +45,16 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP4, "192.168.0.14");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP4, "192.168.0.14");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4f993998bc8cd0797baf6508fa6a66db0697adb3..78ffbf95bc3720ea9a87259e791e405fb417ecf9 100644 (file)
@@ -45,12 +45,16 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP6, "fe80::a9ff:fe46:b619");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP6, "fe80::a9ff:fe46:b619");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 53f7319a930f25473f06b7c15a6a0a6fc1293efd..c8e160a7d84b2b2c4a1a3c4ad37d28b30f53fa79 100644 (file)
@@ -49,12 +49,17 @@ NULL - use system default
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, "192.168.1.100:53,192.168.1.101");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_DNS_SERVERS,
+                     "192.168.1.100:53,192.168.1.101");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ebf0b9aab4b805053ea9eb438b0c25ccf8ebb99b..cc6934d1d34e28c128cb30ab44c51487523d423d 100644 (file)
@@ -54,15 +54,18 @@ performance impacts and may cause IPv4 to be used before IPv6 or vice versa.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3de886119a62488df803782c69155298861315d9..184147b49a3bd08b27e3b0d5febb94e6f5f72688 100644 (file)
@@ -47,15 +47,19 @@ share DNS cache between transfers.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* switch off the use of a global, thread unsafe, cache */
-  curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* switch off the use of a global, thread unsafe, cache */
+    curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L);
+    ret = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
+
 .fi
 .SH AVAILABILITY
 Deprecated since 7.11.1. Function removed in 7.62.0.
index fa49d38f2da0296640133ee07b8d9b3eff40c3a1..0bcd87b7164993819aaa4d07c997dac7a7e9f294 100644 (file)
@@ -62,16 +62,20 @@ of the DoH server certificate.
 DoH
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://cloudflare-dns.com/dns-query");
+    curl_easy_setopt(curl, CURLOPT_DOH_URL,
+                     "https://cloudflare-dns.com/dns-query");
 
-  /* Disable host name verification of the DoH server */
-  curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYHOST, 0L);
+    /* Disable host name verification of the DoH server */
+    curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYHOST, 0L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0e2f5172a863685bdf1e4c3145d5cfb42de8f92e..d894871d493967ef4cae39b88c3e434210b3226d 100644 (file)
@@ -73,16 +73,20 @@ the correct end-point.
 DoH
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://cloudflare-dns.com/dns-query");
+    curl_easy_setopt(curl, CURLOPT_DOH_URL,
+                     "https://cloudflare-dns.com/dns-query");
 
-  /* Disable certificate verification of the DoH server */
-  curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYPEER, 0L);
+    /* Disable certificate verification of the DoH server */
+    curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYPEER, 0L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index acf8bcb39226111d138f396af9253cae7e9ea775..cde868e3693d1fbc19b22d9acbf23adb5b265aab 100644 (file)
@@ -50,16 +50,20 @@ the verification fails.
 DoH
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://cloudflare-dns.com/dns-query");
+    curl_easy_setopt(curl, CURLOPT_DOH_URL,
+                     "https://cloudflare-dns.com/dns-query");
 
-  /* Ask for OCSP stapling when verifying the DoH server */
-  curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYSTATUS, 1L);
+    /* Ask for OCSP stapling when verifying the DoH server */
+    curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYSTATUS, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index cfe4a574d18d8dcc8f8b70072d05cff1e32152e9..35dbed04ab55dfad2bc3e4b20c5a061b7aad150f 100644 (file)
@@ -70,11 +70,14 @@ the default name resolver.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f36469b2b02b922b758f0483614450d0f26304e2..099acd8c598847b8f1ff5400e9495094a6792ae8 100644 (file)
@@ -45,12 +45,16 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_EGDSOCKET, "/var/egd.socket");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_EGDSOCKET, "/var/egd.socket");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 136a11c3f65e8c80751986c1fd3f7df2f5b98a81..76180cba898640fb973504c81a0bfa35f229cfc5 100644 (file)
@@ -55,34 +55,38 @@ NULL
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  CURLcode res;
-  char errbuf[CURL_ERROR_SIZE];
+#include <string.h> /* for strlen() */
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    char errbuf[CURL_ERROR_SIZE];
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* provide a buffer to store errors in */
-  curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
+    /* provide a buffer to store errors in */
+    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
 
-  /* set the error buffer as empty before performing a request */
-  errbuf[0] = 0;
+    /* set the error buffer as empty before performing a request */
+    errbuf[0] = 0;
 
-  /* perform the request */
-  res = curl_easy_perform(curl);
+    /* perform the request */
+    res = curl_easy_perform(curl);
 
-  /* if the request did not complete correctly, show the error
-  information. if no detailed error information was written to errbuf
-  show the more generic information from curl_easy_strerror instead.
-  */
-  if(res != CURLE_OK) {
-    size_t len = strlen(errbuf);
-    fprintf(stderr, "\\nlibcurl: (%d) ", res);
-    if(len)
-      fprintf(stderr, "%s%s", errbuf,
-              ((errbuf[len - 1] != '\\n') ? "\\n" : ""));
-    else
-      fprintf(stderr, "%s\\n", curl_easy_strerror(res));
+    /* if the request did not complete correctly, show the error
+    information. if no detailed error information was written to errbuf
+    show the more generic information from curl_easy_strerror instead.
+    */
+    if(res != CURLE_OK) {
+      size_t len = strlen(errbuf);
+      fprintf(stderr, "\\nlibcurl: (%d) ", res);
+      if(len)
+        fprintf(stderr, "%s%s", errbuf,
+                ((errbuf[len - 1] != '\\n') ? "\\n" : ""));
+      else
+        fprintf(stderr, "%s\\n", curl_easy_strerror(res));
+    }
   }
 }
 .fi
index 7aea1c2ed479ceb2e2e9f2cb1d55dba092c1d370..987092232984603d9d96d668a11d5510b375d4c1 100644 (file)
@@ -43,14 +43,17 @@ sent anyway.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* wait 3 seconds for 100-continue */
-  curl_easy_setopt(curl, CURLOPT_EXPECT_100_TIMEOUT_MS, 3000L);
+    /* wait 3 seconds for 100-continue */
+    curl_easy_setopt(curl, CURLOPT_EXPECT_100_TIMEOUT_MS, 3000L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c62250352354731b9f82a19a7e6bd8444f04b71a..539517125181e6498649e13c7708c791a022f93e 100644 (file)
@@ -52,14 +52,17 @@ get closed and \fICURLE_HTTP_RETURNED_ERROR\fP is returned.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
-  ret = curl_easy_perform(curl);
-  if(ret == CURLE_HTTP_RETURNED_ERROR) {
-    /* an HTTP response error problem */
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
+    ret = curl_easy_perform(curl);
+    if(ret == CURLE_HTTP_RETURNED_ERROR) {
+      /* an HTTP response error problem */
+    }
   }
 }
 .fi
index 05f484a2ff415818960f27112a951afe9ae10fec..39ce7a25b5e1d0fc39a5c35d6fc7479251e3c2db 100644 (file)
@@ -43,21 +43,26 @@ transfer to extract the received time (if any).
 HTTP(S), FTP(S), SFTP, FILE, SMB(S)
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  /* Ask for filetime */
-  curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
-  res = curl_easy_perform(curl);
-  if(CURLE_OK == res) {
-    res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
-    if((CURLE_OK == res) && (filetime >= 0)) {
-      time_t file_time = (time_t)filetime;
-      printf("filetime %s: %s", filename, ctime(&file_time));
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/path.html");
+    /* Ask for filetime */
+    curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
+    res = curl_easy_perform(curl);
+    if(CURLE_OK == res) {
+      long filetime;
+      res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
+      if((CURLE_OK == res) && (filetime >= 0)) {
+        time_t file_time = (time_t)filetime;
+        printf("filetime: %s", ctime(&file_time));
+      }
     }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index e8d9feaa568487c36aad6353311e18b77fc04fa2..89ca2d0397bb6f805bac02cdc38ef4628a8ab37f 100644 (file)
@@ -40,22 +40,36 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
+extern int string_match(const char *s1, const char *s2);
+
+struct local_stuff {
+  void *custom;
+};
+
 static int my_fnmatch(void *clientp,
                       const char *pattern, const char *string)
 {
-  struct local_stuff *data = (struct local_stuff *)clientp;
+  struct local_stuff *my = clientp;
+  printf("my ptr: %p\\n", my->custom);
+
   if(string_match(pattern, string))
     return CURL_FNMATCHFUNC_MATCH;
   else
     return CURL_FNMATCHFUNC_NOMATCH;
 }
 
+int main(void)
 {
   struct local_stuff local_data;
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
-  curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
-  curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
-  curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
+    curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
+    curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
+    curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 43466b3eca439186035d5c014e569decccfa83e9..7dc835766c4fb3cf4c0675c977fc3d68277a9a4a 100644 (file)
@@ -50,22 +50,33 @@ NULL == an internal function for wildcard matching.
 FTP
 .SH EXAMPLE
 .nf
+extern int string_match(const char *s1, const char *s2);
+
+struct local_stuff {
+  void *custom;
+};
 static int my_fnmatch(void *clientp,
                       const char *pattern, const char *string)
 {
-  struct local_stuff *data = (struct local_stuff *)clientp;
+  struct local_stuff *data = clientp;
+  printf("my pointer: %p\\n", data->custom);
   if(string_match(pattern, string))
     return CURL_FNMATCHFUNC_MATCH;
   else
     return CURL_FNMATCHFUNC_NOMATCH;
 }
 
+int main(void)
 {
   struct local_stuff local_data;
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
-  curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
-  curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
-  curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
+    curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
+    curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
+    curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f86e9655a36011f30250963ffed0d2aecfa80302..a78ea330597bfb6983755b0bf1b44571b7fe794d 100644 (file)
@@ -68,14 +68,17 @@ would otherwise select internally.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* example.com is redirected, so we tell libcurl to follow redirection */
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    /* example.com is redirected, so we tell libcurl to follow redirection */
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index aa2948295bcfe50ab7a5db20d410a618d661b518..52d800d67b341fd81e09586c420cf32345d143e1 100644 (file)
@@ -46,13 +46,19 @@ Set to 0 to have libcurl keep the connection open for possible later reuse
 Most
 .SH EXAMPLE
 .nf
+int main(void)
 {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L);
-  curl_easy_perform(curl);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L);
+    curl_easy_perform(curl);
 
-  /* this second transfer may not reuse the same connection */
-  curl_easy_perform(curl);
+    /* this second transfer may not reuse the same connection */
+    curl_easy_perform(curl);
+
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f9e53ab62a3cd578f96ca7d9792a85116bd2d930..00e4addf9a67c6cd2d253680e2b3fdebb2aa973c 100644 (file)
@@ -48,11 +48,16 @@ Set \fIfresh\fP to 0 to have libcurl attempt reusing an existing connection
 Most
 .SH EXAMPLE
 .nf
+int main(void)
 {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L);
-  /* this transfer must use a new connection, not reuse an existing */
-  curl_easy_perform(curl);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L);
+    /* this transfer must use a new connection, not reuse an existing */
+    curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9dff8852669e0a84f922f05510fc27f1d15912ae..ad7f2be539b88daa6ede2829267e847a8a213269 100644 (file)
@@ -78,12 +78,17 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/old-server/file.txt");
-  curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/old-server/file.txt");
+    curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 35a23384002a5f9fa74f3e2f74fdee43b9cfc4db..96b6e9d7f803eeeb64b69295a6e0969ff2adbcf5 100644 (file)
@@ -49,14 +49,18 @@ CURLFTPAUTH_DEFAULT
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
-  curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY);
-  /* funny server, ask for SSL before TLS */
-  curl_easy_setopt(curl, CURLOPT_FTPSSLAUTH, (long)CURLFTPAUTH_SSL);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
+    curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY);
+    /* funny server, ask for SSL before TLS */
+    curl_easy_setopt(curl, CURLOPT_FTPSSLAUTH, (long)CURLFTPAUTH_SSL);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 545689d6a1bd08184361c170d4a022ac54333ae2..0b0513c5c3c0e2855a9f857c5acb77d6a007afe5 100644 (file)
@@ -44,15 +44,19 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
 
-  curl_easy_setopt(curl, CURLOPT_FTP_ACCOUNT, "human-resources");
+    curl_easy_setopt(curl, CURLOPT_FTP_ACCOUNT, "human-resources");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a0c684afdd343d126ee840afcb1a33bd06321ab9..d89a13ac62583510245712c24c410e26a7b26399 100644 (file)
@@ -45,15 +45,17 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_FTP_ALTERNATIVE_TO_USER, "two users");
+    res = curl_easy_perform(curl);
 
-  curl_easy_setopt(curl, CURLOPT_FTP_ALTERNATIVE_TO_USER, "two users");
-
-  ret = curl_easy_perform(curl);
-
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 1693eecb2490c05fc72c519c5ffe908f12f7abec..4d4142967ffae9947eef633e6297e024f9799c54 100644 (file)
@@ -62,15 +62,20 @@ CURLFTP_CREATE_DIR_NONE (0)
 FTP and SFTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/non-existing/new.txt");
-  curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
-                   (long)CURLFTP_CREATE_DIR_RETRY);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/non-existing/new.txt");
+    curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
+                     (long)CURLFTP_CREATE_DIR_RETRY);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 14f0842f76140dd8a471c1bbec80670b14f09fe9..afd3a00dae07a48aadbc4358f9acbcef302ade08 100644 (file)
@@ -57,15 +57,19 @@ CURLFTPMETHOD_MULTICWD
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/1/2/3/4/new.txt");
-  curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD,
-                   (long)CURLFTPMETHOD_SINGLECWD);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/1/2/3/4/new.txt");
+    curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD,
+                     (long)CURLFTPMETHOD_SINGLECWD);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 829b39b123046dab956f7994e85c16a81391aa73..9b6453bdce084cc3875e5fb98ab5fef7f9a4b654 100644 (file)
@@ -50,15 +50,19 @@ This option has no effect if PORT, EPRT or EPSV is used instead of PASV.
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
 
-  /* please ignore the IP in the PASV response */
-  curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1L);
-  ret = curl_easy_perform(curl);
+    /* please ignore the IP in the PASV response */
+    curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1L);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c47b898423fe882bf7db5dd2eae38885c33a7327..a8d39881ca28f5ce31a5f7cd69ea6e0acc2f72e6 100644 (file)
@@ -50,14 +50,18 @@ CURLFTPSSL_CCC_NONE
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
-  curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_CONTROL);
-  /* go back to clear-text FTP after authenticating */
-  curl_easy_setopt(curl, CURLOPT_FTP_SSL_CCC, (long)CURLFTPSSL_CCC_ACTIVE);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
+    curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_CONTROL);
+    /* go back to clear-text FTP after authenticating */
+    curl_easy_setopt(curl, CURLOPT_FTP_SSL_CCC, (long)CURLFTPSSL_CCC_ACTIVE);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9753043dbc9cc9c4faace7375ee93aae72528f65..8731bd6c5bd6bdbd82a4d99ff3ee0feb40fbd5b3 100644 (file)
@@ -50,19 +50,23 @@ then.
 .SH PROTOCOLS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
 
-  /* contact us back, aka "active" FTP */
-  curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
+    /* contact us back, aka "active" FTP */
+    curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
 
-  /* FTP the way the neanderthals did it */
-  curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, 0L);
+    /* FTP the way the neanderthals did it */
+    curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, 0L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8c49874a2465022d7be2aee67ddc422957844774..af5d4ace9882dfe0acb13c1a0ccec02fa1301a75 100644 (file)
@@ -50,16 +50,21 @@ If the server is an IPv6 host, this option has no effect.
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/old-server/file.txt");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/old-server/file.txt");
 
-  /* let's shut off this modern feature */
-  curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L);
+    /* let's shut off this modern feature */
+    curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 63425075490d0c895a682565f9dee73ea8345e07..c4538bda8435f77e54ff6e3c28dd5572bb7bddad 100644 (file)
@@ -42,16 +42,21 @@ no effect when using the active FTP transfers mode.
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/old-server/file.txt");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/old-server/file.txt");
 
-  /* a drftpd server, do it! */
-  curl_easy_setopt(curl, CURLOPT_FTP_USE_PRET, 1L);
+    /* a drftpd server, do it! */
+    curl_easy_setopt(curl, CURLOPT_FTP_USE_PRET, 1L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 055e316c824379232a770b48e6fae5ed5504da4f..2a711b8fac9a8edead271c1df886c6349f1a9670 100644 (file)
@@ -45,14 +45,17 @@ CURLGSSAPI_DELEGATION_NONE
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* delegate if okayed by policy */
-  curl_easy_setopt(curl, CURLOPT_GSSAPI_DELEGATION,
-                   (long)CURLGSSAPI_DELEGATION_POLICY_FLAG);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* delegate if okayed by policy */
+    curl_easy_setopt(curl, CURLOPT_GSSAPI_DELEGATION,
+                     (long)CURLGSSAPI_DELEGATION_POLICY_FLAG);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 
index 2057fbe5c17bdb4d7f831484ec7542f8773b1086..5e3865f1259a529f1f865fef2a85a0d258400d28 100644 (file)
@@ -49,15 +49,18 @@ CURL_HET_DEFAULT (currently defined as 200L)
 All except FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 300L);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 300L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index dab0a1f09e97bd2ca5cba7ba16c3ee4518133b31..5c3b079d8ba00bbc7673f9eca4db85ff7f8da88e 100644 (file)
@@ -47,12 +47,15 @@ Most applications do not need this option.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_HAPROXYPROTOCOL, 1L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_HAPROXYPROTOCOL, 1L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 04d8621f5a0b3cc23c58de05b575923150946728..a2c9b2ff4aa4d1ed9734530864122171405e8fa1 100644 (file)
@@ -45,12 +45,15 @@ NULL, no HAProxy header is sent
 HTTP, HAProxy PROTOCOL
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_HAPROXY_CLIENT_IP, "1.1.1.1");
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_HAPROXY_CLIENT_IP, "1.1.1.1");
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 7decc88aaa7843181d2a53b74830bddb495f1146..193cdf1a5302e884513a7620972919e324ac5c0f 100644 (file)
@@ -57,13 +57,16 @@ custom HTTP headers!
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
+    curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e040a69983f01008ef65b2e9248dd741615c6f0a..20e696e4915b74f1ffd70f116528766a4c6ac8c1 100644 (file)
@@ -58,24 +58,27 @@ struct my_info {
 static size_t header_callback(char *buffer, size_t size,
                               size_t nitems, void *userdata)
 {
-  struct my_info *i = (struct my_info *)userdata;
-
+  struct my_info *i = userdata;
+  printf("shoe size: %d\\n", i->shoesize);
   /* now this callback can access the my_info struct */
 
   return nitems * size;
 }
 
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct my_info my = { 10, "the cookies are in the cupboard" };
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct my_info my = { 10, "the cookies are in the cupboard" };
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
+    curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
 
-  /* pass in custom data to the callback */
-  curl_easy_setopt(curl, CURLOPT_HEADERDATA, &my);
+    /* pass in custom data to the callback */
+    curl_easy_setopt(curl, CURLOPT_HEADERDATA, &my);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0b5ac28c16ee209a4beed02a1d96db98f1641b69..03051b193830e6d3c69c8494c16be2a8a9aa5ced 100644 (file)
@@ -110,13 +110,16 @@ static size_t header_callback(char *buffer, size_t size,
   return nitems * size;
 }
 
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
+    curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 085938f606946b8b56687b67b9babfcb9861d6c8..000f2035ff1bb867850b73722b8fc09d64812ff0 100644 (file)
@@ -52,23 +52,26 @@ CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before then)
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  struct curl_slist *list;
-  list = curl_slist_append(NULL, "Shoesize: 10");
-  list = curl_slist_append(list, "Accept:");
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
-  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    struct curl_slist *list;
+    list = curl_slist_append(NULL, "Shoesize: 10");
+    list = curl_slist_append(list, "Accept:");
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
+    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
 
-  /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
-     libcurl to not send the custom headers to the proxy. Keep them
-     separate! */
-  curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
-  ret = curl_easy_perform(curl);
-  curl_slist_free_all(list);
-  curl_easy_cleanup(curl);
+    /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell
+       libcurl to not send the custom headers to the proxy. Keep them
+       separate! */
+    curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
+    ret = curl_easy_perform(curl);
+    curl_slist_free_all(list);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6c3a39576c54f1339c50b0aa207e1c7f08647b68..30d3f37530086ad5d7d6b44490543164f80fe3ed 100644 (file)
@@ -64,10 +64,13 @@ NULL, no file name
 HTTPS and HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_HSTS, "/home/user/.hsts-cache");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_HSTS, "/home/user/.hsts-cache");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 26bead41da17bba580fede12a713b07819e471b0..3097fbda8cd5cc7b7ed5b1a7ef671bc14f9f1e49 100644 (file)
@@ -44,16 +44,23 @@ NULL
 This feature is only used for HTTP(S) transfer.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-struct MyData this;
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+struct MyData {
+  void *custom;
+};
 
-  /* pass pointer that gets passed in to the
-     CURLOPT_HSTSREADFUNCTION callback */
-  curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &this);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  struct MyData this;
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
 
-  curl_easy_perform(curl);
+    /* pass pointer that gets passed in to the
+       CURLOPT_HSTSREADFUNCTION callback */
+    curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &this);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3dc9244f7ba7bfdcd96553b9f7b226f247096dcf..9fcd0464504773cfdd342e6b3c65accee89436b7 100644 (file)
@@ -69,14 +69,32 @@ NULL - no callback.
 This feature is only used for HTTP(S) transfer.
 .SH EXAMPLE
 .nf
+struct priv {
+  void *custom;
+};
+
+static CURLSTScode hsts_cb(CURL *easy, struct curl_hstsentry *sts,
+                           void *clientp)
+{
+  /* populate the struct as documented */
+  return CURLSTS_OK;
+}
+
+int main(void)
 {
-  /* set HSTS read callback */
-  curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hstsread);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct priv my_stuff;
+    CURLcode res;
+
+    /* set HSTS read callback */
+    curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hsts_cb);
 
-  /* pass in suitable argument to the callback */
-  curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &hstspreload[0]);
+    /* pass in suitable argument to the callback */
+    curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &my_stuff);
 
-  result = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index aba5cb2cc1d9083f5402da4ee67835550a6edfdc..04b7d383ea5b44f794e3b78ccb1bea6f2816a990 100644 (file)
@@ -44,16 +44,23 @@ NULL
 This feature is only used for HTTP(S) transfer.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-struct MyData this;
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+struct MyData {
+  void *custom;
+};
 
-  /* pass pointer that gets passed in to the
-     CURLOPT_HSTSWRITEFUNCTION callback */
-  curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &this);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  struct MyData this;
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
 
-  curl_easy_perform(curl);
+    /* pass pointer that gets passed in to the
+       CURLOPT_HSTSWRITEFUNCTION callback */
+    curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &this);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f7b44faf7338d423430e43a1f7101ae9e22f14e1..e5b3a950bd5f91c795652856fd8204e7286ea76a 100644 (file)
@@ -73,14 +73,32 @@ NULL - no callback.
 This feature is only used for HTTP(S) transfer.
 .SH EXAMPLE
 .nf
+struct priv {
+  void *custom;
+};
+
+static CURLSTScode hswr_cb(CURL *easy, struct curl_hstsentry *sts,
+                           struct curl_index *count, void *clientp)
+{
+  /* save the passed in HSTS data somewhere */
+  return CURLSTS_OK;
+}
+
+int main(void)
 {
-  /* set HSTS read callback */
-  curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct priv my_stuff;
+    CURLcode res;
+
+    /* set HSTS read callback */
+    curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hswr_cb);
 
-  /* pass in suitable argument to the callback */
-  curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &hstspreload[0]);
+    /* pass in suitable argument to the callback */
+    curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &my_stuff);
 
-  result = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ebf336e5f7e33bdfe6d0e4f6258e3cc5914c04c7..2747ccdd7c52658304b0b96a7e3ba4ad24ca82fc 100644 (file)
@@ -55,10 +55,13 @@ to the file when closing the handle.
 HTTPS and HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index da1cc792824987af7c8e6d7b6085abdef524cb59..af8f26bae1a3315edfa4eb9f4ac5d509392e4f3f 100644 (file)
@@ -46,12 +46,15 @@ responses.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_HTTP09_ALLOWED, 1L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_HTTP09_ALLOWED, 1L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 86554fcf70ba5d08fddb977c89704ace827b66b0..05a0e3ac3a8d34b56f88b55b25a9702c4d6371ff 100644 (file)
@@ -51,17 +51,20 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_slist *list;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct curl_slist *list;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  list = curl_slist_append(NULL, "ICY 200 OK");
-  list = curl_slist_append(list, "WEIRDO 99 FINE");
+    list = curl_slist_append(NULL, "ICY 200 OK");
+    list = curl_slist_append(list, "WEIRDO 99 FINE");
 
-  curl_easy_setopt(curl, CURLOPT_HTTP200ALIASES, list);
-  curl_easy_perform(curl);
-  curl_slist_free_all(list); /* free the list again */
+    curl_easy_setopt(curl, CURLOPT_HTTP200ALIASES, list);
+    curl_easy_perform(curl);
+    curl_slist_free_all(list); /* free the list again */
+  }
 }
 .fi
 .SH AVAILABILITY
index f91c548f51ee343e76a752a105a4cf9a96cd83cb..661f52942a5fc713834a2244615b839f2d6ebb33 100644 (file)
@@ -108,14 +108,17 @@ CURLAUTH_BASIC
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* allow whatever auth the server speaks */
-  curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
-  curl_easy_setopt(curl, CURLOPT_USERPWD, "james:bond");
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* allow whatever auth the server speaks */
+    curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
+    curl_easy_setopt(curl, CURLOPT_USERPWD, "james:bond");
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 25c3bd73454e5b4f1637e751c88673d594a04d56..9a3af4d7ca9ce2a11d9d9325403223ff7d62f160 100644 (file)
@@ -48,15 +48,18 @@ reset a handle to default method, consider \fIcurl_easy_reset(3)\fP.
 HTTP(S)
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* use a GET to fetch this */
-  curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
+    /* use a GET to fetch this */
+    curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 04b5a5087c4132bc522f1b368e20bd6f5d57e750..a750b98105ed7b453f78d4d657a53a539e4f0c4c 100644 (file)
@@ -136,21 +136,24 @@ NULL
 HTTP, IMAP and SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
+int main(void)
+{
+  CURL *curl = curl_easy_init();
 
-struct curl_slist *list = NULL;
+  struct curl_slist *list = NULL;
 
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  list = curl_slist_append(list, "Shoesize: 10");
-  list = curl_slist_append(list, "Accept:");
+    list = curl_slist_append(list, "Shoesize: 10");
+    list = curl_slist_append(list, "Accept:");
 
-  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
+    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  curl_slist_free_all(list); /* free the list */
+    curl_slist_free_all(list); /* free the list */
+  }
 }
 .fi
 
index 0cdef31ab39d2a8362179a2a6c3381ea74a93eeb..f86db4ee7ec545a551758b7694bd82ee79dd5a00 100644 (file)
@@ -52,27 +52,41 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-/* Fill in the file upload field. This makes libcurl load data from
-   the given file name when curl_easy_perform() is called. */
-curl_formadd(&formpost,
-             &lastptr,
-             CURLFORM_COPYNAME, "sendfile",
-             CURLFORM_FILE, "postit2.c",
-             CURLFORM_END);
+int main(void)
+{
+  struct curl_httppost *formpost;
+  struct curl_httppost *lastptr;
 
-/* Fill in the filename field */
-curl_formadd(&formpost,
-             &lastptr,
-             CURLFORM_COPYNAME, "filename",
-             CURLFORM_COPYCONTENTS, "postit2.c",
-             CURLFORM_END);
+  /* Fill in the file upload field. This makes libcurl load data from
+     the given file name when curl_easy_perform() is called. */
+  curl_formadd(&formpost,
+               &lastptr,
+               CURLFORM_COPYNAME, "sendfile",
+               CURLFORM_FILE, "postit2.c",
+               CURLFORM_END);
 
-/* Fill in the submit field too, even if this is rarely needed */
-curl_formadd(&formpost,
-             &lastptr,
-             CURLFORM_COPYNAME, "submit",
-             CURLFORM_COPYCONTENTS, "send",
-             CURLFORM_END);
+  /* Fill in the filename field */
+  curl_formadd(&formpost,
+               &lastptr,
+               CURLFORM_COPYNAME, "filename",
+               CURLFORM_COPYCONTENTS, "postit2.c",
+               CURLFORM_END);
+
+  /* Fill in the submit field too, even if this is rarely needed */
+  curl_formadd(&formpost,
+               &lastptr,
+               CURLFORM_COPYNAME, "submit",
+               CURLFORM_COPYCONTENTS, "send",
+               CURLFORM_END);
+
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+    curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
+  curl_formfree(formpost);
+}
 .fi
 .SH AVAILABILITY
 As long as HTTP is enabled. Deprecated in 7.56.0.
index 63ad09adc6939924d0c0215bc99c4e6a4c5947e9..542eefe6c0c2d268c0b3a64214e7b7c63aaeea41 100644 (file)
@@ -56,12 +56,15 @@ rarely works through the proxy anyway).
 All network protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
-  curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
+    curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ab1fdd9fceca67b25e5621686b36300daa18ec07..7d6dabee3751e5c42ce742490193815eaa2491f0 100644 (file)
@@ -42,12 +42,15 @@ default content decoding but requires you to use
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 0L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 0L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2aa0185d8b5ed68176105f9a346f245eebb266e5..a00fb1a1ded555048c57a5a8e5900028f97d65c7 100644 (file)
@@ -41,12 +41,15 @@ does chunked transfer decoding by default unless this option is set to zero.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, 0L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, 0L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index bbccda304d1cd2abf14045b7dc97e45974effd6b..87b133b88a48cbcd2de8bd510c9bae2c54410b7f 100644 (file)
@@ -80,15 +80,18 @@ Before that: CURL_HTTP_VERSION_1_1
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
-                   (long)CURL_HTTP_VERSION_2TLS);
-  ret = curl_easy_perform(curl);
-  if(ret == CURLE_HTTP_RETURNED_ERROR) {
-    /* an HTTP response error problem */
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
+                     (long)CURL_HTTP_VERSION_2TLS);
+    ret = curl_easy_perform(curl);
+    if(ret == CURLE_HTTP_RETURNED_ERROR) {
+      /* an HTTP response error problem */
+    }
   }
 }
 .fi
index c6364b43b79be8c92fe02e1fb0c1fe92948cf3ba..2512b665fc4f6c439f4a39c46dac085593927d79 100644 (file)
@@ -51,14 +51,17 @@ Only use this option if strictly necessary.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* we know the server is silly, ignore content-length */
-  curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L);
+    /* we know the server is silly, ignore content-length */
+    curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9661c025699f14618c7edb0c6bb731970c1c25ee..a26e46302d90b7d663f9f251405f195e564f0a0d 100644 (file)
@@ -57,17 +57,24 @@ Unset
 Many
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  long uploadsize = FILE_SIZE;
 
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/destination.tar.gz");
+#define FILE_SIZE 12345L
 
-  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    long uploadsize = FILE_SIZE;
 
-  curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize);
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/destination.tar.gz");
 
-  curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index fedd9438b1e45e6e20706b34e3e4fc87233b2f6b..5cac9108936085aab876f08b9ef05f3c4fcc55b2 100644 (file)
@@ -53,17 +53,23 @@ Unset
 Many
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_off_t uploadsize = FILE_SIZE;
+#define FILE_SIZE 123456
 
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/destination.tar.gz");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_off_t uploadsize = FILE_SIZE;
 
-  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/destination.tar.gz");
 
-  curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize);
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 921a682a0f0d955d04c49de6e731963aa429e79f..676f8ba7c932ae5085cb0f8d5d2960ef401e6d9f 100644 (file)
@@ -60,15 +60,19 @@ NULL, use whatever the TCP stack finds suitable
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
+    curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b5a6caaafd83c8a41ae4adaab194b312e99dfa53..adc54f6948426d53eb53324a02da5229cdac7b22 100644 (file)
@@ -42,16 +42,27 @@ NULL
 RTSP
 .SH EXAMPLE
 .nf
-static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *user)
+struct local {
+  void *custom;
+};
+static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp)
 {
-  struct local *l = (struct local *)user;
+  struct local *l = userp;
+  printf("my pointer: %p\\n", l->custom);
   /* take care of the packet in 'ptr', then return... */
   return size * nmemb;
 }
+
+int main(void)
 {
   struct local rtp_data;
-  curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
-  curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
+    curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);
+
+    curl_easy_perform(curl);
+ }
 }
 .fi
 .SH AVAILABILITY
index a117c8821646b868c7e43e0272c465042ea8fb37..b2fa947dd1dbd120920ffa958e941d302c2735f4 100644 (file)
@@ -72,16 +72,26 @@ NULL, the interleave data is then passed to the regular write function:
 RTSP
 .SH EXAMPLE
 .nf
-static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *user)
+struct local {
+  void *custom;
+};
+
+static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp)
 {
-  struct local *l = (struct local *)user;
+  struct local *l = userp;
+  printf("our ptr: %p\\n", l->custom);
   /* take care of the packet in 'ptr', then return... */
   return size * nmemb;
 }
+
+int main(void)
 {
   struct local rtp_data;
-  curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
-  curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
+    curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);
+  }
 }
 .fi
 .SH AVAILABILITY
index 41de13c9b532b83c0740c0ac16e53b4a2571d66d..93742c75ee03c392f6f5ed73428fd2c09ba82096 100644 (file)
@@ -40,20 +40,29 @@ By default, the value of this parameter is NULL.
 Used with HTTP
 .SH EXAMPLE
 .nf
+#include <unistd.h> /* for lseek */
+
+struct data {
+  int fd; /* our file descriptor */
+};
+
 static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
 {
   struct data *io = (struct data *)clientp;
   if(cmd == CURLIOCMD_RESTARTREAD) {
-    lseek(fd, 0, SEEK_SET);
-    current_offset = 0;
+    lseek(io->fd, 0, SEEK_SET);
     return CURLIOE_OK;
   }
   return CURLIOE_UNKNOWNCMD;
 }
+int main(void)
 {
   struct data ioctl_data;
-  curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
-  curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
+    curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5eb2a17c617e32598c2156ed66097204f791f7b5..98105147257a1692e7277fa34a4454bebca0951a 100644 (file)
@@ -70,20 +70,29 @@ By default, this parameter is set to NULL. Not used.
 Used with HTTP
 .SH EXAMPLE
 .nf
+#include <unistd.h> /* for lseek */
+
+struct data {
+  int fd; /* our file descriptor */
+};
+
 static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
 {
   struct data *io = (struct data *)clientp;
   if(cmd == CURLIOCMD_RESTARTREAD) {
-    lseek(fd, 0, SEEK_SET);
-    current_offset = 0;
+    lseek(io->fd, 0, SEEK_SET);
     return CURLIOE_OK;
   }
   return CURLIOE_UNKNOWNCMD;
 }
+int main(void)
 {
   struct data ioctl_data;
-  curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
-  curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
+    curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
+  }
 }
 .fi
 .SH AVAILABILITY
index c5970686f88c20d030df993b2cf8ebbd9e88aa85..499aed5138bcba526b269f1af3089280750ffc83 100644 (file)
@@ -53,19 +53,22 @@ CURL_IPRESOLVE_WHATEVER
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  /* of all addresses example.com resolves to, only IPv6 ones are used */
-  curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
+    /* of all addresses example.com resolves to, only IPv6 ones are used */
+    curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
-
 .SH AVAILABILITY
 Always
 .SH RETURN VALUE
index 9ac3d2eef2d02c8853c63f4b9a5724eaa6e5ffb6..a0c2f5f796535aa9d22286d56994c459ed4e4d28 100644 (file)
@@ -56,12 +56,16 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_ISSUERCERT, "/etc/certs/cacert.pem");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_ISSUERCERT, "/etc/certs/cacert.pem");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f9b56057ce97e2b49f55098cbd7c025fa22b7fbb..858987e9b2b9ca30a061419052f804b929653700 100644 (file)
@@ -62,16 +62,24 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  blob.data = certificateData;
-  blob.len = filesize;
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_ISSUERCERT_BLOB, &blob);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+
+extern char *certificateData;
+extern size_t filesize;
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    blob.data = certificateData;
+    blob.len = filesize;
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_ISSUERCERT_BLOB, &blob);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b25af467917c369f1258e838926ed9854af6c374..4664360953c5bd2f9d206758546254b9a7eb9f13 100644 (file)
@@ -48,13 +48,16 @@ Most applications do not need this option.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "sending data");
-  curl_easy_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "sending data");
+    curl_easy_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4d69a3c88f0e1a531b7b3813e46813607475b833..119f26cd1636cb1587b533f2cee3bcdb4ba0d89e 100644 (file)
@@ -45,14 +45,18 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "superman");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "superman");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9a1f4ae92645952fda6be73ff358659ee2640877..7be711e1d00ba91a7ad3580d3f2023970ea65667 100644 (file)
@@ -46,12 +46,16 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_KRBLEVEL, "private");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_KRBLEVEL, "private");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 267a1c87a9313dd2636a11181d38fa3f34d50e4d..e5bddf1c13a438184d57d5c6a4b3c9db9e1f7764 100644 (file)
@@ -42,14 +42,18 @@ this option is set. Valid port numbers are 1 - 65535.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
-  /* and try 20 more ports following that */
-  curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
+    /* and try 20 more ports following that */
+    curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 1e54f43edc061e2e10b38811ef8cdc28f4746a8f..71934e323582ecf5cd26b052aa0edf22aa89405a 100644 (file)
@@ -46,14 +46,18 @@ setup failures.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
-  /* and try 20 more ports following that */
-  curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
+    /* and try 20 more ports following that */
+    curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index aacf18695e8ad0da0bdd8eb56cfe0e3c44dd605e..5410bbdce99eb73c1c68c5ce34353dfedadcbb8f 100644 (file)
@@ -57,12 +57,16 @@ NULL
 Only IMAP, LDAP, POP3 and SMTP support login options.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=*");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=*");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a28ec6bc371c41ccf45c9ccaa47d295ed380a74b..d491e655b718c3494ae93fca6b3f6e1de4a3ac6f 100644 (file)
@@ -43,18 +43,22 @@ slow and abort.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  /* abort if slower than 30 bytes/sec during 60 seconds */
-  curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
-  curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
-  res = curl_easy_perform(curl);
-  if(CURLE_OPERATION_TIMEDOUT == res) {
-    printf("Timeout!\\n");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    /* abort if slower than 30 bytes/sec during 60 seconds */
+    curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
+    curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
+    res = curl_easy_perform(curl);
+    if(CURLE_OPERATION_TIMEDOUT == res) {
+      printf("Timeout!\\n");
+    }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 013cc916dd919ea34b32be5aadceac12f7c56311..507ac4528626d67102447b3ab904bc4d77ccf9d3 100644 (file)
@@ -42,18 +42,22 @@ library to consider it too slow and abort.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, url);
-  /* abort if slower than 30 bytes/sec during 60 seconds */
-  curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
-  curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
-  res = curl_easy_perform(curl);
-  if(CURLE_OPERATION_TIMEDOUT == res) {
-    printf("Timeout!\\n");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    /* abort if slower than 30 bytes/sec during 60 seconds */
+    curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
+    curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
+    res = curl_easy_perform(curl);
+    if(CURLE_OPERATION_TIMEDOUT == res) {
+      printf("Timeout!\\n");
+    }
+    /* always cleanup */
+    curl_easy_cleanup(curl);
   }
-  /* always cleanup */
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 403c1b6b7cb59e37654243f9bc15f6fbe90c98de..340d801d84827125914b23ca957294335a2cac3d 100644 (file)
@@ -56,12 +56,16 @@ NULL
 SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, "<secret@cave>");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, "<secret@cave>");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b0b130ea8b999f48cde4c02f18603cd41075e01b..b76455c61ed24a18aba5fe5539c92f97832c8512 100644 (file)
@@ -49,12 +49,16 @@ blank
 SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "president@example.com");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "president@example.com");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 60a68dc041b2503ed8ccabb538ed5a17fa42a3b3..5a47e3d9a6b8e53f0b879772d4cdfad8a70ea292 100644 (file)
@@ -56,16 +56,20 @@ NULL
 SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_slist *list;
-  list = curl_slist_append(NULL, "root@localhost");
-  list = curl_slist_append(list, "person@example.com");
-  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list);
-  ret = curl_easy_perform(curl);
-  curl_slist_free_all(list);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_slist *list;
+    list = curl_slist_append(NULL, "root@localhost");
+    list = curl_slist_append(list, "person@example.com");
+    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list);
+    res = curl_easy_perform(curl);
+    curl_slist_free_all(list);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8d8c9c7bbeb12b18cfa915f7c5a10eb173e967e4..bef15148541c1791e17f6ca277ce65d95570bff5 100644 (file)
@@ -51,20 +51,24 @@ RCPT TO command.
 SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_slist *list;
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct curl_slist *list;
+    CURLcode res;
 
-  /* Adding one valid and one invalid email address */
-  list = curl_slist_append(NULL, "person@example.com");
-  list = curl_slist_append(list, "invalidemailaddress");
+    /* Adding one valid and one invalid email address */
+    list = curl_slist_append(NULL, "person@example.com");
+    list = curl_slist_append(list, "invalidemailaddress");
 
-  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_MAIL_RCPT_ALLOWFAILS, 1L);
+    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_MAIL_RCPT_ALLOWFAILS, 1L);
 
-  ret = curl_easy_perform(curl);
-  curl_slist_free_all(list);
-  curl_easy_cleanup(curl);
+    res = curl_easy_perform(curl);
+    curl_slist_free_all(list);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index acfab2d78a77f007e450fbdfb4f5a9ee9ebd9ba7..652792857a546574d6c69b894c3ae92bfe8c7750 100644 (file)
@@ -49,14 +49,17 @@ Default maximum age is set to 118 seconds.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* only allow 30 seconds idle time */
-  curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L);
+    /* only allow 30 seconds idle time */
+    curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index eb09ff8fbcd9634cf5bb0cb6b5343eb5db9ea393..bb1c40398bafa33194f6b9b7de0da0bc03482a4d 100644 (file)
@@ -54,13 +54,16 @@ acknowledged, and you must instead use \fIcurl_multi_setopt(3)\fP and the
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* limit the connection cache for this handle to no more than 3 */
-  curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* limit the connection cache for this handle to no more than 3 */
+    curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 88f4d61a713497deb80c2a2f6c7e96dd5b6ccdf8..ed970b29ea65941e3f3acca788b35c3a5234e787 100644 (file)
@@ -50,13 +50,16 @@ None
 FTP, HTTP and MQTT
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* refuse to download if larger than 1000 bytes! */
-  curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* refuse to download if larger than 1000 bytes! */
+    curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 79dadafc5665fab9c381de6c67e91a169bd87c1f..209701c4ed9e8eb5074df5a3603ffc599d5e935a 100644 (file)
@@ -49,14 +49,17 @@ None
 FTP, HTTP and MQTT
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_off_t ridiculous = 1 << 48;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* refuse to download if larger than ridiculous */
-  curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, ridiculous);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_off_t ridiculous = (curl_off_t)1 << 48;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* refuse to download if larger than ridiculous */
+    curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, ridiculous);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8cbf5e9221a6b799c267e8ba22258d1f5f30870f..c3ec8aab9ea0649ef7d94120e40edaafc2e4fb15 100644 (file)
@@ -51,14 +51,17 @@ Default \fImaxlifetime\fP is 0 seconds (i.e., disabled).
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* only allow each connection to be reused for 30 seconds */
-  curl_easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 30L);
+    /* only allow each connection to be reused for 30 seconds */
+    curl_easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 30L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 38a4e3fed090677c4a3d9a7776bcba2ce3027843..763425a07f62cfa11cbc2e142595724d5cbb0f05 100644 (file)
@@ -47,18 +47,21 @@ to get stuck in never-ending redirect loops.
 HTTP(S)
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
 
-  /* enable redirect following */
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    /* enable redirect following */
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
 
-  /* allow three redirects */
-  curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L);
+    /* allow three redirects */
+    curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0fdad4ba3de7b984f80b48fa6d20adc695f9a3ab..9f0a5ac92d767700d2dc8d165d1e692cb8c76abe 100644 (file)
@@ -49,13 +49,16 @@ This option does not affect transfer speeds done with FILE:// URLs.
 All but file://
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* cap the download speed to 31415 bytes/sec */
-  curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)31415);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* cap the download speed to 31415 bytes/sec */
+    curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)31415);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 57ef15059d041646189bb7be08b4f323aaf4149b..364baed310b0a8648f1ef9792798cfafc00ce677 100644 (file)
@@ -51,14 +51,17 @@ This option does not affect transfer speeds done with FILE:// URLs.
 All except file://
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* cap the upload speed to 1000 bytes/sec */
-  curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)1000);
-  /* (set some upload options as well!) */
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* cap the upload speed to 1000 bytes/sec */
+    curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)1000);
+    /* (set some upload options as well!) */
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a5fb508a9784f236e540a01e33fce7c246135d56..02a5a0a7f2b1a7854a18b9faffa17bff22ba902c 100644 (file)
@@ -48,23 +48,30 @@ is reset to GET. Instead you should set a desired request method explicitly.
 HTTP, SMTP, IMAP.
 .SH EXAMPLE
 .nf
- curl_mime *multipart = curl_mime_init(handle);
- curl_mimepart *part = curl_mime_addpart(multipart);
- curl_mime_name(part, "name");
- curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
- part = curl_mime_addpart(multipart);
- curl_mime_name(part, "project");
- curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
- part = curl_mime_addpart(multipart);
- curl_mime_name(part, "logotype-image");
- curl_mime_filedata(part, "curl.png");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_mime *multipart = curl_mime_init(curl);
+    if(multipart) {
+      curl_mimepart *part = curl_mime_addpart(multipart);
+      curl_mime_name(part, "name");
+      curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
+      part = curl_mime_addpart(multipart);
+      curl_mime_name(part, "project");
+      curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
+      part = curl_mime_addpart(multipart);
+      curl_mime_name(part, "logotype-image");
+      curl_mime_filedata(part, "curl.png");
 
- /* Set the form info */
curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart);
     /* Set the form info */
     curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart);
 
- curl_easy_perform(handle); /* post away! */
-
- curl_mime_free(multipart); /* free the post data */
+      curl_easy_perform(curl); /* post away! */
+      curl_mime_free(multipart); /* free the post data */
+    }
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.56.0
index bcef3c5c87f15f026b80e30143e261e8fae060f3..3f72823513cb060dabbc5b48805af6f653c15330 100644 (file)
@@ -60,29 +60,32 @@ When the containing multipart form is sent, this is normally transmitted as
 HTTP, IMAP, SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-curl_mime *form = NULL;
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  curl_mime *form = NULL;
 
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
 
-  form = curl_mime_init(curl);
-  if(form) {
-    curl_mimepart *part = curl_mime_addpart(form);
+    form = curl_mime_init(curl);
+    if(form) {
+      curl_mimepart *part = curl_mime_addpart(form);
 
-    if(part) {
-      curl_mime_filedata(part, "strange\\\\file\\\\name");
-      curl_mime_name(part, "strange\\"field\\"name");
-      curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
+      if(part) {
+        curl_mime_filedata(part, "strange\\\\file\\\\name");
+        curl_mime_name(part, "strange\\"field\\"name");
+        curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
 
-      /* Perform the request */
-      curl_easy_perform(curl);
+        /* Perform the request */
+        curl_easy_perform(curl);
+      }
     }
-  }
 
-  curl_easy_cleanup(curl);
-  curl_mime_free(mime);
+    curl_easy_cleanup(curl);
+    curl_mime_free(form);
+  }
 }
 .fi
 .SH AVAILABILITY
index b9809de8bec3db803de33ec38fc0620c1cf84a6e..3f04fccf704f87f8ba5890231008a831fc4ad5ff 100644 (file)
@@ -105,12 +105,15 @@ CURL_NETRC_IGNORED
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e960813d896cab292acfc09767d0a2bde2c50e77..ff0bb5050647a0af74a726a03ffe91b66e6aa498 100644 (file)
@@ -45,13 +45,16 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
-  curl_easy_setopt(curl, CURLOPT_NETRC_FILE, "/tmp/magic-netrc");
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
+    curl_easy_setopt(curl, CURLOPT_NETRC_FILE, "/tmp/magic-netrc");
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ac2141fc7a6c44cb64a259592db5bd7445859775..97282225a1d31a3039d75a4f8343d193f0984b27 100644 (file)
@@ -42,13 +42,17 @@ this are \fIsftp://\fP, \fIscp://\fP, and \fIfile://\fP.
 SFTP, SCP and FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/newdir/file.zip");
-  curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
-  curl_easy_setopt(curl, CURLOPT_NEW_DIRECTORY_PERMS, 0644L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "sftp://upload.example.com/newdir/file.zip");
+    curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
+    curl_easy_setopt(curl, CURLOPT_NEW_DIRECTORY_PERMS, 0644L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 07de59dca6c419ae0d57f76d48f1d4148443621b..b81041d160d154350ecc2bee95d6b0c282fcb5a6 100644 (file)
@@ -42,12 +42,15 @@ this are \fIsftp://\fP, \fIscp://\fP, and \fIfile://\fP.
 SFTP, SCP and FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/file.txt");
-  curl_easy_setopt(curl, CURLOPT_NEW_FILE_PERMS, 0664L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/file.txt");
+    curl_easy_setopt(curl, CURLOPT_NEW_FILE_PERMS, 0664L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 971b9c7e127efa04ca83047458bc84bdb318ab4a..a21a825a3e8aeb1de6d27fdf1b6bee2de65c5bd4 100644 (file)
@@ -54,15 +54,18 @@ URL you request).
 Most
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* get us the resource without a body - use HEAD! */
-  curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
+    /* get us the resource without a body - use HEAD! */
+    curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 91b20c2b91ad779b8e48ded8547dd11053982dd0..fd4e07f3276fb39da0564daca31c245962d3bf67 100644 (file)
@@ -42,15 +42,18 @@ getting called.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* enable progress meter */
-  curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
+    /* enable progress meter */
+    curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index dd76e78abad11c7cf01362ebdce2dbc3886f14cb..1a5b075700e941f0bff2212b2f2cddfc63098996 100644 (file)
@@ -66,15 +66,18 @@ NULL
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  /* accept various URLs */
-  curl_easy_setopt(curl, CURLOPT_URL, input);
-  /* use this proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
-  /* ... but make sure this host name is not proxied */
-  curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* accept various URLs */
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* use this proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
+    /* ... but make sure this host name is not proxied */
+    curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2ab15c2b6e1ffcc8d0529c19cc134c7449ccb809..290f44e42dfdb19fe253a4ef19fd3341bf13f68a 100644 (file)
@@ -57,15 +57,19 @@ raised.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
 
-  curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
+    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8169411361193d247016bcfff111761bf5de7caa..e4c227a89770a39f9739fa52045d524234f22450 100644 (file)
@@ -61,21 +61,27 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
   return CURL_SOCKOPT_ALREADY_CONNECTED;
 }
 
-curl = curl_easy_init();
-if(curl) {
-  /* libcurl thinks that you connect to the host
-   * and port that you specify in the URL option. */
-  curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
-  /* call this function to get a socket */
-  curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
-  curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    extern int sockfd; /* the already connected one */
+
+    /* libcurl thinks that you connect to the host
+     * and port that you specify in the URL option. */
+    curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
+    /* call this function to get a socket */
+    curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
+    curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
 
-  /* call this function to set options for the socket */
-  curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
+    /* call this function to set options for the socket */
+    curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 86c12240441ffefe734bcfe8bb0060cf8aac6a57..f2f8628b461d668cfcc0eda5c7949ee4378e4fb9 100644 (file)
@@ -101,21 +101,26 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
   return CURL_SOCKOPT_ALREADY_CONNECTED;
 }
 
-curl = curl_easy_init();
-if(curl) {
-  /* libcurl thinks that you connect to the host
-   * and port that you specify in the URL option. */
-  curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
-  /* call this function to get a socket */
-  curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
-  curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    extern int sockfd; /* the already connected one */
+    /* libcurl thinks that you connect to the host
+     * and port that you specify in the URL option. */
+    curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
+    /* call this function to get a socket */
+    curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
+    curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
 
-  /* call this function to set options for the socket */
-  curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
+    /* call this function to set options for the socket */
+    curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3816f78a7adb02bc83952481408abd4151723ba9..73d8627c0b2ca9519a028f9112b5cba3b5f84df1 100644 (file)
@@ -46,15 +46,19 @@ blank
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  curl_easy_setopt(curl, CURLOPT_PASSWORD, "qwerty");
+    curl_easy_setopt(curl, CURLOPT_PASSWORD, "qwerty");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8ffa1d855892e230c77ac15ed0f9239ac14164cb..5bfa0ccdc2a18b7904b755b23a48b2c8105c4078 100644 (file)
@@ -53,13 +53,17 @@ The corresponding flag for the \fIcurl_url_set(3)\fP function is called
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/../../etc/password");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "https://example.com/../../etc/password");
 
-  curl_easy_setopt(curl, CURLOPT_PATH_AS_IS, 1L);
+    curl_easy_setopt(curl, CURLOPT_PATH_AS_IS, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index aa082af704a700bf302ed8e9ed1c5fcd0e2f1f54..9a72fa85f41603a11618f794fcb3c6859664f3e3 100644 (file)
@@ -56,16 +56,22 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "/etc/publickey.der");
-  /* OR
-  curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno=");
-  */
-
-  /* Perform the request */
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "/etc/publickey.der");
+    /* OR
+    curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY,
+                     "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3"
+                     "tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEg"
+                     "oChTociMee9wno=");
+    */
+
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH PUBLIC KEY EXTRACTION
index 593149edd25e8efb1a7a4c410ef65f88e6e709d9..645f788f98c84bfd9d0768f10885ec49aa9ceeeb 100644 (file)
@@ -58,12 +58,15 @@ and support level.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1L);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1L);
 
-  /* now add this easy handle to the multi handle */
+    /* now add this easy handle to the multi handle */
+  }
 }
 .fi
 .SH AVAILABILITY
index f29d33ce8efebc60447d8ba3e4b314ea58216aa9..4b6667ba89047052a0a1f33f3f7bfa05670761bc 100644 (file)
@@ -52,12 +52,16 @@ impossible to set with this API.
 Used for all protocols that speak to a port number.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_PORT, 8080L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_PORT, 8080L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6f8100febeb87a4ed607997e46bdb222bef2f08d..182b59cb83d8ac3706120bd5c24d67a367f5158c 100644 (file)
@@ -78,16 +78,20 @@ Instead you should set a new request type explicitly as described above.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_POST, 1L);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_POST, 1L);
 
-  /* set up the read callback with CURLOPT_READFUNCTION */
+    /* set up the read callback with CURLOPT_READFUNCTION */
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 28632a3861793b303250a8b7bea20034ae788ec7..c42cd65fbf099d48e31cf1631c97fa0b5ba9bbe2 100644 (file)
@@ -77,40 +77,42 @@ HTTP
 .SH EXAMPLE
 .nf
 /* send an application/x-www-form-urlencoded POST */
-CURL *curl = curl_easy_init();
-if(curl) {
-  const char *data = "data to send";
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    const char *data = "data to send";
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* size of the POST data if strlen() is not good enough */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
+    /* size of the POST data if strlen() is not good enough */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
 
-  /* pass in a pointer to the data - libcurl does not copy */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+    /* pass in a pointer to the data - libcurl does not copy */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
 
-  curl_easy_perform(curl);
-}
+    curl_easy_perform(curl);
+  }
 
-/* send an application/json POST */
-CURL *curl = curl_easy_init();
-if(curl) {
-  const char *json = "{\"name\": \"daniel\"}";
-  struct curl_slist *slist1 = NULL;
-  slist1 = curl_slist_append(slist1, "Content-Type: application/json");
-  slist1 = curl_slist_append(slist1, "Accept: application/json");
+  /* send an application/json POST */
+  curl = curl_easy_init();
+  if(curl) {
+    const char *json = "{\"name\": \"daniel\"}";
+    struct curl_slist *slist1 = NULL;
+    slist1 = curl_slist_append(slist1, "Content-Type: application/json");
+    slist1 = curl_slist_append(slist1, "Accept: application/json");
 
-  /* set custom headers */
-  curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
+    /* set custom headers */
+    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1);
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* pass in a pointer to the data - libcurl does not copy */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
+    /* pass in a pointer to the data - libcurl does not copy */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
-
 .fi
 .SH AVAILABILITY
 Always
index e519dd7ac434d1ba711670e4c11f769b3952eb70..75ec0529152e5f0fe245f5315a778b1455afa1eb 100644 (file)
@@ -45,18 +45,23 @@ If you post more than 2GB, use \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  const char *data = "data to send";
+#include <string.h> /* for strlen */
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    const char *data = "data to send";
 
-  /* size of the POST data */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data));
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+    /* size of the POST data */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data));
 
-  curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 22dabf31a87dc20df49db7b035406de150380598..c09feea9a32c3c6e552ab548e596714de0ffd3e6 100644 (file)
@@ -43,19 +43,24 @@ this size is set to -1, libcurl uses strlen() to get the size or relies on the
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  const char *data = large_chunk;
-  curl_off_t length_of_data; /* set somehow */
+extern char *large_chunk; /* pointer to somewhere */
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    const char *data = large_chunk;
+    curl_off_t length_of_data; /* set somehow */
 
-  /* size of the POST data */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length_of_data);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+    /* size of the POST data */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length_of_data);
 
-  curl_easy_perform(curl);
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5568956696cccaa36d7721cee025d12778b4d41a..33c46c7a51efb7184b4c499c4b52dd7d995ccec6 100644 (file)
@@ -45,20 +45,24 @@ NULL
 SFTP and FTP
 .SH EXAMPLE
 .nf
-struct curl_slist *cmdlist = NULL;
-cmdlist = curl_slist_append(cmdlist, "RNFR source-name");
-cmdlist = curl_slist_append(cmdlist, "RNTO new-name");
+int main(void)
+{
+  struct curl_slist *cmdlist = NULL;
+  cmdlist = curl_slist_append(cmdlist, "RNFR source-name");
+  cmdlist = curl_slist_append(cmdlist, "RNTO new-name");
 
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
 
-  /* pass in the FTP commands to run after the transfer */
-  curl_easy_setopt(curl, CURLOPT_POSTQUOTE, cmdlist);
+    /* pass in the FTP commands to run after the transfer */
+    curl_easy_setopt(curl, CURLOPT_POSTQUOTE, cmdlist);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 38b9e8c957d85d42d8a2ecf1d220b226895bb453..da7d826d7ab9fbad67a77d349471a80ee37c061c 100644 (file)
@@ -52,18 +52,21 @@ when setting \fICURLOPT_FOLLOWLOCATION(3)\fP.
 HTTP(S)
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* a silly POST example */
-  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data=true");
+    /* a silly POST example */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data=true");
 
-  /* example.com is redirected, so we tell libcurl to send POST on 301, 302 and
-     303 HTTP response codes */
-  curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
+    /* example.com is redirected, so we tell libcurl to send POST on 301,
+       302 and 303 HTTP response codes */
+    curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b216e9e67e54f9932bbc924374c3188b8bf2ce29..fd5ba04676d2b2c4543c953f3313ae0124c6d14e 100644 (file)
@@ -50,19 +50,23 @@ NULL
 FTP
 .SH EXAMPLE
 .nf
-struct curl_slist *cmdlist = NULL;
-cmdlist = curl_slist_append(cmdlist, "SYST");
+int main(void)
+{
+  struct curl_slist *cmdlist = NULL;
+  cmdlist = curl_slist_append(cmdlist, "SYST");
 
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
 
-  /* pass in the FTP commands to run */
-  curl_easy_setopt(curl, CURLOPT_PREQUOTE, cmdlist);
+    /* pass in the FTP commands to run */
+    curl_easy_setopt(curl, CURLOPT_PREQUOTE, cmdlist);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 617ecf07b1cad30118f0c9ebc5bae791755d0b16..2d9c4e12c2000cda4e172b6f7283bcf1872494da 100644 (file)
@@ -40,20 +40,29 @@ NULL
 All
 .SH EXAMPLE
 .nf
+struct priv {
+  void *custom;
+};
+
 static int prereq_callback(void *clientp,
                            char *conn_primary_ip,
                            char *conn_local_ip,
                            int conn_primary_port,
                            int conn_local_port)
 {
-  printf("Connection made to %s:%s\\n", conn_primary_ip, conn_primary_port);
+  printf("Connection made to %s:%d\\n", conn_primary_ip, conn_primary_port);
   return CURL_PREREQFUNC_OK;
 }
 
+int main(void)
 {
-  struct data prereq_data;
-  curl_easy_setopt(CURL *handle, CURLOPT_PREREQFUNCTION, prereq_callback);
-  curl_easy_setopt(CURL *handle, CURLOPT_PREREQDATA, &prereq_data);
+  struct priv prereq_data;
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback);
+    curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4d13a5491c0eb43d985fb911905bf2ef2f57b8b5..a2e3dd38f71768ef9ddb64b58e7fac72bad29441 100644 (file)
@@ -81,20 +81,29 @@ By default, this is NULL and unused.
 ALL
 .SH EXAMPLE
 .nf
+struct priv {
+  void *custom;
+};
+
 static int prereq_callback(void *clientp,
                            char *conn_primary_ip,
                            char *conn_local_ip,
                            int conn_primary_port,
                            int conn_local_port)
 {
-  printf("Connection made to %s:%s\\n", conn_primary_ip, conn_primary_port);
+  printf("Connection made to %s:%d\\n", conn_primary_ip, conn_primary_port);
   return CURL_PREREQFUNC_OK;
 }
 
+int main(void)
 {
-  struct data prereq_data;
-  curl_easy_setopt(CURL *handle, CURLOPT_PREREQFUNCTION, prereq_callback);
-  curl_easy_setopt(CURL *handle, CURLOPT_PREREQDATA, &prereq_data);
+  struct priv prereq_data;
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback);
+    curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6e06ab8225950ae1a41c02ee0d4b0ef206140009..044d60c0cd64bcf48e9c3ecb03d8b023dac668e8 100644 (file)
@@ -66,12 +66,15 @@ single port number used widely for proxies. Specify it!
 All except file://. Note that some protocols do not work well over proxy.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
-  curl_easy_setopt(curl, CURLOPT_PRE_PROXY, "socks4://socks-proxy:1080");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
+    curl_easy_setopt(curl, CURLOPT_PRE_PROXY, "socks4://socks-proxy:1080");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 20da94775c44f145834d0b6031316cdb9b0a64aa..273ba1df6f3867ac0d1ef2558b5c42294db39b5c 100644 (file)
@@ -42,19 +42,26 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-struct private secrets;
-if(curl) {
-  struct private *extracted;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+struct private {
+  void *custom;
+};
 
-  /* store a pointer to our private struct */
-  curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  struct private secrets;
+  if(curl) {
+    struct private *extracted;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_perform(curl);
+    /* store a pointer to our private struct */
+    curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets);
 
-  /* we can extract the private pointer again too */
-  curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted);
+    curl_easy_perform(curl);
+
+    /* we can extract the private pointer again too */
+    curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted);
+  }
 }
 .fi
 .SH AVAILABILITY
index b83c1d923346900ecc4c4e1c39f21c46c6ac08f0..8d1fef100fa1a5ee7206100e02c3614bff861c5f 100644 (file)
@@ -40,30 +40,38 @@ The default value of this parameter is NULL.
 All
 .SH EXAMPLE
 .nf
- struct progress {
-   char *private;
-   size_t size;
- };
+struct progress {
+  char *private;
+  size_t size;
+};
 
- static size_t progress_callback(void *clientp,
-                                 double dltotal,
-                                 double dlnow,
-                                 double ultotal,
-                                 double ulnow)
- {
-   struct memory *progress = (struct progress *)clientp;
+static size_t progress_callback(void *clientp,
+                                double dltotal,
+                                double dlnow,
+                                double ultotal,
+                                double ulnow)
+{
+  struct progress *memory = clientp;
+  printf("private: %p\\n", memory->private);
 
-   /* use the values */
+  /* use the values */
 
-   return 0; /* all is good */
- }
+  return 0; /* all is good */
+}
 
- struct progress data;
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct progress data;
 
- /* pass struct to callback  */
- curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, &data);
+    /* pass struct to callback  */
+    curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
+    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
 
- curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
+    curl_easy_perform(curl);
+  }
+}
 .fi
 .SH AVAILABILITY
 Always
index 809cf387d35672f2dcaca7ba15d19b939abed746..5682900d5fb031c9873c3f1fbe47395eef6ad18a 100644 (file)
@@ -84,30 +84,38 @@ users.
 All
 .SH EXAMPLE
 .nf
- struct progress {
-   char *private;
-   size_t size;
- };
-
- static size_t progress_callback(void *clientp,
-                                 double dltotal,
-                                 double dlnow,
-                                 double ultotal,
-                                 double ulnow)
- {
-   struct progress *memory = (struct progress *)clientp;
-
-   /* use the values */
-
-   return 0; /* all is good */
- }
-
- struct progress data;
-
- /* pass struct to callback  */
- curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, &data);
-
- curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
+struct progress {
+  char *private;
+  size_t size;
+};
+
+static size_t progress_callback(void *clientp,
+                                double dltotal,
+                                double dlnow,
+                                double ultotal,
+                                double ulnow)
+{
+  struct progress *memory = clientp;
+  printf("private: %p\\n", memory->private);
+
+  /* use the values */
+
+  return 0; /* all is good */
+}
+
+int main(void)
+{
+  struct progress data;
+
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* pass struct to callback  */
+    curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
+    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
+
+    curl_easy_perform(curl);
+  }
+}
 .fi
 .SH AVAILABILITY
 Deprecated since 7.32.0.
index f252e98d458320900eeb245f76e7fc36992e3b17..29538d6602e2486d064db7bf0e3141fbfaa54c7e 100644 (file)
@@ -80,17 +80,20 @@ All protocols built-in.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  /* pass in the URL from an external source */
-  curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
+int main(int argc, char **argv)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* pass in the URL from an external source */
+    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
 
-  /* only allow HTTP, TFTP and SFTP */
-  curl_easy_setopt(curl, CURLOPT_PROTOCOLS,
-                   CURLPROTO_HTTP | CURLPROTO_TFTP | CURLPROTO_SFTP);
+    /* only allow HTTP, TFTP and SFTP */
+    curl_easy_setopt(curl, CURLOPT_PROTOCOLS,
+                     CURLPROTO_HTTP | CURLPROTO_TFTP | CURLPROTO_SFTP);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 561020fd7fbbf4825ccf362f9181d14b61049c67..8af32244d1cbf163963c08466b57f6644e7a1a20 100644 (file)
@@ -61,16 +61,19 @@ All protocols built-in
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  /* pass in the URL from an external source */
-  curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
+int main(int argc, char **argv)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* pass in the URL from an external source */
+    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
 
-  /* only allow HTTP, TFTP and SFTP */
-  curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp");
+    /* only allow HTTP, TFTP and SFTP */
+    curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c645af539d293c04f48b97fc1f7f0d262a84b249..a3a36152ab6a6b84561f9d8605d7ebe35b23c06a 100644 (file)
@@ -109,11 +109,14 @@ single port number used widely for proxies. Specify it!
 All except file://. Note that some protocols do not work well over proxy.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 309d3699e377ea4c70de83ea18731506b9648601..db48dd1fb9f3f544a16094fb2f8fbfffd1605a37 100644 (file)
@@ -48,18 +48,21 @@ CURLAUTH_BASIC
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* use this proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://local.example.com:1080");
-  /* allow whatever auth the proxy speaks */
-  curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
-  /* set the proxy credentials */
-  curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "james:007");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* use this proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://local.example.com:1080");
+    /* allow whatever auth the proxy speaks */
+    curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
+    /* set the proxy credentials */
+    curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "james:007");
+    ret = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4390082010e4aa1e516855d023b78d6f417ca5da..1bc17e9e8bcf4ea441012c50e7a55812021eb6ec 100644 (file)
@@ -51,22 +51,25 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
+int main(void)
+{
+  CURL *curl = curl_easy_init();
 
-struct curl_slist *list;
+  struct curl_slist *list;
 
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com:80");
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com:80");
 
-  list = curl_slist_append(NULL, "Shoesize: 10");
-  list = curl_slist_append(list, "Accept:");
+    list = curl_slist_append(NULL, "Shoesize: 10");
+    list = curl_slist_append(list, "Accept:");
 
-  curl_easy_setopt(curl, CURLOPT_PROXYHEADER, list);
+    curl_easy_setopt(curl, CURLOPT_PROXYHEADER, list);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  curl_slist_free_all(list); /* free the list again */
+    curl_slist_free_all(list); /* free the list again */
+  }
 }
 .fi
 .SH AVAILABILITY
index 766e0b2ad8adaa91584c5f6deefa3b6d0b068634..921caf329ded4ac6a39fb19435cde377a15255d1 100644 (file)
@@ -46,14 +46,18 @@ blank
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
-  curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith");
-  curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
+    curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith");
+    curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 1b369ca0acbe99c5bab553257994245b1da187ce..04a20a7bbc39e0e23a32b0509d0294243295afd8 100644 (file)
@@ -46,13 +46,17 @@ than 65535.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "localhost");
-  curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "localhost");
+    curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3399e2c20c9572ba6bb7added774e774a98350f8..91f3b5a9a3f22407caa3999db228803566b51158 100644 (file)
@@ -65,15 +65,18 @@ CURLPROXY_HTTP
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "local.example.com:1080");
-  /* set the proxy type */
-  curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "local.example.com:1080");
+    /* set the proxy type */
+    curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+    ret = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c594ca2eaf61008098c3f719183f7f0f16a2575d..7a0e54ee23ddce3dfe07f16085b74d5a3fb70956 100644 (file)
@@ -48,14 +48,18 @@ blank
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
-  curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith");
-  curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
+    curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith");
+    curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 76f8bbf2023412bd884f76bb63fd294709ce41c7..e6bdcf956a25eb086de75753c7d0675ce911a380 100644 (file)
@@ -48,13 +48,17 @@ This is NULL by default.
 Used with all protocols that can use a proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
-  curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "clark%20kent:superman");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080");
+    curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "clark%20kent:superman");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index fb2c6dca926b3e6f6a186e34e03c5000397d5723..4b64353e6f222241edc313c0d40e9e786b65ffe8 100644 (file)
@@ -60,14 +60,18 @@ Built-in system specific
 Used with HTTPS proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* using an HTTPS proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
-  curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO, "/etc/certs/cabundle.pem");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* using an HTTPS proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
+    curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO, "/etc/certs/cabundle.pem");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5c8f2443bf00a4ea8d5100686d5804ef3e1277c4..80c03f35499f57baa32b400fb6e6cdc2aff53c6c 100644 (file)
@@ -53,19 +53,25 @@ NULL
 Used with HTTPS proxy
 .SH EXAMPLE
 .nf
-char *strpem; /* strpem must point to a PEM string */
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* using an HTTPS proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
-  blob.data = strpem;
-  blob.len = strlen(strpem);
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO_BLOB, &blob);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+#include <string.h> /* for strlen */
+
+extern char *strpem; /* strpem must point to a PEM string */
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* using an HTTPS proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
+    blob.data = strpem;
+    blob.len = strlen(strpem);
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO_BLOB, &blob);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2db652ead3e0ed42aff16ab01a83cad3ae9c9b24..fd55b0918bcb4b261a3a7717090cbb0f61117bd8 100644 (file)
@@ -48,14 +48,18 @@ NULL
 Everything used over an HTTPS proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* using an HTTPS proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
-  curl_easy_setopt(curl, CURLOPT_PROXY_CAPATH, "/etc/cert-dir");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* using an HTTPS proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
+    curl_easy_setopt(curl, CURLOPT_PROXY_CAPATH, "/etc/cert-dir");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 40fd1cd9ddfc49970a58907b9a4c64b5d18561f5..80891666ab0d3ad3649e45fd9d24a7813d129684 100644 (file)
@@ -60,13 +60,17 @@ NULL
 Used with HTTPS proxy.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:80");
-  curl_easy_setopt(curl, CURLOPT_PROXY_CRLFILE, "/etc/certs/crl.pem");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:80");
+    curl_easy_setopt(curl, CURLOPT_PROXY_CRLFILE, "/etc/certs/crl.pem");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index af0621ca69348af29ffaa42521449bad681163fd..5ddbc712c69c1c4ce6aab81d8652af3a00ffd75d 100644 (file)
@@ -57,14 +57,18 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* using an HTTPS proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
-  curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT, "/etc/certs/cacert.pem");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* using an HTTPS proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
+    curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT, "/etc/certs/cacert.pem");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 32af0cc8e8026294610375b487900f2ebff78848..4f94d2eb0534c5291654b02932109ded2efc4a71 100644 (file)
@@ -63,18 +63,26 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* using an HTTPS proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
-  blob.data = certificateData;
-  blob.len = filesize;
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT_BLOB, &blob);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+
+extern char *certificateData; /* point to the data */
+size_t filesize; /* size of the data */
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* using an HTTPS proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443");
+    blob.data = certificateData;
+    blob.len = filesize;
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT_BLOB, &blob);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 083665fefb9d6ded2890deab551a0f6f30c23584..8d0ba91a01bc07dec7ecdac5621e30c2e71d2deb 100644 (file)
@@ -47,13 +47,17 @@ NULL
 Used with HTTPS proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "superman");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "superman");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 05f76515fabec3910b335dfc13538823a147bbc2..9a9ce119c322560dca6db061c8fbeb66bafc42e1 100644 (file)
@@ -52,15 +52,20 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
-  curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
-  "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno=");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
+    curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
+                     "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjA"
+                     "a3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74"
+                     "Gxa2eg7fRbEgoChTociMee9wno=");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH PUBLIC KEY EXTRACTION
index 31f7805fa837b676d7097ff7a15a7036bc7addeb..712836f60254cee63d03715902b2b009844939d3 100644 (file)
@@ -45,12 +45,15 @@ See above
 All network protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SERVICE_NAME, "custom");
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SERVICE_NAME, "custom");
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0a1c45eb02bf3bbf91ebfcaf8599a91d93766db3..54e6f545ba919ed78bbe7f32119febebba7a79d6 100644 (file)
@@ -55,15 +55,19 @@ NULL
 Used with HTTPS proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c1ef518c22d3ad56d9b2b19691d3b28d7d6efdee..380595c7e26fb46a076803e36fe2770d638847a3 100644 (file)
@@ -48,16 +48,20 @@ option.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3b84126266344c78e10b32807a5514299753abdf..a033193d1bf7b3aecdecedf8f5cabbe7fd27ac1b 100644 (file)
@@ -51,19 +51,27 @@ NULL
 Used with HTTPS proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  blob.data = certificateData;
-  blob.len = filesize;
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+
+extern char *certificateData; /* point to data */
+extern size_t filesize; /* size of the data */
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    blob.data = certificateData;
+    blob.len = filesize;
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e24e0cd3bda1afed9c631883807836f39b590f49..82a5bf9c29bbb80b52b36181bef9632b7d2318b3 100644 (file)
@@ -49,15 +49,19 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c30e832eb112b986448656d4dc9ba2e865e9b034..dfa6ce6d481eee7a6b33c03be67bea8d5ce7318f 100644 (file)
@@ -43,16 +43,20 @@ option.
 Used with HTTPS proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEYTYPE, "PEM");
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEYTYPE, "PEM");
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9b2385d07f9945b3aa2d469fcef4fdd044a382b0..034e1fe0ec46ab6edf03202ede0d73a1e8693f74 100644 (file)
@@ -47,23 +47,34 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  blob.data = certificateData;
-  blob.len = filesize;
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob);
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM");
 
-  blob.data = privateKeyData;
-  blob.len = privateKeySize;
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY_BLOB, &blob);
-  curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+extern char *certificateData; /* point to data */
+extern size_t filesize; /* size of data */
+
+extern char *privateKeyData; /* point to data */
+extern size_t privateKeySize; /* size */
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    blob.data = certificateData;
+    blob.len = filesize;
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob);
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM");
+
+    blob.data = privateKeyData;
+    blob.len = privateKeySize;
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY_BLOB, &blob);
+    curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index abc173557456e6efc44c7ba404cadd47398a8456..3c3fe028962eb44102611b6ee6535f1d08608101 100644 (file)
@@ -85,15 +85,18 @@ CURL_SSLVERSION_DEFAULT
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* ask libcurl to use TLS version 1.0 or later */
-  curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
+    /* ask libcurl to use TLS version 1.0 or later */
+    curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6539a2a9a4ae0e812eb7675ad3e03563287fc14c..5677c655affa57117c9263d06b69c4b0cca6758b 100644 (file)
@@ -65,13 +65,17 @@ NULL, use internal default
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost");
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSL_CIPHER_LIST, "TLSv1");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost");
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSL_CIPHER_LIST, "TLSv1");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index bbeca4af1bba357f65a595ecabe4276fda21846f..b64285afc18308c739f89569f8b37a7f0b4fe0a4 100644 (file)
@@ -83,15 +83,19 @@ could be a privacy violation and unexpected.
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  /* weaken TLS only for use with silly proxies */
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST |
-                   CURLSSLOPT_NO_REVOKE);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    /* weaken TLS only for use with silly proxies */
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST |
+                     CURLSSLOPT_NO_REVOKE);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 83962d7c229a063d99ec9d69550c89313c1894e8..42a96b6c2ff3f2d68dcfa441b776ecb4d662ec59 100644 (file)
@@ -68,14 +68,17 @@ of the proxy certificate.
 All protocols when used over an HTTPS proxy.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Set the default value: strict name check please */
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 2L);
+    /* Set the default value: strict name check please */
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 2L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c6d46029a9fbe1196c4f4ca736e909a6abf7414d..866f07c9f249fe17d518981eee94864971bd9a65 100644 (file)
@@ -72,14 +72,17 @@ the correct end-point.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Set the default value: strict certificate check please */
-  curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 1L);
+    /* Set the default value: strict certificate check please */
+    curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f34f37ccfb886ab2447b830b8ca8f9cdebc98621..d64d17ccc70192e5480a7a6ad8a408a029eb603a 100644 (file)
@@ -54,13 +54,17 @@ NULL, use internal default
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLS13_CIPHERS,
-                   "TLS_CHACHA20_POLY1305_SHA256");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLS13_CIPHERS,
+                     "TLS_CHACHA20_POLY1305_SHA256");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f5990dd4dd23a16604242fdb65f3d93e628d1ef6..327b92a81d45dda88488c6dc430aafd0f3a066a0 100644 (file)
@@ -46,15 +46,19 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0b4154422e17c73abfb40ef173d3c6aeb38dcb02..c4fe02c85842e1bef07069b1eae38b416a7e234f 100644 (file)
@@ -52,15 +52,19 @@ blank
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8cc73fe7aecbcc3ccc2f601b9fdd655d273bed1a..e8362fa2f0358b4fd9da4e1d52801c28b55216c7 100644 (file)
@@ -46,15 +46,19 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b96bc2d21b0a52abb9b88b65ebccaae8819c2632..f948613a8c33eb155d7524e713e5bf1e456a3cb8 100644 (file)
@@ -44,14 +44,19 @@ doing FTP via a proxy. Beware that not all proxies support this feature.
 FTP over proxy
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/old-server/file.txt");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:80");
-  curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
-  curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL,
+                     "ftp://example.com/old-server/file.txt");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:80");
+    curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
+    curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0330878f896ae64794101186385e87face15c77a..fb4e4c9bef046c0fb3fe54e53a85e924ba1b9fbb 100644 (file)
@@ -44,25 +44,41 @@ This option is \fBdeprecated\fP since version 7.12.1. Use
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  /* we want to use our own read function */
-  curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+  FILE *src = userdata;
+  /* copy as much data as possible into the 'ptr' buffer, but no more than
+     'size' * 'nmemb' bytes! */
+  size_t retcode = fread(ptr, size, nmemb, src);
 
-  /* enable PUT */
-  curl_easy_setopt(curl, CURLOPT_PUT, 1L);
+  return retcode;
+}
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    FILE *src = fopen("local-file", "r");
+    curl_off_t fsize; /* set this to the size of the input file */
+
+    /* we want to use our own read function */
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
+
+    /* enable PUT */
+    curl_easy_setopt(curl, CURLOPT_PUT, 1L);
 
-  /* specify target */
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
+    /* specify target */
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
 
-  /* now specify which pointer to pass to our callback */
-  curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
+    /* now specify which pointer to pass to our callback */
+    curl_easy_setopt(curl, CURLOPT_READDATA, src);
 
-  /* Set the size of the file to upload */
-  curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
+    /* Set the size of the file to upload */
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
 
-  /* Now run off and do what you have been told! */
-  curl_easy_perform(curl);
+    /* Now run off and do what you have been told! */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 11fa0edcb885fdf79ce0a6a35cd662d9f5f55598..f34e771ac8d2967710e84a0dcbf36bb8e5698b76 100644 (file)
@@ -44,11 +44,14 @@ possible (though short-lived) leak of associated resources.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L);
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 83f2c50fb64a55c60597ea2cc3ab13bd9d0bbca0..29e0154cd0c35172bfa3a6f4bee18bb6d2daad3a 100644 (file)
@@ -102,20 +102,24 @@ NULL
 SFTP and FTP
 .SH EXAMPLE
 .nf
-struct curl_slist *cmdlist = NULL;
-cmdlist = curl_slist_append(cmdlist, "RNFR source-name");
-cmdlist = curl_slist_append(cmdlist, "RNTO new-name");
+int main(void)
+{
+  struct curl_slist *cmdlist = NULL;
+  cmdlist = curl_slist_append(cmdlist, "RNFR source-name");
+  cmdlist = curl_slist_append(cmdlist, "RNTO new-name");
 
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");
 
-  /* pass in the FTP commands to run before the transfer */
-  curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist);
+    /* pass in the FTP commands to run before the transfer */
+    curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index da5196d1d97e13daf14d2a3e1e80020a097fe0ac..b226d15a0e74165bc57aeb9f68d1babcece589d0 100644 (file)
@@ -45,12 +45,16 @@ NULL, not used
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_RANDOM_FILE, "junk.txt");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_RANDOM_FILE, "junk.txt");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3b20a5206a041b44d7290bad5c046d9f29737ae0..90ad666967a4842fc241969a8bf112ec03f705b8 100644 (file)
@@ -60,15 +60,18 @@ NULL
 HTTP, FTP, FILE, RTSP and SFTP.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* get the first 200 bytes */
-  curl_easy_setopt(curl, CURLOPT_RANGE, "0-199");
+    /* get the first 200 bytes */
+    curl_easy_setopt(curl, CURLOPT_RANGE, "0-199");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f8ab7940a2c6024d26c842a27a6c5ce125ca4849..db0dcfc609508a41706769ec1cb832da69b30b30 100644 (file)
@@ -48,16 +48,23 @@ By default, this is a FILE * to stdin.
 This is used for all protocols when sending data.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-struct MyData this;
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+struct MyData {
+  void *custom;
+};
 
-  /* pass pointer that gets passed in to the
-     CURLOPT_READFUNCTION callback */
-  curl_easy_setopt(curl, CURLOPT_READDATA, &this);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  struct MyData this;
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_perform(curl);
+    /* pass pointer that gets passed in to the
+       CURLOPT_READFUNCTION callback */
+    curl_easy_setopt(curl, CURLOPT_READDATA, &this);
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4aeb6dee09b927b71bfff6094bb8c96d1275cf9b..de689fbdcd9ce52243640b0e42f3f22a2d8e21a4 100644 (file)
@@ -94,18 +94,21 @@ size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
   return retcode;
 }
 
-void setup(char *uploadthis)
+int main(int argc, char **argv)
 {
-  FILE *file = fopen(uploadthis, "rb");
+  FILE *file = fopen(argv[1], "rb");
   CURLcode result;
 
-  /* set callback to use */
-  curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* set callback to use */
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
 
-  /* pass in suitable argument to callback */
-  curl_easy_setopt(curl, CURLOPT_READDATA, (void *)file);
+    /* pass in suitable argument to callback */
+    curl_easy_setopt(curl, CURLOPT_READDATA, (void *)file);
 
-  result = curl_easy_perform(curl);
+    result = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a0cfb0df4f867c19dd2571ca5382713011bd3f26..c45583d792c9d69f427fd530ebddead3aa188323 100644 (file)
@@ -89,17 +89,20 @@ SMB and SMBS.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  /* pass in the URL from an external source */
-  curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
+int main(int argc, char **argv)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* pass in the URL from an external source */
+    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
 
-  /* only allow redirects to HTTP and HTTPS URLs */
-  curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
-                   CURLPROTO_HTTP | CURLPROTO_HTTPS);
+    /* only allow redirects to HTTP and HTTPS URLs */
+    curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
+                     CURLPROTO_HTTP | CURLPROTO_HTTPS);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0ddb6ff02805a8dea045bb1225289ec1498c2e52..db243ad1dbe7d85e22f99f57522189da6734f20d 100644 (file)
@@ -67,16 +67,19 @@ SMB and SMBS.
 All
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  /* pass in the URL from an external source */
-  curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
+int main(int argc, char **argv)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* pass in the URL from an external source */
+    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
 
-  /* only allow redirects to HTTP and HTTPS URLs */
-  curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https");
+    /* only allow redirects to HTTP and HTTPS URLs */
+    curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f294bdaf7fdf29d5793ae9b9e7378910a9506379..38d931b9f7c22061a208708382fdc07b6afde0a9 100644 (file)
@@ -44,14 +44,17 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* tell it where we found the link to this place */
-  curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.com/aboutme.html");
+    /* tell it where we found the link to this place */
+    curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 50d037a9d15b214ac4dcde7e889f2bbbb1429e13..f7a21fedaca2af6b8d9d716019d7283cf8119f79 100644 (file)
@@ -43,16 +43,19 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/*");
-  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
+int main(void)
+{
+  CURL *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, "*");
+    /* issue an OPTIONS * request (no leading slash) */
+    curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*");
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 670089e8bdffc26793e14eadf62b0d3e4a476f30..b0aa0e778121cfb5649ba13605a4ed0f3c553803 100644 (file)
@@ -79,22 +79,25 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl;
-struct curl_slist *host = NULL;
-host = curl_slist_append(NULL, "example.com:443:127.0.0.1");
+int main(void)
+{
+  CURL *curl;
+  struct curl_slist *host = NULL;
+  host = curl_slist_append(NULL, "example.com:443:127.0.0.1");
 
-curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+  curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
-}
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 
-curl_slist_free_all(host);
+  curl_slist_free_all(host);
+}
 .fi
 .SH AVAILABILITY
 Added in 7.21.3. Removal support added in 7.42.0.
index 2344de90837959cfcd68d7cd6b2bc7580cc4f9d6..84bc081a67b78ad2858fcf7a8c557f11ffcba44c 100644 (file)
@@ -51,13 +51,16 @@ static int resolver_start_cb(void *resolver_state, void *reserved,
   return 0;
 }
 
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb);
-  curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb);
+    curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 96e726ae0da00b5e4ea9fbe46d22e12a83f28043..bd2c1189f7f11b276458324eff859161129aafe2 100644 (file)
@@ -59,8 +59,8 @@ NULL (No callback)
 All
 .SH EXAMPLE
 .nf
-static int resolver_start_cb(void *resolver_state, void *reserved,
-                             void *userdata)
+static int start_cb(void *resolver_state, void *reserved,
+                    void *userdata)
 {
   (void)reserved;
   printf("Received resolver_state=%p userdata=%p\\n",
@@ -68,13 +68,16 @@ static int resolver_start_cb(void *resolver_state, void *reserved,
   return 0;
 }
 
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb);
-  curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, start_cb);
+    curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3254f7c12b0c621fbb061e5ed6ceb9f86db90857..30c7fea9eed077ba6789aa1ae21ddb85d4938c29 100644 (file)
@@ -50,21 +50,26 @@ If you need to resume a transfer beyond the 2GB limit, use
 HTTP, FTP, SFTP, FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    long size_of_file;
 
-  /* resume upload at byte index 200 */
-  curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 200L);
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
 
-  /* ask for upload */
-  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+    /* resume upload at byte index 200 */
+    curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 200L);
 
-  /* set total data amount to expect */
-  curl_easy_setopt(curl, CURLOPT_INFILESIZE, size_of_file);
+    /* ask for upload */
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* set total data amount to expect */
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE, size_of_file);
+
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index d4fae3d4487f3dcb0cf55ffe63a603100f8a4b73..e5d91bb8973c9c808bb0f90ee0dc587f49ff6c3f 100644 (file)
@@ -47,24 +47,27 @@ file to the remote target file.
 HTTP, FTP, SFTP, FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_off_t resume_position = GET_IT_SOMEHOW;
-  curl_off_t file_size = GET_IT_SOMEHOW_AS_WELL;
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_off_t resume_position; /* get it somehow */
+    curl_off_t file_size; /* get it somehow as well */
 
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
 
-  /* resuming upload at this position, possibly beyond 2GB */
-  curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position);
+    /* resuming upload at this position, possibly beyond 2GB */
+    curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position);
 
-  /* ask for upload */
-  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+    /* ask for upload */
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
 
-  /* set total data amount to expect */
-  curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size);
+    /* set total data amount to expect */
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 62564117098101750ebc164d8d49dae51e834959..4faf8020aadb3810fe140f3ee897d667b17fc18d 100644 (file)
@@ -41,12 +41,16 @@ increments from this new number henceforth.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 1234L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 1234L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3a8ddb2007049852e60485c8e4c84fe503e1f817..d62cf1d18daa38dec4181da56eff0312e6b999a8 100644 (file)
@@ -100,13 +100,17 @@ application a chance to run.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
-  /* ask for options! */
-  curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
+    /* ask for options! */
+    curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index cadf21cc242aafcbbe5d76fc19b64e616577d520..5c75bd1499ae4e6165ed892760df4644729e2fea 100644 (file)
@@ -41,12 +41,16 @@ unimplemented.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_RTSP_SERVER_CSEQ, 1234L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_RTSP_SERVER_CSEQ, 1234L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3eaae032487db989d3b685f1ca4967482d4de629..acb8e36114ec9e8b5abf7f9e0d8ecaa0ec095a55 100644 (file)
@@ -46,13 +46,17 @@ NULL
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  char *prev_id; /* saved from before somehow */
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, prev_id);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    char *prev_id; /* saved from before somehow */
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, prev_id);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f6eea304761e435d2c69dc86bd8a3af75569a6d0..d2c7a49da64e2999192655701b3f203f208b1188 100644 (file)
@@ -51,14 +51,17 @@ option.
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  char *prev_id; /* saved from before somehow */
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,
-                   "rtsp://foo.example.com/twister/video");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,
+                     "rtsp://foo.example.com/twister/video");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f276cc2b6f230f79ea3cec36dda0abf6ac40162f..9017f915482f445967f88baeb418a4327cbb0cbc 100644 (file)
@@ -45,14 +45,18 @@ NULL
 RTSP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
-  curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT,
-                   "RTP/AVP;unicast;client_port=4588-4589");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
+    curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT,
+                     "RTP/AVP;unicast;client_port=4588-4589");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index d0b73f92338d38728d0290a665f597af7905140d..c06a665e2cbf47c7e9c8823ce76ab9e63b5354e7 100644 (file)
@@ -50,14 +50,18 @@ blank
 IMAP, LDAP, POP3 and SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "imap://example.com/");
-  curl_easy_setopt(curl, CURLOPT_USERNAME, "Kurt");
-  curl_easy_setopt(curl, CURLOPT_PASSWORD, "xipj3plmq");
-  curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID, "Ursel");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "imap://example.com/");
+    curl_easy_setopt(curl, CURLOPT_USERNAME, "Kurt");
+    curl_easy_setopt(curl, CURLOPT_PASSWORD, "xipj3plmq");
+    curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID, "Ursel");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 7c3a7a4ba1addd0825efe75629f434b2ca0c7b9b..50ec074a055b55fdc299ae495d4b7f2f0c47e942 100644 (file)
@@ -52,12 +52,16 @@ SASL-IR CAPABILITY.
 IMAP, POP3 and SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SASL_IR, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SASL_IR, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8810115a3611f0ca89ab05505e1b6217dd3bb59e..eed02af19604f2321168eb5d749086cf8d444e46 100644 (file)
@@ -40,6 +40,12 @@ If you do not set this, NULL is passed to the callback.
 HTTP, FTP, SFTP
 .SH EXAMPLE
 .nf
+#include <unistd.h> /* for lseek() */
+
+struct data {
+  int our_fd;
+};
+
 static int seek_cb(void *clientp, curl_off_t offset, int origin)
 {
   struct data *d = (struct data *)clientp;
@@ -47,10 +53,14 @@ static int seek_cb(void *clientp, curl_off_t offset, int origin)
   return CURL_SEEKFUNC_OK;
 }
 
+int main(void)
 {
   struct data seek_data;
-  curl_easy_setopt(CURL *handle, CURLOPT_SEEKFUNCTION, seek_cb);
-  curl_easy_setopt(CURL *handle, CURLOPT_SEEKDATA, &seek_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_cb);
+    curl_easy_setopt(curl, CURLOPT_SEEKDATA, &seek_data);
+  }
 }
 .fi
 .SH AVAILABILITY
index 1e000bd8a4efde9c6eb41c42d68d0c8fea04a9a6..649eb2ae291d8263b1c3eefca532ec85f3a2d23b 100644 (file)
@@ -70,17 +70,26 @@ By default, this is NULL and unused.
 HTTP, FTP, SFTP
 .SH EXAMPLE
 .nf
+#include <unistd.h> /* for lseek */
+
+struct data {
+  int our_fd;
+};
 static int seek_cb(void *clientp, curl_off_t offset, int origin)
 {
   struct data *d = (struct data *)clientp;
-  lseek(our_fd, offset, origin);
+  lseek(d->our_fd, offset, origin);
   return CURL_SEEKFUNC_OK;
 }
 
+int main(void)
 {
   struct data seek_data;
-  curl_easy_setopt(CURL *handle, CURLOPT_SEEKFUNCTION, seek_cb);
-  curl_easy_setopt(CURL *handle, CURLOPT_SEEKDATA, &seek_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_cb);
+    curl_easy_setopt(curl, CURLOPT_SEEKDATA, &seek_data);
+  }
 }
 .fi
 .SH AVAILABILITY
index 0628b374c0d120d0471884bef7dc4da8c57b48d0..72b2a6264a6bf86d51f579979bdc0ebe6346c548 100644 (file)
@@ -48,14 +48,18 @@ None
 FTP, IMAP, POP3, SMTP, and SSH
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/slow.txt");
-  /* wait no more than 23 seconds */
-  curl_easy_setopt(curl, CURLOPT_SERVER_RESPONSE_TIMEOUT, 23L);
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/slow.txt");
+    /* wait no more than 23 seconds */
+    curl_easy_setopt(curl, CURLOPT_SERVER_RESPONSE_TIMEOUT, 23L);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2c3f70f2da61e2cf3d132bb1c14257c5c6ca95c5..02d18494d957fa452dc74b01db58dcfb97f37e5d 100644 (file)
@@ -45,12 +45,15 @@ See above
 HTTP, FTP, IMAP, LDAP, POP3 and SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  CURLcode ret;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SERVICE_NAME, "custom");
-  ret = curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode ret;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SERVICE_NAME, "custom");
+    ret = curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ec481e561e2a7a678537a3d7e5b71e72794eab1b..22a662ac607566cd57222c99d6925f38174013ce 100644 (file)
@@ -55,26 +55,30 @@ NULL
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-CURL *curl2 = curl_easy_init(); /* a second handle */
-if(curl) {
-  CURLSH *shobject = curl_share_init();
-  curl_share_setopt(shobject, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  CURL *curl2 = curl_easy_init(); /* a second handle */
+  if(curl) {
+    CURLcode res;
+    CURLSH *shobject = curl_share_init();
+    curl_share_setopt(shobject, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
-  curl_easy_setopt(curl, CURLOPT_SHARE, shobject);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
+    curl_easy_setopt(curl, CURLOPT_SHARE, shobject);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
 
-  /* the second handle shares cookies from the first */
-  curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/second");
-  curl_easy_setopt(curl2, CURLOPT_COOKIEFILE, "");
-  curl_easy_setopt(curl2, CURLOPT_SHARE, shobject);
-  ret = curl_easy_perform(curl2);
-  curl_easy_cleanup(curl2);
+    /* the second handle shares cookies from the first */
+    curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/second");
+    curl_easy_setopt(curl2, CURLOPT_COOKIEFILE, "");
+    curl_easy_setopt(curl2, CURLOPT_SHARE, shobject);
+    res = curl_easy_perform(curl2);
+    curl_easy_cleanup(curl2);
 
-  curl_share_cleanup(shobject);
+    curl_share_cleanup(shobject);
+  }
 }
 .fi
 .SH AVAILABILITY
index c63504a99ef8085b3dde62cb6918b280da639647..f671aa9895a2604705518674bf8b466f491ded87 100644 (file)
@@ -44,23 +44,28 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
                             curlsocktype purpose)
 {
   int val = *(int *)clientp;
-  setsockopt(curldfd, SOL_SOCKET, SO_RCVBUF, (const char *)&val, sizeof(val));
+  setsockopt((int)curlfd, SOL_SOCKET, SO_RCVBUF,
+             (const char *)&val, sizeof(val));
   return CURL_SOCKOPT_OK;
 }
 
-curl = curl_easy_init();
-if(curl) {
-  int recvbuffersize = 256 * 1024;
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    int recvbuffersize = 256 * 1024;
 
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
 
-  /* call this function to set options for the socket */
-  curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
-  curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize);
+    /* call this function to set options for the socket */
+    curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
+    curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize);
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 107d68a6a6e66b7f4b3c265032b5cd34ac2052f1..269490f85e356ed2006930f9c44126d9c287050d 100644 (file)
@@ -100,21 +100,27 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
   return CURL_SOCKOPT_ALREADY_CONNECTED;
 }
 
-curl = curl_easy_init();
-if(curl) {
-  /* libcurl thinks that you connect to the host
-   * and port that you specify in the URL option. */
-  curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
-  /* call this function to get a socket */
-  curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
-  curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    int sockfd; /* our custom file descriptor */
+    /* libcurl thinks that you connect to the host
+     * and port that you specify in the URL option. */
+    curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
+    /* call this function to get a socket */
+    curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
+    curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
 
-  /* call this function to set options for the socket */
-  curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
+    /* call this function to set options for the socket */
+    curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
 
-  res = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.16.0. The \fICURL_SOCKOPT_ALREADY_CONNECTED\fP return code was
index 6ee8c30c14a804493a5c07c01fca136240b64480..d2276cffcfdff7c86cf653563b3f398ecc663085 100644 (file)
@@ -44,18 +44,21 @@ CURLAUTH_BASIC|CURLAUTH_GSSAPI
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* request to use a SOCKS5 proxy */
-  curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://user:pass@myproxy.com");
+    /* request to use a SOCKS5 proxy */
+    curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://user:pass@myproxy.com");
 
-  /* enable username/password authentication only */
-  curl_easy_setopt(curl, CURLOPT_SOCKS5_AUTH, (long)CURLAUTH_BASIC);
+    /* enable username/password authentication only */
+    curl_easy_setopt(curl, CURLOPT_SOCKS5_AUTH, (long)CURLAUTH_BASIC);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a8829a7ff5266e43c7505c1fa7eb90c1b9448773..bc9ea693d0ee90b411169e9c35948d78c1e8d235 100644 (file)
@@ -43,13 +43,17 @@ negotiation.
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://proxy");
-  curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://proxy");
+    curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f22aa12fc44bbb6e82e339585480fd28c624c48d..c5b32ec2ab89cd1e5d0beb8a624aa3b0453eae98 100644 (file)
@@ -47,13 +47,17 @@ See above
 All network protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://proxy");
-  curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE, "rcmd-special");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://proxy");
+    curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE, "rcmd-special");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e125429b51d23e26ab8ddef9ccadb3ab93d33635..a6c16c8461568d8ce5fd2d3ec28b6bc4bf57ee1b 100644 (file)
@@ -46,13 +46,17 @@ CURLSSH_AUTH_ANY (all available)
 SFTP and SCP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
-  curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES,
-                   CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
+    curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES,
+                     CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b440f7fb026deb2019116de075bf2952832a191f..9a1fab01d579eb464f6bdf05f14e4ad1028d2787 100644 (file)
@@ -42,15 +42,18 @@ may or may not do it.
 All SSH based protocols: SCP, SFTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com");
 
-  /* enable built-in compression */
-  curl_easy_setopt(curl, CURLOPT_SSH_COMPRESSION, 1L);
+    /* enable built-in compression */
+    curl_easy_setopt(curl, CURLOPT_SSH_COMPRESSION, 1L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ac13dc6a2003160c45c2f5e80cca4b6a9e125547..c0a5720c50086ff42e4adb5701692c72e4546ed0 100644 (file)
@@ -40,21 +40,31 @@ NULL
 SCP and SFTP
 .SH EXAMPLE
 .nf
-int hostkeycb(void *clientp,    /* passed with CURLOPT_SSH_HOSTKEYDATA */
-              int keytype,      /* CURLKHTYPE */
-              const char * key, /* host key to check */
-              size_t keylen);   /* length of the key */
+struct mine {
+  void *custom;
+};
+
+static int hostkeycb(void *clientp,   /* CURLOPT_SSH_HOSTKEYDATA */
+                     int keytype,     /* CURLKHTYPE */
+                     const char *key, /* host key to check */
+                     size_t keylen)   /* length of the key */
 {
   /* 'clientp' points to the callback_data struct */
   /* investigate the situation and return the correct value */
   return CURLKHMATCH_OK;
 }
+
+int main(void)
 {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
-  curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb);
-  curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data);
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct mine callback_data;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
+    curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb);
+    curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 43fa94bf2a2e99843d2fff51442f38b000f7df2b..132e9e94dece7583edece908156263f183211ace 100644 (file)
@@ -61,21 +61,30 @@ NULL
 SCP and SFTP
 .SH EXAMPLE
 .nf
+struct mine {
+  void *custom;
+};
+
 int hostkeycb(void *clientp,    /* passed with CURLOPT_SSH_HOSTKEYDATA */
               int keytype,      /* CURLKHTYPE */
-              const char * key, /* host key to check */
-              size_t keylen);   /* length of the key */
+              const char *key,  /* host key to check */
+              size_t keylen)    /* length of the key */
 {
   /* 'clientp' points to the callback_data struct */
   /* investigate the situation and return the correct value */
   return CURLKHMATCH_OK;
 }
+int main(void)
 {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
-  curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb);
-  curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data);
+  struct mine callback_data;
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
+    curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb);
+    curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 30ed2ec161eb90829f4557849338889b27756cbf..e0b2586edbd05ed5b8dd6a2fb7b33eb70bfe758c 100644 (file)
@@ -47,13 +47,17 @@ NULL
 SCP and SFTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
-  curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5,
-                   "afe17cd62a0f3b61f1ab9cb22ba269a7");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
+    curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5,
+                     "afe17cd62a0f3b61f1ab9cb22ba269a7");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2798d14bda9972dd8fb7a1b9ca5bf005c18b65ba..266b7b0ac53d37968614142be8b352c72d54d219 100644 (file)
@@ -42,13 +42,17 @@ NULL
 SCP and SFTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
-  curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256,
-                   "NDVkMTQxMGQ1ODdmMjQ3MjczYjAyOTY5MmRkMjVmNDQ=");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
+    curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256,
+                     "NDVkMTQxMGQ1ODdmMjQ3MjczYjAyOTY5MmRkMjVmNDQ=");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index bfa7b7738549390e23d5df0efb6fc31f7603ce9d..04ae0a557881ceeec873c9615fcca3372391092d 100644 (file)
@@ -40,6 +40,9 @@ NULL
 SFTP and SCP
 .SH EXAMPLE
 .nf
+struct mine {
+  void *custom;
+};
 static int keycb(CURL *easy,
                  const struct curl_khkey *knownkey,
                  const struct curl_khkey *foundkey,
@@ -50,13 +53,19 @@ static int keycb(CURL *easy,
   /* investigate the situation and return the correct value */
   return CURLKHSTAT_FINE_ADD_TO_FILE;
 }
+
+int main(void)
 {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
-  curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb);
-  curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data);
-  curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts");
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct mine callback_data;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
+    curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb);
+    curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data);
+    curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 7c258519520be2fcb7894d6e42edf1d0e7b1072e..1abe37d63d88e7a15fe8caf74c503f8106a6b253 100644 (file)
@@ -105,6 +105,10 @@ NULL
 SFTP and SCP
 .SH EXAMPLE
 .nf
+struct mine {
+  void *custom;
+};
+
 static int keycb(CURL *easy,
                  const struct curl_khkey *knownkey,
                  const struct curl_khkey *foundkey,
@@ -115,13 +119,19 @@ static int keycb(CURL *easy,
   /* investigate the situation and return the correct value */
   return CURLKHSTAT_FINE_ADD_TO_FILE;
 }
+
+int main(void)
 {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
-  curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb);
-  curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data);
-  curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts");
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct mine callback_data;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
+    curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb);
+    curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data);
+    curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+}
 }
 .fi
 .SH AVAILABILITY
index 419e63ec8587cc9a7bfecbbc33dbf73c4892f80b..8984fedb70ac24f38502dac2043e565bb3a1eaca 100644 (file)
@@ -47,13 +47,17 @@ NULL
 SFTP and SCP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
-  curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS,
-                   "/home/clarkkent/.ssh/known_hosts");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
+    curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS,
+                     "/home/clarkkent/.ssh/known_hosts");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 384aae9b518d86ed5db14e3b060d42a09a08deaf..12cc5410da731fa027d9436830790d4f1a0c300b 100644 (file)
@@ -48,14 +48,18 @@ As explained above
 SFTP and SCP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
-  curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE,
-                   "/home/clarkkent/.ssh/id_rsa");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
+    curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE,
+                     "/home/clarkkent/.ssh/id_rsa");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a97aa4c1fefda0911bd3d3e6c8c38c39a9efb8e1..93d9241e08abe538de2da565ade9686f69ad8cba 100644 (file)
@@ -49,13 +49,17 @@ NULL
 SFTP and SCP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
-  curl_easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE,
-                   "/home/clarkkent/.ssh/id_rsa.pub");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
+    curl_easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE,
+                     "/home/clarkkent/.ssh/id_rsa.pub");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 2727498f46843c6737743090713daea78ae49163..d3ded42fa500033422c2b3f1082ac020264ae650 100644 (file)
@@ -65,14 +65,18 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6c2abd0037e70623ee885a9451d7aeabbb88b412..e800c5cbd845c04b745c9b53485f5359aebfa9e2 100644 (file)
@@ -48,15 +48,19 @@ option.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
-  curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
+    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 45510422e47f5ea769140b6445afe0aa2351346b..37a53362e75610887baadc30ed41b3d31d8c7d14 100644 (file)
@@ -51,18 +51,26 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob stblob;
-  stblob.data = certificateData;
-  stblob.len = filesize;
-  stblob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &stblob);
-  curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "P12");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+
+extern char *certificateData; /* point to data */
+extern size_t filesize; /* size of data */
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob stblob;
+    stblob.data = certificateData;
+    stblob.len = filesize;
+    stblob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &stblob);
+    curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "P12");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 839f59598cda05324fb37223986b25014b6abc9b..495841da9eca51aa051bb09296c8ed58161eb4a4 100644 (file)
@@ -43,12 +43,16 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLENGINE, "dynamic");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLENGINE, "dynamic");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 00a69d26b6637d5f902c0b27535836630e3cdd88..0e904c67fc965cff28ffbe983375d679cc36ee12 100644 (file)
@@ -42,13 +42,17 @@ None
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLENGINE, "dynamic");
-  curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLENGINE, "dynamic");
+    curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index ee85aaff222f88a4b5550528e4dbe28d265b49ac..7f54c4eafbaae4c5df234c72407464f8639c9d3a 100644 (file)
@@ -48,14 +48,18 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6cb46d104a3bb3823d7f4a029a512fd81cd2dea1..957d175eaa374633b08bc5603be1493925f67e91 100644 (file)
@@ -48,15 +48,19 @@ option.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
-  curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
-  curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
+    curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem");
+    curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e43461d3f7da6a09cd4075547e82639ed52a91e0..8d3f21da3f3882059948018bdbeedbabcb40ad94 100644 (file)
@@ -49,23 +49,34 @@ NULL
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_blob blob;
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  blob.data = certificateData;
-  blob.len = filesize;
-  blob.flags = CURL_BLOB_COPY;
-  curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob);
-  curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
 
-  blob.data = privateKeyData;
-  blob.len = privateKeySize;
-  curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob);
-  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
-  curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+extern char *certificateData; /* point to cert */
+extern size_t filesize; /* size of cert */
+
+extern char *privateKeyData; /* point to key */
+extern size_t privateKeySize; /* size of key */
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_blob blob;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    blob.data = certificateData;
+    blob.len = filesize;
+    blob.flags = CURL_BLOB_COPY;
+    curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob);
+    curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
+
+    blob.data = privateKeyData;
+    blob.len = privateKeySize;
+    curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob);
+    curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret");
+    curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e504c0e184958016d2b3c9b5304ce3a044c961c9..2031b68032f0f9863249d41240d935afd02ba004 100644 (file)
@@ -94,15 +94,18 @@ CURL_SSLVERSION_DEFAULT
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* ask libcurl to use TLS version 1.0 or later */
-  curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1);
+    /* ask libcurl to use TLS version 1.0 or later */
+    curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 87626feba41c0f6eb2f2d4b01aefd5d7de185afd..8196b55298cfa0d5cfdf721a8e1523b27fee7806 100644 (file)
@@ -67,12 +67,16 @@ NULL, use internal default
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5dcf059e79e9b640c9fcc9442bcd0321c4a7092e..6abe2a9bf40ad0b1b5478781f3d4a6751ca8df62 100644 (file)
@@ -59,7 +59,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
    * X509 structure that SSL can use
    */
   PEM_read_bio_X509(bio, &cert, 0, NULL);
-  if(cert == NULL)
+  if(!cert)
     printf("PEM_read_bio_X509 failed...\\n");
 
   /* get a pointer to the X509 certificate store (which may be empty) */
@@ -79,7 +79,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
 
 int main(void)
 {
-  CURL * ch;
+  CURL *ch;
   CURLcode rv;
   char *mypem = /* example CA cert PEM - shortened */
     "-----BEGIN CERTIFICATE-----\\n"
index 220f1b992a5eb8ee87e73f02e430d8f679f79b90..3ec1c95e5d39fb8cd720b49d5de935fa08d7236c 100644 (file)
@@ -101,7 +101,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
    * X509 structure that SSL can use
    */
   PEM_read_bio_X509(bio, &cert, 0, NULL);
-  if(cert == NULL)
+  if(!cert)
     printf("PEM_read_bio_X509 failed...\\n");
 
   /* get a pointer to the X509 certificate store (which may be empty) */
@@ -121,7 +121,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
 
 int main(void)
 {
-  CURL * ch;
+  CURL *ch;
   CURLcode rv;
   char *mypem = /* example CA cert PEM - shortened */
     "-----BEGIN CERTIFICATE-----\\n"
index fab3632268ab9dd9854fbd71b1a8f47453637a06..65b5407d54d0d261ca094f65c02d428c1bc3d21d 100644 (file)
@@ -41,12 +41,16 @@ the SSL backend libcurl is built to use supports it).
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSL_EC_CURVES, "X25519:P-521");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSL_EC_CURVES, "X25519:P-521");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 748cdb7462b100a5e7247d795a41b916f95215fe..346ca32bf1b90f5127f59c07ef025c5a73eb9964 100644 (file)
@@ -41,12 +41,16 @@ is built to use supports it), which can be used to negotiate http2.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSL_ENABLE_ALPN, 0L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSL_ENABLE_ALPN, 0L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 04286c02c94456cad112940058903c22b531a6e3..69fd82671a5ac15be22e22b725c2ff88fd4103fd 100644 (file)
@@ -43,12 +43,16 @@ is built to use supports it), which can be used to negotiate http2.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_SSL_ENABLE_NPN, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_SSL_ENABLE_NPN, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4d3339e530b02b8c3c9da92967d39753491c3ae0..34d6633fc80e51e499d3f6ef603496f74c708416 100644 (file)
@@ -44,11 +44,14 @@ when performing a full handshake.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_SSL_FALSESTART, 1L);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_SSL_FALSESTART, 1L);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 59d62b380a450af43809196e47cda52e7a6efe69..d131ac5d68b2a53cd3c090ad5f8baab01b2d9fc7 100644 (file)
@@ -82,14 +82,18 @@ could be a privacy violation and unexpected.
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* weaken TLS only for use with silly servers */
-  curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_ALLOW_BEAST |
-                   CURLSSLOPT_NO_REVOKE);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* weaken TLS only for use with silly servers */
+    curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_ALLOW_BEAST |
+                     CURLSSLOPT_NO_REVOKE);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 3325f3b40427c1a607c9009359fa10604c40ff0f..de2839098c37497dccb2132359b198a807b5ad24 100644 (file)
@@ -43,13 +43,17 @@ wild that may require you to disable this in order for you to succeed.
 All TLS-based
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* switch off session-id use! */
-  curl_easy_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE, 0L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* switch off session-id use! */
+    curl_easy_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE, 0L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 1bff9305a864adb63e06ca680aa74c3864b963f8..3bdf665de0585020af32a0c4c1c21950fd90f993 100644 (file)
@@ -90,14 +90,17 @@ may be inaccessible if SNI is not sent.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Set the default value: strict name check please */
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
+    /* Set the default value: strict name check please */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e26233e841e608bad09e6cc48a986507f71b87ac..a5ec49b0acb637bf74fae4aa3c6eb2e0901bc1cf 100644 (file)
@@ -74,14 +74,17 @@ malicious servers.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Set the default value: strict certificate check please */
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
+    /* Set the default value: strict certificate check please */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8ae2f9b38b6973a0ecf1b5def232aa10732d5ade..0bfe7da12c484b8645b24817409034b8d2961e00 100644 (file)
@@ -45,13 +45,17 @@ extension, the verification fails.
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  /* ask for OCSP stapling! */
-  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    /* ask for OCSP stapling! */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index a1574be3719f3591eff70e73781182694e695e67..949841ddadadf8a7803b9a75b8c7d2f1964d737c 100644 (file)
@@ -45,13 +45,16 @@ stderr
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-FILE *filep = fopen("dump", "wb");
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_STDERR, filep);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  FILE *filep = fopen("dump", "wb");
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_STDERR, filep);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9f8e5308b40f822e98fd502039b2ecd2f5230b8e..48276467cc4b698a2894dfe107a0d4d242783737 100644 (file)
@@ -53,16 +53,19 @@ NULL
 HTTP/2
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-CURL *curl2 = curl_easy_init(); /* a second handle */
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  CURL *curl2 = curl_easy_init(); /* a second handle */
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
 
-  /* the second depends on the first */
-  curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
-  curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS, curl);
+    /* the second depends on the first */
+    curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
+    curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS, curl);
 
-  /* then add both to a multi handle and transfer them! */
+    /* then add both to a multi handle and transfer them! */
+  }
 }
 .fi
 .SH AVAILABILITY
index c8b4cc13ce9c89c55d0c0c2108af6cb11b85da0b..c84173d8542a277c0c8d7044b3b3bb69d75e8641 100644 (file)
@@ -56,16 +56,19 @@ NULL
 HTTP/2
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-CURL *curl2 = curl_easy_init(); /* a second handle */
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  CURL *curl2 = curl_easy_init(); /* a second handle */
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
 
-  /* the second depends on the first */
-  curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
-  curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS_E, curl);
+    /* the second depends on the first */
+    curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
+    curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS_E, curl);
 
-  /* then add both to a multi handle and transfer them! */
+    /* then add both to a multi handle and transfer them! */
+  }
 }
 .fi
 .SH AVAILABILITY
index 9b399757620326139311c37e2b913765b50167df..7534d1d59280bd54506b0f25fa2203d8e6b49dd2 100644 (file)
@@ -56,17 +56,20 @@ If nothing is set, the HTTP/2 protocol itself uses its own default which is
 HTTP/2
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-CURL *curl2 = curl_easy_init(); /* a second handle */
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
-  curl_easy_setopt(curl, CURLOPT_STREAM_WEIGHT, 10L);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  CURL *curl2 = curl_easy_init(); /* a second handle */
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
+    curl_easy_setopt(curl, CURLOPT_STREAM_WEIGHT, 10L);
 
-  /* the second has twice the weight */
-  curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
-  curl_easy_setopt(curl2, CURLOPT_STREAM_WEIGHT, 20L);
+    /* the second has twice the weight */
+    curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
+    curl_easy_setopt(curl2, CURLOPT_STREAM_WEIGHT, 20L);
 
-  /* then add both to a multi handle and transfer them! */
+    /* then add both to a multi handle and transfer them! */
+  }
 }
 .fi
 .SH AVAILABILITY
index a47944d110d4dde0f439afdda1aba0de27e916b4..15b73917d94c4bec25a4b6ac2eb70c6766c7c083 100644 (file)
@@ -73,19 +73,22 @@ Content-Type: application/json
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
-  curl_easy_setopt(curl, CURLOPT_PROXY, "http://foo:3128");
-  curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-  curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L);
+    curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
+    curl_easy_setopt(curl, CURLOPT_PROXY, "http://foo:3128");
+    curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
+    curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 06da3bf4c0462178948881f7f36048046c8f0b4a..53e0fc59d5ee70d88930e0fdffe6c3954e17ca68 100644 (file)
@@ -46,11 +46,14 @@ Fast Open is also known to be problematic on or across certain networks.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index de7a4ce7d720d8a5c397d4c74b82a0ba7b957a91..04e3ecb58afe6478a18153392973c0290b78684c 100644 (file)
@@ -43,20 +43,23 @@ disable keepalive probes
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* enable TCP keep-alive for this transfer */
-  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+    /* 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);
+    /* 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);
+    /* interval time between keep-alive probes: 60 seconds */
+    curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b99ecdbd2c15b31191e302b72d0e02b7844ae55f..f845b73c569e6e17887e73cbed1fe2313701dc5f 100644 (file)
@@ -44,20 +44,23 @@ this amount.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* enable TCP keep-alive for this transfer */
-  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+    /* enable TCP keep-alive for this transfer */
+    curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
 
-  /* set keep-alive idle time to 120 seconds */
-  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
+    /* set 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);
+    /* interval time between keep-alive probes: 60 seconds */
+    curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 86cc83e7e87fc292caa3cf8bdcaba24e2c1f96fb..e3bbbc24d9a6714a0206c0a1267349f6913d1bc7 100644 (file)
@@ -43,20 +43,23 @@ this amount.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* enable TCP keep-alive for this transfer */
-  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+    /* enable TCP keep-alive for this transfer */
+    curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
 
-  /* set keep-alive idle time to 120 seconds */
-  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
+    /* set 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);
+    /* interval time between keep-alive probes: 60 seconds */
+    curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index e0b79030efc2a11891b3ab75807779004970a66a..6166f7847c044ccf59b03f3047929e1fadd075e7 100644 (file)
@@ -52,12 +52,15 @@ overdone.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  /* leave Nagle enabled */
-  curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 0);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    /* leave Nagle enabled */
+    curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 0);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 480314ff5725ec5e168d4a3c8f3a4d198c91dceb..f42e5a42a36930ed7a641cbfbab553498f5caa31 100644 (file)
@@ -43,16 +43,20 @@ NULL
 TELNET
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  struct curl_slist *options;
-  options = curl_slist_append(NULL, "TTTYPE=vt100");
-  options = curl_slist_append(options, "USER=foobar");
-  curl_easy_setopt(curl, CURLOPT_URL, "telnet://example.com/");
-  curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, options);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
-  curl_slist_free_all(options);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    struct curl_slist *options;
+    options = curl_slist_append(NULL, "TTTYPE=vt100");
+    options = curl_slist_append(options, "USER=foobar");
+    curl_easy_setopt(curl, CURLOPT_URL, "telnet://example.com/");
+    curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, options);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+    curl_slist_free_all(options);
+  }
 }
 .fi
 .SH AVAILABILITY
index b6daf806f1d06e3074d976ba4976dd904c17d4ca..dcd3ea79a6fb26f478f2c3a797d402ee34ca8a13 100644 (file)
@@ -44,13 +44,17 @@ is used.
 TFTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/bootimage");
-  /* try using larger blocks */
-  curl_easy_setopt(curl, CURLOPT_TFTP_BLKSIZE, 2048L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/bootimage");
+    /* try using larger blocks */
+    curl_easy_setopt(curl, CURLOPT_TFTP_BLKSIZE, 2048L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index fc3b3b3f81d429890adc7a2c727f9c213d87f89e..70d4c3f44a72c0dbde10aa03d26cbc01be839196 100644 (file)
@@ -49,24 +49,27 @@ size_t write_callback(char *ptr, size_t size, size_t nmemb, void *fp)
   return fwrite(ptr, size, nmemb, (FILE *)fp);
 }
 
-CURL *curl = curl_easy_init();
-if(curl) {
-  FILE *fp = fopen("foo.bin", "wb");
-  if(fp) {
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)fp);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    FILE *fp = fopen("foo.bin", "wb");
+    if(fp) {
+      curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)fp);
+      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
 
-    curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/foo.bin");
+      curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/foo.bin");
 
-    /* do not send TFTP options requests */
-    curl_easy_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L);
+      /* do not send TFTP options requests */
+      curl_easy_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L);
 
-    /* Perform the request */
-    curl_easy_perform(curl);
+      /* Perform the request */
+      curl_easy_perform(curl);
 
-    fclose(fp);
+      fclose(fp);
+    }
+    curl_easy_cleanup(curl);
   }
-  curl_easy_cleanup(curl);
 }
 .fi
 .SH AVAILABILITY
index 4da79f5ef599b8b35400792218b0683a86571bb4..14c901a16901807be0d7b944c1f1f76e9c36c7ea 100644 (file)
@@ -47,19 +47,22 @@ CURL_TIMECOND_NONE (0)
 HTTP, FTP, RTSP, and FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* January 1, 2020 is 1577833200 */
-  curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
+    /* January 1, 2020 is 1577833200 */
+    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
 
-  /* If-Modified-Since the above time stamp */
-  curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
-                   (long)CURL_TIMECOND_IFMODSINCE);
+    /* If-Modified-Since the above time stamp */
+    curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
+                     (long)CURL_TIMECOND_IFMODSINCE);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c9fa4e05e60f0e10675c5f59aeeabc57d96cb6b4..3d608bab4db8147c3289335ef3933541e8a4dcee 100644 (file)
@@ -67,14 +67,17 @@ Default timeout is 0 (zero) which means it never times out during transfer.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* complete within 20 seconds */
-  curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L);
+    /* complete within 20 seconds */
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 4c0936c0fa4f410df395ea8888a46fc24b0d9497..a829881eb5375e00a31c0cfd56abbc8995d7c764 100644 (file)
@@ -42,14 +42,17 @@ Default timeout is 0 (zero) which means it never times out during transfer.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* complete within 20000 milliseconds */
-  curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L);
+    /* complete within 20000 milliseconds */
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9cca94228454726c74494366949b00bd0f9825b6..cf899e0ca532fe002d0f3e18f5aeb3e1e4453f15 100644 (file)
@@ -45,18 +45,21 @@ instead.
 HTTP, FTP, RTSP, and FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* January 1, 2020 is 1577833200 */
-  curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
+    /* January 1, 2020 is 1577833200 */
+    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
 
-  /* If-Modified-Since the above time stamp */
-  curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+    /* If-Modified-Since the above time stamp */
+    curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 75c58a0a3f557f0ec07b794f12c8830b8907c668..e3b7759d52473e7ffc102a375b8503b6558c254c 100644 (file)
@@ -46,18 +46,21 @@ to be used to set dates beyond the year 2038.
 HTTP, FTP, RTSP, and FILE
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* January 1, 2020 is 1577833200 */
-  curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, (curl_off_t)1577833200);
+    /* January 1, 2020 is 1577833200 */
+    curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, (curl_off_t)1577833200);
 
-  /* If-Modified-Since the above time stamp */
-  curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+    /* If-Modified-Since the above time stamp */
+    curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 7e6ec19b0a501f9463ba86f964236dd18b3ffbe3..d7450e154128058481311bb623e7e08ac5d67bb6 100644 (file)
@@ -53,13 +53,17 @@ NULL, use internal default
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_TLS13_CIPHERS,
-                   "TLS_CHACHA20_POLY1305_SHA256");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_TLS13_CIPHERS,
+                     "TLS_CHACHA20_POLY1305_SHA256");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 6e77e80efd659e426c5bc66e5c687068519ecd99..3170bff2d2f9fb5e7301ff33bff96494f5e5fbd6 100644 (file)
@@ -47,14 +47,18 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_TYPE, "SRP");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_TYPE, "SRP");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index c69185fbc1d2a8a6715b258d4f5e9aa662342480..ec743c3721681d507d3f62897cb09efed8c17539 100644 (file)
@@ -52,14 +52,18 @@ blank
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_TYPE, "SRP");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_TYPE, "SRP");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 47593e923274d773edca2f133184172ee27f8303..a604c1ef0a1b61dda186cf9b4399f3cc5a628dfe 100644 (file)
@@ -47,14 +47,18 @@ NULL
 All TLS-based protocols
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_TYPE, "SRP");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user");
-  curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_TYPE, "SRP");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user");
+    curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index fd7830de549cabd59f41daf80ba9f4883101347f..d355232398f9dff13846c51e638fa01efdc54582 100644 (file)
@@ -39,11 +39,18 @@ NULL
 HTTP
 .SH EXAMPLE
 .nf
-/* Assuming we have a CURL handle in the hndl variable. */
+struct MyData {
+  void *custom;
+};
 
-struct MyData data;
-
-curl_easy_setopt(hndl, CURLOPT_TRAILERDATA, &data);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct MyData data;
+    curl_easy_setopt(curl, CURLOPT_TRAILERDATA, &data);
+  }
+}
 .fi
 
 A more complete example can be found in examples/http_trailers.html
index 6c70b5e9c4261e9754b5a367e17f934bd680aa0d..020bfec9ec56821dbeec976571277fa8319f5189 100644 (file)
@@ -47,12 +47,16 @@ simply sets the mode to ASCII and performs a standard transfer.
 FTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/textfile");
-  curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/textfile");
+    curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9795174b938de1c78e915e2992195e18613165de..c472b7a8859981ffff1250b21a09ae7bfba14072 100644 (file)
@@ -51,11 +51,14 @@ by both HTTP clients and HTTP servers.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1L);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1L);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8b988f390928005cbf566900ebbdf9fc34a2ade2..534ae813b976f61fa1f2ee975bdc24389d330945 100644 (file)
@@ -56,16 +56,21 @@ Default is NULL, meaning that no Unix domain sockets are used.
 All protocols except for FILE and FTP are supported in theory. HTTP, IMAP,
 POP3 and SMTP should in particular work (including their SSL/TLS variants).
 .SH EXAMPLE
-Given that you have an HTTP server running listening on /tmp/httpd.sock, you
-can request an HTTP resource with:
-
 .nf
-  curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, "/tmp/httpd.sock");
-  curl_easy_setopt(curl_handle, CURLOPT_URL, "http://localhost/");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, "/tmp/httpd.sock");
+    curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/");
+
+    curl_easy_perform(curl);
+  }
+}
 .fi
 
 If you are on Linux and somehow have a need for paths larger than 107 bytes,
-you could use the proc filesystem to bypass the limitation:
+you can use the proc filesystem to bypass the limitation:
 
 .nf
   int dirfd = open(long_directory_path_to_socket, O_DIRECTORY | O_RDONLY);
index 64fac48e39b8dcfb7ca70ba01f91f78dcaab5a0e..d16f4eab53e763760f2e7545fc5b823020b53cc3 100644 (file)
@@ -57,12 +57,15 @@ redirecting to new hosts.
 HTTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-  curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L);
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+    curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 9b35194647387ff0016014e281e34ade0feddd6e..9af2e03ba33c06b8c0ce43acabfe30fc98bd63ab 100644 (file)
@@ -51,27 +51,30 @@ CURL_UPKEEP_INTERVAL_DEFAULT (currently defined as 60000L, which is 60 seconds)
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  /* Make a connection to an HTTP/2 server. */
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* Make a connection to an HTTP/2 server. */
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* Set the interval to 30000ms / 30s */
-  curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
+    /* Set the interval to 30000ms / 30s */
+    curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
 
-  /* Perform more work here. */
+    /* Perform more work here. */
 
-  /* While the connection is being held open, curl_easy_upkeep() can be
-     called. If curl_easy_upkeep() is called and the time since the last
-     upkeep exceeds the interval, then an HTTP/2 PING is sent. */
-  curl_easy_upkeep(curl);
+    /* While the connection is being held open, curl_easy_upkeep() can be
+       called. If curl_easy_upkeep() is called and the time since the last
+       upkeep exceeds the interval, then an HTTP/2 PING is sent. */
+    curl_easy_upkeep(curl);
 
-  /* Perform more work here. */
+    /* Perform more work here. */
 
-  /* always cleanup */
-  curl_easy_cleanup(curl);
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 14c67d496803235ba66fe6d0ce57e0a887f13ac2..e02295e703807fc2b18e3b1d9ecb0b6b130d4b2a 100644 (file)
@@ -52,25 +52,41 @@ transfer, you must specify the size of the data with
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  /* we want to use our own read function */
-  curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+  FILE *src = userdata;
+  /* copy as much data as possible into the 'ptr' buffer, but no more than
+     'size' * 'nmemb' bytes! */
+  size_t retcode = fread(ptr, size, nmemb, src);
 
-  /* enable uploading */
-  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+  return retcode;
+}
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    FILE *src = fopen("local-file", "r");
+    curl_off_t fsize; /* set this to the size of the input file */
+
+    /* we want to use our own read function */
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
+
+    /* enable uploading */
+    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
 
-  /* specify target */
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
+    /* specify target */
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
 
-  /* now specify which pointer to pass to our callback */
-  curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
+    /* now specify which pointer to pass to our callback */
+    curl_easy_setopt(curl, CURLOPT_READDATA, src);
 
-  /* Set the size of the file to upload */
-  curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
+    /* Set the size of the file to upload */
+    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
 
-  /* Now run off and do what you have been told! */
-  curl_easy_perform(curl);
+    /* Now run off and do what you have been told! */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index f571346806bd090dcb75ddafaaf969840b30b281..521daaee13223040843910ce81396bebcc41e6b3 100644 (file)
@@ -56,16 +56,20 @@ transfer as that may lead to unintended consequences.
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");
 
-  /* ask libcurl to allocate a larger upload buffer */
-  curl_easy_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 120000L);
+    /* ask libcurl to allocate a larger upload buffer */
+    curl_easy_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 120000L);
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b53025b6d4b836601e38ff1ad04dbe10ac28353d..9ef6913d886e72b1b917a0e15d3f3e5cd69af38b 100644 (file)
@@ -113,11 +113,14 @@ User provided URLs can also be made to point to sites that redirect further on
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
-
-  curl_easy_perform(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index b8955aaecd5581ff28a616c454d31fd538d60381..bcb6a3c63a77ba82b533318bed59ced42b3f85ff 100644 (file)
@@ -44,13 +44,16 @@ NULL, no User-Agent: header is used by default.
 HTTP, HTTPS
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0");
+    curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0");
 
-  curl_easy_perform(curl);
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index d72741e85a9df913af5b6ae4b3be0497323e5a14..a7e25e90b159c8f6c6953af5aa2065f67a67093b 100644 (file)
@@ -66,15 +66,19 @@ blank
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  curl_easy_setopt(curl, CURLOPT_USERNAME, "clark");
+    curl_easy_setopt(curl, CURLOPT_USERNAME, "clark");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index cbb1e00b2f9402d35c8b3ae6ee6838033e3e8d24..c63a98cc1d732c661162e8f8663f2ea19c51149c 100644 (file)
@@ -74,15 +74,19 @@ NULL
 Most
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
 
-  curl_easy_setopt(curl, CURLOPT_USERPWD, "clark:kent");
+    curl_easy_setopt(curl, CURLOPT_USERPWD, "clark:kent");
 
-  ret = curl_easy_perform(curl);
+    res = curl_easy_perform(curl);
 
-  curl_easy_cleanup(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 22465755e6af34563eed02029fa36143b7047615..837415ad7596421cf2efb184ea818452eeb7f1e3 100644 (file)
@@ -54,15 +54,18 @@ CURLUSESSL_NONE
 FTP, SMTP, POP3, IMAP, LDAP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext");
 
-  /* require use of SSL for this, or fail */
-  curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
+    /* require use of SSL for this, or fail */
+    curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 003a5eb1ec9c1f976d5c0bb01f5bc46777eb1e48..db1a756a3ad277ad5a8dd60545cfde7b91a80220 100644 (file)
@@ -48,15 +48,18 @@ To also get all the protocol data sent and received, consider using the
 All
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
 
-  /* ask libcurl to show us the verbose output */
-  curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+    /* ask libcurl to show us the verbose output */
+    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
-  /* Perform the request */
-  curl_easy_perform(curl);
+    /* Perform the request */
+    curl_easy_perform(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index be1c465a4a8c6c6883dbdfc777e7101c931ec594..75c5322f1153f3a2afc1c52defd139bfc3f3d6b8 100644 (file)
@@ -86,19 +86,26 @@ Using the rules above, a file name pattern can be constructed:
 This feature is only supported for FTP download.
 .SH EXAMPLE
 .nf
-/* initialization of easy handle */
-handle = curl_easy_init();
 
-/* turn on wildcard matching */
-curl_easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
+extern long begin_cb(struct curl_fileinfo *, void *, int);
+extern long end_cb(void *ptr);
 
-/* callback is called before download of concrete file started */
-curl_easy_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* turn on wildcard matching */
+    curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
 
-/* callback is called after data from the file have been transferred */
-curl_easy_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
+    /* callback is called before download of concrete file started */
+    curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, begin_cb);
 
-/* See more on https://curl.se/libcurl/c/ftp-wildcard.html */
+    /* callback is called after data from the file have been transferred */
+    curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, end_cb);
+
+    /* See more on https://curl.se/libcurl/c/ftp-wildcard.html */
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.21.0
index 138133ceaa4cd29ced7a2c02ade75957339caf9c..d992bde20b5a98e4c3038303670318f9d2127d61 100644 (file)
@@ -81,6 +81,9 @@ libcurl uses 'fwrite' as a callback by default.
 For all protocols
 .SH EXAMPLE
 .nf
+#include <stdlib.h> /* for realloc */
+#include <string.h> /* for memcpy */
+
 struct memory {
   char *response;
   size_t size;
@@ -92,7 +95,7 @@ static size_t cb(void *data, size_t size, size_t nmemb, void *clientp)
   struct memory *mem = (struct memory *)clientp;
 
   char *ptr = realloc(mem->response, mem->size + realsize + 1);
-  if(ptr == NULL)
+  if(!ptr)
     return 0;  /* out of memory! */
 
   mem->response = ptr;
@@ -103,25 +106,26 @@ static size_t cb(void *data, size_t size, size_t nmemb, void *clientp)
   return realsize;
 }
 
-struct memory chunk = {0};
-CURLcode res;
-CURL *curl_handle = curl_easy_init();
-
-if (curl_handle)
+int main(void)
 {
-  /* send all data to this function  */
-  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, cb);
+  struct memory chunk = {0};
+  CURLcode res;
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    /* send all data to this function  */
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb);
 
-  /* we pass our 'chunk' struct to the callback function */
-  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
+    /* we pass our 'chunk' struct to the callback function */
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
 
-  /* send a request */
-  res = curl_easy_perform(curl_handle);
+    /* send a request */
+    res = curl_easy_perform(curl);
 
-  /* remember to free the buffer */
-  free(chunk.response);
+    /* remember to free the buffer */
+    free(chunk.response);
 
-  curl_easy_cleanup(curl_handle);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8321ec66b983e808e2d4b340b409f021f383dbbc..3031b9524fcfd87b27f8d9b8d657e95e97d89cea 100644 (file)
@@ -52,13 +52,17 @@ application.
 WebSocket
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/");
-  /* tell curl we deal with all the WebSocket magic ourselves */
-  curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE);
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/");
+    /* tell curl we deal with all the WebSocket magic ourselves */
+    curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE);
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 5f04f967115d03bbbb6a51ccfde0f4c66158f238..4a03b9ccf453f8a1421c71abc51a85da2598129d 100644 (file)
@@ -42,30 +42,35 @@ The default value of this parameter is NULL.
 All
 .SH EXAMPLE
 .nf
- struct progress {
-   char *private;
-   size_t size;
- };
+struct progress {
+  char *private;
+  size_t size;
+};
 
- static size_t progress_callback(void *clientp,
-                                 curl_off_t dltotal,
-                                 curl_off_t dlnow,
-                                 curl_off_t ultotal,
-                                 curl_off_t ulnow)
- {
-   struct memory *progress = (struct progress *)clientp;
+static size_t progress_cb(void *clientp,
+                          curl_off_t dltotal,
+                          curl_off_t dlnow,
+                          curl_off_t ultotal,
+                          curl_off_t ulnow)
+{
+  struct progress *memory = clientp;
+  printf("private ptr: %p\\n", memory->private);
+  /* use the values */
 
-   /* use the values */
+  return 0; /* all is good */
+}
 
-   return 0; /* all is good */
- }
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct progress data;
 
- struct progress data;
-
- /* pass struct to callback  */
- curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, &data);
-
- curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, progress_callback);
+    /* pass struct to callback  */
+    curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data);
+    curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_cb);
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.32.0
index f339eed81226cad5a67b704f8e4eae9e7add9586..61521f391dfaac9b3dd347826d79d51ed727f5d8 100644 (file)
@@ -81,30 +81,37 @@ users.
 All
 .SH EXAMPLE
 .nf
- struct progress {
-   char *private;
-   size_t size;
- };
-
- static size_t progress_callback(void *clientp,
-                                 curl_off_t dltotal,
-                                 curl_off_t dlnow,
-                                 curl_off_t ultotal,
-                                 curl_off_t ulnow)
- {
-   struct progress *memory = (struct progress *)clientp;
-
-   /* use the values */
-
-   return 0; /* all is good */
- }
-
- struct progress data;
-
- /* pass struct to callback  */
- curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, &data);
-
- curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, progress_callback);
+struct progress {
+  char *private;
+  size_t size;
+};
+
+static size_t progress_callback(void *clientp,
+                                curl_off_t dltotal,
+                                curl_off_t dlnow,
+                                curl_off_t ultotal,
+                                curl_off_t ulnow)
+{
+  struct progress *memory = clientp;
+  printf("my ptr: %p\\n", memory->private);
+
+  /* use the values */
+
+  return 0; /* all is good */
+}
+
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    struct progress data;
+
+    /* pass struct to callback  */
+    curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data);
+
+    curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback);
+  }
+}
 .fi
 .SH AVAILABILITY
 Added in 7.32.0. This callback replaces \fICURLOPT_PROGRESSFUNCTION(3)\fP
index f495ac9358298c983e9ae18e51dd5b14523d600e..0dc5242fdb827801327cd9494145ee6e4a270fde 100644 (file)
@@ -47,12 +47,16 @@ NULL
 HTTP, IMAP, LDAP, POP3 and SMTP
 .SH EXAMPLE
 .nf
-CURL *curl = curl_easy_init();
-if(curl) {
-  curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/");
-  curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7");
-  ret = curl_easy_perform(curl);
-  curl_easy_cleanup(curl);
+int main(void)
+{
+  CURL *curl = curl_easy_init();
+  if(curl) {
+    CURLcode res;
+    curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/");
+    curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7");
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+  }
 }
 .fi
 .SH AVAILABILITY
index 8d146eb67d53f518a348d3196abc84c4a344ef5b..174326cb1eeddaa969018667d1cf316baf55f627 100644 (file)
@@ -55,11 +55,17 @@ This pointer is not used by libcurl itself.
 All
 .SH EXAMPLE
 .nf
+extern void mutex_lock(CURL *handle, curl_lock_data data,
+                       curl_lock_access access, void *clientp);
+
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, mutex_lock);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index d8f5dc87d3a4f3bbc5b2bf0b5b25239852af12b0..49f97604092cd0b16061ccc725b3642cdae33d01 100644 (file)
@@ -86,11 +86,14 @@ Added in 7.88.0
 All
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index 4b52ef3cb13a22212dedd64eecb83699a81f377c..1994b6fd9b3659ee3088f18d920d8c8232524fcc 100644 (file)
@@ -51,11 +51,16 @@ This pointer is not used by libcurl itself.
 All
 .SH EXAMPLE
 .nf
+extern void mutex_unlock(CURL *, curl_lock_data, void *);
+
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, mutex_unlock);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index d469920e10f23ef455dd5494e030ff479af6623a..e0d252bf3808d75bfbefdcad8305548c2df996ae 100644 (file)
@@ -55,11 +55,14 @@ The Public Suffix List is no longer shared.
 All
 .SH EXAMPLE
 .nf
+int main(void)
+{
   CURLSHcode sh;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_UNSHARE, CURL_LOCK_DATA_COOKIE);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index 8684fc3fda75831682712508229ec3a0d4dfcf7a..cb5347fe9a3441fe44b0492b1d72efc25fc14e3e 100644 (file)
@@ -38,12 +38,19 @@ the \fIclientp\fP argument to the callbacks set with
 All
 .SH EXAMPLE
 .nf
+struct secrets {
+  void *custom;
+};
+
+int main(void)
+{
   CURLSHcode sh;
   struct secrets private_stuff;
-  share = curl_share_init();
+  CURLSH *share = curl_share_init();
   sh = curl_share_setopt(share, CURLSHOPT_USERDATA, &private_stuff);
   if(sh)
     printf("Error: %s\\n", curl_share_strerror(sh));
+}
 .fi
 .SH AVAILABILITY
 Added in 7.10
index 94d90539bda51b64654feecdf7cc49db6e306ef8..cc24c05065f0cdc75b3f43c117ec97f2733982bb 100644 (file)
@@ -3211,6 +3211,7 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
 #include "options.h"
 #include "header.h"
 #include "websockets.h"
+#include "mprintf.h"
 
 /* the typechecker doesn't work in C++ (yet) */
 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && \