2015-01-23 00:45:38 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2014-2015 - Alfred Agrell
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-23 03:57:45 +00:00
|
|
|
#ifndef _NET_HTTP_H
|
|
|
|
#define _NET_HTTP_H
|
2015-01-23 00:45:38 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2015-01-23 04:11:15 +00:00
|
|
|
#include <boolean.h>
|
2015-01-23 00:45:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-02-16 01:50:32 +00:00
|
|
|
struct http_t;
|
2015-01-23 00:45:38 +00:00
|
|
|
|
2015-02-16 01:50:32 +00:00
|
|
|
struct http_t *net_http_new(const char * url);
|
2015-01-23 00:45:38 +00:00
|
|
|
|
2015-01-23 03:57:45 +00:00
|
|
|
/* You can use this to call net_http_update
|
2015-01-23 00:45:38 +00:00
|
|
|
* only when something will happen; select() it for reading. */
|
2015-02-16 01:50:32 +00:00
|
|
|
int net_http_fd(struct http_t *state);
|
2015-01-23 00:45:38 +00:00
|
|
|
|
|
|
|
/* Returns true if it's done, or if something broke.
|
|
|
|
* 'total' will be 0 if it's not known. */
|
2015-02-16 01:50:32 +00:00
|
|
|
bool net_http_update(struct http_t *state, size_t* progress, size_t* total);
|
2015-01-23 00:45:38 +00:00
|
|
|
|
|
|
|
/* 200, 404, or whatever. */
|
2015-02-16 01:50:32 +00:00
|
|
|
int net_http_status(struct http_t *state);
|
2015-01-23 00:45:38 +00:00
|
|
|
|
|
|
|
/* Returns the downloaded data. The returned buffer is owned by the
|
2015-01-23 03:57:45 +00:00
|
|
|
* HTTP handler; it's freed by net_http_delete.
|
2015-01-23 00:45:38 +00:00
|
|
|
*
|
|
|
|
* If the status is not 20x and accept_error is false, it returns NULL. */
|
2015-02-16 01:50:32 +00:00
|
|
|
uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error);
|
2015-01-23 00:45:38 +00:00
|
|
|
|
|
|
|
/* Cleans up all memory. */
|
2015-02-16 01:50:32 +00:00
|
|
|
void net_http_delete(struct http_t *state);
|
2015-01-23 00:45:38 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|