UFO: Alien Invasion
Loading...
Searching...
No Matches
http.h
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 1997-2001 Id Software, Inc.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, 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
39
40typedef struct dlqueue_s {
41 struct dlqueue_s* next;
44} dlqueue_t;
45
46typedef struct dlhandle_s {
47 CURL* curl;
51 size_t fileSize;
52 size_t position;
53 double speed;
54 char URL[576];
57#endif
58
59typedef struct upparam_s {
60 const char* name;
61 const char* value;
62 struct upparam_s* next;
63} upparam_t;
64
65typedef void (*http_callback_t) (const char* response, void* userdata);
66
67bool HTTP_Encode(const char* url, char* out, size_t outLength);
68bool HTTP_GetToFile(const char* url, FILE* file, const char* postfields = nullptr);
69bool HTTP_GetURL(const char* url, http_callback_t callback, void* userdata = nullptr, const char* postfields = nullptr);
70bool HTTP_PutFile(const char* formName, const char* fileName, const char* url, const upparam_t* params);
71size_t HTTP_Recv(void* ptr, size_t size, size_t nmemb, void* stream);
72size_t HTTP_Header(void* ptr, size_t size, size_t nmemb, void* stream);
73void HTTP_Cleanup(void);
74bool HTTP_ExtractComponents(const char* url, char* scheme, size_t schemeLength, char* host, size_t hostLength, char* path, size_t pathLength, int* port);
cvar_t * port
Definition common.cpp:58
definitions common between client and server, but not game lib
#define MAX_OSPATH
Definition filesys.h:44
#define MAX_QPATH
Definition filesys.h:40
void(* http_callback_t)(const char *response, void *userdata)
Definition http.h:65
bool HTTP_PutFile(const char *formName, const char *fileName, const char *url, const upparam_t *params)
Definition http.cpp:265
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
Definition http.h:34
@ DLQ_STATE_RUNNING
Definition http.h:36
@ DLQ_STATE_NOT_STARTED
Definition http.h:35
@ DLQ_STATE_DONE
Definition http.h:37
size_t HTTP_Recv(void *ptr, size_t size, size_t nmemb, void *stream)
libcurl callback for HTTP_GetURL
Definition http.cpp:154
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
void HTTP_Cleanup(void)
UFO is exiting or we're changing servers. Clean up.
Definition http.cpp:406
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
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_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
voidpf void uLong size
Definition ioapi.h:42
voidpf stream
Definition ioapi.h:42
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
dlqueue_t * queueEntry
Definition http.h:50
size_t fileSize
Definition http.h:51
char URL[576]
Definition http.h:54
char filePath[MAX_OSPATH]
Definition http.h:48
double speed
Definition http.h:53
FILE * file
Definition http.h:49
char * tempBuffer
Definition http.h:55
size_t position
Definition http.h:52
CURL * curl
Definition http.h:47
char ufoPath[MAX_QPATH]
Definition http.h:42
dlq_state state
Definition http.h:43
struct dlqueue_s * next
Definition http.h:41
struct upparam_s * next
Definition http.h:62
const char * name
Definition http.h:60
const char * value
Definition http.h:61
#define FILE