]> icculus.org git repositories - taylor/freespace2.git/blob - include/inetgetfile.h
rendering functions mostly done; more complete shader setup
[taylor/freespace2.git] / include / inetgetfile.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10 * $Logfile: /Freespace2/code/Inetfile/inetgetfile.h $
11 * $Revision$
12 * $Date$
13 * $Author$
14 *
15 * InternetGetFile Class header
16 *
17 * $Log$
18 * Revision 1.2  2002/06/09 04:41:13  relnev
19 * added copyright header
20 *
21 * Revision 1.1.1.1  2002/05/03 03:28:12  root
22 * Initial import.
23 *
24  * 
25  * 2     4/20/99 6:39p Dave
26  * Almost done with artillery targeting. Added support for downloading
27  * images on the PXO screen.
28  * 
29  * 1     4/20/99 4:37p Dave
30  *  
31  * Initial version
32 *
33 * $NoKeywords: $
34 */
35 #ifndef _INET_GETFILE_HEADER_
36 #define _INET_GETFILE_HEADER_
37
38 //At the end of this file is an example of usage
39
40 #include "cftp.h"
41 #include "chttpget.h"
42
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
51
52 class InetGetFile
53 {
54 public:
55         InetGetFile(char *URL, char *filename, int cf_type = 1 /* CF_TYPE_ROOT */);
56         ~InetGetFile();
57         bool IsFileReceived();
58         bool IsFileError();
59         bool IsConnecting();
60         bool IsReceiving();
61         int GetErrorCode();
62         int GetBytesIn();
63         int GetTotalBytes();
64         void AbortGet();
65
66 protected:
67         CFtpGet *ftp;
68         ChttpGet *http;
69         bool m_bUseHTTP;
70         int m_ErrorCode;
71         int m_State;
72         int m_HardError;
73
74 };
75
76 #endif
77
78 /*
79
80 #include <stdio.h>
81 #include <windows.h>
82 #include <conio.h>
83 #include <time.h>
84
85 #include "inetgetfile.h"
86
87 int main(int argc,char **argv)
88 {
89         unsigned int LastPrintbytes = time(NULL);
90         InetGetFile *inetfile;
91         WSADATA ws_data;
92         WORD ver=MAKEWORD(1,1);
93         
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");
96         do
97         {
98                 if(inetfile->IsFileReceived())
99                 {
100                         printf("File received\n");
101                         break;
102                 }
103                 if(inetfile->IsFileError())
104                 {
105                         printf("File not received. Error code: %d\n",inetfile->GetErrorCode());
106                         break;
107                 }
108                 if(time(NULL)-LastPrintbytes>=1)
109                 {
110                         int ipct = 0;
111                         if(inetfile->GetTotalBytes())
112                         {
113                                 ipct = 100*(float)((float)inetfile->GetBytesIn()/(float)inetfile->GetTotalBytes());
114                         }
115                         printf("Received %d Bytes out of %d (%d%%).\n",inetfile->GetBytesIn(),inetfile->GetTotalBytes(),ipct);
116                         LastPrintbytes = time(NULL);
117                 }
118
119
120         }while(!kbhit());
121         return 0;
122
123 }
124
125
126
127  */
128