Fixed some compile warnings and errors and improved portability in the
examples. Removed ftp3rdparty.c since libcurl doesn't support 3rd party FTP transfers any longer.
This commit is contained in:
7
CHANGES
7
CHANGES
@@ -6,6 +6,13 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Dan F (12 July 2007)
|
||||||
|
- Compile most of the example apps in docs/examples when doing a 'make check'.
|
||||||
|
Fixed some compile warnings and errors in those examples.
|
||||||
|
|
||||||
|
- Removed the example program ftp3rdparty.c since libcurl doesn't support
|
||||||
|
3rd party FTP transfers any longer.
|
||||||
|
|
||||||
Daniel S (12 July 2007)
|
Daniel S (12 July 2007)
|
||||||
- Shmulik Regev found an (albeit rare) case where the proxy CONNECT operation
|
- Shmulik Regev found an (albeit rare) case where the proxy CONNECT operation
|
||||||
could in fact get stuck in an endless loop.
|
could in fact get stuck in an endless loop.
|
||||||
|
|||||||
@@ -135,4 +135,5 @@ int main(void)
|
|||||||
|
|
||||||
curl_easy_cleanup(ch);
|
curl_easy_cleanup(ch);
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ main(void)
|
|||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#endif
|
#endif
|
||||||
/* Netscape format cookie */
|
/* Netscape format cookie */
|
||||||
snprintf(nline, 256, "%s\t%s\t%s\t%s\t%u\t%s\t%s",
|
snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%u\t%s\t%s",
|
||||||
".google.com", "TRUE", "/", "FALSE", time(NULL) + 31337, "PREF", "hello google, i like you very much!");
|
".google.com", "TRUE", "/", "FALSE", time(NULL) + 31337, "PREF", "hello google, i like you very much!");
|
||||||
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
||||||
if (res != CURLE_OK) {
|
if (res != CURLE_OK) {
|
||||||
@@ -83,7 +83,7 @@ main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* HTTP-header style cookie */
|
/* HTTP-header style cookie */
|
||||||
snprintf(nline, 256,
|
snprintf(nline, sizeof(nline),
|
||||||
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
|
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
|
||||||
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com");
|
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com");
|
||||||
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
#include <openssl/x509_vfy.h>
|
#include <openssl/x509_vfy.h>
|
||||||
@@ -94,13 +95,13 @@
|
|||||||
#include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
static char *curlx_usage[]={
|
static const char *curlx_usage[]={
|
||||||
"usage: curlx args\n",
|
"usage: curlx args\n",
|
||||||
" -p12 arg - tia file ",
|
" -p12 arg - tia file ",
|
||||||
" -envpass arg - environement variable which content the tia private key password",
|
" -envpass arg - environement variable which content the tia private key password",
|
||||||
" -out arg - output file (response)- default stdout",
|
" -out arg - output file (response)- default stdout",
|
||||||
" -in arg - input file (request)- default stdin",
|
" -in arg - input file (request)- default stdin",
|
||||||
" -connect arg - URL of the server for the connection ex: www.openevidenve.org",
|
" -connect arg - URL of the server for the connection ex: www.openevidence.org",
|
||||||
" -mimetype arg - MIME type for data in ex : application/timestamp-query or application/dvcs -default application/timestamp-query",
|
" -mimetype arg - MIME type for data in ex : application/timestamp-query or application/dvcs -default application/timestamp-query",
|
||||||
" -acceptmime arg - MIME type acceptable for the response ex : application/timestamp-response or application/dvcs -default none",
|
" -acceptmime arg - MIME type acceptable for the response ex : application/timestamp-response or application/dvcs -default none",
|
||||||
" -accesstype arg - an Object identifier in an AIA/SIA method, e.g. AD_DVCS or ad_timestamping",
|
" -accesstype arg - an Object identifier in an AIA/SIA method, e.g. AD_DVCS or ad_timestamping",
|
||||||
@@ -268,19 +269,21 @@ int main(int argc, char **argv) {
|
|||||||
char* mimetype;
|
char* mimetype;
|
||||||
char* mimetypeaccept=NULL;
|
char* mimetypeaccept=NULL;
|
||||||
char* contenttype;
|
char* contenttype;
|
||||||
char** pp;
|
const char** pp;
|
||||||
unsigned char* hostporturl = NULL;
|
unsigned char* hostporturl = NULL;
|
||||||
binaryptr=(char*)malloc(tabLength);
|
|
||||||
BIO * p12bio ;
|
BIO * p12bio ;
|
||||||
char **args = argv + 1;
|
char **args = argv + 1;
|
||||||
unsigned char * serverurl;
|
unsigned char * serverurl;
|
||||||
sslctxparm p;
|
sslctxparm p;
|
||||||
char *response;
|
char *response;
|
||||||
p.verbose = 0;
|
|
||||||
|
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
struct curl_slist * headers=NULL;
|
struct curl_slist * headers=NULL;
|
||||||
|
int badarg=0;
|
||||||
|
|
||||||
|
binaryptr=(char*)malloc(tabLength);
|
||||||
|
|
||||||
|
p.verbose = 0;
|
||||||
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
|
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
@@ -292,7 +295,6 @@ int main(int argc, char **argv) {
|
|||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
|
|
||||||
|
|
||||||
int badarg=0;
|
|
||||||
|
|
||||||
while (*args && *args[0] == '-') {
|
while (*args && *args[0] == '-') {
|
||||||
if (!strcmp (*args, "-in")) {
|
if (!strcmp (*args, "-in")) {
|
||||||
@@ -407,10 +409,9 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
else if (p.accesstype != 0) { /* see whether we can find an AIA or SIA for a given access type */
|
else if (p.accesstype != 0) { /* see whether we can find an AIA or SIA for a given access type */
|
||||||
if (!(serverurl = my_get_ext(p.usercert,p.accesstype,NID_info_access))) {
|
if (!(serverurl = my_get_ext(p.usercert,p.accesstype,NID_info_access))) {
|
||||||
|
int j=0;
|
||||||
BIO_printf(p.errorbio,"no service URL in user cert "
|
BIO_printf(p.errorbio,"no service URL in user cert "
|
||||||
"cherching in others certificats\n");
|
"cherching in others certificats\n");
|
||||||
int j=0;
|
|
||||||
int find=0;
|
|
||||||
for (j=0;j<sk_X509_num(p.ca);j++) {
|
for (j=0;j<sk_X509_num(p.ca);j++) {
|
||||||
if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
|
if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
|
||||||
NID_info_access)))
|
NID_info_access)))
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
curl_off_t size;
|
|
||||||
struct stat file_info;
|
struct stat file_info;
|
||||||
double speed_upload, total_time;
|
double speed_upload, total_time;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ struct fcurl_data
|
|||||||
typedef struct fcurl_data URL_FILE;
|
typedef struct fcurl_data URL_FILE;
|
||||||
|
|
||||||
/* exported functions */
|
/* exported functions */
|
||||||
URL_FILE *url_fopen(char *url,const char *operation);
|
URL_FILE *url_fopen(const char *url,const char *operation);
|
||||||
int url_fclose(URL_FILE *file);
|
int url_fclose(URL_FILE *file);
|
||||||
int url_feof(URL_FILE *file);
|
int url_feof(URL_FILE *file);
|
||||||
size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file);
|
size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file);
|
||||||
@@ -93,11 +93,11 @@ write_callback(char *buffer,
|
|||||||
URL_FILE *url = (URL_FILE *)userp;
|
URL_FILE *url = (URL_FILE *)userp;
|
||||||
size *= nitems;
|
size *= nitems;
|
||||||
|
|
||||||
rembuff=url->buffer_len - url->buffer_pos;//remaining space in buffer
|
rembuff=url->buffer_len - url->buffer_pos; /* remaining space in buffer */
|
||||||
|
|
||||||
if(size > rembuff)
|
if(size > rembuff)
|
||||||
{
|
{
|
||||||
//not enuf space in buffer
|
/* not enough space in buffer */
|
||||||
newbuff=realloc(url->buffer,url->buffer_len + (size - rembuff));
|
newbuff=realloc(url->buffer,url->buffer_len + (size - rembuff));
|
||||||
if(newbuff==NULL)
|
if(newbuff==NULL)
|
||||||
{
|
{
|
||||||
@@ -211,7 +211,7 @@ use_buffer(URL_FILE *file,int want)
|
|||||||
|
|
||||||
|
|
||||||
URL_FILE *
|
URL_FILE *
|
||||||
url_fopen(char *url,const char *operation)
|
url_fopen(const char *url,const char *operation)
|
||||||
{
|
{
|
||||||
/* this code could check for URLs or types in the 'url' and
|
/* this code could check for URLs or types in the 'url' and
|
||||||
basicly use the real fopen() for standard files */
|
basicly use the real fopen() for standard files */
|
||||||
@@ -236,7 +236,7 @@ url_fopen(char *url,const char *operation)
|
|||||||
|
|
||||||
curl_easy_setopt(file->handle.curl, CURLOPT_URL, url);
|
curl_easy_setopt(file->handle.curl, CURLOPT_URL, url);
|
||||||
curl_easy_setopt(file->handle.curl, CURLOPT_WRITEDATA, file);
|
curl_easy_setopt(file->handle.curl, CURLOPT_WRITEDATA, file);
|
||||||
curl_easy_setopt(file->handle.curl, CURLOPT_VERBOSE, FALSE);
|
curl_easy_setopt(file->handle.curl, CURLOPT_VERBOSE, 0);
|
||||||
curl_easy_setopt(file->handle.curl, CURLOPT_WRITEFUNCTION, write_callback);
|
curl_easy_setopt(file->handle.curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||||
|
|
||||||
if(!multi_handle)
|
if(!multi_handle)
|
||||||
@@ -466,7 +466,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
int nread;
|
int nread;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
char *url;
|
const char *url;
|
||||||
|
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
{
|
{
|
||||||
@@ -481,7 +481,7 @@ main(int argc, char *argv[])
|
|||||||
outf=fopen("fgets.test","w+");
|
outf=fopen("fgets.test","w+");
|
||||||
if(!outf)
|
if(!outf)
|
||||||
{
|
{
|
||||||
perror("couldnt open fgets output file\n");
|
perror("couldn't open fgets output file\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ main(int argc, char *argv[])
|
|||||||
outf=fopen("fread.test","w+");
|
outf=fopen("fread.test","w+");
|
||||||
if(!outf)
|
if(!outf)
|
||||||
{
|
{
|
||||||
perror("couldnt open fread output file\n");
|
perror("couldn't open fread output file\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ main(int argc, char *argv[])
|
|||||||
outf=fopen("rewind.test","w+");
|
outf=fopen("rewind.test","w+");
|
||||||
if(!outf)
|
if(!outf)
|
||||||
{
|
{
|
||||||
perror("couldnt open fread output file\n");
|
perror("couldn't open fread output file\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* _ _ ____ _
|
|
||||||
* Project ___| | | | _ \| |
|
|
||||||
* / __| | | | |_) | |
|
|
||||||
* | (__| |_| | _ <| |___
|
|
||||||
* \___|\___/|_| \_\_____|
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <curl/curl.h>
|
|
||||||
#include <curl/types.h>
|
|
||||||
#include <curl/easy.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is an example showing how to transfer a file between two remote hosts.
|
|
||||||
* 7.13.0 or later required.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
CURL *curl;
|
|
||||||
CURLcode res;
|
|
||||||
char source_url[] = "ftp://remotehost.com/path/to/source";
|
|
||||||
char target_url[] = "ftp://aotherserver.com/path/to/dest";
|
|
||||||
|
|
||||||
char sourceUserPass[] = "user:pass";
|
|
||||||
char targetUserPass[] = "user:pass";
|
|
||||||
char url[100];
|
|
||||||
|
|
||||||
struct curl_slist *source_pre_cmd = NULL;
|
|
||||||
struct curl_slist *target_pre_cmd = NULL;
|
|
||||||
struct curl_slist *source_post_cmd = NULL;
|
|
||||||
struct curl_slist *target_post_cmd = NULL;
|
|
||||||
char cmd[] = "PWD"; /* just to test */
|
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
|
||||||
|
|
||||||
curl = curl_easy_init();
|
|
||||||
if (curl) {
|
|
||||||
/* The ordinary URL is the target when speaking 3rd party transfers */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, target_url);
|
|
||||||
|
|
||||||
/* Set a source URL */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_SOURCE_URL, source_url);
|
|
||||||
|
|
||||||
/* Set target user and password */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, targetUserPass);
|
|
||||||
|
|
||||||
/* Set source user and password */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_SOURCE_USERPWD, sourceUserPass);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* FTPPORT enables PORT on the target side, instead of PASV. */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_FTPPORT, ""); /* optional */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* build a list of commands to pass to libcurl */
|
|
||||||
source_pre_cmd = curl_slist_append(source_pre_cmd, cmd);
|
|
||||||
/* Set a proxy pre-quote command */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_SOURCE_PREQUOTE, source_pre_cmd);
|
|
||||||
|
|
||||||
/* build a list of commands to pass to libcurl */
|
|
||||||
target_pre_cmd = curl_slist_append(target_pre_cmd, cmd);
|
|
||||||
/* Set a pre-quote command */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_PREQUOTE, target_pre_cmd);
|
|
||||||
|
|
||||||
/* build a list of commands to pass to libcurl */
|
|
||||||
source_post_cmd = curl_slist_append(source_post_cmd, cmd);
|
|
||||||
/* Set a proxy post-quote command */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_SOURCE_POSTQUOTE, source_post_cmd);
|
|
||||||
|
|
||||||
/* build a list of commands to pass to libcurl */
|
|
||||||
target_post_cmd = curl_slist_append(target_post_cmd, cmd);
|
|
||||||
/* Set a post-quote command */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, target_post_cmd);
|
|
||||||
|
|
||||||
/* Switch on full protocol/debug output */
|
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
|
||||||
|
|
||||||
res = curl_easy_perform(curl);
|
|
||||||
|
|
||||||
/* clean up the FTP commands list */
|
|
||||||
curl_slist_free_all(source_pre_cmd);
|
|
||||||
curl_slist_free_all(target_pre_cmd);
|
|
||||||
curl_slist_free_all(source_post_cmd);
|
|
||||||
curl_slist_free_all(target_post_cmd);
|
|
||||||
|
|
||||||
/* always cleanup */
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
|
|
||||||
if(CURLE_OK != res) {
|
|
||||||
/* we failed */
|
|
||||||
fprintf(stderr, "curl told us %d\n", res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_global_cleanup();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct FtpFile {
|
struct FtpFile {
|
||||||
char *filename;
|
const char *filename;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ int main(void)
|
|||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
|
||||||
|
|
||||||
/* Switch on full protocol/debug output */
|
/* Switch on full protocol/debug output */
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||||
|
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,13 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
FILE *ftpfile;
|
|
||||||
FILE * hd_src ;
|
FILE * hd_src ;
|
||||||
int hd ;
|
int hd ;
|
||||||
struct stat file_info;
|
struct stat file_info;
|
||||||
|
|
||||||
struct curl_slist *headerlist=NULL;
|
struct curl_slist *headerlist=NULL;
|
||||||
char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
|
static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
|
||||||
char buf_2 [] = "RNTO " RENAME_FILE_TO;
|
static const char buf_2 [] = "RNTO " RENAME_FILE_TO;
|
||||||
|
|
||||||
/* get the file size of the local file */
|
/* get the file size of the local file */
|
||||||
hd = open(LOCAL_FILE, O_RDONLY) ;
|
hd = open(LOCAL_FILE, O_RDONLY) ;
|
||||||
@@ -61,7 +60,7 @@ int main(int argc, char **argv)
|
|||||||
headerlist = curl_slist_append(headerlist, buf_2);
|
headerlist = curl_slist_append(headerlist, buf_2);
|
||||||
|
|
||||||
/* enable uploading */
|
/* enable uploading */
|
||||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
|
||||||
|
|
||||||
/* specify target */
|
/* specify target */
|
||||||
curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
|
curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
|
|
||||||
/* The MinGW headers are missing a few Win32 function definitions,
|
/* The MinGW headers are missing a few Win32 function definitions,
|
||||||
you shouldn't need this if you use VC++ */
|
you shouldn't need this if you use VC++ */
|
||||||
|
#ifdef __MINGW32__
|
||||||
int __cdecl _snscanf(const char * input, size_t length, const char * format, ...);
|
int __cdecl _snscanf(const char * input, size_t length, const char * format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* parse headers for Content-Length */
|
/* parse headers for Content-Length */
|
||||||
@@ -75,7 +77,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, TRUE);
|
curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, 1);
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath);
|
curl_easy_setopt(curlhandle, CURLOPT_URL, remotepath);
|
||||||
|
|
||||||
@@ -91,9 +93,9 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
|
curl_easy_setopt(curlhandle, CURLOPT_READDATA, f);
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */
|
curl_easy_setopt(curlhandle, CURLOPT_FTPPORT, "-"); /* disable passive mode */
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, TRUE);
|
curl_easy_setopt(curlhandle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1);
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, TRUE);
|
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1);
|
||||||
|
|
||||||
for (c = 0; (r != CURLE_OK) && (c < tries); c++) {
|
for (c = 0; (r != CURLE_OK) && (c < tries); c++) {
|
||||||
/* are we resuming? */
|
/* are we resuming? */
|
||||||
@@ -108,22 +110,22 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
|
|||||||
* because HEADER will dump the headers to stdout
|
* because HEADER will dump the headers to stdout
|
||||||
* without it.
|
* without it.
|
||||||
*/
|
*/
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, TRUE);
|
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_HEADER, TRUE);
|
curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1);
|
||||||
|
|
||||||
r = curl_easy_perform(curlhandle);
|
r = curl_easy_perform(curlhandle);
|
||||||
if (r != CURLE_OK)
|
if (r != CURLE_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, FALSE);
|
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_HEADER, FALSE);
|
curl_easy_setopt(curlhandle, CURLOPT_HEADER, 0);
|
||||||
|
|
||||||
fseek(f, uploaded_len, SEEK_SET);
|
fseek(f, uploaded_len, SEEK_SET);
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, TRUE);
|
curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, 1);
|
||||||
}
|
}
|
||||||
else { /* no */
|
else { /* no */
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, FALSE);
|
curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = curl_easy_perform(curlhandle);
|
r = curl_easy_perform(curlhandle);
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ typedef struct _SockInfo {
|
|||||||
|
|
||||||
|
|
||||||
/* Die if we get a bad CURLMcode somewhere */
|
/* Die if we get a bad CURLMcode somewhere */
|
||||||
static void mcode_or_die(char *where, CURLMcode code) {
|
static void mcode_or_die(const char *where, CURLMcode code) {
|
||||||
if ( CURLM_OK != code ) {
|
if ( CURLM_OK != code ) {
|
||||||
char *s;
|
const char *s;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
|
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
|
||||||
case CURLM_OK: s="CURLM_OK"; break;
|
case CURLM_OK: s="CURLM_OK"; break;
|
||||||
@@ -259,7 +259,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
|||||||
{
|
{
|
||||||
GlobalInfo *g = (GlobalInfo*) cbp;
|
GlobalInfo *g = (GlobalInfo*) cbp;
|
||||||
SockInfo *fdp = (SockInfo*) sockp;
|
SockInfo *fdp = (SockInfo*) sockp;
|
||||||
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]);
|
MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||||
if (what == CURL_POLL_REMOVE) {
|
if (what == CURL_POLL_REMOVE) {
|
||||||
@@ -402,7 +402,7 @@ static gboolean fifo_cb (GIOChannel *ch, GIOCondition condition, gpointer data)
|
|||||||
int init_fifo(void)
|
int init_fifo(void)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *fifo = "hiper.fifo";
|
const char *fifo = "hiper.fifo";
|
||||||
int socket;
|
int socket;
|
||||||
|
|
||||||
if (lstat (fifo, &st) == 0) {
|
if (lstat (fifo, &st) == 0) {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
|
|||||||
{
|
{
|
||||||
GlobalInfo *g = (GlobalInfo*) cbp;
|
GlobalInfo *g = (GlobalInfo*) cbp;
|
||||||
SockInfo *fdp = (SockInfo*) sockp;
|
SockInfo *fdp = (SockInfo*) sockp;
|
||||||
char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
|
const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
|
||||||
|
|
||||||
fprintf(MSG_OUT,
|
fprintf(MSG_OUT,
|
||||||
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
|
||||||
@@ -357,7 +357,7 @@ void fifo_cb(int fd, short event, void *arg) {
|
|||||||
/* Create a named pipe and tell libevent to monitor it */
|
/* Create a named pipe and tell libevent to monitor it */
|
||||||
int init_fifo (GlobalInfo *g) {
|
int init_fifo (GlobalInfo *g) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *fifo = "hiper.fifo";
|
static const char *fifo = "hiper.fifo";
|
||||||
int socket;
|
int socket;
|
||||||
|
|
||||||
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
|
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ int main(int argc, char **argv)
|
|||||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||||
|
|
||||||
/* enable uploading */
|
/* enable uploading */
|
||||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
|
||||||
|
|
||||||
/* HTTP PUT please */
|
/* HTTP PUT please */
|
||||||
curl_easy_setopt(curl, CURLOPT_PUT, TRUE);
|
curl_easy_setopt(curl, CURLOPT_PUT, 1);
|
||||||
|
|
||||||
/* specify target URL, and note that this URL should include a file
|
/* specify target URL, and note that this URL should include a file
|
||||||
name, not only a directory */
|
name, not only a directory */
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ int main(void)
|
|||||||
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
||||||
* you.
|
* you.
|
||||||
*/
|
*/
|
||||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SKIP_HOSTNAME_VERFICATION
|
#ifdef SKIP_HOSTNAME_VERFICATION
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
|
|||||||
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "http://website.com");
|
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "http://website.com");
|
||||||
|
|
||||||
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://ftpsite.com");
|
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://ftpsite.com");
|
||||||
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_UPLOAD, TRUE);
|
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_UPLOAD, 1);
|
||||||
|
|
||||||
/* init a multi stack */
|
/* init a multi stack */
|
||||||
multi_handle = curl_multi_init();
|
multi_handle = curl_multi_init();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
|
||||||
|
|
||||||
CURLM *multi_handle;
|
CURLM *multi_handle;
|
||||||
int still_running;
|
int still_running;
|
||||||
@@ -27,7 +26,7 @@ int main(int argc, char *argv[])
|
|||||||
struct curl_httppost *formpost=NULL;
|
struct curl_httppost *formpost=NULL;
|
||||||
struct curl_httppost *lastptr=NULL;
|
struct curl_httppost *lastptr=NULL;
|
||||||
struct curl_slist *headerlist=NULL;
|
struct curl_slist *headerlist=NULL;
|
||||||
char buf[] = "Expect:";
|
static const char buf[] = "Expect:";
|
||||||
|
|
||||||
/* Fill in the file upload field. This makes libcurl load data from
|
/* Fill in the file upload field. This makes libcurl load data from
|
||||||
the given file name when curl_easy_perform() is called. */
|
the given file name when curl_easy_perform() is called. */
|
||||||
@@ -58,7 +57,6 @@ int main(int argc, char *argv[])
|
|||||||
wanted */
|
wanted */
|
||||||
headerlist = curl_slist_append(headerlist, buf);
|
headerlist = curl_slist_append(headerlist, buf);
|
||||||
if(curl && multi_handle) {
|
if(curl && multi_handle) {
|
||||||
int perform=0;
|
|
||||||
|
|
||||||
/* what URL that receives this POST */
|
/* what URL that receives this POST */
|
||||||
curl_easy_setopt(curl, CURLOPT_URL,
|
curl_easy_setopt(curl, CURLOPT_URL,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
http://www.openssl.org/docs/crypto/threads.html#DESCRIPTION
|
http://www.openssl.org/docs/crypto/threads.html#DESCRIPTION
|
||||||
|
|
||||||
*/
|
*/
|
||||||
char *urls[]= {
|
const char *urls[]= {
|
||||||
"http://curl.haxx.se/",
|
"http://curl.haxx.se/",
|
||||||
"ftp://cool.haxx.se/",
|
"ftp://cool.haxx.se/",
|
||||||
"http://www.contactor.se/",
|
"http://www.contactor.se/",
|
||||||
@@ -59,7 +59,7 @@ int main(int argc, char **argv)
|
|||||||
error = pthread_create(&tid[i],
|
error = pthread_create(&tid[i],
|
||||||
NULL, /* default attributes please */
|
NULL, /* default attributes please */
|
||||||
pull_one_url,
|
pull_one_url,
|
||||||
urls[i]);
|
(void *)urls[i]);
|
||||||
if(0 != error)
|
if(0 != error)
|
||||||
fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
|
fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
* Author: Jeremy Brown
|
* Author: Jeremy Brown
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
|
||||||
#define MUTEX_TYPE pthread_mutex_t
|
#define MUTEX_TYPE pthread_mutex_t
|
||||||
#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
|
#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
|
||||||
#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
|
#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
|
||||||
@@ -25,7 +30,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void handle_error(const char *file, int lineno, const char *msg){
|
void handle_error(const char *file, int lineno, const char *msg){
|
||||||
fprintf(stderr, ** %s:%i %s\n, file, lineno, msg);
|
fprintf(stderr, "** %s:%d %s\n", file, lineno, msg);
|
||||||
ERR_print_errors_fp(stderr);
|
ERR_print_errors_fp(stderr);
|
||||||
/* exit(-1); */
|
/* exit(-1); */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
char data[]="this is what we post to the silly web server";
|
const char data[]="this is what we post to the silly web server";
|
||||||
|
|
||||||
struct WriteThis {
|
struct WriteThis {
|
||||||
char *readptr;
|
const char *readptr;
|
||||||
int sizeleft;
|
int sizeleft;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ int main(void)
|
|||||||
curl_easy_setopt(curl, CURLOPT_URL,
|
curl_easy_setopt(curl, CURLOPT_URL,
|
||||||
"http://receivingsite.com.pooh/index.cgi");
|
"http://receivingsite.com.pooh/index.cgi");
|
||||||
/* Now specify we want to POST data */
|
/* Now specify we want to POST data */
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, TRUE);
|
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||||
|
|
||||||
/* we want to use our own read function */
|
/* we want to use our own read function */
|
||||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
|
|||||||
struct curl_httppost *formpost=NULL;
|
struct curl_httppost *formpost=NULL;
|
||||||
struct curl_httppost *lastptr=NULL;
|
struct curl_httppost *lastptr=NULL;
|
||||||
struct curl_slist *headerlist=NULL;
|
struct curl_slist *headerlist=NULL;
|
||||||
char buf[] = "Expect:";
|
static const char buf[] = "Expect:";
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
CURL *curl_handle;
|
CURL *curl_handle;
|
||||||
char *headerfilename = "head.out";
|
static const char *headerfilename = "head.out";
|
||||||
FILE *headerfile;
|
FILE *headerfile;
|
||||||
char *bodyfilename = "body.out";
|
static const char *bodyfilename = "body.out";
|
||||||
FILE *bodyfile;
|
FILE *bodyfile;
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@@ -16,7 +17,7 @@ int main(void)
|
|||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
|
|
||||||
char *postthis="moo mooo moo moo";
|
static const char *postthis="moo mooo moo moo";
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(curl) {
|
if(curl) {
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ int main(int argc, char **argv)
|
|||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
FILE *headerfile;
|
FILE *headerfile;
|
||||||
|
const char *pPassphrase = NULL;
|
||||||
|
|
||||||
const char *pCertFile = "testcert.pem";
|
static const char *pCertFile = "testcert.pem";
|
||||||
const char *pCACertFile="cacert.pem";
|
static const char *pCACertFile="cacert.pem";
|
||||||
|
|
||||||
const char *pKeyName;
|
const char *pKeyName;
|
||||||
const char *pKeyType;
|
const char *pKeyType;
|
||||||
@@ -57,8 +58,6 @@ int main(int argc, char **argv)
|
|||||||
pEngine = NULL;
|
pEngine = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *pPassphrase = NULL;
|
|
||||||
|
|
||||||
headerfile = fopen("dumpit", "w");
|
headerfile = fopen("dumpit", "w");
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ typedef struct
|
|||||||
char timeserver[MAX_STRING1];
|
char timeserver[MAX_STRING1];
|
||||||
} conf_t;
|
} conf_t;
|
||||||
|
|
||||||
char DefaultTimeServer[4][MAX_STRING1] =
|
const char DefaultTimeServer[4][MAX_STRING1] =
|
||||||
{
|
{
|
||||||
"http://nist.time.gov/timezone.cgi?UTC/s/0",
|
"http://nist.time.gov/timezone.cgi?UTC/s/0",
|
||||||
"http://www.google.com/",
|
"http://www.google.com/",
|
||||||
@@ -95,9 +95,9 @@ char DefaultTimeServer[4][MAX_STRING1] =
|
|||||||
"http://www.worldtime.com/cgi-bin/wt.cgi"
|
"http://www.worldtime.com/cgi-bin/wt.cgi"
|
||||||
};
|
};
|
||||||
|
|
||||||
char *DayStr[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
const char *DayStr[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||||
char *MthStr[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
const char *MthStr[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
int ShowAllHeader;
|
int ShowAllHeader;
|
||||||
int AutoSyncTime;
|
int AutoSyncTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user