envelope: skeleton
This commit is contained in:
parent
3b2b3b7f00
commit
4b844ffd20
|
@ -18,3 +18,57 @@
|
|||
|
||||
#include "envelope.h"
|
||||
|
||||
/*
|
||||
* how do the ascii envelopes look like?
|
||||
*
|
||||
* similarly to PGP:
|
||||
*
|
||||
* ------ccr begin typeident termident------
|
||||
* data
|
||||
* ------ccr cut typeident termident------
|
||||
* next part data
|
||||
* ------ccr cut typeident termident------
|
||||
* other next part data
|
||||
* ------ccr end typeident termident------
|
||||
*
|
||||
* To distinguish ourselves from PGP, we use six dashes and prefixed CCR name.
|
||||
* No version information is supplied - versioning should be contained
|
||||
* preferably in typeident, e.g. like "message" "better_message" and
|
||||
* "bettermessage-version3".
|
||||
*
|
||||
* Cleartext two-part messages and similar evil sorceries are generalized to
|
||||
* multipart messages using the "part cut".
|
||||
*
|
||||
* Also, to prevent cleartext embedding conflicts, we add termident, which is
|
||||
* basically a random string of letters and numbers that serves as a mark that
|
||||
* must be the same on the begin and end.
|
||||
*/
|
||||
|
||||
size_t envelope_get (const std::string&data, size_t offset,
|
||||
std::string&out_type,
|
||||
std::vector<std::string>&out_parts)
|
||||
{
|
||||
|
||||
size_t begin;
|
||||
|
||||
restart:
|
||||
//try to find begin mark.
|
||||
begin = data.find ("------ccr begin ", offset);
|
||||
|
||||
//nothing possible found, die.
|
||||
if (begin == data.npos) return 0;
|
||||
|
||||
//try to parse the begin mark
|
||||
std::string type, mark;
|
||||
|
||||
//TODO parse it lol
|
||||
//TODO move offset
|
||||
|
||||
//read all sections
|
||||
for (;;) {
|
||||
|
||||
}
|
||||
|
||||
//return the modified offset
|
||||
return offset;
|
||||
}
|
||||
|
|
|
@ -19,5 +19,23 @@
|
|||
#ifndef _ccr_envelope_h_
|
||||
#define _ccr_envelope_h_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/*
|
||||
* Tools for finding envelopes in ascii/utf-8 text.
|
||||
*
|
||||
* We simply don't care about wide chars in text, UTF-16+, nor conflicting
|
||||
* encodings, nor any similar abominations.
|
||||
*
|
||||
* envelope_get tries to find an envelope in text data, starting from offset,
|
||||
* returning the offset of first possible following envelope or 0 if nothing
|
||||
* usuable was found.
|
||||
*/
|
||||
|
||||
size_t envelope_get (const std::string& data, size_t offset,
|
||||
std::string&out_type,
|
||||
std::vector<std::string>&out_parts);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue