Debian Codegraph @

netcon/includes/inetgetfile.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/Lib/inetgetfile.h $
21 * $Revision: 1.6 $
22 * $Date: 2004/03/21 17:11:39 $
23 * $Author: kevinb $
24 *
25 * InternetGetFile Class header
26 *
27 * $Log: inetgetfile.h,v $
28 * Revision 1.6 2004/03/21 17:11:39 kevinb
29 * Fixes so linux will compile again. Tested with gcc-2.96
30 *
31 * Revision 1.5 2004/02/25 00:04:06 ryan
32 * Removed loki_utils dependency and ported to MacOS X (runs, but incomplete).
33 *
34 * Revision 1.4 2004/02/09 04:14:51 kevinb
35 * Added newlines to all headers to reduce number of warnings printed
36 *
37 * Made some small changes to get everything compiling.
38 *
39 * All Ready to merge the 1.5 tree.
40 *
41 * Revision 1.3 2000/09/22 19:05:09 icculus
42 * updated.
43 *
44 * Revision 1.2 2000/06/03 14:33:51 icculus
45 * Merge with Outrage 1.4 tree...
46 *
47 * Revision 1.1.1.1 2000/04/18 00:00:38 icculus
48 * initial checkin
49 *
50 *
51 * 10 10/21/99 9:27p Jeff
52 * B.A. Macintosh code merge
53 *
54 * 9 8/23/99 5:12p Kevin
55 * Proxy support for http
56 *
57 * 8 8/21/99 6:48a Jeff
58 * Linux port
59 *
60 * 7 4/17/99 5:49a Jeff
61 * changes made so it compiles under Linux
62 *
63 * 6 4/14/99 3:59a Jeff
64 * fixed case mismatches in #includes
65 *
66 * 5 7/31/98 11:57a Kevin
67 * Added new functions for getting state
68 *
69 * 4 7/31/98 11:40a Kevin
70 *
71 * 3 7/31/98 11:17a Nate
72 * Fixed memory leak and added memory alloc checking.
73 *
74 * 2 6/01/98 10:10a Kevin
75 * Added DLL connection interface and auto update DLL
76 *
77 * 1 5/27/98 9:54a Kevin
78 *
79 * 1 5/25/98 5:31p Kevin
80 * Initial version
81 *
82 * $NoKeywords: $
83 */
84 #ifndef _INET_GETFILE_HEADER_
85 #define _INET_GETFILE_HEADER_cxx . . $ `netcon/includes/inetgetfile.h:85:9`!
86
87 // At the end of this file is an example of usage
88
89 #if defined(POSIXcxx . . $ `<built-in>:478:9`!)
90 #include <ctype.h>
91 #include <errno.h>
92 #include <netinet/in.h>
93 #include <arpa/inet.h>
94 #include <sys/types.h>
95 #include <sys/socket.h>
96 #include <netdb.h>
97 #include <sys/time.h>
98 #include <unistd.h>
99
100 #include "linux_fix.h"cxx . . $ `<file>/linux/linux_fix.h`/
101
102 // Linux includes/defines
103 #if defined(__LINUX__cxx . . $ `<external>/8627488274992530813/SDL_platform.h:61:9`!)
104 #include <linux/types.h>
105 // #include <linux/if.h>
106 #endif
107
108 #define BOOLcxx . . $ `netcon/includes/inetgetfile.h:108:9`! bool
109
110 #ifndef SOCKETcxx . . $ `lib/networking.h:217:9`!
111 #define SOCKETcxx . . $ `netcon/includes/inetgetfile.h:111:9`! int
112 #endif
113
114 #define SOCKADDR_INcxx . . $ `netcon/includes/inetgetfile.h:114:9`! sockaddr_in
115 #define SOCKADDRcxx . . $ `netcon/includes/inetgetfile.h:115:9`! sockaddr
116 #define INVALID_SOCKETcxx . . $ `netcon/includes/inetgetfile.h:116:9`! -1
117 #define HOSTENTcxx . . $ `netcon/includes/inetgetfile.h:117:9`! struct hostent
118 #define SERVENTcxx . . $ `netcon/includes/inetgetfile.h:118:9`! struct servent
119 #define TIMEVALcxx . . $ `netcon/includes/inetgetfile.h:119:9`! struct timeval
120 // Winsock = sockets error translation
121 #define WSAEWOULDBLOCKcxx . . $ `netcon/includes/inetgetfile.h:121:9`! EWOULDBLOCK
122 #define WSAEINVALcxx . . $ `netcon/includes/inetgetfile.h:122:9`! EINVAL
123 #define WSAENOPROTOOPTcxx . . $ `netcon/includes/inetgetfile.h:123:9`! ENOPROTOOPT
124 #define WSAEALREADYcxx . . $ `netcon/includes/inetgetfile.h:124:9`! EALREADYcxx . . $ `<external>/17922322188510340118/errno.h:98:9`!
125 #define WSAEISCONNcxx . . $ `netcon/includes/inetgetfile.h:125:9`! EISCONNcxx . . $ `<external>/17922322188510340118/errno.h:90:9`!
126 #define SOCKET_ERRORcxx . . $ `netcon/includes/inetgetfile.h:126:9`! -1
127
128 #ifndef WSAGetLastErrorcxx . . $ `lib/networking.h:241:9`!
129 #define WSAGetLastErrorcxx . . $ `netcon/includes/inetgetfile.h:129:9`!() errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!
130 #endif
131
132
133
134 /*
135 typedef int (*pthread_create_fp)(pthread_t *__thread,__const pthread_attr_t *__attr,void *(*__start_routine) (void
136 *),void *__arg); typedef void (*pthread_exit_fp)(void *__retval); typedef int (*pthread_detach_fp)(pthread_t __th);
137 typedef pthread_t (*pthread_self_fp)(void);
138
139 extern pthread_create_fp df_pthread_create;
140 extern pthread_exit_fp df_pthread_exit;
141 extern pthread_detach_fp df_pthread_detach;
142 extern pthread_self_fp df_pthread_self;
143 */
144
145 bool inet_LoadThreadLibcxx . . $ inet_LoadThreadLib(c9857a73d68e59ba).(void);
146
147 #endif
148
149 #include "CFtp.h"cxx . . $ `<file>/netcon/includes/CFtp.h`/
150 #include "Chttpget.h"cxx . . $ `<file>/netcon/includes/Chttpget.h`/
151
152 #define INET_ERROR_NO_ERRORcxx . . $ `netcon/includes/inetgetfile.h:152:9`! 0
153 #define INET_ERROR_BADPARMScxx . . $ `netcon/includes/inetgetfile.h:153:9`! 1
154 #define INET_ERROR_CANT_WRITE_FILEcxx . . $ `netcon/includes/inetgetfile.h:154:9`! 2
155 #define INET_ERROR_CANT_PARSE_URLcxx . . $ `netcon/includes/inetgetfile.h:155:9`! 3
156 #define INET_ERROR_BAD_FILE_OR_DIRcxx . . $ `netcon/includes/inetgetfile.h:156:9`! 4
157 #define INET_ERROR_HOST_NOT_FOUNDcxx . . $ `netcon/includes/inetgetfile.h:157:9`! 5
158 #define INET_ERROR_UNKNOWN_ERRORcxx . . $ `netcon/includes/inetgetfile.h:158:9`! 6
159 #define INET_ERROR_NO_MEMORYcxx . . $ `netcon/includes/inetgetfile.h:159:9`! 7
160
161 #define INET_STATE_CONNECTINGcxx . . $ `netcon/includes/inetgetfile.h:161:9`! 1
162 #define INET_STATE_ERRORcxx . . $ `netcon/includes/inetgetfile.h:162:9`! 2
163 #define INET_STATE_RECEIVINGcxx . . $ `netcon/includes/inetgetfile.h:163:9`! 3
164 #define INET_STATE_GOT_FILEcxx . . $ `netcon/includes/inetgetfile.h:164:9`! 4
165
166 class InetGetFilecxx . . $ InetGetFile# {
167 public:
168 InetGetFilecxx . . $ InetGetFile#InetGetFile(d0489a02ea06dfc6).(char *URL, char *localfile);
169 InetGetFilecxx . . $ InetGetFile#InetGetFile(70b3d6b1f7183c65).(char *URL, char *localfile, char *proxyip, int16_tcxx . . $ int16_t# proxyport);
170 ~cxx . . $ InetGetFile#`~InetGetFile`(49f6e7a06ebc5aa8).InetGetFilecxx . . $ InetGetFile#();
171 BOOLcxx . . $ `lib/networking.h:218:9`! IsFileReceivedcxx . . $ InetGetFile#IsFileReceived(c9857a73d68e59ba).();
172 BOOLcxx . . $ `netcon/includes/inetgetfile.h:108:9`! IsFileErrorcxx . . $ InetGetFile#IsFileError(c9857a73d68e59ba).();
173 BOOLcxx . . $ `netcon/includes/inetgetfile.h:108:9`! IsConnectingcxx . . $ InetGetFile#IsConnecting(c9857a73d68e59ba).();
174 BOOLcxx . . $ `netcon/includes/inetgetfile.h:108:9`! IsReceivingcxx . . $ InetGetFile#IsReceiving(c9857a73d68e59ba).();
175 int GetErrorCodecxx . . $ InetGetFile#GetErrorCode(b126dc7c1de90089).();
176 int GetBytesIncxx . . $ InetGetFile#GetBytesIn(b126dc7c1de90089).();
177 int GetTotalBytescxx . . $ InetGetFile#GetTotalBytes(b126dc7c1de90089).();
178 void AbortGetcxx . . $ InetGetFile#AbortGet(49f6e7a06ebc5aa8).();
179
180 protected:
181 CFtpGetcxx . . $ CFtpGet# *ftpcxx . . $ InetGetFile#ftp.;
182 ChttpGetcxx . . $ ChttpGet# *httpcxx . . $ InetGetFile#http.;
183 BOOLcxx . . $ `netcon/includes/inetgetfile.h:108:9`! m_bUseHTTPcxx . . $ InetGetFile#m_bUseHTTP.;
184 int m_ErrorCodecxx . . $ InetGetFile#m_ErrorCode.;
185 int m_Statecxx . . $ InetGetFile#m_State.;
186 int m_HardErrorcxx . . $ InetGetFile#m_HardError.;
187 };
188
189 #endif
190
191 /*
192
193 #include <stdio.h>
194 #include <windows.h>
195 #include <conio.h>
196 #include <time.h>
197
198 #include "inetgetfile.h"
199
200 int main(int argc,char **argv)
201 {
202 uint32_t LastPrintbytes = time(NULL);
203 InetGetFile *inetfile;
204 WSADATA ws_data;
205 WORD ver=MAKEWORD(1,1);
206
207 int error=WSAStartup(ver,&ws_data);
208 inetfile = new
209 InetGetFile("http://www.volition-inc.com/images/download/freespace/fsdemo1x-12u.exe","e:\\fsdemo1x-12u.exe"); do
210 {
211 if(inetfile->IsFileReceived())
212 {
213 printf("File received\n");
214 break;
215 }
216 if(inetfile->IsFileError())
217 {
218 printf("File not received. Error code: %d\n",inetfile->GetErrorCode());
219 break;
220 }
221 if(time(NULL)-LastPrintbytes>=1)
222 {
223 int ipct = 0;
224 if(inetfile->GetTotalBytes())
225 {
226 ipct = 100*(float)((float)inetfile->GetBytesIn()/(float)inetfile->GetTotalBytes());
227 }
228 printf("Received %d Bytes out of %d
229 (%d%%).\n",inetfile->GetBytesIn(),inetfile->GetTotalBytes(),ipct); LastPrintbytes = time(NULL);
230 }
231
232
233 }while(!kbhit());
234 return 0;
235
236 }
237
238
239
240 */