#include #include #include #include int HTDoConnect(); int HTDoRead(); #define HTSIZE 4096 #define MAX_BUF 1025 static char htbuff[HTSIZE]; static int htbufflen; static int htbuffptr; static int socket; main(argc,argv) int argc; char *argv[]; { char *cp; int i,handle; FILE *fl; char comm[MAX_BUF]; strcpy(comm,argv[1]); if(argc<=2) fl=stdout; else fl=fopen(argv[2],"wb"); if(fl==NULL){printf("Error opening output file %s\n",argv[2]);exit(1);}; cp=strchr(comm+7,'/'); if(cp==NULL)return -999; strcpy(htbuff,"GET /"); strcat(htbuff,cp+1); *cp =0; i=HTDoConnect(comm,"HTTP",80,&handle); if(i) {printf("Connect to %s failed\n",comm);exit(1);}; socket = handle; cp=htbuff+strlen(htbuff); *(cp++)=13; *(cp++)=10; *cp=0; write(handle,htbuff,strlen(htbuff)); while(htbufflen=HTDoRead(socket,htbuff,HTSIZE)) fwrite(htbuff,1,htbufflen,fl); fclose(fl); close(socket); }