Still working out parsing buffer stuff.

This commit is contained in:
Brad Arant 2025-12-18 15:40:37 -08:00
parent ccfab5aecf
commit d415e0abd3
2 changed files with 23 additions and 8 deletions

View File

@ -8,13 +8,25 @@ namespace coreutils {
IMFHeader::IMFHeader(int fd) {}
virtual int parse() {
char ch;
int rc = ::read(fd, &ch, 1);
while(ch != '\r') {
IMFHeaderField *headerField = new IMFHeaderField(ch, fd);
headers.push_back(headerField);
switch(state) {
case NAME:
name << buffer.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789");
if(buffer.ifNext(":"))
state = FIELD;
else
return 2;
case FIELD:
field << buffer.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-;'\"0123456789");
if(!buffer.ifNext("\r\n"))
if(buffer.eod())
return 2;
// Right here is where we should check if next line is an extension to the previous line.
}
rc = ::read(fd, &ch, 1);
}
}

View File

@ -3,6 +3,7 @@
# include "StreamReader.h"
# include "Parser.h"
# include "MString.h"
# include "IMFHeaderField.h"
# include <vector>
@ -16,7 +17,9 @@ namespace coreutils {
virtual int parse();
private:
std::vector<IMFHeaderField *> headers;
MString name;
MString field;
std::map<MString, MString> headers;
};