[Ilugc] [TIP] C program to download a file using HTTP#include <stdio.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> #include <string.h> #include <stdlib.h> #include <fcntl.h> #include <netdb.h> #defi

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Wed, 16 Nov 2011 08:16:41 +0530

Please don't reply to this thread. The other one please. Looks
horrible in the archive view.

It may also crash some people's mail clients.

Your points taken. But the dl() function ain't long.

-Girish

On Wed, Nov 16, 2011 at 8:03 AM, Shakthi Kannan <shakthimaan at gmail.com> 
wrote:

Hi,

--- On Wed, Nov 16, 2011 at 7:38 AM, Girish Venkatachalam
<girishvenkatachalam at gmail.com> wrote:
| ? ? ? ?int c, ret = -1, fd = -1;
| ? ? ? ?int bytes, off;
| ? ? ? ?struct hostent *h;
| ? ? ? ?struct sockaddr_in s;
\--

int c = 0;
int bytes = 0;
int off = 0;
struct hostent *h = NULL;

---
| ? ? ? ?char *p, *p2, host[1024], ip[40], outf[1024];
| ? ? ? ?char cmd[1024], buf[8192], path[1024];
\--

Would be good to avoid magic numbers. #define the values.

The dl() function is too long. It can be split into functions to
initialize, connect, and download. The following can be used for
reference:

?http://queue.acm.org/detail.cfm?id=2063168

SK

--
Shakthi Kannan
http://www.shakthimaan.com
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc




-- 
G3 Tech
Networking appliance company
web: http://g3tech.in ?mail: girish at g3tech.in

Other related posts: