binc: indent and cie
This commit is contained in:
parent
631532f100
commit
8a7e00a029
@ -1,4 +1,3 @@
|
||||
/* -*- mode:c++;c-basic-offset:2 -*- */
|
||||
/* --------------------------------------------------------------------
|
||||
* Filename:
|
||||
* src/mime-inputsource.h
|
||||
@ -25,7 +24,6 @@
|
||||
*/
|
||||
#ifndef mime_inputsource_h_included
|
||||
#define mime_inputsource_h_included
|
||||
#include "autoconfig.h"
|
||||
// Data source for MIME parser
|
||||
|
||||
// Note about large files: we might want to change the unsigned int
|
||||
@ -36,15 +34,15 @@
|
||||
// stream input source (from a memory buffer, no file offsets). When
|
||||
// parsing a raw message file, it's only one message.
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "safeunistd.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Binc {
|
||||
|
||||
class MimeInputSource {
|
||||
public:
|
||||
class MimeInputSource {
|
||||
public:
|
||||
// Note that we do NOT take ownership of fd, won't close it on delete
|
||||
inline MimeInputSource(int fd, unsigned int start = 0);
|
||||
virtual inline ~MimeInputSource(void);
|
||||
@ -60,7 +58,7 @@ namespace Binc {
|
||||
|
||||
inline unsigned int getOffset(void) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
int fd;
|
||||
char data[16384];
|
||||
unsigned int offset;
|
||||
@ -68,10 +66,10 @@ namespace Binc {
|
||||
unsigned int head;
|
||||
unsigned int start;
|
||||
char lastChar;
|
||||
};
|
||||
};
|
||||
|
||||
inline MimeInputSource::MimeInputSource(int fd, unsigned int start)
|
||||
{
|
||||
inline MimeInputSource::MimeInputSource(int fd, unsigned int start)
|
||||
{
|
||||
this->fd = fd;
|
||||
this->start = start;
|
||||
offset = 0;
|
||||
@ -81,19 +79,19 @@ namespace Binc {
|
||||
memset(data, '\0', sizeof(data));
|
||||
|
||||
seek(start);
|
||||
}
|
||||
}
|
||||
|
||||
inline MimeInputSource::~MimeInputSource(void)
|
||||
{
|
||||
}
|
||||
inline MimeInputSource::~MimeInputSource(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline ssize_t MimeInputSource::fillRaw(char *raw, size_t nbytes)
|
||||
{
|
||||
inline ssize_t MimeInputSource::fillRaw(char *raw, size_t nbytes)
|
||||
{
|
||||
return read(fd, raw, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool MimeInputSource::fillInputBuffer(void)
|
||||
{
|
||||
inline bool MimeInputSource::fillInputBuffer(void)
|
||||
{
|
||||
char raw[4096];
|
||||
ssize_t nbytes = fillRaw(raw, 4096);
|
||||
if (nbytes <= 0) {
|
||||
@ -124,19 +122,19 @@ namespace Binc {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline void MimeInputSource::reset(void)
|
||||
{
|
||||
inline void MimeInputSource::reset(void)
|
||||
{
|
||||
offset = head = tail = 0;
|
||||
lastChar = '\0';
|
||||
|
||||
if (fd != -1)
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
inline void MimeInputSource::seek(unsigned int seekToOffset)
|
||||
{
|
||||
inline void MimeInputSource::seek(unsigned int seekToOffset)
|
||||
{
|
||||
if (offset > seekToOffset)
|
||||
reset();
|
||||
|
||||
@ -147,56 +145,56 @@ namespace Binc {
|
||||
break;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline bool MimeInputSource::getChar(char *c)
|
||||
{
|
||||
inline bool MimeInputSource::getChar(char *c)
|
||||
{
|
||||
if (head == tail && !fillInputBuffer())
|
||||
return false;
|
||||
|
||||
*c = data[head++ & (0x4000-1)];
|
||||
++offset;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline void MimeInputSource::ungetChar()
|
||||
{
|
||||
inline void MimeInputSource::ungetChar()
|
||||
{
|
||||
--head;
|
||||
--offset;
|
||||
}
|
||||
}
|
||||
|
||||
inline int MimeInputSource::getFileDescriptor(void) const
|
||||
{
|
||||
inline int MimeInputSource::getFileDescriptor(void) const
|
||||
{
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int MimeInputSource::getOffset(void) const
|
||||
{
|
||||
inline unsigned int MimeInputSource::getOffset(void) const
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
class MimeInputSourceStream : public MimeInputSource {
|
||||
public:
|
||||
inline MimeInputSourceStream(istream& s, unsigned int start = 0);
|
||||
///////////////////////////////////
|
||||
class MimeInputSourceStream : public MimeInputSource {
|
||||
public:
|
||||
inline MimeInputSourceStream(std::istream& s, unsigned int start = 0);
|
||||
virtual inline ssize_t fillRaw(char *raw, size_t nb);
|
||||
virtual inline void reset(void);
|
||||
private:
|
||||
istream& s;
|
||||
};
|
||||
private:
|
||||
std::istream& s;
|
||||
};
|
||||
|
||||
inline MimeInputSourceStream::MimeInputSourceStream(istream& si,
|
||||
inline MimeInputSourceStream::MimeInputSourceStream(std::istream& si,
|
||||
unsigned int start)
|
||||
: MimeInputSource(-1, start), s(si)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
inline ssize_t MimeInputSourceStream::fillRaw(char *raw, size_t nb)
|
||||
{
|
||||
inline ssize_t MimeInputSourceStream::fillRaw(char *raw, size_t nb)
|
||||
{
|
||||
// Why can't streams tell how many characters were actually read
|
||||
// when hitting eof ?
|
||||
std::streampos st = s.tellg();
|
||||
s.seekg(0, ios::end);
|
||||
s.seekg(0, std::ios::end);
|
||||
std::streampos lst = s.tellg();
|
||||
s.seekg(st);
|
||||
size_t nbytes = size_t(lst - st);
|
||||
@ -209,13 +207,13 @@ namespace Binc {
|
||||
|
||||
s.read(raw, nbytes);
|
||||
return static_cast<ssize_t>(nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
inline void MimeInputSourceStream::reset(void)
|
||||
{
|
||||
inline void MimeInputSourceStream::reset(void)
|
||||
{
|
||||
MimeInputSource::reset();
|
||||
s.seekg(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -36,15 +36,14 @@
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace ::std;
|
||||
#endif /* NO_NAMESPACES */
|
||||
|
||||
#include "mime.h"
|
||||
#include "mime-utils.h"
|
||||
#include "mime-inputsource.h"
|
||||
#include "convert.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// #define MPF
|
||||
#ifdef MPF
|
||||
#define MPFDEB(X) fprintf X
|
||||
|
||||
@ -40,9 +40,7 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace ::std;
|
||||
#endif /* NO_NAMESPACES */
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void Binc::MimeDocument::parseOnlyHeader(int fd)
|
||||
|
||||
@ -35,15 +35,13 @@
|
||||
#include <map>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#ifndef NO_NAMESPACES
|
||||
using namespace ::std;
|
||||
#endif /* NO_NAMESPACES */
|
||||
|
||||
|
||||
#include "mime.h"
|
||||
#include "convert.h"
|
||||
#include "mime-inputsource.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
Binc::MimeDocument::MimeDocument(void)
|
||||
{
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
/* -*- mode:c++;c-basic-offset:2 -*- */
|
||||
/* --------------------------------------------------------------------
|
||||
* Filename:
|
||||
* src/parsers/mime/mime.h
|
||||
@ -25,6 +24,7 @@
|
||||
*/
|
||||
#ifndef mime_h_included
|
||||
#define mime_h_included
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@ -57,7 +57,8 @@ private:
|
||||
|
||||
public:
|
||||
bool getFirstHeader(const std::string &key, HeaderItem &dest) const;
|
||||
bool getAllHeaders(const std::string &key, std::vector<HeaderItem> &dest) const;
|
||||
bool getAllHeaders(const std::string &key, std::vector<HeaderItem> &dest)
|
||||
const;
|
||||
void add(const std::string &name, const std::string &content);
|
||||
void clear(void);
|
||||
|
||||
@ -104,10 +105,13 @@ public:
|
||||
inline unsigned int getNofLines(void) const { return nlines; }
|
||||
inline unsigned int getNofBodyLines(void) const { return nbodylines; }
|
||||
inline unsigned int getBodyLength(void) const { return bodylength; }
|
||||
inline unsigned int getBodyStartOffset(void) const { return bodystartoffsetcrlf; }
|
||||
inline unsigned int getBodyStartOffset(void) const {
|
||||
return bodystartoffsetcrlf; }
|
||||
|
||||
void printBody(Binc::IODevice &output, unsigned int startoffset, unsigned int length) const;
|
||||
void getBody(std::string& s, unsigned int startoffset, unsigned int length) const;
|
||||
void printBody(Binc::IODevice &output, unsigned int startoffset,
|
||||
unsigned int length) const;
|
||||
void getBody(std::string& s, unsigned int startoffset, unsigned int length)
|
||||
const;
|
||||
virtual void clear(void);
|
||||
|
||||
virtual int doParseOnlyHeader(MimeInputSource *ms);
|
||||
@ -166,12 +170,10 @@ public:
|
||||
|
||||
void clear(void);
|
||||
|
||||
bool isHeaderParsed(void) const
|
||||
{
|
||||
bool isHeaderParsed(void) const {
|
||||
return headerIsParsed;
|
||||
}
|
||||
bool isAllParsed(void) const
|
||||
{
|
||||
bool isAllParsed(void) const {
|
||||
return allIsParsed;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user