more IMF work.
This commit is contained in:
1 parent
fd7a9ed860
commit
2866056072
7 files changed
+11
-38
No files matched your search
+4
-32
@@ -1,28 +1,26 @@
|
||||
#include "IMFMultipart.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFMultipart::IMFMultipart(int fd, ZString boundary) {
|
||||
IMFMultipart::IMFMultipart(int fd, MString boundary) {
|
||||
int ch = 0;
|
||||
int rc = 0;
|
||||
while((ch != '\r') && (ch != '\n')) {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if((ch != '\r') && (ch != '\n'))
|
||||
boundary.write(ch);
|
||||
}
|
||||
if(ch == '\r') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
}
|
||||
while(1) {
|
||||
sections.emplace_back(fd, boundary);
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '-') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '-') {
|
||||
break;
|
||||
}
|
||||
@@ -30,40 +28,14 @@ namespace coreutils {
|
||||
|
||||
}
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '\r') {
|
||||
rc = ::read(fd, &ch, 1);
|
||||
--length;
|
||||
if(ch == '\n') {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IMFMultipart::IMFMultipart(ZString &in, ZString &boundary) {
|
||||
Log(LOG_DEBUG_1) << in;
|
||||
std::stringstream temp;
|
||||
temp << "--" << boundary;
|
||||
sections = in.split(temp.str().c_str());
|
||||
for(int ix = 0; ix < sections.size(); ++ix) {
|
||||
sections[ix].ifNext("\r\n");
|
||||
sections[ix].trimCRLF();
|
||||
Log(LOG_DEBUG_1) << "[" << sections[ix] << "].";
|
||||
if(sections[ix].equals("--"))
|
||||
sections[ix] = ZString("");
|
||||
sections[ix].ifNext("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string IMFMultipart::toString() {
|
||||
return std::string(getData(), getLength());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user