File: ghttpASCII.h

package info (click to toggle)
openmohaa 0.81.1%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 29,124 kB
  • sloc: ansic: 270,865; cpp: 250,173; sh: 234; asm: 141; xml: 64; makefile: 7
file content (270 lines) | stat: -rw-r--r-- 12,346 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
 /*
GameSpy GHTTP SDK 
Dan "Mr. Pants" Schoenblum
dan@gamespy.com

Copyright 1999-2007 GameSpy Industries, Inc

devsupport@gamespy.com
*/

// ASCII PROTOTYPES FOR USE IN UNICODE MODE
// INCLUDED TO SILENCE CODEWARRIOR WARNINGS
#ifndef _GHTTPASCII_H_
#define _GHTTPASCII_H_

#include "../common/gsCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

// Get a file from an http server.
// Returns GHTTPRequestError if an error occurs.
//////////////////////////////////
GHTTPRequest ghttpGetA
(
	const char * URL,       	// The URL for the file ("http://host.domain[:port]/path/filename").
	GHTTPBool blocking,         // If true, this call doesn't return until the file has been recevied.
	ghttpCompletedCallback completedCallback,  // Called when the file has been received.
	void * param                // User-data to be passed to the callbacks.
);

// Get a file from an http server.
// Returns GHTTPRequestError if an error occurs.
// Allows an optional user-supplied buffer to be used,
// optional extra http headers,
// and an optional progress callback.
// The optional headers must be 0 or more HTTP headers,
//   each terminated by a CR-LF pair (0xD, 0xA).
// If using a user-supplied buffer:
//   set buffer to the buffer to use,
//   set bufferSize to the size of the buffer in bytes.
// To have the library allocate a buffer:
//   set buffer to NULL, set bufferSize to 0
///////////////////////////////////////////////////////
GHTTPRequest ghttpGetExA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	const char * headers,   // Optional headers to pass with the request.  Can be NULL or "".
	char * buffer,              // Optional user-supplied buffer.  Set to NULL to have one allocated.
	int bufferSize,             // The size of the user-supplied buffer in bytes.  0 if buffer is NULL.
	GHTTPPost post,             // Optional data to be posted.
	GHTTPBool throttle,         // If true, throttle this connection's download speed.
	GHTTPBool blocking,         // If true, this call doesn't return until the file has been recevied.
	ghttpProgressCallback progressCallback,    // Called periodically with progress updates.
	ghttpCompletedCallback completedCallback,  // Called when the file has been received.
	void * param                // User-data to be passed to the callbacks.
);

// Gets a file and saves it to disk.
// Returns GHTTPRequestError if an error occurs.
////////////////////////////////////
GHTTPRequest ghttpSaveA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	const char * filename,  // The path and name to store the file as locally.
	GHTTPBool blocking,         // If true, this call doesn't return until the file has been recevied.
	ghttpCompletedCallback completedCallback,  // Called when the file has been received.
	void * param                // User-data to be passed to the callbacks.
);

// Gets a file and saves it to disk.
// Returns GHTTPRequestError if an error occurs.
// Allows optional extra http headers and
// an optional progress callback.
/////////////////////////////////////////
GHTTPRequest ghttpSaveExA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	const char * filename,  // The path and name to store the file as locally.
	const char * headers,   // Optional headers to pass with the request.  Can be NULL or "".
	GHTTPPost post,             // Optional data to be posted.
	GHTTPBool throttle,         // If true, throttle this connection's download speed.
	GHTTPBool blocking,         // If true, this call doesn't return until the file has been recevied.
	ghttpProgressCallback progressCallback,    // Called periodically with progress updates.
	ghttpCompletedCallback completedCallback,  // Called when the file has been received.
	void * param                // User-data to be passed to the callbacks.
);

// Streams a file from an http server.
// Returns GHTTPRequestError if an error occurs.
//////////////////////////////////////
GHTTPRequest ghttpStreamA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	GHTTPBool blocking,         // If true, this call doesn't return until the file has finished streaming.
	ghttpProgressCallback progressCallback,    // Called whenever new data is received.
	ghttpCompletedCallback completedCallback,  // Called when the file has finished streaming.
	void * param                // User-data to be passed to the callbacks.
);

// Streams a file from an http server.
// Returns GHTTPRequestError if an error occurs.
// Allows optional extra http headers.
//////////////////////////////////////
GHTTPRequest ghttpStreamExA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	const char * headers,   // Optional headers to pass with the request.  Can be NULL or "".
	GHTTPPost post,             // Optional data to be posted.
	GHTTPBool throttle,         // If true, throttle this connection's download speed.
	GHTTPBool blocking,         // If true, this call doesn't return until the file has finished streaming.
	ghttpProgressCallback progressCallback,    // Called whenever new data is received.
	ghttpCompletedCallback completedCallback,  // Called when the file has finished streaming.
	void * param                // User-data to be passed to the callbacks.
);

// Does a file request without actually getting the file.
// Use this to check the headers returned by a server when a request is made.
// Returns GHTTPRequestError if an error occurs.
/////////////////////////////////////////////////////////////////////////////
GHTTPRequest ghttpHeadA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	GHTTPBool blocking,         // If true, this call doesn't return until finished
	ghttpCompletedCallback completedCallback,  // Called when the request has finished.
	void * param                // User-data to be passed to the callbacks.
);

