-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_write_header_cb.h
30 lines (23 loc) · 1.08 KB
/
main_write_header_cb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//#define IMG_URL "http://ece252-1.uwaterloo.ca:2520/image?img=1"
//#define DUM_URL "https://example.com/"
#ifndef MAIN_WRITE_HEADER_CB_H
#define MAIN_WRITE_HEADER_CB_H
#define ECE252_HEADER "X-Ece252-Fragment: "
#define BUF_SIZE 1048576 /* 1024*1024 = 1M */
#define BUF_INC 524288 /* 1024*512 = 0.5M */
#define max(a, b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
typedef struct recv_buf {
char *buf; /* memory to hold a copy of received data */
size_t size; /* size of valid data in buf in bytes*/
size_t max_size; /* max capacity of buf in bytes*/
int seq; /* >=0 sequence number extracted from http header */ /* <0 indicates an invalid seq number */
} RECV_BUF;
size_t header_cb_curl(char *p_recv, size_t size, size_t nmemb, void *userdata);
size_t write_cb_curl3(char *p_recv, size_t size, size_t nmemb, void *p_userdata);
int recv_buf_init(RECV_BUF *ptr, size_t max_size);
int recv_buf_cleanup(RECV_BUF *ptr);
int write_file(const char *path, const void *in, size_t len);
#endif