OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
ghttpCommon.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#ifndef _GHTTPCOMMON_H_
12#define _GHTTPCOMMON_H_
13
14#include "ghttp.h"
15#include "ghttpConnection.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21// HTTP Line-terminator.
23#define CRLF "\xD\xA"
24
25// HTTP URL Encoding
27#define GHI_LEGAL_URLENCODED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@-.*"
28#define GHI_DIGITS "0123456789ABCDEF"
29
30// Default HTTP port.
32#define GHI_DEFAULT_PORT 80
33#define GHI_DEFAULT_SECURE_PORT 443
34#define GHI_DEFAULT_THROTTLE_BUFFER_SIZE 125
35#define GHI_DEFAULT_THROTTLE_TIME_DELAY 250
36
37// Proxy server.
39extern char * ghiProxyAddress;
40extern unsigned short ghiProxyPort;
41
42// Throttle settings.
44extern int ghiThrottleBufferSize;
45extern gsi_time ghiThrottleTimeDelay;
46
47// Our thread lock.
49void ghiCreateLock(void);
50void ghiFreeLock(void);
51void ghiLock(void);
52void ghiUnlock(void);
53
54// Do logging.
56#ifdef HTTP_LOG
57void ghiLogToFile
58(
59 const char * buffer,
60 int len,
61 const char * fileName
62);
63#define ghiLogRequest(b,c) ghiLogToFile(b,c,"request.log");
64#define ghiLogResponse(b,c) ghiLogToFile(b,c,"response.log");
65#define ghiLogPost(b,c) ghiLogToFile(b,c,"post.log");
66#else
67#define ghiLogRequest(b,c)
68#define ghiLogResponse(b,c)
69#define ghiLogPost(b,c)
70#endif
71
72
73// Possible results from ghiDoReceive.
75typedef enum
76{
77 GHIRecvData, // Data was received.
78 GHINoData, // No data was available.
79 GHIConnClosed, // The connection was closed.
80 GHIError // There was a socket error.
81} GHIRecvResult;
82
83// Receive some data.
85GHIRecvResult ghiDoReceive
86(
87 GHIConnection * connection,
88 char buffer[],
89 int * bufferLen
90);
91
92// Do a send on the connection's socket.
93// Returns number of bytes sent (0 or more).
94// If error, returns (-1).
96int ghiDoSend
97(
98 GHIConnection * connection,
99 const char * buffer,
100 int len
101);
102
103// Results for ghtTrySendThenBuffer.
105typedef enum
106{
107 GHITrySendError, // There was an error sending.
108 GHITrySendSent, // Everything was sent.
109 GHITrySendBuffered // Some or all of the data was buffered.
110} GHITrySendResult;
111
112// Sends whatever it can on the socket.
113// Buffers whatever can't be sent in the sendBuffer.
115GHITrySendResult ghiTrySendThenBuffer
116(
117 GHIConnection * connection,
118 const char * buffer,
119 int len
120);
121
122// Set the proxy server
124GHTTPBool ghiSetProxy
125(
126 const char * server
127);
128
129// Set the proxy server for a specific request
131GHTTPBool ghiSetRequestProxy
132(
133 GHTTPRequest request,
134 const char * server
135);
136
137// Set the throttle settings.
139void ghiThrottleSettings
140(
141 int bufferSize,
142 gsi_time timeDelay
143);
144
145// Decrypt data from the decode buffer into the receive buffer.
147GHTTPBool ghiDecryptReceivedData(struct GHIConnection * connection);
148
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif
Definition ghttpConnection.h:84