]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Fixed some compile warnings and errors and improved portability in the
authorDan Fandrich <dan@coneharvesters.com>
Thu, 12 Jul 2007 21:11:10 +0000 (21:11 +0000)
committerDan Fandrich <dan@coneharvesters.com>
Thu, 12 Jul 2007 21:11:10 +0000 (21:11 +0000)
examples.
Removed ftp3rdparty.c since libcurl doesn't support 3rd party FTP transfers
any longer.

24 files changed:
CHANGES
docs/examples/cacertinmem.c
docs/examples/cookie_interface.c
docs/examples/curlx.c
docs/examples/fileupload.c
docs/examples/fopen.c
docs/examples/ftp3rdparty.c [deleted file]
docs/examples/ftpget.c
docs/examples/ftpupload.c
docs/examples/ftpuploadresume.c
docs/examples/ghiper.c
docs/examples/hiperfifo.c
docs/examples/httpput.c
docs/examples/https.c
docs/examples/multi-app.c
docs/examples/multi-post.c
docs/examples/multithread.c
docs/examples/opensslthreadlock.c
docs/examples/post-callback.c
docs/examples/postit2.c
docs/examples/sepheaders.c
docs/examples/simplepost.c
docs/examples/simplessl.c
docs/examples/synctime.c

diff --git a/CHANGES b/CHANGES
index f03c4c3b79a3ba6b284df0a16dca9490811a86b0..91f34259398bf1fced88088d3899db79b1b494e1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,13 @@
 
                                   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)
 - Shmulik Regev found an (albeit rare) case where the proxy CONNECT operation
   could in fact get stuck in an endless loop.
index de5e3248e79ce3629c4f91605324dcf1ef53f0d9..e58c9ace9508d0bf52c0e191dcc1202ed2a83eb3 100644 (file)
@@ -135,4 +135,5 @@ int main(void)
 
   curl_easy_cleanup(ch);
   curl_global_cleanup();
+  return rv;
 }
index d184edb54e427bc2fedd3bf6677e164df04d172e..a39106e34d3579af85b292156e13feda4eaffa36 100644 (file)
@@ -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);
index 31f01e8ad4f845973020fd692fa4a14dbb08f275..636c8b4fec46ce380c908fca24554aef3d16b4fa 100644 (file)
@@ -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>
 #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)))
index 455cb0ecf7498ea70e9daa970716632f9a82256e..0f6e69d20621d7639597b278e5d3d404cd73e876 100644 (file)
@@ -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;
index de235bbc4cbf12c35199f02feccb0cc20a2f9fc0..7c50b0cc65fe0d23386cb906c3179822b15caec0 100644 (file)
@@ -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 (file)
index b4756f5..0000000
+++ /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;
-}
index 0274b7f696c05b3d42784f539edb1a76047efb5d..4e3fc8fc351eaeef8f308581c772c49a2e813f99 100644 (file)
@@ -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);
 
index c0ae40a26c5df3db7b4265283811d5f8fcc364f0..65f8a8a79528406fe2b74f8890bdabdda4a19a3b 100644 (file)
@@ -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);
index f83cd0a2d1a6200f14d4a1ad1b06b267e74b2778..8e6be977a4581b793acfd376647ddb11097bdbbc 100644 (file)
@@ -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);
index cd0895b5fd5d163db6e7648d8eb260b53f4f3d4c..db7d3cb1c00c3d4eca155f6cad25f5b97edd12f5 100644 (file)
@@ -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) {
index e8d767133cdd9645936a04e3d5daadc579cd0ae5..76e506fb56286aa80c8e26dea38a4192492183f4 100644 (file)
@@ -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);
index 0d360adc7c4911140421f8bb6299a0d55a4c721f..8fd423c7db332c0190ea7b5a8641ade04bf28a0b 100644 (file)
@@ -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 */
index 8ce7c0b3ab0e32936bbb5a86e92a9dc9f028aa95..4a83f5f936473bd8368205e8990d06751659e51b 100644 (file)
@@ -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
index 6c0ef7e7f1c8d63a1c50be03bef58b825e7fde48..5969c91c8ba198004ebed730142a96c009002b79 100644 (file)
@@ -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();
index 894ace0ed52338ed1eeba59d9db4f5ade13ecafd..c560bb916c949155b1701326b2cabe0cf5f20760 100644 (file)
@@ -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,
index fc9a9a87ced838a79a96c8a343de64409f925c00..78c3a157af69434612d15c6e2f06b5556b743cb3 100644 (file)
@@ -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
index 82de206dae956aaa81a831241e7d250376da3c8e..18a2f77fcaf8514321ea5bed5f7af9330825dbbe 100644 (file)
  * 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); */
  }
index 1da88a8afc37b741ce5821c41546d9ad493a5fab..a2c89873f3f60700f9368620974974f32a01e3ba 100644 (file)
 #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);
index e022d284fe6ab0719f9e0150af297098fc39891c..0660cc5b5a579b66bf9e36a5b7ae342f9cecc9a0 100644 (file)
@@ -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);
 
index cf2f419d679bed5c4626880eee73e9fec8dc9bbd..e35aebfb19cdb0cfc770281fbb0309fc7034536c 100644 (file)
@@ -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);
index 1d156c5837023fa290468eb3ca6d8faf39e31992..9bab83b7d986bfe0c54f58bd83e5c42d3a8cca10 100644 (file)
@@ -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) {
index 745d6e82c6bfdd0173d610b601f89403d46941db..7ad35237c96ba9d4a17859723515965f22b386d5 100644 (file)
@@ -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);
index cd8d0805d34bd90e6754ff48f232cbd46059631c..2d5a8e51e1b12bb09f268c9c092b05cee691c52d 100644 (file)
@@ -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;