diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2013-06-20 16:07:59 +0200 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2013-06-20 16:07:59 +0200 |
commit | 21ac350ef7d59e88dd0ee725cdd94edbfdfcb7d6 (patch) | |
tree | 78fa68f40d1b091931ee94ad8c8dd55ef64428ea | |
parent | 06e7d4abafc176e6209772523640d3c5a1867fa7 (diff) | |
download | litheweb-21ac350ef7d59e88dd0ee725cdd94edbfdfcb7d6.tar.gz litheweb-21ac350ef7d59e88dd0ee725cdd94edbfdfcb7d6.tar.bz2 |
multipart getchar
-rw-r--r-- | picohttp.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -885,3 +885,47 @@ int picohttpResponseWrite ( return len; } +uint16_t picohttpMultipartGetch( + struct picohttpMultiPart * const mp); +{ + if( mp->replay + mp->in_boundary < 0) { + uint16_t ch = mp->replay < 1 ? '-' : + mp->req->query.multipartboundary[mp->replay - 1]; + mp->replay++; + return ch; + } else if( mp->finished) { + return -1; + } else { + uint16_t ch; + ch = picohttpIoGetch(mp->req->ioops); + if( 0 > ch ) { + return ch; + } + + if( (0 == mp->in_boundary && '\r' == ch) || + (1 == mp->in_boundary && '\n' == ch) || + (2 < mp->in_boundary && '-' == ch) || + (4 < mp->in_boundary && + mp->req->query.multipartboundary[mp->in_boundary-4] == ch) ) { + if( 5 < mp->in_boundary && + 0 == mp->req->query.multipartboundary[mp->in_boundary-3] ) { + /* matched boundary */ + mp->finished = 1; + return 0; + } + mp->in_boundary++; + ch = picohttpIoGetch(mp->req->ioops); + if( 0 >= ch ) { + return -1; + } + } else { + mp->replay = mp->in_boundary + 1; + return '-'; + } + } +} + + + + + |