Parsing simple MIME files from C/C++?
It's been a while. So I'll just answer my own question.
After spending some more time on this, I ended up writing my own implementation. MIME is quite simple indeed, and if you read the documentation, you have something up and running in a short time.
However, I think there should be something like vMime, but open source. I can't believe that so few people have to deal with MIME structures as it's a real standard.
Are there .NET Framework methods to parse an email (MIME)?
I know you said no external libraries, but I have a library posted on codeplex:
https://bitbucket.org/otac0n/mailutilities
MimeMessage msg = new MimeMessage(/* string, stream, or Byte[] */);
It has been tested with over 40,000 real-world mail messages.
I'm not too happy with my namespace choice, but... I'm too lazy to change it.
PS:
Internally, my library uses these regexes as a parser:
internal static string FullMessageMatch =
@"\A(?<header>(?:[^\r\n]+\r\n)*)(?<header_term>\r\n)(?<body>.*)\z";
internal static string HeadersMatch =
@"^(?<header_key>[-A-Za-z0-9]+)(?<seperator>:[ \t]*)(?<header_value>([^\r\n]|\r\n[ \t]+)*)(?<terminator>\r\n)";
internal static string HeaderSeperator =
"\r\n";
internal static string KeyValueSeparator =
@"\A:[ \t]*\z";
Related Topics
Getting the Current Time (In Milliseconds) from the System Clock in Windows
Proper Way of Casting Pointer Types
C++ Cannot Convert from Base a to Derived Type B via Virtual Base A
How to Define a Move Constructor
Google Protocol Buffers on iOS
Does Scopeguard Use Really Lead to Better Code
How to Pan Images in Qgraphicsview
Implementing Future::Then() Equivalent for Asynchronous Execution in C++11
Which Header Should I Include for 'Size_T'
How to Perform a Pairwise Binary Operation Between the Elements of Two Containers
Why Gcc Does Not Use Load(Without Fence) and Store+Sfence for Sequential Consistency
Typeid() Returns Extra Characters in G++
How to Use Makefiles in Visual Studio
G++ Error:/Usr/Lib/Rpm/Redhat/Redhat-Hardened-Cc1: No Such File or Directory
When Do We Need to Have a Default Constructor