/[apt-spy]/update.c
ViewVC logotype

Contents of /update.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Thu Jun 19 21:08:01 2003 UTC (10 years ago) by bagpuss
Branch: MAIN, bagpuss
CVS Tags: initial, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
initial import
1 /* apt-spy (c) Steven Holmes, 2003. This software is licensed as detailed in the LICENSE file. */
2
3 #include <stdio.h>
4 #include <curl/curl.h>
5
6 #include "include/update.h"
7
8 int update(FILE *mirror_p, char *update_url, char *proxy)
9 {
10 CURL *curl;
11 char errorbuff[CURL_ERROR_SIZE];
12 int error;
13
14 curl = curl_easy_init();
15
16 if (curl == NULL)
17 return 1;
18
19 if (proxy != NULL)
20 if (curl_easy_setopt(curl, CURLOPT_PROXY, proxy) != 0)
21 return 1;
22
23 /* Turn off libcurl's progress indicator */
24 if (curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1) != 0)
25 return 1;
26
27 /* Fail on error */
28 if (curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1) != 0)
29 return 1;
30
31 /* And give us nice, human-readable error messages */
32 if (curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuff) != 0)
33 return 1;
34
35 /* set URL to use */
36 if (curl_easy_setopt(curl, CURLOPT_URL, update_url) != 0)
37 return 1;
38
39 /* set file to output stuff to */
40 if (curl_easy_setopt(curl, CURLOPT_FILE, mirror_p) != 0)
41 return 1;
42
43 printf("Updating...\n");
44 printf("Grabbing file %s...\n", update_url);
45
46 /* Do the transfer */
47 if ((error = curl_easy_perform(curl)) != 0) {
48 fprintf(stderr, "Error: %i: %s\n", error, errorbuff);
49 return 1;
50 }
51
52 /* And cleanup */
53 curl_easy_cleanup(curl);
54
55 return 0;
56 }

  ViewVC Help
Powered by ViewVC 1.1.5