aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2007-07-12 21:11:10 +0000
committerDan Fandrich <dan@coneharvesters.com>2007-07-12 21:11:10 +0000
commit49ce3e5160a9576e797bf87cef012b09d1c54ecb (patch)
tree9b8e476de272cfd92bb3d857aa3c6eef273140b7 /docs
parent4a728747e6f8845e500910e397dfc99aaf4a7984 (diff)
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.
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/cacertinmem.c1
-rw-r--r--docs/examples/cookie_interface.c4
-rw-r--r--docs/examples/curlx.c17
-rw-r--r--docs/examples/fileupload.c1
-rw-r--r--docs/examples/fopen.c18
-rw-r--r--docs/examples/ftp3rdparty.c103
-rw-r--r--docs/examples/ftpget.c4
-rw-r--r--docs/examples/ftpupload.c7
-rw-r--r--docs/examples/ftpuploadresume.c20
-rw-r--r--docs/examples/ghiper.c8
-rw-r--r--docs/examples/hiperfifo.c4
-rw-r--r--docs/examples/httpput.c4
-rw-r--r--docs/examples/https.c2
-rw-r--r--docs/examples/multi-app.c2
-rw-r--r--docs/examples/multi-post.c4
-rw-r--r--docs/examples/multithread.c4
-rw-r--r--docs/examples/opensslthreadlock.c7
-rw-r--r--docs/examples/post-callback.c6
-rw-r--r--docs/examples/postit2.c2
-rw-r--r--docs/examples/sepheaders.c4
-rw-r--r--docs/examples/simplepost.c3
-rw-r--r--docs/examples/simplessl.c7
-rw-r--r--docs/examples/synctime.c8
23 files changed, 71 insertions, 169 deletions
diff --git a/docs/examples/cacertinmem.c b/docs/examples/cacertinmem.c
index de5e3248e..e58c9ace9 100644
--- a/docs/examples/cacertinmem.c
+++ b/docs/examples/cacertinmem.c
@@ -135,4 +135,5 @@ int main(void)
curl_easy_cleanup(ch);
curl_global_cleanup();
+ return rv;
}
diff --git a/docs/examples/cookie_interface.c b/docs/examples/cookie_interface.c
index d184edb54..a39106e34 100644
--- a/docs/examples/cookie_interface.c
+++ b/docs/examples/cookie_interface.c
@@ -74,7 +74,7 @@ main(void)
#define snprintf _snprintf
#endif
/* 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!");
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
if (res != CURLE_OK) {
@@ -83,7 +83,7 @@ main(void)
}
/* HTTP-header style cookie */
- snprintf(nline, 256,
+ snprintf(nline, sizeof(nline),
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com");
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
diff --git a/docs/examples/curlx.c b/docs/examples/curlx.c
index 31f01e8ad..636c8b4fe 100644
--- a/docs/examples/curlx.c
+++ b/docs/examples/curlx.c
@@ -81,6 +81,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <curl/curl.h>
#include <openssl/x509v3.h>
#include <openssl/x509_vfy.h>
@@ -94,13 +95,13 @@
#include <openssl/bio.h>
#include <openssl/ssl.h>
-static char *curlx_usage[]={
+static const char *curlx_usage[]={
"usage: curlx args\n",
" -p12 arg - tia file ",
" -envpass arg - environement variable which content the tia private key password",
" -out arg - output file (response)- default stdout",
" -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",
" -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",
@@ -268,19 +269,21 @@ int main(int argc, char **argv) {
char* mimetype;
char* mimetypeaccept=NULL;
char* contenttype;
- char** pp;
+ const char** pp;
unsigned char* hostporturl = NULL;
- binaryptr=(char*)malloc(tabLength);
BIO * p12bio ;
char **args = argv + 1;
unsigned char * serverurl;
sslctxparm p;
char *response;
- p.verbose = 0;
CURLcode res;
struct curl_slist * headers=NULL;
+ int badarg=0;
+
+ binaryptr=(char*)malloc(tabLength);
+ p.verbose = 0;
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
curl_global_init(CURL_GLOBAL_DEFAULT);
@@ -292,7 +295,6 @@ int main(int argc, char **argv) {
ERR_load_crypto_strings();
- int badarg=0;
while (*args && *args[0] == '-') {
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 */
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 "
"cherching in others certificats\n");
- int j=0;
- int find=0;
for (j=0;j<sk_X509_num(p.ca);j++) {
if ((serverurl = my_get_ext(sk_X509_value(p.ca,j),p.accesstype,
NID_info_access)))
diff --git a/docs/examples/fileupload.c b/docs/examples/fileupload.c
index 455cb0ecf..0f6e69d20 100644
--- a/docs/examples/fileupload.c
+++ b/docs/examples/fileupload.c
@@ -17,7 +17,6 @@ int main(void)
{
CURL *curl;
CURLcode res;
- curl_off_t size;
struct stat file_info;
double speed_upload, total_time;
FILE *fd;
diff --git a/docs/examples/fopen.c b/docs/examples/fopen.c
index de235bbc4..7c50b0cc6 100644
--- a/docs/examples/fopen.c
+++ b/docs/examples/fopen.c
@@ -70,7 +70,7 @@ struct fcurl_data
typedef struct fcurl_data URL_FILE;
/* 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_feof(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;
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)
{
- //not enuf space in buffer
+ /* not enough space in buffer */
newbuff=realloc(url->buffer,url->buffer_len + (size - rembuff));
if(newbuff==NULL)
{
@@ -211,7 +211,7 @@ use_buffer(URL_FILE *file,int want)
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
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_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);
if(!multi_handle)
@@ -466,7 +466,7 @@ main(int argc, char *argv[])
int nread;
char buffer[256];
- char *url;
+ const char *url;
if(argc < 2)
{
@@ -481,7 +481,7 @@ main(int argc, char *argv[])
outf=fopen("fgets.test","w+");
if(!outf)
{
- perror("couldnt open fgets output file\n");
+ perror("couldn't open fgets output file\n");
return 1;
}
@@ -508,7 +508,7 @@ main(int argc, char *argv[])
outf=fopen("fread.test","w+");
if(!outf)
{
- perror("couldnt open fread output file\n");
+ perror("couldn't open fread output file\n");
return 1;
}
@@ -533,7 +533,7 @@ main(int argc, char *argv[])
outf=fopen("rewind.test","w+");
if(!outf)
{
- perror("couldnt open fread output file\n");
+ perror("couldn't open fread output file\n");
return 1;
}
diff --git a/docs/examples/ftp3rdparty.c b/docs/examples/ftp3rdparty.c
deleted file mode 100644
index b4756f580..000000000
--- a/docs/examples/ftp3rdparty.c
+++ /dev/null
@@ -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;
-}
diff --git a/docs/examples/ftpget.c b/docs/examples/ftpget.c
index 0274b7f69..4e3fc8fc3 100644
--- a/docs/examples/ftpget.c
+++ b/docs/examples/ftpget.c
@@ -22,7 +22,7 @@
*/
struct FtpFile {
- char *filename;
+ const char *filename;
FILE *stream;
};
@@ -65,7 +65,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
/* 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);
diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c
index c0ae40a26..65f8a8a79 100644
--- a/docs/examples/ftpupload.c
+++ b/docs/examples/ftpupload.c
@@ -31,14 +31,13 @@ int main(int argc, char **argv)
{
CURL *curl;
CURLcode res;
- FILE *ftpfile;
FILE * hd_src ;
int hd ;
struct stat file_info;
struct curl_slist *headerlist=NULL;
- char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
- char buf_2 [] = "RNTO " RENAME_FILE_TO;
+ static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
+ static const char buf_2 [] = "RNTO " RENAME_FILE_TO;
/* get the file size of the local file */
hd = open(LOCAL_FILE, O_RDONLY) ;
@@ -61,7 +60,7 @@ int main(int argc, char **argv)
headerlist = curl_slist_append(headerlist, buf_2);
/* enable uploading */
- curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
+ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
/* specify target */
curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
diff --git a/docs/examples/ftpuploadresume.c b/docs/examples/ftpuploadresume.c
index f83cd0a2d..8e6be977a 100644
--- a/docs/examples/ftpuploadresume.c
+++ b/docs/examples/ftpuploadresume.c
@@ -24,7 +24,9 @@
/* The MinGW headers are missing a few Win32 function definitions,
you shouldn't need this if you use VC++ */
+#ifdef __MINGW32__
int __cdecl _snscanf(const char * input, size_t length, const char * format, ...);
+#endif
/* parse headers for Content-Length */
@@ -75,7 +77,7 @@ int upload(CURL *curlhandle, const char * remotepath, const char * localpath,
return 0;
}
- curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, TRUE);
+ curl_easy_setopt(curlhandle, CURLOPT_UPLOAD, 1);
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_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++) {
/* 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
* without it.
*/
- curl_easy_setopt(curlhandle, CURLOPT_NOBODY, TRUE);
- curl_easy_setopt(curlhandle, CURLOPT_HEADER, TRUE);
+ curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1);
+ curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1);
r = curl_easy_perform(curlhandle);
if (r != CURLE_OK)
continue;
- curl_easy_setopt(curlhandle, CURLOPT_NOBODY, FALSE);
- curl_easy_setopt(curlhandle, CURLOPT_HEADER, FALSE);
+ curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 0);
+ curl_easy_setopt(curlhandle, CURLOPT_HEADER, 0);
fseek(f, uploaded_len, SEEK_SET);
- curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, TRUE);
+ curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, 1);
}
else { /* no */
- curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, FALSE);
+ curl_easy_setopt(curlhandle, CURLOPT_FTPAPPEND, 0);
}
r = curl_easy_perform(curlhandle);
diff --git a/docs/examples/ghiper.c b/docs/examples/ghiper.c
index cd0895b5f..db7d3cb1c 100644
--- a/docs/examples/ghiper.c
+++ b/docs/examples/ghiper.c
@@ -91,9 +91,9 @@ typedef struct _SockInfo {
/* 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 ) {
- char *s;
+ const char *s;
switch (code) {
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; 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;
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]);
if (what == CURL_POLL_REMOVE) {
@@ -402,7 +402,7 @@ static gboolean fifo_cb (GIOChannel *ch, GIOCondition condition, gpointer data)
int init_fifo(void)
{
struct stat st;
- char *fifo = "hiper.fifo";
+ const char *fifo = "hiper.fifo";
int socket;
if (lstat (fifo, &st) == 0) {
diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c
index e8d767133..76e506fb5 100644
--- a/docs/examples/hiperfifo.c
+++ b/docs/examples/hiperfifo.c
@@ -252,7 +252,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
GlobalInfo *g = (GlobalInfo*) cbp;
SockInfo *fdp = (SockInfo*) sockp;
- 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]);
@@ -357,7 +357,7 @@ void fifo_cb(int fd, short event, void *arg) {
/* Create a named pipe and tell libevent to monitor it */
int init_fifo (GlobalInfo *g) {
struct stat st;
- char *fifo = "hiper.fifo";
+ static const char *fifo = "hiper.fifo";
int socket;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
diff --git a/docs/examples/httpput.c b/docs/examples/httpput.c
index 0d360adc7..8fd423c7d 100644
--- a/docs/examples/httpput.c
+++ b/docs/examples/httpput.c
@@ -75,10 +75,10 @@ int main(int argc, char **argv)
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* enable uploading */
- curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
+ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
/* 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
name, not only a directory */
diff --git a/docs/examples/https.c b/docs/examples/https.c
index 8ce7c0b3a..4a83f5f93 100644
--- a/docs/examples/https.c
+++ b/docs/examples/https.c
@@ -31,7 +31,7 @@ int main(void)
* default bundle, then the CURLOPT_CAPATH option might come handy for
* you.
*/
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
#endif
#ifdef SKIP_HOSTNAME_VERFICATION
diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c
index 6c0ef7e7f..5969c91c8 100644
--- a/docs/examples/multi-app.c
+++ b/docs/examples/multi-app.c
@@ -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[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 */
multi_handle = curl_multi_init();
diff --git a/docs/examples/multi-post.c b/docs/examples/multi-post.c
index 894ace0ed..c560bb916 100644
--- a/docs/examples/multi-post.c
+++ b/docs/examples/multi-post.c
@@ -19,7 +19,6 @@
int main(int argc, char *argv[])
{
CURL *curl;
- CURLcode res;
CURLM *multi_handle;
int still_running;
@@ -27,7 +26,7 @@ int main(int argc, char *argv[])
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=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
the given file name when curl_easy_perform() is called. */
@@ -58,7 +57,6 @@ int main(int argc, char *argv[])
wanted */
headerlist = curl_slist_append(headerlist, buf);
if(curl && multi_handle) {
- int perform=0;
/* what URL that receives this POST */
curl_easy_setopt(curl, CURLOPT_URL,
diff --git a/docs/examples/multithread.c b/docs/examples/multithread.c
index fc9a9a87c..78c3a157a 100644
--- a/docs/examples/multithread.c
+++ b/docs/examples/multithread.c
@@ -24,7 +24,7 @@
http://www.openssl.org/docs/crypto/threads.html#DESCRIPTION
*/
-char *urls[]= {
+const char *urls[]= {
"http://curl.haxx.se/",
"ftp://cool.haxx.se/",
"http://www.contactor.se/",
@@ -59,7 +59,7 @@ int main(int argc, char **argv)
error = pthread_create(&tid[i],
NULL, /* default attributes please */
pull_one_url,
- urls[i]);
+ (void *)urls[i]);
if(0 != error)
fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
else
diff --git a/docs/examples/opensslthreadlock.c b/docs/examples/opensslthreadlock.c
index 82de206da..18a2f77fc 100644
--- a/docs/examples/opensslthreadlock.c
+++ b/docs/examples/opensslthreadlock.c
@@ -16,6 +16,11 @@
* Author: Jeremy Brown
*/
+
+#include <stdio.h>
+#include <pthread.h>
+#include <openssl/err.h>
+
#define MUTEX_TYPE pthread_mutex_t
#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
@@ -25,7 +30,7 @@
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);
/* exit(-1); */
}
diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c
index 1da88a8af..a2c89873f 100644
--- a/docs/examples/post-callback.c
+++ b/docs/examples/post-callback.c
@@ -15,10 +15,10 @@
#include <string.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 {
- char *readptr;
+ const char *readptr;
int sizeleft;
};
@@ -55,7 +55,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL,
"http://receivingsite.com.pooh/index.cgi");
/* 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 */
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
diff --git a/docs/examples/postit2.c b/docs/examples/postit2.c
index e022d284f..0660cc5b5 100644
--- a/docs/examples/postit2.c
+++ b/docs/examples/postit2.c
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct curl_slist *headerlist=NULL;
- char buf[] = "Expect:";
+ static const char buf[] = "Expect:";
curl_global_init(CURL_GLOBAL_ALL);
diff --git a/docs/examples/sepheaders.c b/docs/examples/sepheaders.c
index cf2f419d6..e35aebfb1 100644
--- a/docs/examples/sepheaders.c
+++ b/docs/examples/sepheaders.c
@@ -25,9 +25,9 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
int main(int argc, char **argv)
{
CURL *curl_handle;
- char *headerfilename = "head.out";
+ static const char *headerfilename = "head.out";
FILE *headerfile;
- char *bodyfilename = "body.out";
+ static const char *bodyfilename = "body.out";
FILE *bodyfile;
curl_global_init(CURL_GLOBAL_ALL);
diff --git a/docs/examples/simplepost.c b/docs/examples/simplepost.c
index 1d156c583..9bab83b7d 100644
--- a/docs/examples/simplepost.c
+++ b/docs/examples/simplepost.c
@@ -9,6 +9,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <curl/curl.h>
int main(void)
@@ -16,7 +17,7 @@ int main(void)
CURL *curl;
CURLcode res;
- char *postthis="moo mooo moo moo";
+ static const char *postthis="moo mooo moo moo";
curl = curl_easy_init();
if(curl) {
diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c
index 745d6e82c..7ad35237c 100644
--- a/docs/examples/simplessl.c
+++ b/docs/examples/simplessl.c
@@ -38,9 +38,10 @@ int main(int argc, char **argv)
CURL *curl;
CURLcode res;
FILE *headerfile;
+ const char *pPassphrase = NULL;
- const char *pCertFile = "testcert.pem";
- const char *pCACertFile="cacert.pem";
+ static const char *pCertFile = "testcert.pem";
+ static const char *pCACertFile="cacert.pem";
const char *pKeyName;
const char *pKeyType;
@@ -57,8 +58,6 @@ int main(int argc, char **argv)
pEngine = NULL;
#endif
- const char *pPassphrase = NULL;
-
headerfile = fopen("dumpit", "w");
curl_global_init(CURL_GLOBAL_DEFAULT);
diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c
index cd8d0805d..2d5a8e51e 100644
--- a/docs/examples/synctime.c
+++ b/docs/examples/synctime.c
@@ -87,7 +87,7 @@ typedef struct
char timeserver[MAX_STRING1];
} conf_t;
-char DefaultTimeServer[4][MAX_STRING1] =
+const char DefaultTimeServer[4][MAX_STRING1] =
{
"http://nist.time.gov/timezone.cgi?UTC/s/0",
"http://www.google.com/",
@@ -95,9 +95,9 @@ char DefaultTimeServer[4][MAX_STRING1] =
"http://www.worldtime.com/cgi-bin/wt.cgi"
};
-char *DayStr[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-char *MthStr[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+const char *DayStr[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+const char *MthStr[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
int ShowAllHeader;
int AutoSyncTime;