Debian Codegraph @

netcon/includes/Chttpget.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/Chttpget.h $
21 * $Revision: 1.2 $
22 * $Date: 2004/02/09 04:14:51 $
23 * $Author: kevinb $
24 *
25 * HTTP Client class (get only)
26 *
27 * $Log: Chttpget.h,v $
28 * Revision 1.2 2004/02/09 04:14:51 kevinb
29 * Added newlines to all headers to reduce number of warnings printed
30 *
31 * Made some small changes to get everything compiling.
32 *
33 * All Ready to merge the 1.5 tree.
34 *
35 * Revision 1.1.1.1 2000/04/18 00:00:38 icculus
36 * initial checkin
37 *
38 *
39 * 7 8/21/99 9:14p Kevin
40 * Added support for redirection
41 *
42 * 6 8/21/99 6:48a Jeff
43 * Linux port
44 *
45 * 5 8/20/99 3:01p Kevin
46 * Added support for Proxies (I hope!)
47 *
48 * 4 7/31/98 12:19p Nate
49 * Fixed http abort problem.
50 *
51 * 3 7/31/98 11:57a Kevin
52 * Added new functions for getting state
53 *
54 * 2 6/01/98 10:10a Kevin
55 * Added DLL connection interface and auto update DLL
56 *
57 * 1 5/27/98 9:54a Kevin
58 *
59 * 1 5/25/98 5:31p Kevin
60 * Initial version
61 *
62 * $NoKeywords: $
63 */
64 #ifndef _CHTTPGET_HEADER_
65 #define _CHTTPGET_HEADER_
66
67 #include <cstdint>
68 #include "networking.h"
69
70 #define HTTP_STATE_INTERNAL_ERROR 0
71 #define HTTP_STATE_SOCKET_ERROR 1
72 #define HTTP_STATE_URL_PARSING_ERROR 2
73 #define HTTP_STATE_CONNECTING 3
74 #define HTTP_STATE_HOST_NOT_FOUND 4
75 #define HTTP_STATE_CANT_CONNECT 5
76 #define HTTP_STATE_CONNECTED 6
77 #define HTTP_STATE_FILE_NOT_FOUND 10
78 #define HTTP_STATE_RECEIVING 11
79 #define HTTP_STATE_FILE_RECEIVED 12
80 #define HTTP_STATE_UNKNOWN_ERROR 13
81 #define HTTP_STATE_RECV_FAILED 14
82 #define HTTP_STATE_CANT_WRITE_FILE 15
83 #define HTTP_STATE_STARTUP 16
84
85 #define MAX_URL_LEN 300
86
87 class ChttpGet {
88 public:
89 ChttpGet(char *URL, char *localfile);
90 ChttpGet(char *URL, char *localfile, char *proxyip, uint16_t proxyport);
91 void PrepSocket(char *URL);
92 ~ChttpGet();
93 void GetFile(char *URL, char *localfile);
94 int GetStatus();
95 uint32_t GetBytesIn();
96 uint32_t GetTotalBytes();
97 void AbortGet();
98 void WorkerThread();
99 bool m_Aborted;
100
101 protected:
102 int ConnectSocket();
103 char *GetHTTPLine();
104 uint32_t ReadDataChannel();
105 uint32_t m_iBytesIn;
106 uint32_t m_iBytesTotal;
107 uint32_t m_State;
108 bool m_ProxyEnabled;
109 char *m_ProxyIP;
110 char m_URL[MAX_URL_LEN];
111 uint16_t m_ProxyPort;
112
113 char m_szUserName[100];
114 char m_szPassword[100];
115 char m_szHost[200];
116 char m_szDir[200];
117 char m_szFilename[100];
118
119 bool m_Aborting;
120
121 SOCKET m_DataSock;
122
123 FILE *LOCALFILE;
124 char recv_buffer[1000];
125 };
126
127 #endif