UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
http.h
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 1997-2001 Id Software, Inc.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17
See the GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23
*/
24
25
#pragma once
26
27
#include "
common.h
"
28
#ifndef NO_HTTP
29
#ifndef CURL_STATICLIB
30
#define CURL_STATICLIB
31
#endif
32
#include <curl/curl.h>
33
34
typedef
enum
{
35
DLQ_STATE_NOT_STARTED
,
36
DLQ_STATE_RUNNING
,
37
DLQ_STATE_DONE
38
}
dlq_state
;
39
40
typedef
struct
dlqueue_s {
41
struct
dlqueue_s*
next
;
42
char
ufoPath
[
MAX_QPATH
];
43
dlq_state
state
;
44
}
dlqueue_t
;
45
46
typedef
struct
dlhandle_s {
47
CURL*
curl
;
48
char
filePath
[
MAX_OSPATH
];
49
FILE
*
file
;
50
dlqueue_t
*
queueEntry
;
51
size_t
fileSize
;
52
size_t
position
;
53
double
speed
;
54
char
URL
[576];
55
char
*
tempBuffer
;
56
}
dlhandle_t
;
57
#endif
58
59
typedef
struct
upparam_s {
60
const
char
*
name
;
61
const
char
*
value
;
62
struct
upparam_s*
next
;
63
}
upparam_t
;
64
65
typedef
void
(*
http_callback_t
) (
const
char
* response,
void
* userdata);
66
67
bool
HTTP_Encode
(
const
char
* url,
char
* out,
size_t
outLength);
68
bool
HTTP_GetToFile
(
const
char
* url,
FILE
* file,
const
char
* postfields =
nullptr
);
69
bool
HTTP_GetURL
(
const
char
* url,
http_callback_t
callback,
void
* userdata =
nullptr
,
const
char
* postfields =
nullptr
);
70
bool
HTTP_PutFile
(
const
char
* formName,
const
char
* fileName,
const
char
* url,
const
upparam_t
* params);
71
size_t
HTTP_Recv
(
void
* ptr,
size_t
size
,
size_t
nmemb,
void
*
stream
);
72
size_t
HTTP_Header
(
void
* ptr,
size_t
size
,
size_t
nmemb,
void
*
stream
);
73
void
HTTP_Cleanup
(
void
);
74
bool
HTTP_ExtractComponents
(
const
char
* url,
char
* scheme,
size_t
schemeLength,
char
* host,
size_t
hostLength,
char
* path,
size_t
pathLength,
int
*
port
);
port
cvar_t * port
Definition
common.cpp:58
common.h
definitions common between client and server, but not game lib
MAX_OSPATH
#define MAX_OSPATH
Definition
filesys.h:44
MAX_QPATH
#define MAX_QPATH
Definition
filesys.h:40
http_callback_t
void(* http_callback_t)(const char *response, void *userdata)
Definition
http.h:65
HTTP_PutFile
bool HTTP_PutFile(const char *formName, const char *fileName, const char *url, const upparam_t *params)
Definition
http.cpp:265
HTTP_GetToFile
bool HTTP_GetToFile(const char *url, FILE *file, const char *postfields=nullptr)
Downloads the given url into the given file.
Definition
http.cpp:346
dlq_state
dlq_state
Definition
http.h:34
DLQ_STATE_RUNNING
@ DLQ_STATE_RUNNING
Definition
http.h:36
DLQ_STATE_NOT_STARTED
@ DLQ_STATE_NOT_STARTED
Definition
http.h:35
DLQ_STATE_DONE
@ DLQ_STATE_DONE
Definition
http.h:37
HTTP_Recv
size_t HTTP_Recv(void *ptr, size_t size, size_t nmemb, void *stream)
libcurl callback for HTTP_GetURL
Definition
http.cpp:154
HTTP_ExtractComponents
bool HTTP_ExtractComponents(const char *url, char *scheme, size_t schemeLength, char *host, size_t hostLength, char *path, size_t pathLength, int *port)
Extract the servername, the port and the path part of the given url.
Definition
http.cpp:38
HTTP_Cleanup
void HTTP_Cleanup(void)
UFO is exiting or we're changing servers. Clean up.
Definition
http.cpp:406
HTTP_GetURL
bool HTTP_GetURL(const char *url, http_callback_t callback, void *userdata=nullptr, const char *postfields=nullptr)
Downloads the given url and return the data to the callback (optional).
Definition
http.cpp:384
HTTP_Header
size_t HTTP_Header(void *ptr, size_t size, size_t nmemb, void *stream)
libcurl callback to update header info.
Definition
http.cpp:126
HTTP_Encode
bool HTTP_Encode(const char *url, char *out, size_t outLength)
This function converts the given url to an URL encoded string. All input characters that are not a-z,...
Definition
http.cpp:362
size
voidpf void uLong size
Definition
ioapi.h:42
stream
voidpf stream
Definition
ioapi.h:42
void
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
dlhandle_t
Definition
http.h:46
dlhandle_t::queueEntry
dlqueue_t * queueEntry
Definition
http.h:50
dlhandle_t::fileSize
size_t fileSize
Definition
http.h:51
dlhandle_t::URL
char URL[576]
Definition
http.h:54
dlhandle_t::filePath
char filePath[MAX_OSPATH]
Definition
http.h:48
dlhandle_t::speed
double speed
Definition
http.h:53
dlhandle_t::file
FILE * file
Definition
http.h:49
dlhandle_t::tempBuffer
char * tempBuffer
Definition
http.h:55
dlhandle_t::position
size_t position
Definition
http.h:52
dlhandle_t::curl
CURL * curl
Definition
http.h:47
dlqueue_t
Definition
http.h:40
dlqueue_t::ufoPath
char ufoPath[MAX_QPATH]
Definition
http.h:42
dlqueue_t::state
dlq_state state
Definition
http.h:43
dlqueue_t::next
struct dlqueue_s * next
Definition
http.h:41
upparam_t
Definition
http.h:59
upparam_t::next
struct upparam_s * next
Definition
http.h:62
upparam_t::name
const char * name
Definition
http.h:60
upparam_t::value
const char * value
Definition
http.h:61
FILE
#define FILE
Definition
test_webapi.cpp:30
src
common
http.h
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0