// Does a file request without actually getting the file.
// Use this to check the headers returned by a server when a request is made.
// Returns GHTTPRequestError if an error occurs.
// Allows optional extra http headers.
/////////////////////////////////////////////////////////////////////////////
GHTTPRequest ghttpHeadExA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	const char * headers,   // Optional headers to pass with the request.  Can be NULL or "".
	GHTTPBool throttle,         // If true, throttle this connection's download speed.
	GHTTPBool blocking,         // If true, this call doesn't return until finished
	ghttpProgressCallback progressCallback,    // Called whenever new data is received.
	ghttpCompletedCallback completedCallback,  // Called when the request has finished.
	void * param                // User-data to be passed to the callbacks.
);

// Does an HTTP POST, which can be used to upload data to a web server.
// The post parameter must be a valid GHTTPPost, setup with the data to be uploaded.
// No data will be returned from this request.  If data is needed, use one of the
// ghttp*FileEx() functions, and pass in a GHTTPPost object.
// Returns GHTTPRequestError if an error occurs.
///////////////////////////////////////////////////////////////////////////////////
GHTTPRequest ghttpPostA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	GHTTPPost post,             // The data to be posted.
	GHTTPBool blocking,         // If true, this call doesn't return until finished
	ghttpCompletedCallback completedCallback,  // Called when the file has finished streaming.
	void * param                // User-data to be passed to the callbacks.
);

// Does an HTTP POST, which can be used to upload data to a web server.
// The post parameter must be a valid GHTTPPost, setup with the data to be uploaded.
// No data will be returned from this request.  If data is needed, use one of the
// ghttp*FileEx() functions, and pass in a GHTTPPost object.
// Returns GHTTPRequestError if an error occurs.
// Allows optional extra http headers and
// an optional progress callback.
///////////////////////////////////////////////////////////////////////////////////
GHTTPRequest ghttpPostExA
(
	const char * URL,       // The URL for the file ("http://host.domain[:port]/path/filename").
	const char * headers,   // Optional headers to pass with the request.  Can be NULL or "".
	GHTTPPost post,             // The data to be posted.
	GHTTPBool throttle,         // If true, throttle this connection's download speed.
	GHTTPBool blocking,         // If true, this call doesn't return until finished
	ghttpProgressCallback progressCallback,    // Called whenever new data is received.
	ghttpCompletedCallback completedCallback,  // Called when the file has finished streaming.
	void * param                // User-data to be passed to the callbacks.
);


// Gets the status code and status string for a request.
// A pointer to the status string is returned, or NULL on error.
// Only valid if the GHTTPState for this request
// is greater than GHTTPReceivingStatus.
////////////////////////////////////////////////////////////////
const char * ghttpGetResponseStatus
(
	GHTTPRequest request,       // The request to get the response state of.
	int * statusCode            // If not NULL, the status code is stored here.
);

// Gets headers returned by the http server.
// Only valid if the GHTTPState for this
// request is GHTTPReceivingFile.
////////////////////////////////////////////
const char * ghttpGetHeaders
(
	GHTTPRequest request
);

// Gets the URL for a given request.
////////////////////////////////////
const char * ghttpGetURL
(
	GHTTPRequest request
);

// Sets a proxy server address.  The address should be of the
// form "<server>[:port]".  If port is omitted, 80 will be used.
// If server is NULL or "", no proxy server will be used.
// This should not be called while there are any current requests.
//////////////////////////////////////////////////////////////////
GHTTPBool ghttpSetProxyA
(
	const char * server
);

// Adds a string to the post object.
////////////////////////////////////
GHTTPBool ghttpPostAddStringA
(
	GHTTPPost post,             // The post object to add to.
	const char * name,      // The name to attach to this string.
	const char * string     // The actual string.
);

// Adds a disk file to the post object.
// The reportFilename is what is reported to the server as the filename.
// If NULL or empty, the filename will be used (including any possible path).
// The contentType is the MIME type to report for this file.
// If NULL, "application/octet-stream" is used.
// The file isn't read from until the data is actually sent to the server.
// Returns false for any error.
/////////////////////////////////////////////////////////////////////////////
GHTTPBool ghttpPostAddFileFromDiskA
(
	GHTTPPost post,                 // The post object to add to.
	const char * name,          // The name to attach to this file.
	const char * filename,      // The name (and possibly path) to the file to upload.
	const char * reportFilename,// The filename given to the web server.
	const char * contentType    // The MIME type for this file.
);

// Adds a file, in memory, to the post object.
// The reportFilename is what is reported to the server as the filename.
// Cannot be NULL or empty.
// The contentType is the MIME type to report for this file.
// If NULL, "application/octet-stream" is used.
// The data is NOT copied off in this call.  The data pointer is read from
// as the data is actually sent to the server.  The pointer must remain
// valid during requests.
// Returns false for any error.
//////////////////////////////////////////////////////////////////////////
GHTTPBool ghttpPostAddFileFromMemoryA
(
	GHTTPPost post,             // The post object to add to.
	const char * name,      // The name to attach to this string.
	const char * buffer,		// The data to send.
	int bufferLen,              // The number of bytes of data to send.
	const char * reportFilename,  // The filename given to the web server.
	const char * contentType    // The MIME type for this file.
);


#ifdef __cplusplus
}
#endif

#endif