mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Added ftpget.c just to show that it is exactly as easy to get FTP files
This commit is contained in:
parent
8b08dfed38
commit
053bf49bd2
@ -6,8 +6,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
EXTRA_DIST =
|
||||
README curlgtk.c sepheaders.c simple.c postit.c \
|
||||
win32sockets.c persistant.c \
|
||||
getpageinvar.php simpleget.php simplepost.php
|
||||
win32sockets.c persistant.c ftpget.c
|
||||
|
||||
all:
|
||||
@echo "done"
|
||||
|
44
docs/examples/ftpget.c
Normal file
44
docs/examples/ftpget.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*****************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
/* to make this work under windows, use the win32-functions from the
|
||||
win32socket.c file as well */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE *ftpfile;
|
||||
|
||||
/* local file name to store the file as */
|
||||
ftpfile = fopen("curl.tar.gz", "wb"); /* b is binary for win */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Get curl 7.7 from sunet.se's FTP site: */
|
||||
curl_easy_setopt(curl, CURLOPT_URL,
|
||||
"ftp://ftp.sunet.se/pub/www/utilities/curl/curl-7.7.tar.gz");
|
||||
curl_easy_setopt(curl, CURLOPT_FILE, ftpfile);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
fclose(ftpfile); /* close the local file */
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user