CoreUtils/IMFMultipart.cpp
2025-03-11 16:59:16 -07:00

52 lines
974 B
C++

#include "IMFMultipart.h"
#include "Log.h"
#include <unistd.h>
namespace coreutils {
IMFMultipart::IMFMultipart(int fd, MString boundary) {
int ch = 0;
int rc = 0;
while((ch != '\r') && (ch != '\n')) {
rc = ::read(fd, &ch, 1);
if((ch != '\r') && (ch != '\n'))
boundary.write(ch);
}
if(ch == '\r') {
rc = ::read(fd, &ch, 1);
}
while(1) {
sections.emplace_back(fd, boundary);
rc = ::read(fd, &ch, 1);
if(ch == '-') {
rc = ::read(fd, &ch, 1);
if(ch == '-') {
break;
}
}
}
rc = ::read(fd, &ch, 1);
if(ch == '\r') {
rc = ::read(fd, &ch, 1);
if(ch == '\n') {
}
}
}
std::string IMFMultipart::toString() {
return std::string(getData(), getLength());
}
int IMFMultipart::getCount() {
return sections.size();
}
ZString IMFMultipart::getSectionAt(int index) {
return sections[index];
}
}