RetroArch
net_http.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (net_http.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef _LIBRETRO_SDK_NET_HTTP_H
24 #define _LIBRETRO_SDK_NET_HTTP_H
25 
26 #include <stdint.h>
27 #include <boolean.h>
28 #include <string.h>
29 
30 #include <retro_common_api.h>
31 
33 
34 struct http_t;
35 struct http_connection_t;
36 
37 struct http_connection_t *net_http_connection_new(const char *url, const char *method, const char *data);
38 
40 
42 
44 
45 const char *net_http_connection_url(struct http_connection_t *conn);
46 
47 struct http_t *net_http_new(struct http_connection_t *conn);
48 
49 /* You can use this to call net_http_update
50  * only when something will happen; select() it for reading. */
51 int net_http_fd(struct http_t *state);
52 
53 /* Returns true if it's done, or if something broke.
54  * 'total' will be 0 if it's not known. */
55 bool net_http_update(struct http_t *state, size_t* progress, size_t* total);
56 
57 /* 200, 404, or whatever. */
58 int net_http_status(struct http_t *state);
59 
60 bool net_http_error(struct http_t *state);
61 
62 /* Returns the downloaded data. The returned buffer is owned by the
63  * HTTP handler; it's freed by net_http_delete.
64  *
65  * If the status is not 20x and accept_error is false, it returns NULL. */
66 uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error);
67 
68 /* Cleans up all memory. */
69 void net_http_delete(struct http_t *state);
70 
71 /* URL Encode a string */
72 void net_http_urlencode(char **dest, const char *source);
73 
74 /* Re-encode a full URL */
75 void net_http_urlencode_full(char *dest, const char *source, size_t size);
76 
78 
79 #endif
void net_http_connection_free(struct http_connection_t *conn)
Definition: net_http.c:342
struct http_connection_t * net_http_connection_new(const char *url, const char *method, const char *data)
Definition: net_http.c:239
void net_http_urlencode(char **dest, const char *source)
Definition: net_http.c:107
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
void net_http_delete(struct http_t *state)
Definition: net_http.c:770
void net_http_urlencode_full(char *dest, const char *source, size_t size)
Definition: net_http.c:141
GLenum GLsizei len
Definition: glext.h:7389
GLsizeiptr size
Definition: glext.h:6559
struct http_t * net_http_new(struct http_connection_t *conn)
Definition: net_http.c:372
const char * net_http_connection_url(struct http_connection_t *conn)
Definition: net_http.c:367
Definition: net_http.c:62
bool net_http_connection_done(struct http_connection_t *conn)
Definition: net_http.c:307
Definition: ibxm.h:9
bool net_http_connection_iterate(struct http_connection_t *conn)
Definition: net_http.c:296
static uint64_t state[MAX_PADS]
Definition: xenon360_input.c:33
bool net_http_update(struct http_t *state, size_t *progress, size_t *total)
Definition: net_http.c:516
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
int net_http_fd(struct http_t *state)
Definition: net_http.c:509
uint8_t * net_http_data(struct http_t *state, size_t *len, bool accept_error)
Definition: net_http.c:752
GLsizei GLsizei GLchar * source
Definition: glext.h:6688
int net_http_status(struct http_t *state)
Definition: net_http.c:745
bool net_http_error(struct http_t *state)
Definition: net_http.c:789
unsigned char uint8_t
Definition: stdint.h:124
Definition: net_http.c:77