#ifndef DBOX_MTOOL_H
#define DBOX_MTOOL_H
#include <string>
#include <stdio.h>
#include <general.h>
class messaget
{
public:
const char *data; // pointer to the begin of the message
const char *endofmail; // pointer to end of message
const char *endoffile; // pointer to end of file
dword len, headerlen; // length of the message body and of the header
virtual void copyheaderid(char *dest, const char *id, size_t maxlen) const=0;
// copies a header id from a message to a string
virtual void copyheaderid(std::string &dest, const char *id) const=0;
// copies a header id from a message to a string
virtual void copyheadertext(char *dest, const char *text, size_t maxlen) const=0;
// copies the content of a header to a string
virtual void copyheadertext(std::string &dest, const char *text) const=0;
// copies the content of a header to a string
virtual bool parseline(const char **start,
const char **id,
const char **text) const=0;
virtual bool parse()=0; // parse a message
virtual bool eof() const { return data==endoffile; }
virtual bool findheader(const char **start,
const char *id,
const char **text) const;
// TRUE: nothing found
// FALSE: found a header
virtual bool findsingleheader(char *dest,
const char *id, size_t maxlen) const;
// TRUE: nothing found
// FALSE: found a header
virtual bool findsingleheader(std::string &dest, const char *id) const;
virtual bool findsingleheader(std::string &dest, const std::string &id) const;
// TRUE: nothing found
// FALSE: found a header
virtual bool copybody(FILE *outfile) const;
// copy the body to a file
virtual bool copybody(std::ostream &out) const;
// copy the body to a stream
virtual bool copy(FILE *outfile) const;
// copy the complete message to a file
virtual bool copy(std::ostream &out) const;
// copy the complete message to a stream
virtual bool copyheader(FILE *outfile) const;
// copy the header to a file
virtual bool copyheader(std::ostream &out) const;
// copy the header to a stream
};
bool getline(messaget *m, char *line, size_t maxlen, const char **ptr);
bool getline(const messaget &m, std::string &line, const char *&ptr);
#endif
syntax highlighted by Code2HTML, v. 0.9.1