diff --git a/IMFFormData.cpp b/IMFFormData.cpp index 6115b3d..0b5a838 100644 --- a/IMFFormData.cpp +++ b/IMFFormData.cpp @@ -5,8 +5,11 @@ namespace coreutils { IMFFormData::IMFFormData(int fd, ZString boundary) { + std::cout << "030" << std::endl; IMFHeader header(fd); + std::cout << "031" << std::endl; IMFText text(fd, boundary); + std::cout << "032" << std::endl; } } diff --git a/IMFHeader.cpp b/IMFHeader.cpp index 0c18226..83d2c24 100644 --- a/IMFHeader.cpp +++ b/IMFHeader.cpp @@ -7,12 +7,16 @@ namespace coreutils { IMFHeader::IMFHeader(int fd) { char ch; + std::cout << "040" << std::endl; int rc = ::read(fd, &ch, 1); - while(ch != 'r') { + while(ch != '\r') { + std::cout << (char)ch << std::endl; IMFHeaderField *headerField = new IMFHeaderField(ch, fd); headers.push_back(headerField); } + std::cout << "041: " << ch << std::endl; rc = ::read(fd, &ch, 1); + std::cout << "042: " << ch << std::endl; } } \ No newline at end of file diff --git a/IMFHeaderField.cpp b/IMFHeaderField.cpp index c5572ba..77d841b 100644 --- a/IMFHeaderField.cpp +++ b/IMFHeaderField.cpp @@ -9,6 +9,8 @@ namespace coreutils { IMFHeaderField::IMFHeaderField(char &ch, int fd) { int rc = 0; + std::cout << "050" << std::endl; + if((ch >= 'A') && (ch <= 'Z')) key.write(ch); @@ -17,6 +19,9 @@ namespace coreutils { if(ch != ':') key.write(ch); } + + std::cout << "051: " << key << std::endl; + rc = ::read(fd, &ch, 1); while(ch == ' ') rc = ::read(fd, &ch, 1); @@ -25,8 +30,10 @@ namespace coreutils { rc = ::read(fd, &ch, 1); if(ch != '\r') value.write(ch); - } - rc = ::read(fd, &ch, 1); + } + std::cout << "052: " << value << std::endl; + rc = ::read(fd, &ch, 1); + std::cout << "053" << std::endl; } } \ No newline at end of file diff --git a/IMFMultipart.cpp b/IMFMultipart.cpp index 5c2cc42..edbfda6 100644 --- a/IMFMultipart.cpp +++ b/IMFMultipart.cpp @@ -8,16 +8,22 @@ namespace coreutils { IMFMultipart::IMFMultipart(int fd, MString boundary) { int ch = 0; int rc = 0; + std::cout << "020" << std::endl; while((ch != '\r') && (ch != '\n')) { rc = ::read(fd, &ch, 1); if((ch != '\r') && (ch != '\n')) + std::cout << (char)ch; boundary.write(ch); } if(ch == '\r') { + std::cout << std::endl; rc = ::read(fd, &ch, 1); } while(1) { - sections.emplace_back(fd, boundary); + std::cout << "021: " << boundary << std::endl; + IMFFormData *formData = new IMFFormData(fd, boundary); + std::cout << "022" << std::endl; + rc = ::read(fd, &ch, 1); if(ch == '-') { rc = ::read(fd, &ch, 1); diff --git a/IMFText.cpp b/IMFText.cpp index 9b0751f..8c56a13 100644 --- a/IMFText.cpp +++ b/IMFText.cpp @@ -1,9 +1,28 @@ #include "IMFText.h" +#include namespace coreutils { IMFText::IMFText(int fd, ZString boundary) : MString() { - + int ch = 0; + int rc = 0; + char *endcursor; + char *index = boundary.getData(); + + while(1) { + rc = ::read(fd, &ch, 1); + if(ch == *index) { + ++index; + ZString check(index, index - endcursor); + if(check == boundary) { + break; + } + } else { + endcursor = index; + } + write(ch); + } + } }