CoreUtils/IMFBoundary.cpp
2025-12-16 16:51:44 -08:00

30 lines
616 B
C++

#include "IMFBoundary.h"
#include "Exception.h"
#include <unistd.h>
namespace coreutils {
IMFBoundary(StreamReader &reader, ZString boundary) : boundary(boundary) {
}
int IMFBoundary::parse() {
switch(state) {
case PREFIX:
if(buffer.remaining() > 3)
if(reader.nextIf("\r\n--"))
state = BOUNDARY;
case BOUNDARY:
while(buffer.getTokenInclude(""));
if(buffer.eod())
return 2;
else if(buffer.remaining() > 1)
if(buffer.ifNext("--"))
state = LAST_BOUNDARY;
case LAST_BOUNDARY:
return 0;
}
}
}