RetroArch/net_http.h

73 lines
1.8 KiB
C
Raw Normal View History

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/>.
*/
#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-01-23 04:08:34 +00:00
typedef struct
{
int fd;
int status;
char part;
char bodytype;
bool error;
#if 0
char padding[5];
#endif
size_t pos;
size_t len;
size_t buflen;
char * data;
} http_t;
2015-01-23 00:45:38 +00:00
2015-01-23 04:08:34 +00:00
http_t *net_http_new(const char * url);
2015-01-23 00:45:38 +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-01-23 04:08:34 +00:00
int net_http_fd(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-01-23 04:08:34 +00:00
bool net_http_update(http_t *state, size_t* progress, size_t* total);
2015-01-23 00:45:38 +00:00
/* 200, 404, or whatever. */
2015-01-23 04:08:34 +00:00
int net_http_status(http_t *state);
2015-01-23 00:45:38 +00:00
/* Returns the downloaded data. The returned buffer is owned by the
* 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-01-23 04:08:34 +00:00
uint8_t* net_http_data(http_t *state, size_t* len, bool accept_error);
2015-01-23 00:45:38 +00:00
/* Cleans up all memory. */
2015-01-23 04:08:34 +00:00
void net_http_delete(http_t *state);
2015-01-23 00:45:38 +00:00
#ifdef __cplusplus
}
#endif
#endif