aboutsummaryrefslogtreecommitdiff
path: root/src/multipart.c
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-07-13 05:43:49 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-07-13 05:43:49 +0300
commit7428c24a2e3bb8897815b85fbbe61ec2ece6cfbc (patch)
tree78cdaf90e7fd80c198615fed11d01445a81b40cc /src/multipart.c
parent4570daec42c1e38c2df88facc23743f45f907b3d (diff)
downloadmagi-7428c24a2e3bb8897815b85fbbe61ec2ece6cfbc.tar
magi-7428c24a2e3bb8897815b85fbbe61ec2ece6cfbc.tar.xz
magi-7428c24a2e3bb8897815b85fbbe61ec2ece6cfbc.zip
Added newfile in callback.
Diffstat (limited to 'src/multipart.c')
-rw-r--r--src/multipart.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/multipart.c b/src/multipart.c
index a265184..8164bfd 100644
--- a/src/multipart.c
+++ b/src/multipart.c
@@ -48,6 +48,7 @@ typedef struct automata {
int is_CR_readed;
int is_quoted;
int readed;
+ int newfile;
} automata;
typedef void *(*state)(automata *a, char c);
@@ -120,9 +121,10 @@ static int param_end(automata *a)
{
if (a->file.filename) {
a->request->callback.act(a->request->callback.userdata,
- &a->file, a->buf, a->buf_size);
+ a->newfile, &a->file, a->buf, a->buf_size);
a->request->callback.act(a->request->callback.userdata,
- &a->file, 0, 0);
+ 0, &a->file, 0, 0);
+ a->newfile = 1;
a->readed -= a->buf_size;
a->buf_size = 0;
magi_files_add(&a->request->files, &a->file);
@@ -216,7 +218,8 @@ static void apply_callback(automata *a)
int full = a->buf_size == a->request->callback.addon_max;
if (a->file.filename && full) {
a->request->callback.act(a->request->callback.userdata,
- &a->file, a->buf, a->buf_size);
+ a->newfile, &a->file, a->buf, a->buf_size);
+ a->newfile = 0;
a->readed -= a->buf_size;
a->buf_size = 0;
}
@@ -412,7 +415,7 @@ void magi_parse_multipart(magi_request *request,
void *next_userdata)
{
automata a = {
- 0, { 0, 0, 0 }, { 0, 0 }, { 0, 0 }, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0
+ 0, { 0, 0, 0 }, { 0, 0 }, { 0, 0 }, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 1
};
a.request = request;
a.boundary = boundary;