From 0be1fe8a1fafb8129447b9fb75ccb5dbe35f273b Mon Sep 17 00:00:00 2001 From: Tyler Dauwalder Date: Mon, 29 Jul 2002 06:57:11 +0000 Subject: [PATCH] New MIME Sniffer files git-svn-id: file:///srv/svn/repos/haiku/trunk/current@529 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/storage/sniffer/Expr.h | 25 ++++++++++++++ headers/private/storage/sniffer/Range.h | 31 +++++++++++++++++ src/kits/storage/sniffer/Range.cpp | 45 +++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 headers/private/storage/sniffer/Expr.h create mode 100644 headers/private/storage/sniffer/Range.h create mode 100644 src/kits/storage/sniffer/Range.cpp diff --git a/headers/private/storage/sniffer/Expr.h b/headers/private/storage/sniffer/Expr.h new file mode 100644 index 0000000000..578ffcc610 --- /dev/null +++ b/headers/private/storage/sniffer/Expr.h @@ -0,0 +1,25 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +//--------------------------------------------------------------------- +/*! + \file sniffer/Expr.h + Mime Sniffer Expression declarations +*/ +#ifndef _sk_sniffer_expr_h_ +#define _sk_sniffer_expr_h_ + +namespace Sniffer { + +class BFile; + +//! Abstract class definining an interface for sniffing BFile objects +class Expr { +public: + virtual ~Expr() {} + virtual bool Sniff(BFile *file) = 0; +}; + +} + +#endif // _sk_sniffer_expr_h_ \ No newline at end of file diff --git a/headers/private/storage/sniffer/Range.h b/headers/private/storage/sniffer/Range.h new file mode 100644 index 0000000000..6af58a5d61 --- /dev/null +++ b/headers/private/storage/sniffer/Range.h @@ -0,0 +1,31 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +//--------------------------------------------------------------------- +/*! + \file sniffer/Range.h + MIME sniffer range declarations +*/ +#ifndef _sk_sniffer_range_h_ +#define _sk_sniffer_range_h_ + +#include + +namespace Sniffer { + +class Range { +public: + Range(int32 start, int32 end); + + int32 Start() const; + int32 End() const; + + void SetTo(int32 start, int32 end); +private: + int32 fStart; + int32 fEnd; +}; + +} + +#endif // _sk_sniffer_range_h_ \ No newline at end of file diff --git a/src/kits/storage/sniffer/Range.cpp b/src/kits/storage/sniffer/Range.cpp new file mode 100644 index 0000000000..d48dc8fce7 --- /dev/null +++ b/src/kits/storage/sniffer/Range.cpp @@ -0,0 +1,45 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +//--------------------------------------------------------------------- +/*! + \file Range.cpp + MIME sniffer range implementation +*/ + +#include +#include +#include + +using namespace Sniffer; + +Range::Range(int32 start, int32 end) + : fStart(-1) + , fEnd(-1) +{ + SetTo(start, end); +} + +int32 +Range::Start() const { + return fStart; +} + +int32 +Range::End() const { + return fEnd; +} + +void +Range::SetTo(int32 start, int32 end) { + if (start > end) { + char start_str[32]; + char end_str[32]; + sprintf(start_str, "%ld", start); + sprintf(end_str, "%ld", end); + throw new Err(std::string("Sniffer Parser Error -- Invalid range: [") + start_str + ":" + end_str + "]", -1); + } else { + fStart = start; + fEnd = end; + } +}