Rev 5725 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5725 | Rev 5731 | ||
---|---|---|---|
1 | #ifndef __HTTP_H__ |
1 | #ifndef __HTTP_H__ |
2 | #define __HTTP_H__ |
2 | #define __HTTP_H__ |
3 | 3 | ||
4 | #define FLAG_GOT_ALL_DATA (1 << 2) |
4 | #define FLAG_GOT_ALL_DATA (1 << 2) |
5 | 5 | ||
6 | #define FLAG_STREAM (1 << 9) |
6 | #define FLAG_STREAM (1 << 9) |
7 | #define FLAG_REUSE_BUFFER (1 << 10) |
7 | #define FLAG_REUSE_BUFFER (1 << 10) |
8 | 8 | ||
9 | 9 | ||
10 | typedef struct |
10 | typedef struct |
11 | { |
11 | { |
12 | int socket; // socket on which the actual transfer happens |
12 | int socket; // socket on which the actual transfer happens |
13 | int flags; // flags, reflects status of the transfer using bitflags |
13 | int flags; // flags, reflects status of the transfer using bitflags |
14 | int write_ptr; // internal use only (where to write new data in buffer) |
14 | int write_ptr; // internal use only (where to write new data in buffer) |
15 | int buffer_length; // internal use only (number of available bytes in buffer) |
15 | int buffer_length; // internal use only (number of available bytes in buffer) |
16 | int chunk_ptr; // internal use only (where the next chunk begins) |
16 | int chunk_ptr; // internal use only (where the next chunk begins) |
17 | int timestamp; // internal use only (when last data was received) |
17 | int timestamp; // internal use only (when last data was received) |
18 | 18 | ||
19 | int status; // HTTP status |
19 | int status; // HTTP status |
20 | int header_length; // length of HTTP header |
20 | int header_length; // length of HTTP header |
21 | void *content_ptr; // ptr to content |
21 | void *content_ptr; // ptr to content |
22 | int content_length; // total length of HTTP content |
22 | int content_length; // total length of HTTP content |
23 | int content_received; // number of currently received content bytes |
23 | int content_received; // number of currently received content bytes |
24 | }http_t; |
24 | }http_t; |
25 | 25 | ||
26 | int http_init(); |
26 | int http_init(); |
27 | int http_load(char *buf, const char *path); |
27 | int http_load(char *buf, const char *path); |
28 | 28 | ||
29 | http_t* __attribute__ ((stdcall)) http_get(const char *url, http_t *conn, int flags, const char *header); |
29 | http_t* __stdcall http_get(const char *url, http_t *conn, int flags, const char *header); |
30 | int __attribute__ ((stdcall)) http_receive(http_t *conn); |
30 | int __stdcall http_receive(http_t *conn); |
31 | void __attribute__ ((stdcall)) http_free(http_t *conn); |
31 | void __stdcall http_free(http_t *conn); |
32 | 32 | ||
33 | static inline int http_receive_with_retry(http_t *http, int retry_count) |
33 | static inline int http_receive_with_retry(http_t *http, int retry_count) |
34 | { |
34 | { |
35 | int err; |
35 | int err; |
36 | 36 | ||
37 | do |
37 | do |
38 | { |
38 | { |
39 | if(err = http_receive(http)) |
39 | err = http_receive(http); |
- | 40 | if(err) |
|
40 | delay(1); |
41 | wait_for_event(1); |
41 | 42 | ||
42 | }while(err && --retry_count); |
43 | }while(err && --retry_count); |
43 | 44 | ||
44 | return err; |
45 | return err; |
45 | } |
46 | } |
- | 47 | ||
- | 48 | void __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t); |
|
- | 49 | void __stdcall con_exit(char bCloseWindow); |
|
- | 50 | unsigned __stdcall con_get_flags(void); |
|
- | 51 | unsigned __stdcall con_set_flags(unsigned new_flags); |
|
- | 52 | void __stdcall con_cls(void); |
|
- | 53 | void __stdcall con_write_asciiz(const char* string); |
|
- | 54 | ||
46 | 55 | ||
47 | #endif /* __HTTP_H__ */><>><>><> |
56 | #endif /* __HTTP_H__ */><>><>><> |