UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
web_main.h
Go to the documentation of this file.
1 
7 /*
8 Copyright (C) 2002-2020 UFO: Alien Invasion.
9 
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 See the GNU General Public License for more details.m
20 
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25 
26 #pragma once
27 
28 #include "../../common/common.h"
29 #include "../../common/http.h"
30 
31 #define WEB_API_SERVER "http://ufoai.org/"
32 
33 extern cvar_t* web_username;
34 extern cvar_t* web_password;
35 extern cvar_t* web_userid;
36 
37 bool WEB_CheckAuth(void);
38 bool WEB_Auth(const char* username, const char* password);
39 void WEB_InitStartup(void);
40 bool WEB_GetURL(const char* url, http_callback_t callback, void* userdata = nullptr);
41 bool WEB_GetToFile(const char* url, FILE* file);
42 bool WEB_PutFile(const char* formName, const char* fileName, const char* url, upparam_t* params = nullptr);
void WEB_InitStartup(void)
Definition: web_main.cpp:185
bool WEB_GetToFile(const char *url, FILE *file)
Downloads the given url directly into the given file. The login credentials are automatically added a...
Definition: web_main.cpp:65
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
bool WEB_Auth(const char *username, const char *password)
Performs a web auth request.
Definition: web_main.cpp:135
#define FILE
Definition: test_webapi.cpp:30
cvar_t * web_password
Definition: web_main.cpp:34
void(* http_callback_t)(const char *response, void *userdata)
Definition: http.h:65
bool WEB_CheckAuth(void)
Pushes the webauth window if the password is not yet set.
Definition: web_main.cpp:176
bool WEB_GetURL(const char *url, http_callback_t callback, void *userdata=nullptr)
Downloads the given url and notify the callback. The login credentials are automatically added as GET...
Definition: web_main.cpp:44
cvar_t * web_username
Definition: web_main.cpp:33
bool WEB_PutFile(const char *formName, const char *fileName, const char *url, upparam_t *params=nullptr)
Uploads a file to the server with the login credentials.
Definition: web_main.cpp:87
cvar_t * password
Definition: g_main.cpp:67
cvar_t * web_userid
Definition: web_main.cpp:35
Definition: http.h:59