mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:11:40 +03:00
parent
7a1e99eefa
commit
0476e4fc65
149 changed files with 1381 additions and 1376 deletions
|
|
@ -81,7 +81,7 @@ static const char *urls[] = {
|
|||
};
|
||||
|
||||
#define MAX_PARALLEL 10 /* number of simultaneous transfers */
|
||||
#define NUM_URLS (sizeof(urls) / sizeof(char *))
|
||||
#define NUM_URLS (sizeof(urls) / sizeof(char *))
|
||||
|
||||
static size_t write_cb(char *data, size_t n, size_t l, void *userp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ static curl_socket_t opensocket(void *clientp,
|
|||
|
||||
if(ip && filter->type == CONNECTION_FILTER_BLACKLIST) {
|
||||
if(filter->verbose) {
|
||||
char buf[128] = {0};
|
||||
char buf[128] = { 0 };
|
||||
inet_ntop(address->family, cinaddr, buf, sizeof(buf));
|
||||
fprintf(stderr, "* Rejecting IP %s due to blacklist entry %s.\n",
|
||||
buf, ip->str);
|
||||
|
|
@ -277,7 +277,7 @@ static curl_socket_t opensocket(void *clientp,
|
|||
}
|
||||
else if(!ip && filter->type == CONNECTION_FILTER_WHITELIST) {
|
||||
if(filter->verbose) {
|
||||
char buf[128] = {0};
|
||||
char buf[128] = { 0 };
|
||||
inet_ntop(address->family, cinaddr, buf, sizeof(buf));
|
||||
fprintf(stderr,
|
||||
"* Rejecting IP %s due to missing whitelist entry.\n", buf);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer)
|
|||
BIO *cbio = BIO_new_mem_buf(mypem, sizeof(mypem));
|
||||
X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
|
||||
ossl_valsize_t i;
|
||||
STACK_OF(X509_INFO) *inf;
|
||||
STACK_OF(X509_INFO) * inf;
|
||||
|
||||
(void)curl;
|
||||
(void)pointer;
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ static CURL *make_handle(const char *url)
|
|||
/* HREF finder implemented in libxml2 but could be any HTML parser */
|
||||
static size_t follow_links(CURLM *multi, struct memory *mem, const char *url)
|
||||
{
|
||||
int opts = HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | \
|
||||
HTML_PARSE_NOWARNING | HTML_PARSE_NONET;
|
||||
int opts = HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING |
|
||||
HTML_PARSE_NONET;
|
||||
htmlDocPtr doc = htmlReadMemory(mem->buf, (int)mem->size, url, NULL, opts);
|
||||
size_t count;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ static void timer_cb(struct GlobalInfo *g, int revents)
|
|||
}
|
||||
|
||||
rc = curl_multi_socket_action(g->multi,
|
||||
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
|
||||
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
|
||||
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
|
||||
check_multi_info(g);
|
||||
}
|
||||
|
|
@ -303,7 +303,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
|||
{
|
||||
struct GlobalInfo *g = (struct GlobalInfo *)cbp;
|
||||
struct SockInfo *fdp = (struct SockInfo *)sockp;
|
||||
const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"};
|
||||
const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||
|
||||
fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||
if(what == CURL_POLL_REMOVE) {
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
|||
{
|
||||
struct GlobalInfo *g = (struct GlobalInfo *)cbp;
|
||||
struct SockInfo *fdp = (struct SockInfo *)sockp;
|
||||
const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"};
|
||||
const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||
|
||||
printf("%s e %p s %i what %i cbp %p sockp %p\n",
|
||||
__PRETTY_FUNCTION__, e, s, what, cbp, sockp);
|
||||
|
|
|
|||
|
|
@ -43,17 +43,17 @@
|
|||
#ifdef _WIN32
|
||||
#define close closesocket
|
||||
#else
|
||||
#include <sys/types.h> /* socket types */
|
||||
#include <sys/socket.h> /* socket definitions */
|
||||
#include <sys/types.h> /* socket types */
|
||||
#include <sys/socket.h> /* socket definitions */
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h> /* inet (3) functions */
|
||||
#include <unistd.h> /* misc. Unix functions */
|
||||
#include <arpa/inet.h> /* inet (3) functions */
|
||||
#include <unistd.h> /* misc. Unix functions */
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* The IP address and port number to connect to */
|
||||
#define IPADDR "127.0.0.1"
|
||||
#define IPADDR "127.0.0.1"
|
||||
#define PORTNUM 80
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ int main(int argc, char **argv)
|
|||
CURL *curl;
|
||||
|
||||
/* help data */
|
||||
struct callback_data data = {0};
|
||||
struct callback_data data = { 0 };
|
||||
|
||||
/* global initialization */
|
||||
CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ static size_t write_response(void *ptr, size_t size, size_t nmemb, void *data)
|
|||
return fwrite(ptr, size, nmemb, writehere);
|
||||
}
|
||||
|
||||
#define FTPBODY "ftp-list"
|
||||
#define FTPBODY "ftp-list"
|
||||
#define FTPHEADERS "ftp-responses"
|
||||
|
||||
int main(void)
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ struct FtpFile {
|
|||
FILE *stream;
|
||||
};
|
||||
|
||||
static size_t write_cb(void *buffer, size_t size, size_t nmemb,
|
||||
void *stream)
|
||||
static size_t write_cb(void *buffer, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
struct FtpFile *out = (struct FtpFile *)stream;
|
||||
if(!out->stream) {
|
||||
|
|
@ -53,7 +52,6 @@ static size_t write_cb(void *buffer, size_t size, size_t nmemb,
|
|||
return fwrite(buffer, size, nmemb, out->stream);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define LOCAL_FILE "/tmp/uploadthis.txt"
|
||||
#define UPLOAD_FILE_AS "while-uploading.txt"
|
||||
#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS
|
||||
#define RENAME_FILE_TO "renamed-and-fine.txt"
|
||||
#define LOCAL_FILE "/tmp/uploadthis.txt"
|
||||
#define UPLOAD_FILE_AS "while-uploading.txt"
|
||||
#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS
|
||||
#define RENAME_FILE_TO "renamed-and-fine.txt"
|
||||
|
||||
/* NOTE: if you want this example to work on Windows with libcurl as a DLL,
|
||||
you MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
|
|||
return n;
|
||||
}
|
||||
|
||||
|
||||
static int upload(CURL *curl, const char *remotepath,
|
||||
const char *localpath, long timeout, long tries)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@
|
|||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#define MSG_OUT g_print /* Change to "g_error" to write to stderr */
|
||||
#define SHOW_VERBOSE 0L /* Set to non-zero for libcurl messages */
|
||||
#define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */
|
||||
#define MSG_OUT g_print /* Change to "g_error" to write to stderr */
|
||||
#define SHOW_VERBOSE 0L /* Set to non-zero for libcurl messages */
|
||||
#define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */
|
||||
|
||||
/* Global information, common to all connections */
|
||||
struct GlobalInfo {
|
||||
|
|
@ -261,7 +261,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
|||
{
|
||||
struct GlobalInfo *g = (struct GlobalInfo *)cbp;
|
||||
struct SockInfo *fdp = (struct SockInfo *)sockp;
|
||||
static const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"};
|
||||
static const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||
|
||||
MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||
if(what == CURL_POLL_REMOVE) {
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
|||
{
|
||||
struct GlobalInfo *g = (struct GlobalInfo *)cbp;
|
||||
struct SockInfo *fdp = (struct SockInfo *)sockp;
|
||||
const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"};
|
||||
const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||
|
||||
fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||
if(what == CURL_POLL_REMOVE) {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ int main(void)
|
|||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
struct state st = {0};
|
||||
struct state st = { 0 };
|
||||
|
||||
/* enable HSTS for this handle */
|
||||
curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, CURLHSTS_ENABLE);
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ int main(int argc, char **argv)
|
|||
CURL *curl;
|
||||
char curl_errbuf[CURL_ERROR_SIZE];
|
||||
TidyDoc tdoc;
|
||||
TidyBuffer docbuf = {0};
|
||||
TidyBuffer tidy_errbuf = {0};
|
||||
TidyBuffer docbuf = { 0 };
|
||||
TidyBuffer tidy_errbuf = { 0 };
|
||||
CURLcode res;
|
||||
|
||||
if(argc != 2) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
//
|
||||
// libxml callback context structure
|
||||
//
|
||||
|
||||
struct Context {
|
||||
Context() : addTitle(false) {}
|
||||
|
||||
|
|
@ -71,7 +70,6 @@ static std::string buffer;
|
|||
//
|
||||
// libcurl write callback function
|
||||
//
|
||||
|
||||
static size_t writer(char *data, size_t size, size_t nmemb,
|
||||
std::string *writerData)
|
||||
{
|
||||
|
|
@ -86,7 +84,6 @@ static size_t writer(char *data, size_t size, size_t nmemb,
|
|||
//
|
||||
// libcurl connection initialization
|
||||
//
|
||||
|
||||
static bool init(CURL *&curl, const char *url)
|
||||
{
|
||||
CURLcode res;
|
||||
|
|
@ -134,7 +131,6 @@ static bool init(CURL *&curl, const char *url)
|
|||
//
|
||||
// libxml start element callback function
|
||||
//
|
||||
|
||||
static void StartElement(void *voidContext,
|
||||
const xmlChar *name,
|
||||
const xmlChar **attributes)
|
||||
|
|
@ -151,7 +147,6 @@ static void StartElement(void *voidContext,
|
|||
//
|
||||
// libxml end element callback function
|
||||
//
|
||||
|
||||
static void EndElement(void *voidContext,
|
||||
const xmlChar *name)
|
||||
{
|
||||
|
|
@ -164,7 +159,6 @@ static void EndElement(void *voidContext,
|
|||
//
|
||||
// Text handling helper function
|
||||
//
|
||||
|
||||
static void handleCharacters(Context *context,
|
||||
const xmlChar *chars,
|
||||
int length)
|
||||
|
|
@ -177,7 +171,6 @@ static void handleCharacters(Context *context,
|
|||
//
|
||||
// libxml PCDATA callback function
|
||||
//
|
||||
|
||||
static void Characters(void *voidContext,
|
||||
const xmlChar *chars,
|
||||
int length)
|
||||
|
|
@ -190,7 +183,6 @@ static void Characters(void *voidContext,
|
|||
//
|
||||
// libxml CDATA callback function
|
||||
//
|
||||
|
||||
static void cdata(void *voidContext,
|
||||
const xmlChar *chars,
|
||||
int length)
|
||||
|
|
@ -203,9 +195,7 @@ static void cdata(void *voidContext,
|
|||
//
|
||||
// libxml SAX callback structure
|
||||
//
|
||||
|
||||
static htmlSAXHandler saxHandler =
|
||||
{
|
||||
static htmlSAXHandler saxHandler = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
@ -243,7 +233,6 @@ static htmlSAXHandler saxHandler =
|
|||
//
|
||||
// Parse given (assumed to be) HTML text and return the title
|
||||
//
|
||||
|
||||
static void parseHtml(const std::string &html,
|
||||
std::string &title)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,10 +200,10 @@ int main(int argc, char **argv)
|
|||
/* if given a number, do that many transfers */
|
||||
num_transfers = atoi(argv[1]);
|
||||
if((num_transfers < 1) || (num_transfers > 1000))
|
||||
num_transfers = 3; /* a suitable low default */
|
||||
num_transfers = 3; /* a suitable low default */
|
||||
}
|
||||
else
|
||||
num_transfers = 3; /* a suitable low default */
|
||||
num_transfers = 3; /* a suitable low default */
|
||||
|
||||
res = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if(res)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ static int setup(CURL *curl, const char *url)
|
|||
{
|
||||
out_download = fopen(OUTPUTFILE, "wb");
|
||||
if(!out_download)
|
||||
return 1; /* failed */
|
||||
return 1; /* failed */
|
||||
|
||||
/* set the same URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ static int my_gettimeofday(struct timeval *tp, void *tzp)
|
|||
{
|
||||
(void)tzp;
|
||||
if(tp) {
|
||||
/* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */
|
||||
#define WIN32_FT_OFFSET (116444736000000000)
|
||||
/* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */
|
||||
#define WIN32_FT_OFFSET (116444736000000000)
|
||||
union {
|
||||
CURL_TYPEOF_CURL_OFF_T ns100; /* time since 1 Jan 1601 in 100ns units */
|
||||
FILETIME ft;
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@
|
|||
* Note that this example requires libcurl 7.30.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
|
||||
static const char *payload_text =
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
|
||||
|
|
@ -95,7 +95,7 @@ int main(void)
|
|||
if(curl) {
|
||||
size_t filesize;
|
||||
long infilesize = LONG_MAX;
|
||||
struct upload_status upload_ctx = {0};
|
||||
struct upload_status upload_ctx = { 0 };
|
||||
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ int main(void)
|
|||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
const char *urls[] = { "https://example.com",
|
||||
const char *urls[] = {
|
||||
"https://example.com",
|
||||
"https://curl.se",
|
||||
"https://www.example/",
|
||||
NULL /* end of list */
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#define HTTP_HANDLE 0 /* Index for the HTTP transfer */
|
||||
#define FTP_HANDLE 1 /* Index for the FTP transfer */
|
||||
#define FTP_HANDLE 1 /* Index for the FTP transfer */
|
||||
#define HANDLECOUNT 2 /* Number of simultaneous transfers */
|
||||
|
||||
int main(void)
|
||||
|
|
|
|||
|
|
@ -183,8 +183,8 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp,
|
|||
case CURL_POLL_IN:
|
||||
case CURL_POLL_OUT:
|
||||
case CURL_POLL_INOUT:
|
||||
curl_context = socketp ?
|
||||
(struct curl_context *)socketp : create_curl_context(s);
|
||||
curl_context =
|
||||
socketp ? (struct curl_context *)socketp : create_curl_context(s);
|
||||
|
||||
curl_multi_assign(multi, s, (void *)curl_context);
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp,
|
|||
|
||||
event_del(curl_context->event);
|
||||
event_assign(curl_context->event, base, curl_context->sockfd,
|
||||
(short)events, curl_perform, curl_context);
|
||||
(short)events, curl_perform, curl_context);
|
||||
event_add(curl_context->event, NULL);
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@
|
|||
* Download an HTTP file and upload an FTP file simultaneously.
|
||||
*/
|
||||
|
||||
#define HTTP_HANDLE 0 /* Index for the HTTP transfer */
|
||||
#define FTP_HANDLE 1 /* Index for the FTP transfer */
|
||||
#define HANDLECOUNT 2 /* Number of simultaneous transfers */
|
||||
#define HTTP_HANDLE 0 /* Index for the HTTP transfer */
|
||||
#define FTP_HANDLE 1 /* Index for the FTP transfer */
|
||||
#define HANDLECOUNT 2 /* Number of simultaneous transfers */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ int main(void)
|
|||
rc = 0;
|
||||
#else
|
||||
/* Portable sleep for platforms other than Windows. */
|
||||
struct timeval wait = {0};
|
||||
struct timeval wait = { 0 };
|
||||
wait.tv_usec = 100 * 1000; /* 100ms */
|
||||
rc = select(0, NULL, NULL, NULL, &wait);
|
||||
#endif
|
||||
|
|
@ -155,7 +155,7 @@ int main(void)
|
|||
case -1:
|
||||
/* select error */
|
||||
break;
|
||||
case 0: /* timeout */
|
||||
case 0: /* timeout */
|
||||
default: /* action */
|
||||
curl_multi_perform(multi, &still_running);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action,
|
|||
case CURL_POLL_IN:
|
||||
case CURL_POLL_OUT:
|
||||
case CURL_POLL_INOUT:
|
||||
curl_context = socketp ?
|
||||
(struct curl_context *)socketp : create_curl_context(s, uv);
|
||||
curl_context =
|
||||
socketp ? (struct curl_context *)socketp : create_curl_context(s, uv);
|
||||
|
||||
curl_multi_assign(uv->multi, s, (void *)curl_context);
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action,
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
CURLcode res;
|
||||
struct datauv uv = {0};
|
||||
struct datauv uv = { 0 };
|
||||
int running_handles;
|
||||
|
||||
if(argc <= 1)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
https://curl.se/libcurl/c/threadsafe.html
|
||||
|
||||
*/
|
||||
static const char * const urls[NUMT]= {
|
||||
static const char * const urls[NUMT] = {
|
||||
"https://curl.se/",
|
||||
"ftp://example.com/",
|
||||
"https://example.net/",
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
/* silly test data to POST */
|
||||
static const char data[]="Lorem ipsum dolor sit amet, consectetur adipiscing "
|
||||
"elit. Sed vel urna neque. Ut quis leo metus. Quisque eleifend, ex at "
|
||||
static const char data[] =
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
|
||||
"Sed vel urna neque. Ut quis leo metus. Quisque eleifend, ex at "
|
||||
"laoreet rhoncus, odio ipsum semper metus, at tempus ante urna in mauris. "
|
||||
"Suspendisse ornare tempor venenatis. Ut dui neque, pellentesque a ______ "
|
||||
"eget, mattis vitae ligula. Fusce ut pharetra est. Ut ullamcorper mi ac "
|
||||
|
|
@ -61,7 +62,7 @@ static size_t read_cb(char *dest, size_t size, size_t nmemb, void *userp)
|
|||
return copy_this_much; /* we copied this many bytes */
|
||||
}
|
||||
|
||||
return 0; /* no more data left to deliver */
|
||||
return 0; /* no more data left to deliver */
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ int main(void)
|
|||
return (int)res;
|
||||
|
||||
chunk.memory = malloc(1); /* grown as needed by realloc above */
|
||||
chunk.size = 0; /* no data at this point */
|
||||
chunk.size = 0; /* no data at this point */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000
|
||||
#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES 6000
|
||||
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000
|
||||
#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES 6000
|
||||
|
||||
struct myprogress {
|
||||
curl_off_t lastruntime; /* type depends on version, see above */
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@
|
|||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#if !CURL_AT_LEAST_VERSION(7,87,0)
|
||||
#if !CURL_AT_LEAST_VERSION(7, 87, 0)
|
||||
#error "too old libcurl"
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
curl_version_info_data *ver;
|
||||
const char *const *ptr;
|
||||
const char * const *ptr;
|
||||
|
||||
CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if(res)
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ int main(void)
|
|||
do {
|
||||
nsent = 0;
|
||||
res = curl_easy_send(curl, request + nsent_total,
|
||||
request_len - nsent_total, &nsent);
|
||||
request_len - nsent_total, &nsent);
|
||||
nsent_total += nsent;
|
||||
|
||||
if(res == CURLE_AGAIN && !wait_on_socket(sockfd, 0, 60000L)) {
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||
gnutls_x509_crt_import(cert, &chainp[i], GNUTLS_X509_FMT_DER)) {
|
||||
if(GNUTLS_E_SUCCESS ==
|
||||
gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_FULL, &dn)) {
|
||||
fprintf(stderr, "Certificate #%u: %.*s", i,
|
||||
(int)dn.size, dn.data);
|
||||
fprintf(stderr, "Certificate #%u: %.*s", i, (int)dn.size,
|
||||
dn.data);
|
||||
|
||||
gnutls_free(dn.data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@
|
|||
/* The libcurl options want plain addresses, the viewable headers in the mail
|
||||
* can get a full name as well.
|
||||
*/
|
||||
#define FROM_ADDR "<ursel@example.org>"
|
||||
#define SENDER_ADDR "<kurt@example.org>"
|
||||
#define TO_ADDR "<addressee@example.net>"
|
||||
#define FROM_ADDR "<ursel@example.org>"
|
||||
#define SENDER_ADDR "<kurt@example.org>"
|
||||
#define TO_ADDR "<addressee@example.net>"
|
||||
|
||||
#define FROM_MAIL "Ursel " FROM_ADDR
|
||||
#define SENDER_MAIL "Kurt " SENDER_ADDR
|
||||
#define TO_MAIL "A Receiver " TO_ADDR
|
||||
#define FROM_MAIL "Ursel " FROM_ADDR
|
||||
#define SENDER_MAIL "Kurt " SENDER_ADDR
|
||||
#define TO_MAIL "A Receiver " TO_ADDR
|
||||
|
||||
static const char *payload_text =
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
|
||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx = {0};
|
||||
struct upload_status upload_ctx = { 0 };
|
||||
|
||||
/* This is the URL for your mailserver. In this example we connect to the
|
||||
smtp-submission port as we require an authenticated connection. */
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
/* The libcurl options want plain addresses, the viewable headers in the mail
|
||||
* can get a full name as well.
|
||||
*/
|
||||
#define FROM_ADDR "<sender@example.org>"
|
||||
#define TO_ADDR "<addressee@example.net>"
|
||||
#define CC_ADDR "<info@example.org>"
|
||||
#define FROM_ADDR "<sender@example.org>"
|
||||
#define TO_ADDR "<addressee@example.net>"
|
||||
#define CC_ADDR "<info@example.org>"
|
||||
|
||||
#define FROM_MAIL "Sender Person " FROM_ADDR
|
||||
#define TO_MAIL "A Receiver " TO_ADDR
|
||||
|
|
@ -96,7 +96,7 @@ int main(void)
|
|||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx = {0};
|
||||
struct upload_status upload_ctx = { 0 };
|
||||
|
||||
/* This is the URL for your mailserver */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
* Note that this example requires libcurl 7.56.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
#define FROM "<sender@example.org>"
|
||||
#define TO "<addressee@example.net>"
|
||||
#define CC "<info@example.org>"
|
||||
|
||||
static const char *headers_text[] = {
|
||||
"Date: Tue, 22 Aug 2017 14:08:43 +0100",
|
||||
|
|
@ -47,7 +47,7 @@ static const char *headers_text[] = {
|
|||
"From: " FROM " (Example User)",
|
||||
"Cc: " CC " (Another example User)",
|
||||
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
|
||||
"rfcpedant.example.org>",
|
||||
"rfcpedant.example.org>",
|
||||
"Subject: example sending a MIME-formatted message",
|
||||
NULL
|
||||
};
|
||||
|
|
@ -66,7 +66,6 @@ static const char inline_html[] =
|
|||
"email viewers able to handle HTML.</p>"
|
||||
"</body></html>\r\n";
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@
|
|||
* libcurl's multi interface.
|
||||
*/
|
||||
|
||||
#define FROM_MAIL "<sender@example.com>"
|
||||
#define TO_MAIL "<recipient@example.com>"
|
||||
#define CC_MAIL "<info@example.com>"
|
||||
#define FROM_MAIL "<sender@example.com>"
|
||||
#define TO_MAIL "<recipient@example.com>"
|
||||
#define CC_MAIL "<info@example.com>"
|
||||
|
||||
static const char *payload_text =
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
|
||||
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
if(multi) {
|
||||
int still_running = 1;
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx = {0};
|
||||
struct upload_status upload_ctx = { 0 };
|
||||
|
||||
/* This is the URL for your mailserver */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@
|
|||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM_MAIL "<sender@example.com>"
|
||||
#define TO_MAIL "<recipient@example.com>"
|
||||
#define CC_MAIL "<info@example.com>"
|
||||
#define FROM_MAIL "<sender@example.com>"
|
||||
#define TO_MAIL "<recipient@example.com>"
|
||||
#define CC_MAIL "<info@example.com>"
|
||||
|
||||
static const char *payload_text =
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
|
||||
|
|
@ -93,7 +93,7 @@ int main(void)
|
|||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx = {0};
|
||||
struct upload_status upload_ctx = { 0 };
|
||||
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@
|
|||
* Note that this example requires libcurl 7.20.0 or above.
|
||||
*/
|
||||
|
||||
#define FROM_MAIL "<sender@example.com>"
|
||||
#define TO_MAIL "<recipient@example.com>"
|
||||
#define CC_MAIL "<info@example.com>"
|
||||
#define FROM_MAIL "<sender@example.com>"
|
||||
#define TO_MAIL "<recipient@example.com>"
|
||||
#define CC_MAIL "<info@example.com>"
|
||||
|
||||
static const char *payload_text =
|
||||
"Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n"
|
||||
|
|
@ -93,7 +93,7 @@ int main(void)
|
|||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
struct curl_slist *recipients = NULL;
|
||||
struct upload_status upload_ctx = {0};
|
||||
struct upload_status upload_ctx = { 0 };
|
||||
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@
|
|||
*/
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), gmtime(),
|
||||
localtime(), sscanf() */
|
||||
#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), gmtime(),
|
||||
localtime(), sscanf() */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -74,9 +74,9 @@ int main(void)
|
|||
#else
|
||||
|
||||
#if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
|
||||
defined(WINAPI_FAMILY)
|
||||
defined(WINAPI_FAMILY)
|
||||
# include <winapifamily.h>
|
||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
||||
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
# define CURL_WINDOWS_UWP
|
||||
# endif
|
||||
|
|
@ -100,8 +100,8 @@ int main(void)
|
|||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define MAX_STRING 256
|
||||
#define MAX_STRING1 MAX_STRING + 1
|
||||
#define MAX_STRING 256
|
||||
#define MAX_STRING1 MAX_STRING + 1
|
||||
|
||||
#define SYNCTIME_UA "synctime/1.0"
|
||||
|
||||
|
|
@ -111,8 +111,7 @@ struct conf {
|
|||
char timeserver[MAX_STRING1];
|
||||
};
|
||||
|
||||
static const char DefaultTimeServer[3][MAX_STRING1] =
|
||||
{
|
||||
static const char DefaultTimeServer[3][MAX_STRING1] = {
|
||||
"https://nist.time.gov/",
|
||||
"https://www.google.com/"
|
||||
};
|
||||
|
|
@ -128,8 +127,8 @@ static int AutoSyncTime;
|
|||
static SYSTEMTIME SYSTime;
|
||||
static SYSTEMTIME LOCALTime;
|
||||
|
||||
#define HTTP_COMMAND_HEAD 0
|
||||
#define HTTP_COMMAND_GET 1
|
||||
#define HTTP_COMMAND_HEAD 0
|
||||
#define HTTP_COMMAND_GET 1
|
||||
|
||||
static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
|
|
@ -167,17 +166,17 @@ static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
|
|||
|
||||
if(RetVal == 7) {
|
||||
int i;
|
||||
SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */
|
||||
SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */
|
||||
for(i = 0; i < 12; i++) {
|
||||
if(strcmp(MthStr[i], TmpStr2) == 0) {
|
||||
SYSTime.wMonth = (WORD)(i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AutoSyncTime = 3; /* Computer clock is adjusted */
|
||||
AutoSyncTime = 3; /* Computer clock is adjusted */
|
||||
}
|
||||
else {
|
||||
AutoSyncTime = 0; /* Error in sscanf() fields conversion */
|
||||
AutoSyncTime = 0; /* Error in sscanf() fields conversion */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +221,7 @@ static CURLcode SyncTime_CURL_Fetch(CURL *curl, const char *URL_Str,
|
|||
res = curl_easy_perform(curl);
|
||||
if(outfile)
|
||||
fclose(outfile);
|
||||
return res; /* (CURLE_OK) */
|
||||
return res; /* (CURLE_OK) */
|
||||
}
|
||||
|
||||
static void showUsage(void)
|
||||
|
|
@ -251,7 +250,7 @@ static int conf_init(struct conf *conf)
|
|||
|
||||
*conf->http_proxy = 0;
|
||||
for(i = 0; i < MAX_STRING1; i++)
|
||||
conf->proxy_user[i] = 0; /* Clean up password from memory */
|
||||
conf->proxy_user[i] = 0; /* Clean up password from memory */
|
||||
*conf->timeserver = 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -263,9 +262,9 @@ int main(int argc, char *argv[])
|
|||
struct conf conf[1];
|
||||
int RetValue;
|
||||
|
||||
ShowAllHeader = 0; /* Do not show HTTP Header */
|
||||
AutoSyncTime = 0; /* Do not synchronise computer clock */
|
||||
RetValue = 0; /* Successful Exit */
|
||||
ShowAllHeader = 0; /* Do not show HTTP Header */
|
||||
AutoSyncTime = 0; /* Do not synchronise computer clock */
|
||||
RetValue = 0; /* Successful Exit */
|
||||
conf_init(conf);
|
||||
|
||||
if(argc > 1) {
|
||||
|
|
@ -295,7 +294,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if(*conf->timeserver == 0) /* Use default server for time information */
|
||||
if(*conf->timeserver == 0) /* Use default server for time information */
|
||||
snprintf(conf->timeserver, MAX_STRING, "%s", DefaultTimeServer[0]);
|
||||
|
||||
/* Init CURL before usage */
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ static size_t write_cb(char *b, size_t size, size_t nitems, void *p)
|
|||
CURL *curl = p;
|
||||
size_t i;
|
||||
const struct curl_ws_frame *frame = curl_ws_meta(curl);
|
||||
fprintf(stderr, "Type: %s\n", frame->flags & CURLWS_BINARY ?
|
||||
"binary" : "text");
|
||||
fprintf(stderr, "Type: %s\n",
|
||||
frame->flags & CURLWS_BINARY ? "binary" : "text");
|
||||
fprintf(stderr, "Bytes: %u", (unsigned int)(nitems * size));
|
||||
for(i = 0; i < nitems; i++)
|
||||
fprintf(stderr, "%02x ", (unsigned char)b[i]);
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ static size_t write_cb(char *b, size_t size, size_t nitems, void *p)
|
|||
size_t i;
|
||||
unsigned int blen = (unsigned int)(nitems * size);
|
||||
const struct curl_ws_frame *frame = curl_ws_meta(curl);
|
||||
fprintf(stderr, "Type: %s\n", frame->flags & CURLWS_BINARY ?
|
||||
"binary" : "text");
|
||||
fprintf(stderr, "Type: %s\n",
|
||||
frame->flags & CURLWS_BINARY ? "binary" : "text");
|
||||
if(frame->flags & CURLWS_BINARY) {
|
||||
fprintf(stderr, "Bytes: %u", blen);
|
||||
for(i = 0; i < nitems; i++)
|
||||
|
|
@ -111,7 +111,6 @@ int main(int argc, const char *argv[])
|
|||
curl_easy_setopt(curl, CURLOPT_READDATA, &rctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
|
||||
/* Perform the request, res gets the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
/* Check for errors */
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ static CURLcode ping(CURL *curl, const char *send_payload)
|
|||
buf += sent; /* deduct what was sent */
|
||||
blen -= sent;
|
||||
}
|
||||
else if(res == CURLE_AGAIN) { /* blocked on sending */
|
||||
else if(res == CURLE_AGAIN) { /* blocked on sending */
|
||||
fprintf(stderr, "ws: sent PING blocked, waiting a second\n");
|
||||
sleep(1); /* either select() on socket or max timeout would
|
||||
be good here. */
|
||||
sleep(1); /* either select() on socket or max timeout would
|
||||
be good here. */
|
||||
}
|
||||
else /* real error sending */
|
||||
break;
|
||||
|
|
@ -85,8 +85,7 @@ retry:
|
|||
same ? "same" : "different");
|
||||
}
|
||||
else if(meta->flags & CURLWS_TEXT) {
|
||||
fprintf(stderr, "ws: received TEXT frame '%.*s'\n", (int)rlen,
|
||||
buffer);
|
||||
fprintf(stderr, "ws: received TEXT frame '%.*s'\n", (int)rlen, buffer);
|
||||
}
|
||||
else if(meta->flags & CURLWS_BINARY) {
|
||||
fprintf(stderr, "ws: received BINARY frame of %u bytes\n",
|
||||
|
|
@ -99,10 +98,10 @@ retry:
|
|||
goto retry;
|
||||
}
|
||||
}
|
||||
else if(res == CURLE_AGAIN) { /* blocked on receiving */
|
||||
else if(res == CURLE_AGAIN) { /* blocked on receiving */
|
||||
fprintf(stderr, "ws: PONG not there yet, waiting a second\n");
|
||||
sleep(1); /* either select() on socket or max timeout would
|
||||
be good here. */
|
||||
sleep(1); /* either select() on socket or max timeout would
|
||||
be good here. */
|
||||
goto retry;
|
||||
}
|
||||
if(res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue