2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Inetfile/inetgetfile.h $
15 * InternetGetFile Class header
18 * Revision 1.2 2002/06/09 04:41:13 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 2 4/20/99 6:39p Dave
26 * Almost done with artillery targeting. Added support for downloading
27 * images on the PXO screen.
29 * 1 4/20/99 4:37p Dave
35 #ifndef _INET_GETFILE_HEADER_
36 #define _INET_GETFILE_HEADER_
38 //At the end of this file is an example of usage
43 #define INET_ERROR_NO_ERROR 0
44 #define INET_ERROR_BADPARMS 1
45 #define INET_ERROR_CANT_WRITE_FILE 2
46 #define INET_ERROR_CANT_PARSE_URL 3
47 #define INET_ERROR_BAD_FILE_OR_DIR 4
48 #define INET_ERROR_HOST_NOT_FOUND 5
49 #define INET_ERROR_UNKNOWN_ERROR 6
50 #define INET_ERROR_NO_MEMORY 7
55 InetGetFile(char *URL,char *localfile);
57 BOOL IsFileReceived();
85 #include "inetgetfile.h"
87 int main(int argc,char **argv)
89 unsigned int LastPrintbytes = time(NULL);
90 InetGetFile *inetfile;
92 WORD ver=MAKEWORD(1,1);
94 int error=WSAStartup(ver,&ws_data);
95 inetfile = new InetGetFile("http://www.volition-inc.com/images/download/freespace/fsdemo1x-12u.exe","e:\\fsdemo1x-12u.exe");
98 if(inetfile->IsFileReceived())
100 printf("File received\n");
103 if(inetfile->IsFileError())
105 printf("File not received. Error code: %d\n",inetfile->GetErrorCode());
108 if(time(NULL)-LastPrintbytes>=1)
111 if(inetfile->GetTotalBytes())
113 ipct = 100*(float)((float)inetfile->GetBytesIn()/(float)inetfile->GetTotalBytes());
115 printf("Received %d Bytes out of %d (%d%%).\n",inetfile->GetBytesIn(),inetfile->GetTotalBytes(),ipct);
116 LastPrintbytes = time(NULL);