339 |
mateuszvis |
1 |
/*
|
|
|
2 |
* unpacks a http "chunked" transfer into a raw data stream.
|
|
|
3 |
* this file is part of the pkgnet tool from the SvarDOS project.
|
|
|
4 |
*
|
|
|
5 |
* Copyright (C) 2021 Mateusz Viste
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
#ifndef UNCHUNK_H
|
|
|
9 |
#define UNCHUNK_H
|
|
|
10 |
|
341 |
mateuszvis |
11 |
struct unchunk_state {
|
|
|
12 |
char partial_hdr[16]; /* a small buffer for storing partial chunk headers, if these are transmitted in separate parts */
|
|
|
13 |
long bytesleft; /* how many bytes are expected yet in the ongoing chunk */
|
|
|
14 |
};
|
339 |
mateuszvis |
15 |
|
341 |
mateuszvis |
16 |
/* transforms a http CHUNKED stream into actual data, returns the amount of
|
|
|
17 |
* raw data to read or -1 on error. st MUST be zeroed before first call. */
|
|
|
18 |
int unchunk(unsigned char *buff, int bufflen, struct unchunk_state *st);
|
|
|
19 |
|
339 |
mateuszvis |
20 |
#endif
|