OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
ghttpASCII.h
1 /*
2GameSpy GHTTP SDK
3Dan "Mr. Pants" Schoenblum
4dan@gamespy.com
5
6Copyright 1999-2007 GameSpy Industries, Inc
7
8devsupport@gamespy.com
9*/
10
11// ASCII PROTOTYPES FOR USE IN UNICODE MODE
12// INCLUDED TO SILENCE CODEWARRIOR WARNINGS
13#ifndef _GHTTPASCII_H_
14#define _GHTTPASCII_H_
15
16#include "../common/gsCommon.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22// Get a file from an http server.
23// Returns GHTTPRequestError if an error occurs.
25GHTTPRequest ghttpGetA
26(
27 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
28 GHTTPBool blocking, // If true, this call doesn't return until the file has been recevied.
29 ghttpCompletedCallback completedCallback, // Called when the file has been received.
30 void * param // User-data to be passed to the callbacks.
31);
32
33// Get a file from an http server.
34// Returns GHTTPRequestError if an error occurs.
35// Allows an optional user-supplied buffer to be used,
36// optional extra http headers,
37// and an optional progress callback.
38// The optional headers must be 0 or more HTTP headers,
39// each terminated by a CR-LF pair (0xD, 0xA).
40// If using a user-supplied buffer:
41// set buffer to the buffer to use,
42// set bufferSize to the size of the buffer in bytes.
43// To have the library allocate a buffer:
44// set buffer to NULL, set bufferSize to 0
46GHTTPRequest ghttpGetExA
47(
48 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
49 const char * headers, // Optional headers to pass with the request. Can be NULL or "".
50 char * buffer, // Optional user-supplied buffer. Set to NULL to have one allocated.
51 int bufferSize, // The size of the user-supplied buffer in bytes. 0 if buffer is NULL.
52 GHTTPPost post, // Optional data to be posted.
53 GHTTPBool throttle, // If true, throttle this connection's download speed.
54 GHTTPBool blocking, // If true, this call doesn't return until the file has been recevied.
55 ghttpProgressCallback progressCallback, // Called periodically with progress updates.
56 ghttpCompletedCallback completedCallback, // Called when the file has been received.
57 void * param // User-data to be passed to the callbacks.
58);
59
60// Gets a file and saves it to disk.
61// Returns GHTTPRequestError if an error occurs.
63GHTTPRequest ghttpSaveA
64(
65 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
66 const char * filename, // The path and name to store the file as locally.
67 GHTTPBool blocking, // If true, this call doesn't return until the file has been recevied.
68 ghttpCompletedCallback completedCallback, // Called when the file has been received.
69 void * param // User-data to be passed to the callbacks.
70);
71
72// Gets a file and saves it to disk.
73// Returns GHTTPRequestError if an error occurs.
74// Allows optional extra http headers and
75// an optional progress callback.
77GHTTPRequest ghttpSaveExA
78(
79 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
80 const char * filename, // The path and name to store the file as locally.
81 const char * headers, // Optional headers to pass with the request. Can be NULL or "".
82 GHTTPPost post, // Optional data to be posted.
83 GHTTPBool throttle, // If true, throttle this connection's download speed.
84 GHTTPBool blocking, // If true, this call doesn't return until the file has been recevied.
85 ghttpProgressCallback progressCallback, // Called periodically with progress updates.
86 ghttpCompletedCallback completedCallback, // Called when the file has been received.
87 void * param // User-data to be passed to the callbacks.
88);
89
90// Streams a file from an http server.
91// Returns GHTTPRequestError if an error occurs.
93GHTTPRequest ghttpStreamA
94(
95 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
96 GHTTPBool blocking, // If true, this call doesn't return until the file has finished streaming.
97 ghttpProgressCallback progressCallback, // Called whenever new data is received.
98 ghttpCompletedCallback completedCallback, // Called when the file has finished streaming.
99 void * param // User-data to be passed to the callbacks.
100);
101
102// Streams a file from an http server.
103// Returns GHTTPRequestError if an error occurs.
104// Allows optional extra http headers.
106GHTTPRequest ghttpStreamExA
107(
108 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
109 const char * headers, // Optional headers to pass with the request. Can be NULL or "".
110 GHTTPPost post, // Optional data to be posted.
111 GHTTPBool throttle, // If true, throttle this connection's download speed.
112 GHTTPBool blocking, // If true, this call doesn't return until the file has finished streaming.
113 ghttpProgressCallback progressCallback, // Called whenever new data is received.
114 ghttpCompletedCallback completedCallback, // Called when the file has finished streaming.
115 void * param // User-data to be passed to the callbacks.
116);
117
118// Does a file request without actually getting the file.
119// Use this to check the headers returned by a server when a request is made.
120// Returns GHTTPRequestError if an error occurs.
122GHTTPRequest ghttpHeadA
123(
124 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
125 GHTTPBool blocking, // If true, this call doesn't return until finished
126 ghttpCompletedCallback completedCallback, // Called when the request has finished.
127 void * param // User-data to be passed to the callbacks.
128);
129
130// Does a file request without actually getting the file.
131// Use this to check the headers returned by a server when a request is made.
132// Returns GHTTPRequestError if an error occurs.
133// Allows optional extra http headers.
135GHTTPRequest ghttpHeadExA
136(
137 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
138 const char * headers, // Optional headers to pass with the request. Can be NULL or "".
139 GHTTPBool throttle, // If true, throttle this connection's download speed.
140 GHTTPBool blocking, // If true, this call doesn't return until finished
141 ghttpProgressCallback progressCallback, // Called whenever new data is received.
142 ghttpCompletedCallback completedCallback, // Called when the request has finished.
143 void * param // User-data to be passed to the callbacks.
144);
145
146// Does an HTTP POST, which can be used to upload data to a web server.
147// The post parameter must be a valid GHTTPPost, setup with the data to be uploaded.
148// No data will be returned from this request. If data is needed, use one of the
149// ghttp*FileEx() functions, and pass in a GHTTPPost object.
150// Returns GHTTPRequestError if an error occurs.
152GHTTPRequest ghttpPostA
153(
154 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
155 GHTTPPost post, // The data to be posted.
156 GHTTPBool blocking, // If true, this call doesn't return until finished
157 ghttpCompletedCallback completedCallback, // Called when the file has finished streaming.
158 void * param // User-data to be passed to the callbacks.
159);
160
161// Does an HTTP POST, which can be used to upload data to a web server.
162// The post parameter must be a valid GHTTPPost, setup with the data to be uploaded.
163// No data will be returned from this request. If data is needed, use one of the
164// ghttp*FileEx() functions, and pass in a GHTTPPost object.
165// Returns GHTTPRequestError if an error occurs.
166// Allows optional extra http headers and
167// an optional progress callback.
169GHTTPRequest ghttpPostExA
170(
171 const char * URL, // The URL for the file ("http://host.domain[:port]/path/filename").
172 const char * headers, // Optional headers to pass with the request. Can be NULL or "".
173 GHTTPPost post, // The data to be posted.
174 GHTTPBool throttle, // If true, throttle this connection's download speed.
175 GHTTPBool blocking, // If true, this call doesn't return until finished
176 ghttpProgressCallback progressCallback, // Called whenever new data is received.
177 ghttpCompletedCallback completedCallback, // Called when the file has finished streaming.
178 void * param // User-data to be passed to the callbacks.
179);
180
181
182// Gets the status code and status string for a request.
183// A pointer to the status string is returned, or NULL on error.
184// Only valid if the GHTTPState for this request
185// is greater than GHTTPReceivingStatus.
187const char * ghttpGetResponseStatus
188(
189 GHTTPRequest request, // The request to get the response state of.
190 int * statusCode // If not NULL, the status code is stored here.
191);
192
193// Gets headers returned by the http server.
194// Only valid if the GHTTPState for this
195// request is GHTTPReceivingFile.
197const char * ghttpGetHeaders
198(
199 GHTTPRequest request
200);
201
202// Gets the URL for a given request.
204const char * ghttpGetURL
205(
206 GHTTPRequest request
207);
208
209// Sets a proxy server address. The address should be of the
210// form "<server>[:port]". If port is omitted, 80 will be used.
211// If server is NULL or "", no proxy server will be used.
212// This should not be called while there are any current requests.
214GHTTPBool ghttpSetProxyA
215(
216 const char * server
217);
218
219// Adds a string to the post object.
221GHTTPBool ghttpPostAddStringA
222(
223 GHTTPPost post, // The post object to add to.
224 const char * name, // The name to attach to this string.
225 const char * string // The actual string.
226);
227
228// Adds a disk file to the post object.
229// The reportFilename is what is reported to the server as the filename.
230// If NULL or empty, the filename will be used (including any possible path).
231// The contentType is the MIME type to report for this file.
232// If NULL, "application/octet-stream" is used.
233// The file isn't read from until the data is actually sent to the server.
234// Returns false for any error.
236GHTTPBool ghttpPostAddFileFromDiskA
237(
238 GHTTPPost post, // The post object to add to.
239 const char * name, // The name to attach to this file.
240 const char * filename, // The name (and possibly path) to the file to upload.
241 const char * reportFilename,// The filename given to the web server.
242 const char * contentType // The MIME type for this file.
243);
244
245// Adds a file, in memory, to the post object.
246// The reportFilename is what is reported to the server as the filename.
247// Cannot be NULL or empty.
248// The contentType is the MIME type to report for this file.
249// If NULL, "application/octet-stream" is used.
250// The data is NOT copied off in this call. The data pointer is read from
251// as the data is actually sent to the server. The pointer must remain
252// valid during requests.
253// Returns false for any error.
255GHTTPBool ghttpPostAddFileFromMemoryA
256(
257 GHTTPPost post, // The post object to add to.
258 const char * name, // The name to attach to this string.
259 const char * buffer, // The data to send.
260 int bufferLen, // The number of bytes of data to send.
261 const char * reportFilename, // The filename given to the web server.
262 const char * contentType // The MIME type for this file.
263);
264
265
266#ifdef __cplusplus
267}
268#endif
269
270#endif