Index: include/curl/curl.h
===================================================================
RCS file: /repository/curl/include/curl/curl.h,v
retrieving revision 1.221
diff -c -r1.221 curl.h
*** include/curl/curl.h	8 Oct 2003 13:54:36 -0000	1.221
--- include/curl/curl.h	11 Oct 2003 17:11:46 -0000
***************
*** 217,222 ****
--- 217,223 ----
    CURLE_SSL_CACERT,              /* 60 - problem with the CA cert (path?) */
    CURLE_BAD_CONTENT_ENCODING,    /* 61 - Unrecognized transfer encoding */
    CURLE_LDAP_INVALID_URL,        /* 62 - Invalid LDAP URL */
+   CURLE_FILESIZE_EXCEEDED,       /* 63 - Maximum file size exceeded */
  
    CURL_LAST /* never use! */
  } CURLcode;
***************
*** 688,693 ****
--- 689,698 ----
       tell libcurl to resolve names to those IP versions only. This only has
       affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */
    CINIT(IPRESOLVE, LONG, 113),
+ 
+   /* Set this option to limit the size of a file that will be downloaded from
+      an HTTP or FTP server. */
+   CINIT(MAXFILESIZE, LONG, 114),
  
    CURLOPT_LASTENTRY /* the last unused */
  } CURLoption;
Index: lib/ftp.c
===================================================================
RCS file: /repository/curl/lib/ftp.c,v
retrieving revision 1.200
diff -c -r1.200 ftp.c
*** lib/ftp.c	4 Oct 2003 15:25:02 -0000	1.200
--- lib/ftp.c	11 Oct 2003 17:11:47 -0000
***************
*** 1777,1784 ****
           downloads and when talking to servers that don't give away the size
           in the RETR response line. */
        result = ftp_getsize(conn, ftp->file, &foundsize);
!       if(CURLE_OK == result)
          downloadsize = foundsize;
  
        if(conn->resume_from) {
  
--- 1777,1789 ----
           downloads and when talking to servers that don't give away the size
           in the RETR response line. */
        result = ftp_getsize(conn, ftp->file, &foundsize);
!       if(CURLE_OK == result) {
!         if (data->set.max_filesize && foundsize > data->set.max_filesize) {
!           failf(data, "Maximum file size exceeded");
!           return CURLE_FILESIZE_EXCEEDED;
!         }
          downloadsize = foundsize;
+       }
  
        if(conn->resume_from) {
  
Index: lib/transfer.c
===================================================================
RCS file: /repository/curl/lib/transfer.c,v
retrieving revision 1.176
diff -c -r1.176 transfer.c
*** lib/transfer.c	3 Sep 2003 21:51:28 -0000	1.176
--- lib/transfer.c	11 Oct 2003 17:11:48 -0000
***************
*** 580,585 ****
--- 580,590 ----
              /* check for Content-Length: header lines to get size */
              if (checkprefix("Content-Length:", k->p) &&
                  sscanf (k->p+15, " %ld", &k->contentlength)) {
+               if (data->set.max_filesize && k->contentlength > 
+                   data->set.max_filesize) {
+                 failf(data, "Maximum file size exceeded");
+                 return CURLE_FILESIZE_EXCEEDED;
+               }
                conn->size = k->contentlength;
                Curl_pgrsSetDownloadSize(data, k->contentlength);
              }
Index: lib/url.c
===================================================================
RCS file: /repository/curl/lib/url.c,v
retrieving revision 1.305
diff -c -r1.305 url.c
*** lib/url.c	9 Oct 2003 20:04:47 -0000	1.305
--- lib/url.c	11 Oct 2003 17:11:49 -0000
***************
*** 1276,1281 ****
--- 1276,1288 ----
      data->set.http200aliases = va_arg(param, struct curl_slist *);
      break;
  
+   case CURLOPT_MAXFILESIZE:
+     /*
+      * Set the maximum size of a file to download.
+      */
+     data->set.max_filesize = va_arg(param, long);
+     break;
+ 
    default:
      /* unknown tag and its companion, just ignore: */
      return CURLE_FAILED_INIT; /* correct this */
Index: lib/urldata.h
===================================================================
RCS file: /repository/curl/lib/urldata.h,v
retrieving revision 1.178
diff -c -r1.178 urldata.h
*** lib/urldata.h	19 Sep 2003 15:16:49 -0000	1.178
--- lib/urldata.h	11 Oct 2003 17:11:49 -0000
***************
*** 828,833 ****
--- 828,835 ----
    struct curl_slist *http200aliases; /* linked list of aliases for http200 */
  
    int ip_version; 
+ 
+   long max_filesize; /* Maximum file size to download */
    
  /* Here follows boolean settings that define how to behave during
     this session. They are STATIC, set by libcurl users or at least initially
Index: src/main.c
===================================================================
RCS file: /repository/curl/src/main.c,v
retrieving revision 1.199
diff -c -r1.199 main.c
*** src/main.c	22 Sep 2003 22:29:11 -0000	1.199
--- src/main.c	11 Oct 2003 17:11:50 -0000
***************
*** 427,432 ****
--- 427,433 ----
      "                    following locations, even when hostname changed",
      " -m/--max-time <seconds> Maximum time allowed for the transfer",
      "    --max-redirs <num> Set maximum number of redirections allowed (H)",
+     "    --max-filesize <bytes> Set the maximum file size to download (H/F)",
      " -M/--manual        Display huge help text",
      " -n/--netrc         Must read .netrc for user name and password",
      "    --netrc-optional  Use either .netrc or URL; overrides -n",
***************
*** 505,510 ****
--- 506,512 ----
    long timeout;
    long connecttimeout;
    long maxredirs;
+   long max_filesize;
    char *headerfile;
    char *ftpport;
    char *iface;
***************
*** 1104,1109 ****
--- 1106,1112 ----
      {"*v", "stderr",      TRUE},
      {"*w", "interface",   TRUE},
      {"*x", "krb4",        TRUE},
+     {"*y", "max-filesize", TRUE},
      {"0", "http1.0",     FALSE},
      {"1", "tlsv1",       FALSE},
      {"2", "sslv2",       FALSE},
***************
*** 1370,1375 ****
--- 1373,1381 ----
          /* krb4 level string */
          GetStr(&config->krb4level, nextarg);
          break;
+       case 'y': /* --max-filesize */
+         config->max_filesize = atoi(nextarg);
+         break;
  
        default: /* the URL! */
          {
***************
*** 3208,3213 ****
--- 3214,3223 ----
                           config->ftp_create_dirs);
          if(config->proxyntlm)
            curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
+ 
+         /* new in curl 7.10.8 */
+         if (config->max_filesize)
+           curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, config->max_filesize);
  
          res = curl_easy_perform(curl);
          

