2002-08-06 12:25:41 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// This software is part of the OpenBeOS distribution and is covered
|
|
|
|
// by the OpenBeOS license.
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
/*!
|
|
|
|
\file sniffer/Pattern.h
|
|
|
|
Mime Sniffer Pattern declarations
|
|
|
|
*/
|
2002-08-12 11:24:02 +04:00
|
|
|
#ifndef _SNIFFER_PATTERN_H
|
|
|
|
#define _SNIFFER_PATTERN_H
|
2002-08-06 12:25:41 +04:00
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <string>
|
|
|
|
#include <sniffer/Range.h>
|
|
|
|
|
|
|
|
class BPositionIO;
|
|
|
|
|
2002-08-12 12:42:01 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
namespace Storage {
|
2002-08-06 12:25:41 +04:00
|
|
|
namespace Sniffer {
|
|
|
|
|
|
|
|
class Err;
|
|
|
|
|
2002-08-08 11:20:47 +04:00
|
|
|
//! A byte string and optional mask to be compared against a data stream.
|
|
|
|
/*! The byte string and mask (if supplied) must be of the same length. */
|
2002-08-06 12:25:41 +04:00
|
|
|
class Pattern {
|
|
|
|
public:
|
2002-08-09 14:30:38 +04:00
|
|
|
Pattern(const std::string &string, const std::string &mask);
|
|
|
|
Pattern(const std::string &string);
|
2002-08-06 12:25:41 +04:00
|
|
|
~Pattern();
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
Err* GetErr() const;
|
|
|
|
|
2002-08-10 13:36:00 +04:00
|
|
|
bool Sniff(Range range, BPositionIO *data, bool caseInsensitive) const;
|
2002-09-24 09:27:46 +04:00
|
|
|
ssize_t BytesNeeded() const;
|
2002-08-06 12:25:41 +04:00
|
|
|
|
2002-08-09 14:30:38 +04:00
|
|
|
status_t SetTo(const std::string &string, const std::string &mask);
|
2002-08-06 12:25:41 +04:00
|
|
|
private:
|
2002-08-10 13:36:00 +04:00
|
|
|
bool Sniff(off_t start, off_t size, BPositionIO *data, bool caseInsensitive) const;
|
2002-08-06 12:25:41 +04:00
|
|
|
|
|
|
|
void SetStatus(status_t status, const char *msg = NULL);
|
|
|
|
void SetErrorMessage(const char *msg);
|
|
|
|
|
|
|
|
std::string fString;
|
|
|
|
std::string fMask;
|
|
|
|
|
|
|
|
status_t fCStatus;
|
|
|
|
Err *fErrorMessage;
|
|
|
|
};
|
|
|
|
|
2002-08-12 12:42:01 +04:00
|
|
|
}; // namespace Sniffer
|
|
|
|
}; // namespace Storage
|
|
|
|
}; // namespace BPrivate
|
|
|
|
|
|
|
|
#endif // _SNIFFER_PATTERN_H
|
|
|
|
|
2002-08-06 12:25:41 +04:00
|
|
|
|