UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
http.h
Go to the documentation of this file.
1 
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 {
38 } dlq_state;
39 
40 typedef struct dlqueue_s {
41  struct dlqueue_s* next;
44 } dlqueue_t;
45 
46 typedef struct dlhandle_s {
47  CURL* curl;
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);
char URL[576]
Definition: http.h:54
struct upparam_s * next
Definition: http.h:62
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:352
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
struct upparam_s upparam_t
const char * value
Definition: http.h:61
#define FILE
Definition: test_webapi.cpp:30
void HTTP_Cleanup(void)
UFO is exiting or we're changing servers. Clean up.
Definition: http.cpp:396
dlq_state
Definition: http.h:34
#define MAX_OSPATH
Definition: filesys.h:44
size_t HTTP_Recv(void *ptr, size_t size, size_t nmemb, void *stream)
libcurl callback for HTTP_GetURL
Definition: http.cpp:154
struct dlqueue_s dlqueue_t
void(* http_callback_t)(const char *response, void *userdata)
Definition: http.h:65
char * tempBuffer
Definition: http.h:55
const char * name
Definition: http.h:60
char filePath[MAX_OSPATH]
Definition: http.h:48
bool HTTP_GetToFile(const char *url, FILE *file, const char *postfields=nullptr)
Downloads the given url into the given file.
Definition: http.cpp:336
Definition: http.h:40
GLsizei size
Definition: r_gl.h:152
size_t HTTP_Header(void *ptr, size_t size, size_t nmemb, void *stream)
libcurl callback to update header info.
Definition: http.cpp:126
bool HTTP_PutFile(const char *formName, const char *fileName, const char *url, const upparam_t *params)
Definition: http.cpp:265
double speed
Definition: http.h:53
char ufoPath[MAX_QPATH]
Definition: http.h:42
const GLuint *typedef void(APIENTRY *GenRenderbuffersEXT_t)(GLsizei
Definition: r_gl.h:189
CURL * curl
Definition: http.h:47
voidpf stream
Definition: ioapi.h:42
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:374
FILE * file
Definition: http.h:49
#define MAX_QPATH
Definition: filesys.h:40
dlq_state state
Definition: http.h:43
size_t fileSize
Definition: http.h:51
cvar_t * port
Definition: common.cpp:58
definitions common between client and server, but not game lib
Definition: http.h:59
struct dlhandle_s dlhandle_t
dlqueue_t * queueEntry
Definition: http.h:50
struct dlqueue_s * next
Definition: http.h:41
size_t position
Definition: http.h:52